diff options
| author | 2023-04-27 11:33:12 +0000 | |
|---|---|---|
| committer | 2023-05-02 09:16:34 +0000 | |
| commit | 14a2e5712edd1e095fe5f99aa881f15c78573cee (patch) | |
| tree | 3e54db190ca8e48039e11ef8d93dfe3d7af6cf28 | |
| parent | a54b7778f63aa7fb50a299b3bc6903a419112c47 (diff) | |
Allow system to retrieve keyguardDisabledFeatures for an admin
Bug: 279692817
Test: manual
Test: btest a.d.c.KeyguardTest
Change-Id: Iea6baeb8b775ceacc8e75b73c5cc5a5fd21e1d10
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 675ebd3ddd60..faa995eb4e87 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -9425,12 +9425,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { synchronized (getLockObject()) { if (who != null) { if (isPermissionCheckFlagEnabled()) { - EnforcingAdmin admin = getEnforcingAdminForCaller( - who, who.getPackageName()); + EnforcingAdmin admin = getEnforcingAdminForPackage( + who, who.getPackageName(), userHandle); Integer features = mDevicePolicyEngine.getLocalPolicySetByAdmin( PolicyDefinition.KEYGUARD_DISABLED_FEATURES, admin, affectedUserId); + return features == null ? 0 : features; } else { ActiveAdmin admin = getActiveAdminUncheckedLocked(who, userHandle, parent); @@ -23566,6 +23567,30 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub { return EnforcingAdmin.createEnforcingAdmin(caller.getPackageName(), userId, admin); } + private EnforcingAdmin getEnforcingAdminForPackage(@Nullable ComponentName who, + String packageName, int userId) { + ActiveAdmin admin; + if (who != null) { + if (isDeviceOwner(who, userId) || isProfileOwner(who, userId)) { + synchronized (getLockObject()) { + admin = getActiveAdminUncheckedLocked(who, userId); + } + if (admin != null) { + return EnforcingAdmin.createEnterpriseEnforcingAdmin(who, userId, admin); + } + } else { + // Check for non-DPC active admins. + admin = getActiveAdminUncheckedLocked(who, userId); + if (admin != null) { + return EnforcingAdmin.createDeviceAdminEnforcingAdmin(who, userId, admin); + } + } + } + + admin = getUserData(userId).createOrGetPermissionBasedAdmin(userId); + return EnforcingAdmin.createEnforcingAdmin(packageName, userId, admin); + } + private int getAffectedUser(boolean calledOnParent) { int callingUserId = mInjector.userHandleGetCallingUserId(); return calledOnParent ? getProfileParentId(callingUserId) : callingUserId; |