getUserInfo fail when app trying to get self user info
isSameProfileGroupLP return false when user has no profile, we should
check callingUserId != userId explictly.
Please notice that isSameProfileGroup handles this case, but we would like
to avoid the permission checking of isSameProfileGroup.
Change-Id: Ibb2d09eaaf7e8f099445490aa9ec287e86945125
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 5342f98..5fd196b 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -641,12 +641,16 @@
@Override
public UserInfo getUserInfo(int userId) {
- if (!hasManageUsersPermission()
- && !isSameProfileGroupLP(UserHandle.getCallingUserId(), userId)) {
- throw new SecurityException(
- "You need MANAGE_USERS permission to: query users outside profile group");
+ int callingUserId = UserHandle.getCallingUserId();
+ if (callingUserId != userId && !hasManageUsersPermission()) {
+ synchronized (mPackagesLock) {
+ if (!isSameProfileGroupLP(callingUserId, userId)) {
+ throw new SecurityException(
+ "You need MANAGE_USERS permission to: query users outside profile" +
+ " group");
+ }
+ }
}
-
synchronized (mUsersLock) {
return getUserInfoLU(userId);
}