Merge "Make flushing broadcast loopers optional." into udc-dev

This commit is contained in:
Sudheer Shanka
2023-05-15 18:59:58 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 6 deletions

View File

@@ -18894,12 +18894,14 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void waitForBroadcastIdle() {
waitForBroadcastIdle(LOG_WRITER_INFO);
waitForBroadcastIdle(LOG_WRITER_INFO, false);
}
public void waitForBroadcastIdle(@NonNull PrintWriter pw) {
void waitForBroadcastIdle(@NonNull PrintWriter pw, boolean flushBroadcastLoopers) {
enforceCallingPermission(permission.DUMP, "waitForBroadcastIdle()");
BroadcastLoopers.waitForIdle(pw);
if (flushBroadcastLoopers) {
BroadcastLoopers.waitForIdle(pw);
}
for (BroadcastQueue queue : mBroadcastQueues) {
queue.waitForIdle(pw);
}
@@ -18912,7 +18914,7 @@ public class ActivityManagerService extends IActivityManager.Stub
waitForBroadcastBarrier(LOG_WRITER_INFO, false, false);
}
public void waitForBroadcastBarrier(@NonNull PrintWriter pw,
void waitForBroadcastBarrier(@NonNull PrintWriter pw,
boolean flushBroadcastLoopers, boolean flushApplicationThreads) {
enforceCallingPermission(permission.DUMP, "waitForBroadcastBarrier()");
if (flushBroadcastLoopers) {
@@ -18930,7 +18932,7 @@ public class ActivityManagerService extends IActivityManager.Stub
* Wait for all pending {@link IApplicationThread} events to be processed in
* all currently running apps.
*/
public void waitForApplicationBarrier(@NonNull PrintWriter pw) {
void waitForApplicationBarrier(@NonNull PrintWriter pw) {
final CountDownLatch finishedLatch = new CountDownLatch(1);
final AtomicInteger pingCount = new AtomicInteger(0);
final AtomicInteger pongCount = new AtomicInteger(0);

View File

@@ -3447,7 +3447,17 @@ final class ActivityManagerShellCommand extends ShellCommand {
int runWaitForBroadcastIdle(PrintWriter pw) throws RemoteException {
pw = new PrintWriter(new TeeWriter(LOG_WRITER_INFO, pw));
mInternal.waitForBroadcastIdle(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.waitForBroadcastIdle(pw, flushBroadcastLoopers);
return 0;
}