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

Commit 02d29b3c authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Allow querying isPreCreated to anyone with INTERACT_ACROSS_USERS...

Merge "Allow querying isPreCreated to anyone with INTERACT_ACROSS_USERS permission." into rvc-dev am: 3c788e8e

Change-Id: I8c8e91e7fd89c2064b1e480416c71ad248087d93
parents eb66c3a0 3c788e8e
Loading
Loading
Loading
Loading
+18 −19
Original line number Diff line number Diff line
@@ -1300,14 +1300,15 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public boolean hasBadge(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "hasBadge");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "hasBadge");
        final UserTypeDetails userTypeDetails = getUserTypeDetailsNoChecks(userId);
        return userTypeDetails != null && userTypeDetails.hasBadge();
    }

    @Override
    public @StringRes int getUserBadgeLabelResId(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "getUserBadgeLabelResId");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId,
                "getUserBadgeLabelResId");
        final UserInfo userInfo = getUserInfoNoChecks(userId);
        final UserTypeDetails userTypeDetails = getUserTypeDetails(userInfo);
        if (userInfo == null || userTypeDetails == null || !userTypeDetails.hasBadge()) {
@@ -1320,7 +1321,8 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public @ColorRes int getUserBadgeColorResId(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "getUserBadgeColorResId");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId,
                "getUserBadgeColorResId");
        final UserInfo userInfo = getUserInfoNoChecks(userId);
        final UserTypeDetails userTypeDetails = getUserTypeDetails(userInfo);
        if (userInfo == null || userTypeDetails == null || !userTypeDetails.hasBadge()) {
@@ -1333,7 +1335,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public @DrawableRes int getUserIconBadgeResId(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "getUserIconBadgeResId");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "getUserIconBadgeResId");
        final UserTypeDetails userTypeDetails = getUserTypeDetailsNoChecks(userId);
        if (userTypeDetails == null || !userTypeDetails.hasBadge()) {
            Slog.e(LOG_TAG, "Requested icon badge for non-badged user " + userId);
@@ -1344,7 +1346,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public @DrawableRes int getUserBadgeResId(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "getUserBadgeResId");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "getUserBadgeResId");
        final UserTypeDetails userTypeDetails = getUserTypeDetailsNoChecks(userId);
        if (userTypeDetails == null || !userTypeDetails.hasBadge()) {
            Slog.e(LOG_TAG, "Requested badge for non-badged user " + userId);
@@ -1355,7 +1357,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public @DrawableRes int getUserBadgeNoBackgroundResId(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId,
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId,
                "getUserBadgeNoBackgroundResId");
        final UserTypeDetails userTypeDetails = getUserTypeDetailsNoChecks(userId);
        if (userTypeDetails == null || !userTypeDetails.hasBadge()) {
@@ -1367,7 +1369,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public boolean isProfile(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isProfile");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "isProfile");
        synchronized (mUsersLock) {
            UserInfo userInfo = getUserInfoLU(userId);
            return userInfo != null && userInfo.isProfile();
@@ -1376,7 +1378,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public boolean isManagedProfile(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isManagedProfile");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "isManagedProfile");
        synchronized (mUsersLock) {
            UserInfo userInfo = getUserInfoLU(userId);
            return userInfo != null && userInfo.isManagedProfile();
@@ -1385,19 +1387,20 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public boolean isUserUnlockingOrUnlocked(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlockingOrUnlocked");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId,
                "isUserUnlockingOrUnlocked");
        return mLocalService.isUserUnlockingOrUnlocked(userId);
    }

    @Override
    public boolean isUserUnlocked(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlocked");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "isUserUnlocked");
        return mLocalService.isUserUnlocked(userId);
    }

    @Override
    public boolean isUserRunning(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserRunning");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "isUserRunning");
        return mLocalService.isUserRunning(userId);
    }

@@ -1437,7 +1440,7 @@ public class UserManagerService extends IUserManager.Stub {
        }
    }

    private void checkManageOrInteractPermIfCallerInOtherProfileGroup(@UserIdInt int userId,
    private void checkManageOrInteractPermissionIfCallerInOtherProfileGroup(@UserIdInt int userId,
            String name) {
        final int callingUserId = UserHandle.getCallingUserId();
        if (callingUserId == userId || isSameProfileGroupNoChecks(callingUserId, userId) ||
@@ -1466,11 +1469,7 @@ public class UserManagerService extends IUserManager.Stub {

    @Override
    public boolean isPreCreated(@UserIdInt int userId) {
        final int callingUserId = UserHandle.getCallingUserId();
        if (callingUserId != userId && !hasManageUsersPermission()) {
            throw new SecurityException("You need MANAGE_USERS permission to query if u=" + userId
                    + " is pre-created");
        }
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "isPreCreated");
        synchronized (mUsersLock) {
            UserInfo userInfo = getUserInfoLU(userId);
            return userInfo != null && userInfo.preCreated;
@@ -1826,7 +1825,7 @@ public class UserManagerService extends IUserManager.Stub {
    /** @return a specific user restriction that's in effect currently. */
    @Override
    public boolean hasUserRestriction(String restrictionKey, @UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "hasUserRestriction");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "hasUserRestriction");
        return mLocalService.hasUserRestriction(restrictionKey, userId);
    }

@@ -1951,7 +1950,7 @@ public class UserManagerService extends IUserManager.Stub {
     */
    @Override
    public Bundle getUserRestrictions(@UserIdInt int userId) {
        checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "getUserRestrictions");
        checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "getUserRestrictions");
        return UserRestrictionsUtils.clone(getEffectiveUserRestrictions(userId));
    }