OSDN Git Service

Send launch token to activity manager
authorTodd Kennedy <toddke@google.com>
Mon, 20 Mar 2017 23:05:48 +0000 (16:05 -0700)
committerTodd Kennedy <toddke@google.com>
Mon, 20 Mar 2017 23:05:48 +0000 (16:05 -0700)
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

core/java/android/content/Intent.java
services/core/java/com/android/server/am/ActivityMetricsLogger.java
services/core/java/com/android/server/am/ActivityStackSupervisor.java
services/core/java/com/android/server/pm/InstantAppResolver.java

index bd31b03..e7d306d 100644 (file)
@@ -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.
index dd8c05e..04a09fe 100644 (file)
@@ -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);
index 217515b..bb93174 100644 (file)
@@ -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;
     }
index 86124a8..59f8a2d 100644 (file)
@@ -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(