summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/Intent.java22
-rw-r--r--core/java/android/os/BaseBundle.java9
2 files changed, 22 insertions, 9 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 3d75423edfa9..e3e10388754c 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -12401,19 +12401,23 @@ public class Intent implements Parcelable, Cloneable {
private void collectNestedIntentKeysRecur(Set<Intent> visited) {
addExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED);
- if (mExtras != null && !mExtras.isEmpty()) {
+ if (mExtras != null && !mExtras.isParcelled() && !mExtras.isEmpty()) {
for (String key : mExtras.keySet()) {
Object value;
try {
- value = mExtras.get(key);
+ // Do not unparcel any Parcelable objects. It may cause issues for app who would
+ // change class loader before it reads a parceled value. b/382633789.
+ // It is okay to not collect a parceled intent since it would have been
+ // coming from another process and collected by its containing intent already
+ // in that process.
+ if (!mExtras.isValueParceled(key)) {
+ value = mExtras.get(key);
+ } else {
+ value = null;
+ }
} catch (BadParcelableException e) {
- // This could happen when the key points to a LazyValue whose class cannot be
- // found by the classLoader - A nested object more than 1 level deeper who is
- // of type of a custom class could trigger this situation. In such case, we
- // ignore it since it is not an intent. However, it could be a custom type that
- // extends from Intent. If such an object is retrieved later in another
- // component, then trying to launch such a custom class object will fail unless
- // removeLaunchSecurityProtection() is called before it is launched.
+ // This probably would never happen. But just in case, simply ignore it since
+ // it is not an intent anyway.
value = null;
}
if (value instanceof Intent intent) {
diff --git a/core/java/android/os/BaseBundle.java b/core/java/android/os/BaseBundle.java
index ecd90e46e432..1041041b2a27 100644
--- a/core/java/android/os/BaseBundle.java
+++ b/core/java/android/os/BaseBundle.java
@@ -386,6 +386,15 @@ public class BaseBundle implements Parcel.ClassLoaderProvider {
}
/**
+ * return true if the value corresponding to this key is still parceled.
+ * @hide
+ */
+ public boolean isValueParceled(String key) {
+ if (mMap == null) return true;
+ int i = mMap.indexOfKey(key);
+ return (mMap.valueAt(i) instanceof BiFunction<?, ?, ?>);
+ }
+ /**
* Returns the value for a certain position in the array map for expected return type {@code
* clazz} (or pass {@code null} for no type check).
*