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

Commit b28bcb6e authored by Alex Stetson's avatar Alex Stetson Committed by Android (Google) Code Review
Browse files

Merge "Use context id for getMainDisplayIdAssignedToUser" into main

parents 5ab27b38 06b61275
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -139,7 +139,7 @@ interface IUserManager {
    boolean isUserForeground(int userId);
    boolean isUserVisible(int userId);
    int[] getVisibleUsers();
    int getMainDisplayIdAssignedToUser();
    int getMainDisplayIdAssignedToUser(int userId);
    boolean isForegroundUserAdmin();
    boolean isUserNameSet(int userId);
    boolean hasRestrictedProfiles(int userId);
+5 −1
Original line number Diff line number Diff line
@@ -3706,9 +3706,13 @@ public class UserManager {
     * @hide
     */
    @TestApi
    @UserHandleAware(
            requiresAnyOfPermissionsIfNotCaller = {
                    android.Manifest.permission.MANAGE_USERS,
                    android.Manifest.permission.INTERACT_ACROSS_USERS})
    public int getMainDisplayIdAssignedToUser() {
        try {
            return mService.getMainDisplayIdAssignedToUser();
            return mService.getMainDisplayIdAssignedToUser(mUserId);
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
+9 −5
Original line number Diff line number Diff line
@@ -2647,11 +2647,15 @@ public class UserManagerService extends IUserManager.Stub {
    }

    @Override
    public int getMainDisplayIdAssignedToUser() {
        // Not checking for any permission as it returns info about calling user
        int userId = UserHandle.getUserId(Binder.getCallingUid());
        int displayId = mUserVisibilityMediator.getMainDisplayAssignedToUser(userId);
        return displayId;
    public int getMainDisplayIdAssignedToUser(int userId) {
        final int callingUserId = UserHandle.getCallingUserId();
        if (callingUserId != userId
                && !hasManageUsersOrPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)) {
            throw new SecurityException("Caller from user " + callingUserId + " needs MANAGE_USERS "
                    + "or INTERACT_ACROSS_USERS permission to get the main display for (" + userId
                    + ")");
        }
        return mUserVisibilityMediator.getMainDisplayAssignedToUser(userId);
    }

    @Override