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

Commit dde7a331 authored by Yasin Kilicdere's avatar Yasin Kilicdere
Browse files

wait-for-broadcast-idle before stopUser in UserLifecycleTests.

Stopping a user heavily depends on broadcast queue, and that gets
crowded after user creation and switches. Which leads to a timeout
on stopping user. This CL makes sure broadcast queue is idle before
stopping a user, to prevent the timeout.

Bug: 200217686
Test: atest MultiUserPerfTests:android.multiuser.UserLifecycleTests --no-bazel-mode
Change-Id: Ic08933212d1e4c8f4966cf1c86b9083b708fcd51
parent 5357a3b3
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -316,6 +316,8 @@ public class UserLifecycleTests {
                mIam.startUserInBackground(userId);
            }, Intent.ACTION_USER_STARTED, Intent.ACTION_MEDIA_MOUNTED);

            waitForBroadcastIdle();

            mRunner.resumeTiming();
            Log.i(TAG, "Starting timer");

@@ -678,6 +680,8 @@ public class UserLifecycleTests {
    }

    private void stopUser(int userId, boolean force) throws RemoteException {
        waitForBroadcastIdle();

        final CountDownLatch latch = new CountDownLatch(1);
        mIam.stopUser(userId, force /* force */, new IStopUserCallback.Stub() {
            @Override
@@ -882,4 +886,8 @@ public class UserLifecycleTests {
        assertEquals("", ShellHelper.runShellCommand("setprop " + name + " " + value));
        return oldValue;
    }

    private void waitForBroadcastIdle() {
        ShellHelper.runShellCommand("am wait-for-broadcast-idle");
    }
}