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

Commit 9d1f8423 authored by John Wu's avatar John Wu
Browse files

Simplify and fix resolveIntent implementation

- `exportOnly` is false only when resolving on behalf of system_server,
  which is automatically handled in `filterNonExportedComponents`, so
  there is no need to additionally pass this boolean.
- `resolveIntentExported` is unnecessary as functionality is duplicated
- PM#resolveIntent() should follow normal intent resolving process and
  return the correct Activity. The implementation before this CL is
  incorrect (`exportOnly` is set to false).

Test: TH
Change-Id: I01b3295295b4b2dbdced54971b525aaa6126ed01
parent 2246bcc5
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -610,18 +610,10 @@ public abstract class PackageManagerInternal {
            @NonNull Set<String> outUpdatedPackageNames,
            @NonNull Set<String> outInvalidPackageNames);

    /**
     * Resolves an activity intent, allowing instant apps to be resolved.
     */
    public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType,
            @PackageManager.ResolveInfoFlagsBits long flags,
            @PrivateResolveFlags long privateResolveFlags, int userId, boolean resolveForStart,
            int filterCallingUid);

    /**
     * Resolves an exported activity intent, allowing instant apps to be resolved.
     */
    public abstract ResolveInfo resolveIntentExported(Intent intent, String resolvedType,
    public abstract ResolveInfo resolveIntent(Intent intent, String resolvedType,
            @PackageManager.ResolveInfoFlagsBits long flags,
            @PrivateResolveFlags long privateResolveFlags, int userId, boolean resolveForStart,
            int filterCallingUid, int callingPid);
+1 −1
Original line number Diff line number Diff line
@@ -13775,7 +13775,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                });
            }
            boolean hasToBeExportedToMatch = platformCompat.isChangeEnabledByUid(
            boolean hasToBeExportedToMatch = platformCompat.isChangeEnabledByUidInternal(
                    ActivityManagerService.IMPLICIT_INTENTS_ONLY_MATCH_EXPORTED_COMPONENTS,
                    callingUid);
            ActivityManagerUtils.logUnsafeIntentEvent(
+1 −1
Original line number Diff line number Diff line
@@ -1139,7 +1139,7 @@ public abstract class IPackageManagerBase extends IPackageManager.Stub {
            @PackageManager.ResolveInfoFlagsBits long flags, int userId) {
        return mResolveIntentHelper.resolveIntentInternal(snapshot(), intent,
                resolvedType, flags, 0 /*privateResolveFlags*/, userId, false,
                Binder.getCallingUid());
                Binder.getCallingUid(), Binder.getCallingPid());
    }

    @Override
+1 −15
Original line number Diff line number Diff line
@@ -470,26 +470,12 @@ abstract class PackageManagerInternalBase extends PackageManagerInternal {
    @Override
    @Deprecated
    public final ResolveInfo resolveIntent(Intent intent, String resolvedType,
            @PackageManager.ResolveInfoFlagsBits long flags,
            @PackageManagerInternal.PrivateResolveFlags long privateResolveFlags, int userId,
            boolean resolveForStart, int filterCallingUid) {
        return getResolveIntentHelper().resolveIntentInternal(snapshot(),
                intent, resolvedType, flags, privateResolveFlags, userId, resolveForStart,
                filterCallingUid);
    }

    /**
     * @deprecated similar to {@link resolveIntent} but limits the matches to exported components.
     */
    @Override
    @Deprecated
    public final ResolveInfo resolveIntentExported(Intent intent, String resolvedType,
            @PackageManager.ResolveInfoFlagsBits long flags,
            @PackageManagerInternal.PrivateResolveFlags long privateResolveFlags, int userId,
            boolean resolveForStart, int filterCallingUid, int callingPid) {
        return getResolveIntentHelper().resolveIntentInternal(snapshot(),
                intent, resolvedType, flags, privateResolveFlags, userId, resolveForStart,
                filterCallingUid, true, callingPid);
                filterCallingUid, callingPid);
    }

    @Override
+3 −2
Original line number Diff line number Diff line
@@ -2140,7 +2140,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
        mResolveIntentHelper = new ResolveIntentHelper(mContext, mPreferredActivityHelper,
                injector.getCompatibility(), mUserManager, mDomainVerificationManager,
                mUserNeedsBadging, () -> mResolveInfo, () -> mInstantAppInstallerActivity,
                injector.getBackgroundHandler());
                injector.getBackgroundHandler(), injector.getActivityManagerInternal());
        mDexOptHelper = new DexOptHelper(this);
        mSuspendPackageHelper = new SuspendPackageHelper(this, mInjector, mBroadcastHelper,
                mProtectedPackages);
@@ -2695,7 +2695,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService

        final ResolveInfo resolveInfo = mResolveIntentHelper.resolveIntentInternal(computer, intent,
                null, MATCH_SYSTEM_ONLY | MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE,
                0 /*privateResolveFlags*/, UserHandle.USER_SYSTEM, false, Binder.getCallingUid());
                0 /*privateResolveFlags*/, UserHandle.USER_SYSTEM, false,
                Binder.getCallingUid(), Binder.getCallingPid());
        if (resolveInfo == null ||
                mResolveActivity.name.equals(resolveInfo.getComponentInfo().name)) {
            throw new RuntimeException("There must be exactly one uninstaller; found "
Loading