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

Commit abf1698d authored by Nan Wu's avatar Nan Wu
Browse files

intent.collectExtraIntentKeys only required when there are extra Intent

Set a flag FLAG_HAS_INTENT when an intent is added to a bundle so
that we can check if an intent's extra bundle contains intent.
We only requires top level intent calls intent.collectExtraIntentKeys
if it contains extra intents.

Bug: 380716871
Test: Manual
Flag: android.security.prevent_intent_redirect
Change-Id: I460f63fcf2bd04d3b22c4f2deba956d4af232f56
parent beed0e80
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -7856,6 +7856,10 @@ public class Intent implements Parcelable, Cloneable {
     */
    public static final int URI_ALLOW_UNSAFE = 1<<2;
    static {
        Bundle.intentClass = Intent.class;
    }
    // ---------------------------------------------------------------------
    private String mAction;
+24 −0
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
     */
    static final int FLAG_VERIFY_TOKENS_PRESENT = 1 << 13;

    /**
     * Indicates the bundle definitely contains an Intent.
     */
    static final int FLAG_HAS_INTENT = 1 << 14;


    /**
     * Status when the Bundle can <b>assert</b> that the underlying Parcel DOES NOT contain
@@ -117,6 +122,11 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
    /** An unmodifiable {@code Bundle} that is always {@link #isEmpty() empty}. */
    public static final Bundle EMPTY;

    /**
     * @hide
     */
    public static Class<?> intentClass;

    /**
     * Special extras used to denote extras have been stripped off.
     * @hide
@@ -388,6 +398,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
        if ((bundle.mFlags & FLAG_HAS_BINDERS_KNOWN) == 0) {
            mFlags &= ~FLAG_HAS_BINDERS_KNOWN;
        }
        mFlags |= bundle.mFlags & FLAG_HAS_INTENT;
    }

    /**
@@ -447,6 +458,16 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
        }
    }

    /**
     * Returns if the bundle definitely contains at least an intent. This method returns false does
     * not guarantee the bundle does not contain a nested intent. An intent could still exist in a
     * ParcelableArrayList, ParcelableArray, ParcelableList, a bundle in this bundle, etc.
     * @hide
     */
    public boolean hasIntent() {
        return (mFlags & FLAG_HAS_INTENT) != 0;
    }

    /** {@hide} */
    @Override
    public void putObject(@Nullable String key, @Nullable Object value) {
@@ -569,6 +590,9 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
        mMap.put(key, value);
        mFlags &= ~FLAG_HAS_FDS_KNOWN;
        mFlags &= ~FLAG_HAS_BINDERS_KNOWN;
        if (intentClass != null && intentClass.isInstance(value)) {
            mFlags |= FLAG_HAS_INTENT;
        }
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -19334,7 +19334,8 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (!preventIntentRedirect()) return;
        if (intent == null) return;
        if ((intent.getExtendedFlags() & Intent.EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED) == 0) {
        if (((intent.getExtendedFlags() & Intent.EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED) == 0)
                && intent.getExtras() != null && intent.getExtras().hasIntent()) {
            Slog.wtf(TAG,
                    "[IntentRedirect] The intent does not have its nested keys collected as a "
                            + "preparation for creating intent creator tokens. Intent: "