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

Commit e0800e13 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Make flushing the broadcast loopers optional.

Some of the loopers in system_server process are
quite busy and it takes a while to reach the barrier
and the callers doesn't always need it. So, making
it optional so callers who actually need it can pass
an additional argument to the "wait-for-barrier" command
to use it.

Bug: 260158381
Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java
Test: atest services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java
Change-Id: I4f23baf352b03919175662ddc85fafd95dc1598b
parent 16344766
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -18322,9 +18322,11 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
    }
    public void waitForBroadcastBarrier(@Nullable PrintWriter pw) {
    public void waitForBroadcastBarrier(@Nullable PrintWriter pw, boolean flushBroadcastLoopers) {
        enforceCallingPermission(permission.DUMP, "waitForBroadcastBarrier()");
        if (flushBroadcastLoopers) {
            BroadcastLoopers.waitForBarrier(pw);
        }
        for (BroadcastQueue queue : mBroadcastQueues) {
            queue.waitForBarrier(pw);
        }
+11 −1
Original line number Diff line number Diff line
@@ -3131,7 +3131,17 @@ final class ActivityManagerShellCommand extends ShellCommand {
    }

    int runWaitForBroadcastBarrier(PrintWriter pw) throws RemoteException {
        mInternal.waitForBroadcastBarrier(pw);
        boolean flushBroadcastLoopers = false;
        String opt;
        while ((opt = getNextOption()) != null) {
            if (opt.equals("--flush-broadcast-loopers")) {
                flushBroadcastLoopers = true;
            } else {
                getErrPrintWriter().println("Error: Unknown option: " + opt);
                return -1;
            }
        }
        mInternal.waitForBroadcastBarrier(pw, flushBroadcastLoopers);
        return 0;
    }