diff options
| author | 2025-03-07 14:18:23 +0000 | |
|---|---|---|
| committer | 2025-03-08 19:29:09 -0800 | |
| commit | aa68eb995a1a5ed9830c4a14a49aa22c4901f451 (patch) | |
| tree | 55c1ba4612dcec664e02b7561c1f863ac632091b | |
| parent | 9e3d8610faf7c77c705fa72811a6fc9da31ea2b9 (diff) | |
Fix collect extra intent keys on server
Previously, when keys are collected on the client side, intent is
marked as keys are collected as long as the bundle is unparceled.
But it is still possible that a Parcelable value is still parceled.
In such a case, if the Parcelable happens to be an intent, its key
is not collected, but the intent is marked as keys are collected.
As a result, the server side also won't try to collect it.
To fix it, remove the mark if there is any unparceled value.
Also, if the mExtras is null or definitely empty without having
to unparcel the bundle and check, mark the intent as keys are
collected.
Bug: 390317645
Test: manual
Flag: EXEMPT bugfix
Change-Id: I0e4bad042063c995364a4ba829cfc556b4698973
| -rw-r--r-- | core/java/android/content/Intent.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 038756148a32..bb62ac321202 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -12426,6 +12426,8 @@ public class Intent implements Parcelable, Cloneable { } private void collectNestedIntentKeysRecur(Set<Intent> visited, boolean forceUnparcel) { + // if forceUnparcel is false, do not unparcel the mExtras bundle. + // forceUnparcel will only be true when this method is called from system server. if (mExtras != null && (forceUnparcel || !mExtras.isParcelled()) && !mExtras.isEmpty()) { addExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED); for (String key : mExtras.keySet()) { @@ -12440,6 +12442,7 @@ public class Intent implements Parcelable, Cloneable { value = mExtras.get(key); } else { value = null; + removeExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED); } } catch (BadParcelableException e) { // This may still happen if the keys are collected on the system server side, in @@ -12459,6 +12462,13 @@ public class Intent implements Parcelable, Cloneable { } } + // if there is no extras in the bundle, we also mark the intent as keys are collected. + // isDefinitelyEmpty() will not unparceled the mExtras. This is the best we can do without + // unparceling the extra bundle. + if (mExtras == null || mExtras.isDefinitelyEmpty()) { + addExtendedFlags(EXTENDED_FLAG_NESTED_INTENT_KEYS_COLLECTED); + } + if (mClipData != null) { for (int i = 0; i < mClipData.getItemCount(); i++) { Intent intent = mClipData.getItemAt(i).mIntent; |