Allow calls from the same profile group

isManagedProfile/isUserUnlockingOrUnlocked should allow callers from
the same profile group.

Test: manual
Change-Id: Ic90a379ca324914c1f60a5af5214b33448d3a70e
Fixes: 32158068
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 6498b0e..9f6e8c0 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -673,6 +673,10 @@
     public boolean isSameProfileGroup(int userId, int otherUserId) {
         if (userId == otherUserId) return true;
         checkManageUsersPermission("check if in the same profile group");
+        return isSameProfileGroupNoChecks(userId, otherUserId);
+    }
+
+    private boolean isSameProfileGroupNoChecks(int userId, int otherUserId) {
         synchronized (mUsersLock) {
             UserInfo userInfo = getUserInfoLU(userId);
             if (userInfo == null || userInfo.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) {
@@ -874,7 +878,7 @@
     public boolean isManagedProfile(int userId) {
         int callingUserId = UserHandle.getCallingUserId();
         if (callingUserId != userId && !hasManageUsersPermission()) {
-            if (!isSameProfileGroup(callingUserId, userId)) {
+            if (!isSameProfileGroupNoChecks(callingUserId, userId)) {
                 throw new SecurityException(
                         "You need MANAGE_USERS permission to: check if specified user a " +
                         "managed profile outside your profile group");
@@ -890,7 +894,7 @@
     public boolean isUserUnlockingOrUnlocked(int userId) {
         int callingUserId = UserHandle.getCallingUserId();
         if (callingUserId != userId && !hasManageUsersPermission()) {
-            if (!isSameProfileGroup(callingUserId, userId)) {
+            if (!isSameProfileGroupNoChecks(callingUserId, userId)) {
                 throw new SecurityException(
                         "You need MANAGE_USERS permission to: check isUserUnlockingOrUnlocked");
             }