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

Commit 7f9d899a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Changes on am / cmd user for ITestDevice integration"

parents c7f6a80c bd7a1cc9
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4434,7 +4434,8 @@ public class ActivityManager {
                    "device does not support users on secondary displays");
        }
        try {
            return getService().startUserInBackgroundVisibleOnDisplay(userId, displayId);
            return getService().startUserInBackgroundVisibleOnDisplay(userId, displayId,
                    /* unlockProgressListener= */ null);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -805,7 +805,7 @@ interface IActivityManager {
     */
    @JavaPassthrough(annotation=
            "@android.annotation.RequiresPermission(anyOf = {android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS}, conditional = true)")
    boolean startUserInBackgroundVisibleOnDisplay(int userid, int displayId);
    boolean startUserInBackgroundVisibleOnDisplay(int userid, int displayId, IProgressListener unlockProgressListener);

    /**
     * Similar to {@link #startProfile(int userId)}, but with a listener to report user unlock
+9 −6
Original line number Diff line number Diff line
@@ -16713,7 +16713,8 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    @Override
    public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId) {
    public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId,
            @Nullable IProgressListener unlockListener) {
        int[] displayIds = getDisplayIdsForStartingVisibleBackgroundUsers();
        boolean validDisplay = false;
        if (displayIds != null) {
@@ -16730,11 +16731,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        if (DEBUG_MU) {
            Slogf.d(TAG_MU, "Calling startUserOnSecondaryDisplay(%d, %d) using injector %s", userId,
                    displayId, mInjector);
            Slogf.d(TAG_MU, "Calling startUserOnSecondaryDisplay(%d, %d, %s) using injector %s",
                    userId, displayId, unlockListener, mInjector);
        }
        // Permission check done inside UserController.
        return mInjector.startUserInBackgroundVisibleOnDisplay(userId, displayId);
        return mInjector.startUserInBackgroundVisibleOnDisplay(userId, displayId, unlockListener);
    }
    @Override
@@ -19115,8 +19116,10 @@ public class ActivityManagerService extends IActivityManager.Stub
        /**
         * Called by {@code AMS.startUserInBackgroundVisibleOnDisplay()}.
         */
        public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId) {
            return mUserController.startUserVisibleOnDisplay(userId, displayId);
        public boolean startUserInBackgroundVisibleOnDisplay(int userId, int displayId,
                @Nullable IProgressListener unlockProgressListener) {
            return mUserController.startUserVisibleOnDisplay(userId, displayId,
                    unlockProgressListener);
        }
        /**
+5 −3
Original line number Diff line number Diff line
@@ -2261,9 +2261,10 @@ final class ActivityManagerShellCommand extends ShellCommand {
                    pw.println("Not supported");
                    return -1;
                }
                Slogf.d(TAG, "calling startUserInBackgroundVisibleOnDisplay(%d,%d)", userId,
                        displayId);
                success = mInterface.startUserInBackgroundVisibleOnDisplay(userId, displayId);
                Slogf.d(TAG, "calling startUserInBackgroundVisibleOnDisplay(%d, %d, %s)", userId,
                        displayId, waiter);
                success = mInterface.startUserInBackgroundVisibleOnDisplay(userId, displayId,
                        waiter);
                displaySuffix = " on display " + displayId;
            }
            if (wait && success) {
@@ -3867,6 +3868,7 @@ final class ActivityManagerShellCommand extends ShellCommand {

    int runListDisplaysForStartingUsers(PrintWriter pw) throws RemoteException {
        int[] displayIds = mInterface.getDisplayIdsForStartingVisibleBackgroundUsers();
        // NOTE: format below cannot be changed as it's used by ITestDevice
        pw.println(displayIds == null || displayIds.length == 0
                ? "none"
                : Arrays.toString(displayIds));
+4 −2
Original line number Diff line number Diff line
@@ -1560,16 +1560,18 @@ class UserController implements Handler.Callback {
     *
     * @param userId user to be started
     * @param displayId display where the user will be visible
     * @param unlockListener Listener to be informed when the user has started and unlocked.
     *
     * @return whether the user was started
     */
    boolean startUserVisibleOnDisplay(@UserIdInt int userId, int displayId) {
    boolean startUserVisibleOnDisplay(@UserIdInt int userId, int displayId,
            @Nullable IProgressListener unlockListener) {
        checkCallingHasOneOfThosePermissions("startUserOnDisplay",
                MANAGE_USERS, INTERACT_ACROSS_USERS);

        try {
            return startUserNoChecks(userId, displayId, USER_START_MODE_BACKGROUND_VISIBLE,
                    /* unlockListener= */ null);
                    unlockListener);
        } catch (RuntimeException e) {
            Slogf.e(TAG, "startUserOnSecondaryDisplay(%d, %d) failed: %s", userId, displayId, e);
            return false;
Loading