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
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user