Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08b1e8f9 authored by Yisroel Forta's avatar Yisroel Forta
Browse files

Ensure AppStartInfo Intent does not contain large objects

The current strip for history solution does not remove extras if data is not parcelled.
Update to:
- use strip for history if that's available
- if extras is not null, use more aggressive clonefilter
- if extras is null, still clone it to avoid leaking it
- always remove the original intent if present

Note: a better long term solution may be to address the existing todo in maybeStripForHistory, will look at this for future version.

Bug: 344851030
Test: presubmit
Flag: EXEMPT - day-to-day bugfix
Change-Id: Ic659d0567fc6c0129e1c01ed584de0f03863789f
parent 6b410e61
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -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) {
            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);
            }
        }
    }