summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ApplicationStartInfo.java25
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);
+ }
}
}