diff options
| -rw-r--r-- | services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java index 8b9a65103c6d..24f73c3ac54c 100644 --- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java @@ -8903,17 +8903,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } @Override - public ComponentName getProfileOwnerAsUser(int userHandle) { + public ComponentName getProfileOwnerAsUser(int userId) { if (!mHasFeature) { return null; } - Preconditions.checkArgumentNonnegative(userHandle, "Invalid userId"); + Preconditions.checkArgumentNonnegative(userId, "Invalid userId"); - final CallerIdentity caller = getCallerIdentity(); - Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userHandle)); + CallerIdentity caller = getCallerIdentity(); + Preconditions.checkCallAuthorization(hasCrossUsersPermission(caller, userId)); synchronized (getLockObject()) { - return mOwners.getProfileOwnerComponent(userHandle); + return mOwners.getProfileOwnerComponent(userId); } } @@ -9357,19 +9357,20 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { public List<UserHandle> listForegroundAffiliatedUsers() { checkIsDeviceOwner(getCallerIdentity()); - int userId = mInjector.binderWithCleanCallingIdentity(() -> getCurrentForegroundUserId()); - - boolean isAffiliated; - synchronized (getLockObject()) { - isAffiliated = isUserAffiliatedWithDeviceLocked(userId); - } + return mInjector.binderWithCleanCallingIdentity(() -> { + int userId = getCurrentForegroundUserId(); + boolean isAffiliated; + synchronized (getLockObject()) { + isAffiliated = isUserAffiliatedWithDeviceLocked(userId); + } - if (!isAffiliated) return Collections.emptyList(); + if (!isAffiliated) return Collections.emptyList(); - List<UserHandle> users = new ArrayList<>(1); - users.add(UserHandle.of(userId)); + List<UserHandle> users = new ArrayList<>(1); + users.add(UserHandle.of(userId)); - return users; + return users; + }); } protected int getProfileParentId(int userHandle) { @@ -14129,7 +14130,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } - private boolean isUserAffiliatedWithDeviceLocked(int userId) { + private boolean isUserAffiliatedWithDeviceLocked(@UserIdInt int userId) { if (!mOwners.hasDeviceOwner()) { return false; } |