Skip to content

Commit 5f004a3

Browse files
author
Alex Johnston
committed
Do not call time APIs introduced in R if device is pre-R
* If the device is pre-R, do not call setAutoTimeEnabled and setAutoTimeZoneEnabled. * Call setGlobalSettings instead. Manual testing steps * Install TestDPC * Set device in device owner mode * Select setTime and setTimeZone * Verify TestDPC does not crash Bug: 165592867 Test: manual testing with TestDPC Change-Id: Ife22d85f0415b978b34c89e5950242df5815e8e5
1 parent f83bd52 commit 5f004a3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/src/main/java/com/afwsamples/testdpc/policy/PolicyManagementFragment.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,11 +1229,21 @@ public void onPositiveButtonClicked(String[] lockTaskArray) {
12291229
return true;
12301230
case SET_TIME_KEY:
12311231
// Disable auto time before we could set time manually.
1232-
setAutoTimeEnabled(false);
1232+
if (Util.SDK_INT >= VERSION_CODES.R) {
1233+
setAutoTimeEnabled(false);
1234+
} else {
1235+
mDevicePolicyManager.setGlobalSetting(mAdminComponentName,
1236+
Settings.Global.AUTO_TIME, "0");
1237+
}
12331238
showSetTimeDialog();
12341239
return true;
12351240
case SET_TIME_ZONE_KEY:
1236-
setAutoTimeZoneEnabled(false);
1241+
if (Util.SDK_INT >= VERSION_CODES.R) {
1242+
setAutoTimeZoneEnabled(false);
1243+
} else {
1244+
mDevicePolicyManager.setGlobalSetting(mAdminComponentName,
1245+
Settings.Global.AUTO_TIME_ZONE, "0");
1246+
}
12371247
showSetTimeZoneDialog();
12381248
return true;
12391249
case MANAGE_OVERRIDE_APN_KEY:

0 commit comments

Comments
 (0)