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

Commit 2b9be040 authored by Sudheer Shanka's avatar Sudheer Shanka Committed by Android (Google) Code Review
Browse files

Merge "Cleanup flag com.android.server.am.avoid_note_op_at_enqueue." into main

parents 9a3fc488 f3349093
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -826,9 +826,7 @@ class BroadcastQueueImpl extends BroadcastQueue {

            // If this receiver is going to be skipped, skip it now itself and don't even enqueue
            // it.
            final String skipReason = Flags.avoidNoteOpAtEnqueue()
                    ? mSkipPolicy.shouldSkipAtEnqueueMessage(r, receiver)
                    : mSkipPolicy.shouldSkipMessage(r, receiver);
            final String skipReason = mSkipPolicy.shouldSkipAtEnqueueMessage(r, receiver);
            if (skipReason != null) {
                setDeliveryState(null, null, r, i, receiver, BroadcastRecord.DELIVERY_SKIPPED,
                        "skipped by policy at enqueue: " + skipReason);
+0 −11
Original line number Diff line number Diff line
package: "com.android.server.am"
container: "system"

flag {
    name: "avoid_note_op_at_enqueue"
    namespace: "backstage_power"
    description: "Avoid triggering noteOp while enqueueing a broadcast"
    is_fixed_read_only: true
    bug: "268016162"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "log_broadcast_processed_event"
    namespace: "backstage_power"
+0 −39
Original line number Diff line number Diff line
@@ -1761,45 +1761,6 @@ public final class BroadcastQueueImplTest extends BaseBroadcastQueueTest {
    }

    @SuppressWarnings("GuardedBy")
    @DisableFlags(Flags.FLAG_AVOID_NOTE_OP_AT_ENQUEUE)
    @Test
    public void testSkipPolicy_atEnqueueTime_flagDisabled() throws Exception {
        final Intent userPresent = new Intent(Intent.ACTION_USER_PRESENT);
        final Object greenReceiver = makeManifestReceiver(PACKAGE_GREEN, CLASS_GREEN);
        final Object redReceiver = makeManifestReceiver(PACKAGE_RED, CLASS_RED);

        final BroadcastRecord userPresentRecord = makeBroadcastRecord(userPresent,
                List.of(greenReceiver, redReceiver));

        final Intent timeTick = new Intent(Intent.ACTION_TIME_TICK);
        final BroadcastRecord timeTickRecord = makeBroadcastRecord(timeTick,
                List.of(greenReceiver, redReceiver));

        doAnswer(invocation -> {
            final BroadcastRecord r = invocation.getArgument(0);
            final Object o = invocation.getArgument(1);
            if (userPresent.getAction().equals(r.intent.getAction())
                    && isReceiverEquals(o, greenReceiver)) {
                return "receiver skipped by test";
            }
            return null;
        }).when(mSkipPolicy).shouldSkipMessage(any(BroadcastRecord.class), any());

        mImpl.enqueueBroadcastLocked(userPresentRecord);
        mImpl.enqueueBroadcastLocked(timeTickRecord);

        final BroadcastProcessQueue greenQueue = mImpl.getProcessQueue(PACKAGE_GREEN,
                getUidForPackage(PACKAGE_GREEN));
        // There should be only one broadcast for green process as the other would have
        // been skipped.
        verifyPendingRecords(greenQueue, List.of(timeTick));
        final BroadcastProcessQueue redQueue = mImpl.getProcessQueue(PACKAGE_RED,
                getUidForPackage(PACKAGE_RED));
        verifyPendingRecords(redQueue, List.of(userPresent, timeTick));
    }

    @SuppressWarnings("GuardedBy")
    @EnableFlags(Flags.FLAG_AVOID_NOTE_OP_AT_ENQUEUE)
    @Test
    public void testSkipPolicy_atEnqueueTime() throws Exception {
        final Intent userPresent = new Intent(Intent.ACTION_USER_PRESENT);