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

Commit b3b43130 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Send launch token to activity manager

When an instant app is installed, control passes from the platform
to the instant app installer. However, when the instant app is
launched, the original launch token needs to be associated with that
launch. Do this by sending the launch token along with the original
launch intent

Change-Id: I5741be343862d4e5c8bfb6b4a81d0bac8e53ea9c
Fixes: 35445667
Test: Build and manully inspect the event logs to ensure the launch token is sent on instant app launch
parent d3c51069
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -5123,6 +5123,8 @@ public class Intent implements Parcelable, Cloneable {
    private Intent mSelector;
    private ClipData mClipData;
    private int mContentUserHint = UserHandle.USER_CURRENT;
    /** Token to track instant app launches. Local only; do not copy cross-process. */
    private String mLaunchToken;

    // ---------------------------------------------------------------------

@@ -5143,6 +5145,7 @@ public class Intent implements Parcelable, Cloneable {
        this.mComponent = o.mComponent;
        this.mFlags = o.mFlags;
        this.mContentUserHint = o.mContentUserHint;
        this.mLaunchToken = o.mLaunchToken;
        if (o.mCategories != null) {
            this.mCategories = new ArraySet<String>(o.mCategories);
        }
@@ -6379,6 +6382,16 @@ public class Intent implements Parcelable, Cloneable {
        return mContentUserHint;
    }

    /** @hide */
    public String getLaunchToken() {
        return mLaunchToken;
    }

    /** @hide */
    public void setLaunchToken(String launchToken) {
        mLaunchToken = launchToken;
    }

    /**
     * Sets the ClassLoader that will be used when unmarshalling
     * any Parcelable values from the extras of this Intent.
+1 −0
Original line number Diff line number Diff line
@@ -321,6 +321,7 @@ class ActivityMetricsLogger {
            if (info.launchedActivity.info.launchToken != null) {
                builder.addTaggedData(FIELD_INSTANT_APP_LAUNCH_TOKEN,
                        info.launchedActivity.info.launchToken);
                info.launchedActivity.info.launchToken = null;
            }
            builder.addTaggedData(APP_TRANSITION_IS_EPHEMERAL,
                    info.launchedActivity.info.applicationInfo.isInstantApp() ? 1 : 0);
+4 −0
Original line number Diff line number Diff line
@@ -1226,6 +1226,10 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
                    mService.setProfileApp(aInfo.applicationInfo, aInfo.processName, profilerInfo);
                }
            }
            final String intentLaunchToken = intent.getLaunchToken();
            if (aInfo.launchToken == null && intentLaunchToken != null) {
                aInfo.launchToken = intentLaunchToken;
            }
        }
        return aInfo;
    }
+2 −0
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ public abstract class InstantAppResolver {
            // Intent that is launched if the package couldn't be installed for any reason.
            final Intent failureIntent = new Intent(origIntent);
            failureIntent.setFlags(failureIntent.getFlags() | Intent.FLAG_IGNORE_EPHEMERAL);
            failureIntent.setLaunchToken(token);
            try {
                final IIntentSender failureIntentTarget = ActivityManager.getService()
                        .getIntentSender(
@@ -216,6 +217,7 @@ public abstract class InstantAppResolver {

            // Intent that is launched if the package was installed successfully.
            final Intent successIntent = new Intent(origIntent);
            successIntent.setLaunchToken(token);
            try {
                final IIntentSender successIntentTarget = ActivityManager.getService()
                        .getIntentSender(