Subtle fix when queue becomes unrunnable.

When broadcasts are skipped or failed during list traversal, we might
encounter a queue that is no longer runnable; skip it.

Also add new mPendingUrgent contents to dumpsys output.

Bug: 253906105
Test: atest FrameworksMockingServicesTests:BroadcastRecordTest
Test: atest FrameworksMockingServicesTests:BroadcastQueueTest
Test: atest FrameworksMockingServicesTests:BroadcastQueueModernImplTest
Change-Id: Ib85f3f33a9475cd4cd35f04afbc548e386b75c60
This commit is contained in:
Jeff Sharkey
2022-10-26 10:11:36 -06:00
parent 64379f2372
commit d48202e156
2 changed files with 12 additions and 1 deletions

View File

@@ -807,7 +807,7 @@ class BroadcastProcessQueue {
@NeverCompile
public void dumpLocked(@UptimeMillisLong long now, @NonNull IndentingPrintWriter pw) {
if ((mActive == null) && mPending.isEmpty()) return;
if ((mActive == null) && isEmpty()) return;
pw.print(toShortString());
if (isRunnable()) {
@@ -823,6 +823,10 @@ class BroadcastProcessQueue {
if (mActive != null) {
dumpRecord(now, pw, mActive, mActiveIndex, mActiveBlockedUntilTerminalCount);
}
for (SomeArgs args : mPendingUrgent) {
final BroadcastRecord r = (BroadcastRecord) args.arg1;
dumpRecord(now, pw, r, args.argi1, args.argi2);
}
for (SomeArgs args : mPending) {
final BroadcastRecord r = (BroadcastRecord) args.arg1;
dumpRecord(now, pw, r, args.argi1, args.argi2);

View File

@@ -364,6 +364,13 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
BroadcastProcessQueue nextQueue = queue.runnableAtNext;
final long runnableAt = queue.getRunnableAt();
// When broadcasts are skipped or failed during list traversal, we
// might encounter a queue that is no longer runnable; skip it
if (!queue.isRunnable()) {
queue = nextQueue;
continue;
}
// If queues beyond this point aren't ready to run yet, schedule
// another pass when they'll be runnable
if (runnableAt > now && !waitingFor) {