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

Commit c2dba53c authored by John Wu's avatar John Wu Committed by Android (Google) Code Review
Browse files

Merge "Fix several bugs in SaferIntentUtils" into main

parents 11a6de6f d4ac3c2d
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -248,6 +248,25 @@ public class PlatformCompat extends IPlatformCompat.Stub {
        return enabled;
    }

    /**
     * Internal version of {@link #isChangeEnabledByUid(long, int)}.
     *
     * <p>Does not perform costly permission check and logging.
     */
    public boolean isChangeEnabledByUidInternalNoLogging(long changeId, int uid) {
        String[] packages = mContext.getPackageManager().getPackagesForUid(uid);
        if (packages == null || packages.length == 0) {
            return mCompatConfig.defaultChangeIdValue(changeId);
        }
        boolean enabled = true;
        final int userId = UserHandle.getUserId(uid);
        for (String packageName : packages) {
            final var appInfo = getApplicationInfo(packageName, userId);
            enabled &= isChangeEnabledInternalNoLogging(changeId, appInfo);
        }
        return enabled;
    }

    @Override
    @EnforcePermission(OVERRIDE_COMPAT_CHANGE_CONFIG)
    public void setOverrides(CompatibilityChangeConfig overrides, String packageName) {
+4 −2
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ public class SaferIntentUtils {
    @Disabled
    private static final long ENFORCE_INTENTS_TO_MATCH_INTENT_FILTERS = 161252188;

    @Nullable
    private static ParsedMainComponent infoToComponent(
            ComponentInfo info, ComponentResolverApi resolver, boolean isReceiver) {
        if (info instanceof ActivityInfo) {
@@ -186,7 +187,7 @@ public class SaferIntentUtils {
        }

        boolean isChangeEnabled(long changeId) {
            return platformCompat == null || platformCompat.isChangeEnabledByUidInternal(
            return platformCompat == null || platformCompat.isChangeEnabledByUidInternalNoLogging(
                    changeId, callingUid);
        }

@@ -233,7 +234,8 @@ public class SaferIntentUtils {
                }
                final ParsedMainComponent comp = infoToComponent(
                        resolveInfo.getComponentInfo(), resolver, args.isReceiver);
                if (!comp.getIntents().isEmpty() && args.intent.getAction() == null) {
                if (comp != null && !comp.getIntents().isEmpty()
                        && args.intent.getAction() == null) {
                    match = false;
                }
            } else if (c instanceof IntentFilter) {