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

Commit e5b4ecaf authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "Improvements on "start bg user on secondary display":"

parents df84d924 cf9d95ff
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -131,6 +131,7 @@ package android.app {
    method public static void resumeAppSwitches() throws android.os.RemoteException;
    method @RequiresPermission(android.Manifest.permission.CHANGE_CONFIGURATION) public void scheduleApplicationInfoChanged(java.util.List<java.lang.String>, int);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}) public void setStopUserOnSwitch(int);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean startUserInBackgroundOnSecondaryDisplay(int, int);
    method @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) public boolean stopUser(int, boolean);
    method @RequiresPermission(android.Manifest.permission.CHANGE_CONFIGURATION) public boolean updateMccMncConfiguration(@NonNull String, @NonNull String);
    method @RequiresPermission(android.Manifest.permission.DUMP) public void waitForBroadcastIdle();
@@ -1875,6 +1876,7 @@ package android.os {
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public java.util.List<android.content.pm.UserInfo> getUsers(boolean, boolean, boolean);
    method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public boolean hasBaseUserRestriction(@NonNull String, @NonNull android.os.UserHandle);
    method public static boolean isSplitSystemUser();
    method public static boolean isUsersOnSecondaryDisplaysEnabled();
    method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}) public android.content.pm.UserInfo preCreateUser(@NonNull String) throws android.os.UserManager.UserOperationException;
  }

+32 −3
Original line number Diff line number Diff line
@@ -4336,12 +4336,41 @@ public class ActivityManager {
    @RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.CREATE_USERS})
    public boolean switchUser(@NonNull UserHandle user) {
        if (user == null) {
            throw new IllegalArgumentException("UserHandle cannot be null.");
        }
        Preconditions.checkNotNull(user, "UserHandle cannot be null.");

        return switchUser(user.getIdentifier());
    }

    /**
     * Starts the given user in background and associate the user with the given display.
     *
     * <p>This method will allow the user to launch activities on that display, and it's typically
     * used only on automotive builds when the vehicle has multiple displays (you can verify if it's
     * supported by calling {@link UserManager#isBackgroundUsersOnSecondaryDisplaysSupported()}).
     *
     * @return whether the user was started.
     *
     * @throws UnsupportedOperationException if the device does not support background users on
     * secondary displays.
     * @throws IllegalArgumentException if the display does not exist.
     * @throws IllegalStateException if the user cannot be started on that display (for example, if
     * there's already a user using that display or if the user is already associated with other
     * display).
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS,
            android.Manifest.permission.CREATE_USERS})
    public boolean startUserInBackgroundOnSecondaryDisplay(@UserIdInt int userId,
            int displayId) {
        try {
            return getService().startUserInBackgroundOnSecondaryDisplay(userId, displayId);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Gets the message that is shown when a user is switched from.
     *
+1 −1
Original line number Diff line number Diff line
@@ -769,6 +769,6 @@ interface IActivityManager {
     *
     * <p>Typically used only by automotive builds when the vehicle has multiple displays.
     */
    boolean startUserInBackgroundOnSecondaryDisplay(int userid, int displayId, IProgressListener unlockProgressListener);
    boolean startUserInBackgroundOnSecondaryDisplay(int userid, int displayId);

}
+1 −0
Original line number Diff line number Diff line
@@ -2841,6 +2841,7 @@ public class UserManager {
    /**
     * @hide
     */
    @TestApi
    public static boolean isUsersOnSecondaryDisplaysEnabled() {
        return SystemProperties.getBoolean("fw.users_on_secondary_displays",
                Resources.getSystem()
+3 −3
Original line number Diff line number Diff line
@@ -16202,10 +16202,10 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    @Override
    public boolean startUserInBackgroundOnSecondaryDisplay(int userId, int displayId,
            @Nullable IProgressListener unlockListener) {
    public boolean startUserInBackgroundOnSecondaryDisplay(int userId, int displayId) {
        // Permission check done inside UserController.
        return mUserController.startUserOnSecondaryDisplay(userId, displayId, unlockListener);
        return mUserController.startUserOnSecondaryDisplay(userId, displayId,
                /* unlockListener= */ null);
    }
    /**
Loading