Loading services/core/java/com/android/server/pm/UserManagerInternal.java +11 −0 Original line number Diff line number Diff line Loading @@ -321,4 +321,15 @@ public abstract class UserManagerInternal { * {@link UserManager#isUserVisible()} in the given display. */ public abstract boolean isUserVisible(@UserIdInt int userId, int displayId); /** * Returns the display id assigned to the user, or {@code Display.INVALID_DISPLAY} if the * user is not assigned to any display. * * <p>The current foreground user is associated with the main display, while other users would * only assigned to a display if they were started with * {@code ActivityManager.startUserInBackgroundOnSecondaryDisplay()}. If the user is a profile * and is running, it's assigned to its parent display. */ public abstract int getDisplayAssignedToUser(@UserIdInt int userId); } services/core/java/com/android/server/pm/UserManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -1731,6 +1731,18 @@ public class UserManagerService extends IUserManager.Stub { return false; } // TODO(b/239982558): add unit test private int getDisplayAssignedToUser(@UserIdInt int userId) { if (isCurrentUserOrRunningProfileOfCurrentUser(userId)) { return Display.DEFAULT_DISPLAY; } synchronized (mUsersLock) { return mUsersOnSecondaryDisplays == null ? Display.INVALID_DISPLAY : mUsersOnSecondaryDisplays.get(userId, Display.INVALID_DISPLAY); } } private boolean isCurrentUserOrRunningProfileOfCurrentUser(@UserIdInt int userId) { int currentUserId = Binder.withCleanCallingIdentity(() -> ActivityManager.getCurrentUser()); Loading Loading @@ -6695,6 +6707,11 @@ public class UserManagerService extends IUserManager.Stub { public boolean isUserVisible(int userId, int displayId) { return isUserVisibleOnDisplay(userId, displayId); } @Override public int getDisplayAssignedToUser(int userId) { return UserManagerService.this.getDisplayAssignedToUser(userId); } } // class LocalService /** Loading Loading
services/core/java/com/android/server/pm/UserManagerInternal.java +11 −0 Original line number Diff line number Diff line Loading @@ -321,4 +321,15 @@ public abstract class UserManagerInternal { * {@link UserManager#isUserVisible()} in the given display. */ public abstract boolean isUserVisible(@UserIdInt int userId, int displayId); /** * Returns the display id assigned to the user, or {@code Display.INVALID_DISPLAY} if the * user is not assigned to any display. * * <p>The current foreground user is associated with the main display, while other users would * only assigned to a display if they were started with * {@code ActivityManager.startUserInBackgroundOnSecondaryDisplay()}. If the user is a profile * and is running, it's assigned to its parent display. */ public abstract int getDisplayAssignedToUser(@UserIdInt int userId); }
services/core/java/com/android/server/pm/UserManagerService.java +17 −0 Original line number Diff line number Diff line Loading @@ -1731,6 +1731,18 @@ public class UserManagerService extends IUserManager.Stub { return false; } // TODO(b/239982558): add unit test private int getDisplayAssignedToUser(@UserIdInt int userId) { if (isCurrentUserOrRunningProfileOfCurrentUser(userId)) { return Display.DEFAULT_DISPLAY; } synchronized (mUsersLock) { return mUsersOnSecondaryDisplays == null ? Display.INVALID_DISPLAY : mUsersOnSecondaryDisplays.get(userId, Display.INVALID_DISPLAY); } } private boolean isCurrentUserOrRunningProfileOfCurrentUser(@UserIdInt int userId) { int currentUserId = Binder.withCleanCallingIdentity(() -> ActivityManager.getCurrentUser()); Loading Loading @@ -6695,6 +6707,11 @@ public class UserManagerService extends IUserManager.Stub { public boolean isUserVisible(int userId, int displayId) { return isUserVisibleOnDisplay(userId, displayId); } @Override public int getDisplayAssignedToUser(int userId) { return UserManagerService.this.getDisplayAssignedToUser(userId); } } // class LocalService /** Loading