Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b531d086 authored by Tony Mak's avatar Tony Mak
Browse files

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
parent ac9cac71
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -641,12 +641,16 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public UserInfo getUserInfo(int userId) {
        if (!hasManageUsersPermission()
                && !isSameProfileGroupLP(UserHandle.getCallingUserId(), userId)) {
        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");
                            "You need MANAGE_USERS permission to: query users outside profile" +
                                    " group");
                }
            }
        }

        synchronized (mUsersLock) {
            return getUserInfoLU(userId);
        }