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

Commit 00d699f3 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Relax delivery group policy constraints for prioritized bcasts.

When a receiver has been deferred for a prioritized broadcast,
it indicates that a decision has already been made to deliver
to other receivers in lower priority tranches. In that case,
upon the arrival of a new broadcast, the old broadcast for a
deferred receiver can be skipped and removed, provided that
the receiver is also an intended recipient of the new broadcast.

Bug: 344407893
Test: atest ./services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueTest.java
Test: atest ./services/tests/mockingservicestests/src/com/android/server/am/BroadcastQueueModernImplTest.java
Flag: NONE small fix
Change-Id: I386c823e58a7d586f5c8b6eace0ffd5f12ce16e8
parent 42fa58b8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -929,9 +929,9 @@ class BroadcastQueueModernImpl extends BroadcastQueue {
            // For ordered broadcast, check if the receivers for the new broadcast is a superset
            // of those for the previous one as skipping and removing only one of them could result
            // in an inconsistent state.
            if (testRecord.ordered || testRecord.prioritized) {
            if (testRecord.ordered) {
                return containsAllReceivers(r, testRecord, recordsLookupCache);
            } else if (testRecord.resultTo != null) {
            } else if (testRecord.prioritized || testRecord.resultTo != null) {
                return testRecord.getDeliveryState(testIndex) == DELIVERY_DEFERRED
                        ? r.containsReceiver(testRecord.receivers.get(testIndex))
                        : containsAllReceivers(r, testRecord, recordsLookupCache);
+11 −0
Original line number Diff line number Diff line
@@ -1176,6 +1176,17 @@ public final class BroadcastQueueModernImplTest extends BaseBroadcastQueueTest {
        verifyPendingRecords(greenQueue, List.of(screenOff, screenOn));
        verifyPendingRecords(redQueue, List.of(screenOff));
        verifyPendingRecords(blueQueue, List.of(screenOff, screenOn));

        final BroadcastRecord screenOffRecord = makeBroadcastRecord(screenOff, screenOnOffOptions,
                List.of(greenReceiver, redReceiver, blueReceiver), false);
        screenOffRecord.setDeliveryState(2, BroadcastRecord.DELIVERY_DEFERRED,
                "testDeliveryGroupPolicy_prioritized_diffReceivers");
        mImpl.enqueueBroadcastLocked(screenOffRecord);
        mImpl.enqueueBroadcastLocked(makeBroadcastRecord(screenOn, screenOnOffOptions,
                List.of(greenReceiver, blueReceiver), false));
        verifyPendingRecords(greenQueue, List.of(screenOff, screenOn));
        verifyPendingRecords(redQueue, List.of(screenOff));
        verifyPendingRecords(blueQueue, List.of(screenOn));
    }

    /**