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

Commit 7dd99e3d authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Don't set the failure extra on split install

Change-Id: I2f836b5ebc9f377ae8fe0a0d4a60541dd1666011
Fixes: 37852108
Test: Manual
Test: Install and run pico blast
Test: Note that the failure extra is set
Test: Click "New" to install a split
Test: Note that the failure extra isn't set
parent d05dda1d
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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);
    }
+31 −21
Original line number Diff line number Diff line
@@ -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,9 +207,7 @@ 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);
            if (failureIntent != null) {
                try {
                    final IIntentSender failureIntentTarget = ActivityManager.getService()
                            .getIntentSender(
@@ -216,6 +221,7 @@ public abstract class InstantAppResolver {
                    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);
+3 −3
Original line number Diff line number Diff line
@@ -6702,7 +6702,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
@@ -7375,7 +7375,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
@@ -7496,7 +7496,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