Skip to content

Commit 2c93dee

Browse files
author
Alex Johnston
committed
Fix reloadSetAutoTimeUi in TestDPC
* Add check to make sure active admin is either a device owner or profile owner of an organization-owned device before calling the API getAutoTimeEnabled. Manual Testing Steps * Set up a device with a device owner and verified that preference was working as expected. * Set up a profile owner of organization -owned device and verified that preference was working as expected. * Set up a profile owner (managed profile) and verified no exception was thrown and that preference is disabled. Bug: 152939119 Test: Manual testing Change-Id: Iae2a3999ed4df044af030793989b7cd12d9c9d7f
1 parent 3f69b93 commit 2c93dee

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,14 +2598,23 @@ private void reloadSetAutoTimeRequiredUi() {
25982598

25992599
@TargetApi(Util.R_VERSION_CODE)
26002600
private void reloadSetAutoTimeUi() {
2601-
boolean isAutoTime = mDevicePolicyManager.getAutoTimeEnabled(mAdminComponentName);
2602-
mSetAutoTimePreference.setChecked(isAutoTime);
2601+
if (mDevicePolicyManager.isDeviceOwnerApp(mPackageName)
2602+
|| (mDevicePolicyManager.isProfileOwnerApp(mPackageName)
2603+
&& mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile())) {
2604+
boolean isAutoTime = mDevicePolicyManager.getAutoTimeEnabled(mAdminComponentName);
2605+
mSetAutoTimePreference.setChecked(isAutoTime);
2606+
}
26032607
}
26042608

26052609
@TargetApi(Util.R_VERSION_CODE)
26062610
private void reloadSetAutoTimeZoneUi() {
2607-
boolean isAutoTimeZone = mDevicePolicyManager.getAutoTimeZoneEnabled(mAdminComponentName);
2608-
mSetAutoTimeZonePreference.setChecked(isAutoTimeZone);
2611+
if (mDevicePolicyManager.isDeviceOwnerApp(mPackageName)
2612+
|| (mDevicePolicyManager.isProfileOwnerApp(mPackageName)
2613+
&& mDevicePolicyManager.isOrganizationOwnedDeviceWithManagedProfile())) {
2614+
boolean isAutoTimeZone = mDevicePolicyManager
2615+
.getAutoTimeZoneEnabled(mAdminComponentName);
2616+
mSetAutoTimeZonePreference.setChecked(isAutoTimeZone);
2617+
}
26092618
}
26102619

26112620
@TargetApi(VERSION_CODES.LOLLIPOP)

0 commit comments

Comments
 (0)