diff options
| -rw-r--r-- | core/java/android/content/Intent.java | 4 | ||||
| -rw-r--r-- | core/java/android/os/Bundle.java | 24 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 3 |
3 files changed, 30 insertions, 1 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index d7660172a2f1..d9e4700a5cd1 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -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; diff --git a/core/java/android/os/Bundle.java b/core/java/android/os/Bundle.java index 05bd10b053fe..819d58d9f059 100644 --- a/core/java/android/os/Bundle.java +++ b/core/java/android/os/Bundle.java @@ -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 @@ -118,6 +123,11 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { 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; + } } /** diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index f41aaeebc49f..ebe7fa5e5a3f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -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: " |