diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-05 14:21:14 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-05 14:21:18 +0000 |
commit | d14e67656f61d35ca4982cbee7aa9692f35fe9eb (patch) | |
tree | 940945a6cb81b1f0b8dcaa3f4b5fd0339090a099 | |
parent | d55670bcf57febb38ec2b3bac86ad86a8200b443 (diff) | |
parent | 7dd99e3d463eb2354e5ddb0cbeed1333ec590235 (diff) |
Merge "Don't set the failure extra on split install" into oc-dev
4 files changed, 44 insertions, 27 deletions
diff --git a/core/java/android/content/pm/AuxiliaryResolveInfo.java b/core/java/android/content/pm/AuxiliaryResolveInfo.java index 69bfeca403e1..323733c7c5e4 100644 --- a/core/java/android/content/pm/AuxiliaryResolveInfo.java +++ b/core/java/android/content/pm/AuxiliaryResolveInfo.java @@ -43,13 +43,16 @@ public final class AuxiliaryResolveInfo extends IntentFilter { public final String token; /** The version code of the package */ public final int versionCode; + /** An intent to start upon failure to install */ + public final Intent failureIntent; /** Create a response for installing an instant application. */ public AuxiliaryResolveInfo(@NonNull InstantAppResolveInfo resolveInfo, @NonNull IntentFilter orig, @Nullable String splitName, @NonNull String token, - boolean needsPhase2) { + boolean needsPhase2, + @Nullable Intent failureIntent) { super(orig); this.resolveInfo = resolveInfo; this.packageName = resolveInfo.getPackageName(); @@ -57,12 +60,14 @@ public final class AuxiliaryResolveInfo extends IntentFilter { this.token = token; this.needsPhaseTwo = needsPhase2; this.versionCode = resolveInfo.getVersionCode(); + this.failureIntent = failureIntent; } /** Create a response for installing a split on demand. */ public AuxiliaryResolveInfo(@NonNull String packageName, @Nullable String splitName, - int versionCode) { + int versionCode, + @Nullable Intent failureIntent) { super(); this.packageName = packageName; this.splitName = splitName; @@ -70,5 +75,6 @@ public final class AuxiliaryResolveInfo extends IntentFilter { this.resolveInfo = null; this.token = null; this.needsPhaseTwo = false; + this.failureIntent = failureIntent; } }
\ No newline at end of file diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index 1f1aa8e8cdd9..6d6f33d5a776 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -534,7 +534,8 @@ class ActivityStarter { verificationBundle, userId); } return InstantAppResolver.buildEphemeralInstallerIntent(originalIntent, - callingPackage, verificationBundle, resolvedType, userId, auxiliaryResponse.packageName, + auxiliaryResponse.failureIntent, callingPackage, verificationBundle, + resolvedType, userId, auxiliaryResponse.packageName, auxiliaryResponse.splitName, auxiliaryResponse.versionCode, auxiliaryResponse.token, auxiliaryResponse.needsPhaseTwo); } diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java index 624d8c9ef13e..f3c9cbbdbf6c 100644 --- a/services/core/java/com/android/server/pm/InstantAppResolver.java +++ b/services/core/java/com/android/server/pm/InstantAppResolver.java @@ -125,6 +125,7 @@ public abstract class InstantAppResolver { final String packageName; final String splitName; final int versionCode; + final Intent failureIntent; if (instantAppResolveInfoList != null && instantAppResolveInfoList.size() > 0) { final AuxiliaryResolveInfo instantAppIntentInfo = InstantAppResolver.filterInstantAppIntent( @@ -135,18 +136,22 @@ public abstract class InstantAppResolver { packageName = instantAppIntentInfo.resolveInfo.getPackageName(); splitName = instantAppIntentInfo.splitName; versionCode = instantAppIntentInfo.resolveInfo.getVersionCode(); + failureIntent = instantAppIntentInfo.failureIntent; } else { packageName = null; splitName = null; versionCode = -1; + failureIntent = null; } } else { packageName = null; splitName = null; versionCode = -1; + failureIntent = null; } final Intent installerIntent = buildEphemeralInstallerIntent( requestObj.origIntent, + failureIntent, requestObj.callingPackage, requestObj.verificationBundle, requestObj.resolvedType, @@ -172,7 +177,9 @@ public abstract class InstantAppResolver { /** * Builds and returns an intent to launch the instant installer. */ - public static Intent buildEphemeralInstallerIntent(@NonNull Intent origIntent, + public static Intent buildEphemeralInstallerIntent( + @NonNull Intent origIntent, + @NonNull Intent failureIntent, @NonNull String callingPackage, @Nullable Bundle verificationBundle, @NonNull String resolvedType, @@ -200,22 +207,21 @@ public abstract class InstantAppResolver { // We have all of the data we need; just start the installer without a second phase if (!needsPhaseTwo) { // 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( - ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, - null /*token*/, null /*resultWho*/, 1 /*requestCode*/, - new Intent[] { failureIntent }, - new String[] { resolvedType }, - PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT - | PendingIntent.FLAG_IMMUTABLE, - null /*bOptions*/, userId); - intent.putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, - new IntentSender(failureIntentTarget)); - } catch (RemoteException ignore) { /* ignore; same process */ } + if (failureIntent != null) { + try { + final IIntentSender failureIntentTarget = ActivityManager.getService() + .getIntentSender( + ActivityManager.INTENT_SENDER_ACTIVITY, callingPackage, + null /*token*/, null /*resultWho*/, 1 /*requestCode*/, + new Intent[] { failureIntent }, + new String[] { resolvedType }, + PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT + | PendingIntent.FLAG_IMMUTABLE, + null /*bOptions*/, userId); + intent.putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, + new IntentSender(failureIntentTarget)); + } catch (RemoteException ignore) { /* ignore; same process */ } + } // Intent that is launched if the package was installed successfully. final Intent successIntent = new Intent(origIntent); @@ -248,10 +254,13 @@ public abstract class InstantAppResolver { private static AuxiliaryResolveInfo filterInstantAppIntent( List<InstantAppResolveInfo> instantAppResolveInfoList, - Intent intent, String resolvedType, int userId, String packageName, + Intent origIntent, String resolvedType, int userId, String packageName, InstantAppDigest digest, String token) { final int[] shaPrefix = digest.getDigestPrefix(); final byte[][] digestBytes = digest.getDigestBytes(); + final Intent failureIntent = new Intent(origIntent); + failureIntent.setFlags(failureIntent.getFlags() | Intent.FLAG_IGNORE_EPHEMERAL); + failureIntent.setLaunchToken(token); // Go in reverse order so we match the narrowest scope first. for (int i = shaPrefix.length - 1; i >= 0 ; --i) { for (InstantAppResolveInfo instantAppInfo : instantAppResolveInfoList) { @@ -271,7 +280,8 @@ public abstract class InstantAppResolver { } return new AuxiliaryResolveInfo(instantAppInfo, new IntentFilter(Intent.ACTION_VIEW) /*intentFilter*/, - null /*splitName*/, token, true /*needsPhase2*/); + null /*splitName*/, token, true /*needsPhase2*/, + null /*failureIntent*/); } // We have a domain match; resolve the filters to see if anything matches. final PackageManagerService.EphemeralIntentResolver instantAppResolver = @@ -286,12 +296,12 @@ public abstract class InstantAppResolver { final AuxiliaryResolveInfo intentInfo = new AuxiliaryResolveInfo(instantAppInfo, splitFilters.get(k), instantAppFilter.getSplitName(), - token, false /*needsPhase2*/); + token, false /*needsPhase2*/, failureIntent); instantAppResolver.addFilter(intentInfo); } } List<AuxiliaryResolveInfo> matchedResolveInfoList = instantAppResolver.queryIntent( - intent, resolvedType, false /*defaultOnly*/, userId); + origIntent, resolvedType, false /*defaultOnly*/, userId); if (!matchedResolveInfoList.isEmpty()) { if (DEBUG_EPHEMERAL) { final AuxiliaryResolveInfo info = matchedResolveInfoList.get(0); diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 2e0b065d7868..78d931f7a76a 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -6715,7 +6715,7 @@ public class PackageManagerService extends IPackageManager.Stub final ResolveInfo installerInfo = new ResolveInfo(mInstantAppInstallerInfo); installerInfo.auxiliaryInfo = new AuxiliaryResolveInfo( info.activityInfo.packageName, info.activityInfo.splitName, - info.activityInfo.applicationInfo.versionCode); + info.activityInfo.applicationInfo.versionCode, null /*failureIntent*/); // make sure this resolver is the default installerInfo.isDefault = true; installerInfo.match = IntentFilter.MATCH_CATEGORY_SCHEME_SPECIFIC_PART @@ -7388,7 +7388,7 @@ public class PackageManagerService extends IPackageManager.Stub final ResolveInfo installerInfo = new ResolveInfo(mInstantAppInstallerInfo); installerInfo.auxiliaryInfo = new AuxiliaryResolveInfo( info.serviceInfo.packageName, info.serviceInfo.splitName, - info.serviceInfo.applicationInfo.versionCode); + info.serviceInfo.applicationInfo.versionCode, null /*failureIntent*/); // make sure this resolver is the default installerInfo.isDefault = true; installerInfo.match = IntentFilter.MATCH_CATEGORY_SCHEME_SPECIFIC_PART @@ -7509,7 +7509,7 @@ public class PackageManagerService extends IPackageManager.Stub final ResolveInfo installerInfo = new ResolveInfo(mInstantAppInstallerInfo); installerInfo.auxiliaryInfo = new AuxiliaryResolveInfo( info.providerInfo.packageName, info.providerInfo.splitName, - info.providerInfo.applicationInfo.versionCode); + info.providerInfo.applicationInfo.versionCode, null /*failureIntent*/); // make sure this resolver is the default installerInfo.isDefault = true; installerInfo.match = IntentFilter.MATCH_CATEGORY_SCHEME_SPECIFIC_PART |