diff options
| author | 2023-04-26 12:51:13 +0100 | |
|---|---|---|
| committer | 2023-04-26 12:51:13 +0100 | |
| commit | 84ff04d3c285c98d1048f93b975a13210bd7c5d9 (patch) | |
| tree | 3dda521bad9db184991836bd0f0fd2560417cdea | |
| parent | 304ace5611bba777821f70266e8e131f7aa27908 (diff) | |
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
| -rw-r--r-- | apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java index 91f0681c9d7b..e5d4a2087fd4 100644 --- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java +++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java @@ -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. */ |