Skip to content

Commit 66429ef

Browse files
author
yuemingw
committed
Fix build version check in TestDPC.
Bug: 117767560 Test: manual Change-Id: If7b4b32ff90c78ed915f1f7bee588984377d771d
1 parent 89218a9 commit 66429ef

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

app/src/main/java/com/afwsamples/testdpc/common/Util.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import android.graphics.BitmapFactory;
2828
import android.net.Uri;
2929
import android.os.Build;
30+
import android.os.Build.VERSION;
3031
import android.os.Build.VERSION_CODES;
3132
import android.os.Bundle;
3233
import android.os.UserHandle;
@@ -153,6 +154,12 @@ public static boolean isAtLeastM() {
153154
return Build.VERSION.SDK_INT >= VERSION_CODES.M;
154155
}
155156

157+
public static boolean isAtLeastQ() {
158+
return VERSION.CODENAME.length() == 1
159+
&& VERSION.CODENAME.charAt(0) >= 'Q'
160+
&& VERSION.CODENAME.charAt(0) <= 'Z';
161+
}
162+
156163
@TargetApi(VERSION_CODES.O)
157164
public static List<UserHandle> getBindDeviceAdminTargetUsers(Context context) {
158165
if (!BuildCompat.isAtLeastO()) {

app/src/main/java/com/afwsamples/testdpc/common/preference/DpcPreferenceHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import android.os.Build;
2323
import android.support.annotation.IntDef;
2424
import android.support.annotation.StringRes;
25-
import android.support.v4.os.BuildCompat;
2625
import android.support.v7.preference.Preference;
2726
import android.support.v7.preference.PreferenceViewHolder;
2827
import android.text.TextUtils;
@@ -93,6 +92,10 @@ public class DpcPreferenceHelper {
9392
* not yet assigned.
9493
*/
9594
private int getDeviceSdkInt() {
95+
// TODO(b/117767701): Remove this when Q version code is finalized.
96+
if (Util.isAtLeastQ()) {
97+
return Build.VERSION_CODES.CUR_DEVELOPMENT;
98+
}
9699
return Build.VERSION.SDK_INT;
97100
}
98101

app/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<enum name="O" value="26" />
2929
<enum name="O_MR1" value="27" />
3030
<enum name="P" value="28" />
31+
<enum name="Q" value="10000" />
3132
</attr>
3233

3334
<!-- Constrain a preference to DO or PO admins. -->

0 commit comments

Comments
 (0)