diff options
author | Alex Johnston <acjohnston@google.com> | 2022-06-23 22:35:28 +0100 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-28 01:27:02 +0000 |
commit | b927d9db6bff7fd2e61cc75199aefcd3a654a396 (patch) | |
tree | dde5e7260f3cba978ee1797e85ecca379e46724a | |
parent | b50382982ce5f81bd7393f08f97efc9aaf9c58b4 (diff) | |
download | base-b927d9db6bff7fd2e61cc75199aefcd3a654a396.tar.gz |
DPMS workaround to check the device owner type in PermissionController
Context:
* If the device is managed, then hibernation should not be
handled unless the device is financed.
* We need a way to check if a device is financed in
PermissionController. However, PermissionController
is a mainline module so cannot call the TestAPI
Dpm.getDeviceOwnerType
Change:
* User Global Settings to let permission controller know
if the device is financed
Bug: 236283038
Test: Manual testing following go/hibernation-local-testing
Change-Id: Ib9a1a9116014d041c9514752882cdd364bfe777b
(cherry picked from commit 7d1eae2df6d3fb521fcfc0e5c9360e6e44da7299)
Merged-In: Ib9a1a9116014d041c9514752882cdd364bfe777b
-rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 590de7b5e119..9d708add5ca5 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -1982,6 +1982,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { synchronized (getLockObject()) { mOwners.load(); setDeviceOwnershipSystemPropertyLocked(); + if (mOwners.hasDeviceOwner()) { + setGlobalSettingDeviceOwnerType( + mOwners.getDeviceOwnerType(mOwners.getDeviceOwnerPackageName())); + } } } @@ -8811,6 +8815,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { deleteTransferOwnershipBundleLocked(userId); toggleBackupServiceActive(UserHandle.USER_SYSTEM, true); pushUserControlDisabledPackagesLocked(userId); + setGlobalSettingDeviceOwnerType(DEVICE_OWNER_TYPE_DEFAULT); } private void clearApplicationRestrictions(int userId) { @@ -18377,6 +18382,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { "Test only admins can only set the device owner type more than once"); mOwners.setDeviceOwnerType(packageName, deviceOwnerType, isAdminTestOnly); + setGlobalSettingDeviceOwnerType(deviceOwnerType); + } + + // TODO(b/237065504): Allow mainline modules to get the device owner type. This is a workaround + // to get the device owner type in PermissionController. See HibernationPolicy.kt. + private void setGlobalSettingDeviceOwnerType(int deviceOwnerType) { + mInjector.binderWithCleanCallingIdentity( + () -> mInjector.settingsGlobalPutInt("device_owner_type", deviceOwnerType)); } @Override |