diff options
| author | 2024-06-07 01:07:52 +0000 | |
|---|---|---|
| committer | 2024-06-07 01:07:52 +0000 | |
| commit | 9b212379f33a0b86ef744739065718fd2f23b64a (patch) | |
| tree | 5ce511a87ab93e8ac6caf7b4764de8a0d73d2344 | |
| parent | 43b19a4aabefec0796781a27a7719f65e7ab79a5 (diff) | |
| parent | 08b1e8f9b2116f7338b74aecac2c576a53a96487 (diff) | |
Merge "Ensure AppStartInfo Intent does not contain large objects" into main
| -rw-r--r-- | core/java/android/app/ApplicationStartInfo.java | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/core/java/android/app/ApplicationStartInfo.java b/core/java/android/app/ApplicationStartInfo.java index 3715c6e633dc..f77c50a271be 100644 --- a/core/java/android/app/ApplicationStartInfo.java +++ b/core/java/android/app/ApplicationStartInfo.java @@ -416,11 +416,34 @@ public final class ApplicationStartInfo implements Parcelable { /** * @see #getStartIntent + * + * <p class="note"> Note: This method will clone the provided intent and ensure that the cloned + * intent doesn't contain any large objects like bitmaps in its extras by stripping it in the + * least aggressive acceptable way for the individual intent.</p> + * * @hide */ public void setIntent(Intent startIntent) { if (startIntent != null) { - mStartIntent = startIntent.maybeStripForHistory(); + if (startIntent.canStripForHistory()) { + // If maybeStripForHistory will return a lightened version, do that. + mStartIntent = startIntent.maybeStripForHistory(); + } else if (startIntent.getExtras() != null) { + // If maybeStripForHistory would not return a lightened version and extras is + // non-null then extras contains un-parcelled data. Use cloneFilter to strip data + // more aggressively. + mStartIntent = startIntent.cloneFilter(); + } else { + // Finally, if maybeStripForHistory would not return a lightened version and extras + // is null then do a regular clone so we don't leak the intent. + mStartIntent = new Intent(startIntent); + } + + // If the newly cloned intent has an original intent, clear that as we don't need it and + // can't guarantee it doesn't need to be stripped as well. + if (mStartIntent.getOriginalIntent() != null) { + mStartIntent.setOriginalIntent(null); + } } } |