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

Commit c7aa329d authored by Christopher Tate's avatar Christopher Tate
Browse files

Fix crash recording broadcast receiver duration

Edge case: when a broadcast is skipped outright (e.g. because the recipient
app had just crashed) the which-receiver-is-current bookkeeping is not
initialized.  That means we can't trust it for array-indexing.

Test: atest com.android.cts.devicepolicy.ManagedProfileTest
Change-Id: Id27ddea2e241dbddf34da6a7bab7997f5d9c5070
parent 1d41d539
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -414,7 +414,11 @@ public final class BroadcastQueue {
        if (state == BroadcastRecord.IDLE) {
            Slog.w(TAG, "finishReceiver [" + mQueueName + "] called but state is IDLE");
        }
        // If we're abandoning this broadcast before any receivers were actually spun up,
        // nextReceiver is zero; in which case time-to-process bookkeeping doesn't apply.
        if (r.nextReceiver > 0) {
            r.duration[r.nextReceiver - 1] = finishTime - r.receiverTime;
        }
        r.receiver = null;
        r.intent.setComponent(null);
        if (r.curApp != null && r.curApp.curReceivers.contains(r)) {