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

Commit d3c63a66 authored by Adam Powell's avatar Adam Powell
Browse files

Make Activity.getReferrer tolerate custom Parcelables in intents

Referrer information is passed as an intent extra to each Activity,
therefore if that intent contains a custom parcelable unmarshaling
the intent extras will fail in a call to getReferrer. Insulate apps
from this concern and log a warning when it happens.

Bug 28972438

Change-Id: I37dbc033bfcfe816e4b58b382c012854fbed943b
parent e82ac10f
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import android.hardware.input.InputManager;
import android.media.AudioManager;
import android.media.session.MediaController;
import android.net.Uri;
import android.os.BadParcelableException;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
@@ -5006,6 +5007,7 @@ public class Activity extends ContextThemeWrapper
    @Nullable
    public Uri getReferrer() {
        Intent intent = getIntent();
        try {
            Uri referrer = intent.getParcelableExtra(Intent.EXTRA_REFERRER);
            if (referrer != null) {
                return referrer;
@@ -5014,6 +5016,10 @@ public class Activity extends ContextThemeWrapper
            if (referrerName != null) {
                return Uri.parse(referrerName);
            }
        } catch (BadParcelableException e) {
            Log.w(TAG, "Cannot read referrer from intent;"
                    + " intent extras contain unknown custom Parcelable objects");
        }
        if (mReferrer != null) {
            return new Uri.Builder().scheme("android-app").authority(mReferrer).build();
        }