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

Commit 81fe96be authored by John Wu's avatar John Wu
Browse files

Return early in SaferIntentUtils.blockNullAction when action is not null

All operations can be skipped if the target intent is not null, making
the most common case: implicit intent query, basically no-op to improve
performance.

Bug: 336039853
Test: atest SaferIntentTest
Flag: EXEMPT bugfix
Change-Id: If162bf2b46bce184213a14200228f1497e76e883
parent 844824aa
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ public class SaferIntentUtils {
     * CTS tests. The code in this method shall properly avoid control flows using these arguments.
     */
    public static void blockNullAction(IntentArgs args, List componentList) {
        if (args.intent.getAction() != null) return;
        if (ActivityManager.canAccessUnexportedComponents(args.callingUid)) return;

        final Computer computer = (Computer) args.snapshot;
@@ -235,15 +236,12 @@ public class SaferIntentUtils {
                }
                final ParsedMainComponent comp = infoToComponent(
                        resolveInfo.getComponentInfo(), resolver, args.isReceiver);
                if (comp != null && !comp.getIntents().isEmpty()
                        && args.intent.getAction() == null) {
                if (comp != null && !comp.getIntents().isEmpty()) {
                    match = false;
                }
            } else if (c instanceof IntentFilter) {
                if (args.intent.getAction() == null) {
                match = false;
            }
            }

            if (!match) {
                args.reportEvent(