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

Commit aadbb7fa authored by Jesse Evans's avatar Jesse Evans
Browse files

Load IA resolver settings from resolver package

Changes the logic of getEphemeralResolverSettingsLPr() to resolve
a settings component in any of the packages whitelisted to provide
the instant apps installer.

Test: Boots

Bug: 36840581
Change-Id: Iac5e3dfa2cb97a630092212322f9c983c2d29926
(cherry picked from commit d4310934)
parent 31a6d784
Loading
Loading
Loading
Loading
+15 −30
Original line number Diff line number Diff line
@@ -842,11 +842,11 @@ public class PackageManagerService extends IPackageManager.Stub {
    /** The service connection to the ephemeral resolver */
    final EphemeralResolverConnection mInstantAppResolverConnection;
    /** Component used to show resolver settings for Instant Apps */
    final ComponentName mInstantAppResolverSettingsComponent;
    /** Component used to install ephemeral applications */
    ComponentName mInstantAppInstallerComponent;
    /** Component used to show resolver settings for Instant Apps */
    ComponentName mInstantAppResolverSettingsComponent;
    ActivityInfo mInstantAppInstallerActivity;
    final ResolveInfo mInstantAppInstallerInfo = new ResolveInfo();
@@ -2807,11 +2807,13 @@ public class PackageManagerService extends IPackageManager.Stub {
                }
                mInstantAppResolverConnection =
                        new EphemeralResolverConnection(mContext, ephemeralResolverComponent);
                mInstantAppResolverSettingsComponent =
                        getEphemeralResolverSettingsLPr(ephemeralResolverComponent);
            } else {
                mInstantAppResolverConnection = null;
                mInstantAppResolverSettingsComponent = null;
            }
            updateInstantAppInstallerLocked();
            mInstantAppResolverSettingsComponent = getEphemeralResolverSettingsLPr();
            // Read and update the usage of dex files.
            // Do this at the end of PM init so that all the packages have their
@@ -3119,35 +3121,18 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
    }
    private @Nullable ComponentName getEphemeralResolverSettingsLPr() {
        final Intent intent = new Intent(Intent.ACTION_EPHEMERAL_RESOLVER_SETTINGS);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        final int resolveFlags =
                MATCH_DIRECT_BOOT_AWARE
                | MATCH_DIRECT_BOOT_UNAWARE
                | (!Build.IS_DEBUGGABLE ? MATCH_SYSTEM_ONLY : 0);
        final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, null,
                resolveFlags, UserHandle.USER_SYSTEM);
        Iterator<ResolveInfo> iter = matches.iterator();
        while (iter.hasNext()) {
            final ResolveInfo rInfo = iter.next();
            final PackageSetting ps = mSettings.mPackages.get(rInfo.activityInfo.packageName);
            if (ps != null) {
                final PermissionsState permissionsState = ps.getPermissionsState();
                if (permissionsState.hasPermission(Manifest.permission.ACCESS_INSTANT_APPS, 0)) {
                    continue;
                }
            }
            iter.remove();
        }
        if (matches.size() == 0) {
    private @Nullable ComponentName getEphemeralResolverSettingsLPr(
            @NonNull ComponentName resolver) {
        final Intent intent =  new Intent(Intent.ACTION_EPHEMERAL_RESOLVER_SETTINGS)
                .addCategory(Intent.CATEGORY_DEFAULT)
                .setPackage(resolver.getPackageName());
        final int resolveFlags = MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE;
        final List<ResolveInfo> matches = queryIntentActivitiesInternal(intent, null, resolveFlags,
                UserHandle.USER_SYSTEM);
        if (matches.isEmpty()) {
            return null;
        } else if (matches.size() == 1) {
            return matches.get(0).getComponentInfo().getComponentName();
        } else {
            throw new RuntimeException(
                    "There must be at most one ephemeral resolver settings; found " + matches);
        }
        return matches.get(0).getComponentInfo().getComponentName();
    }
    private void primeDomainVerificationsLPw(int userId) {