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

Commit d8aa6daa authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Wait for broadcast barrier to speed up tests."

parents eb36823e 3789c092
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -823,6 +823,7 @@ interface IActivityManager {

    /** Blocks until all broadcast queues become idle. */
    void waitForBroadcastIdle();
    void waitForBroadcastBarrier();

    /** Delays delivering broadcasts to the specified package. */
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.DUMP)")
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ import androidx.test.InstrumentationRegistry;
import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;

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

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -96,6 +98,7 @@ abstract class AbstractCrossUserContentResolverTest {
        mContext.registerReceiverAsUser(receiver, UserHandle.of(mCrossUserId),
                new IntentFilter(Intent.ACTION_USER_UNLOCKED), null, null);
        ActivityManager.getService().startUserInBackground(mCrossUserId);
        SystemUtil.runShellCommand("am wait-for-broadcast-barrier");

        try {
            if (!latch.await(TIMEOUT_USER_UNLOCK_SEC, TimeUnit.SECONDS)) {
+5 −0
Original line number Diff line number Diff line
@@ -18843,6 +18843,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    @Override
    public void waitForBroadcastBarrier() {
        waitForBroadcastBarrier(/* printWriter= */ null, false);
    }
    public void waitForBroadcastBarrier(@Nullable PrintWriter pw, boolean flushBroadcastLoopers) {
        enforceCallingPermission(permission.DUMP, "waitForBroadcastBarrier()");
        if (flushBroadcastLoopers) {