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

Commit 91039b94 authored by Yao Li's avatar Yao Li
Browse files

UserLifecycleStressTest: not stop user on switch

For devices with fw.stop_bg_users_on_switch=1, user will be stopped on
switch. This would cause the test itself to be killed, when the running
user is stopped.

This CL would prevent stop user on switch, by calling setStopUserOnSwitch,
which has higher priority.

Bug: 408273239
Flag: TEST_ONLY
Test: atest FrameworksServicesTests:com.android.server.pm.UserLifecycleStressTest will not crash on device with fw.stop_bg_users_on_switch=1
Change-Id: Id363f105354768a2c500914455ec1496df84abaf
parent 0ff724a9
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ package com.android.server.pm;

import static android.os.UserHandle.USER_NULL;

import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;

import static com.google.common.truth.Truth.assertWithMessage;

import static org.junit.Assume.assumeFalse;
@@ -92,10 +94,16 @@ public final class UserLifecycleStressTest {
                Settings.Global.REMOVE_GUEST_ON_EXIT);
        waitForBroadcastBarrier(); // isolate tests from each other
        mOriginalCurrentUserId = ActivityManager.getCurrentUser();
        runWithShellPermissionIdentity(
                () -> mActivityManager.setStopUserOnSwitch(
                        ActivityManager.STOP_USER_ON_SWITCH_FALSE));
    }

    @After
    public void tearDown() throws Exception {
        runWithShellPermissionIdentity(
                () -> mActivityManager.setStopUserOnSwitch(
                        ActivityManager.STOP_USER_ON_SWITCH_DEFAULT));
        switchUser("on tearDown()", mOriginalCurrentUserId);
        mUserSwitchWaiter.close();
        Settings.Global.putString(mContext.getContentResolver(),