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

Commit ca397424 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge changes Ib3d70d21,I005c7665,I41bbcff0 am: e9565c93

Change-Id: Ic1ab941fa0bc95ebaadc8dd8484d872733e9fb34
parents 0db55184 e9565c93
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -1710,6 +1710,12 @@ final class ActivityManagerShellCommand extends ShellCommand {
    }

    private boolean switchUserAndWaitForComplete(int userId) throws RemoteException {
        UserInfo currentUser = mInterface.getCurrentUser();
        if (currentUser != null && userId == currentUser.id) {
            // Already switched to the correct user, exit early.
            return true;
        }

        // Register switch observer.
        final CountDownLatch switchLatch = new CountDownLatch(1);
        mInterface.registerUserSwitchObserver(
@@ -1724,13 +1730,18 @@ final class ActivityManagerShellCommand extends ShellCommand {

        // Switch.
        boolean switched = mInterface.switchUser(userId);
        if (!switched) {
            // Switching failed, don't wait for the user switch observer.
            return false;
        }

        // Wait.
        try {
            switchLatch.await(USER_OPERATION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
            switched = switchLatch.await(USER_OPERATION_TIMEOUT_MS, TimeUnit.MILLISECONDS);
        } catch (InterruptedException e) {
            getErrPrintWriter().println("Thread interrupted unexpectedly.");
            getErrPrintWriter().println("Error: Thread interrupted unexpectedly.");
        }

        return switched;
    }

@@ -1762,7 +1773,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
        if (switched) {
            return 0;
        } else {
            pw.printf("Failed to switch to user %d\n", userId);
            pw.printf("Error: Failed to switch to user %d\n", userId);
            return 1;
        }
    }