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

Commit 84ff04d3 authored by Yasin Kilicdere's avatar Yasin Kilicdere
Browse files

Start user in background via adb command instead of calling the API.

If the user to be started is a profile of a current foreground user,
it should be started via IActivityManager.startProfileWithListener API
instead of IActivityManager.startUserInBackgroundWithListener. This
logic is already implemented in ActivityManagerShellCommand, so rather
than duplicating it, we'll be doing it by running the shell command.

Bug: 279403644
Test: atest UserLifecycleTests
Change-Id: I4b9e6f1e565187e93e13ad94f41d51ee5f7e3e42
parent 304ace56
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -1261,15 +1261,13 @@ public class UserLifecycleTests {
     * <p> This should always be used for profiles since profiles cannot be started in foreground.
     */
    private void startUserInBackgroundAndWaitForUnlock(int userId) {
        final ProgressWaiter waiter = new ProgressWaiter();
        boolean success = false;
        try {
            mIam.startUserInBackgroundWithListener(userId, waiter);
            success = waiter.waitForFinish(TIMEOUT_IN_SECOND);
        } catch (RemoteException e) {
            Log.e(TAG, "startUserInBackgroundAndWaitForUnlock failed", e);
            attestTrue("Failed to start user " + userId + " in background.",
                    ShellHelper.runShellCommandWithTimeout("am start-user -w " + userId,
                            TIMEOUT_IN_SECOND).startsWith("Success:"));
        } catch (TimeoutException e) {
            fail("Could not start user " + userId + " in " + TIMEOUT_IN_SECOND + " seconds");
        }
        attestTrue("Failed to start user " + userId + " in background.", success);
    }

    /** Starts the given user in the foreground. */