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

Commit b6e72978 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Breaks isInstantApp into public and internal

This change breaks isInstantApp up into a public and internal
implementation so that internal interfaces have a means of calling
without any permission checks that only apply to public callers.

Fixes: 141288362
Test: Work profile setup
Change-Id: I2cb8338c2a68bc9c4a61c075398d767980c504ed
parent a486c752
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -334,11 +334,11 @@ public abstract class PackageManagerInternal {
     * <p>
     * <p>
     * @param userId the user
     * @param userId the user
     * @param intent the intent that triggered the grant
     * @param intent the intent that triggered the grant
     * @param callingAppId The app ID of the calling application
     * @param callingUid The uid of the calling application
     * @param targetAppId The app ID of the target application
     * @param targetAppId The app ID of the target application
     */
     */
    public abstract void grantImplicitAccess(
    public abstract void grantImplicitAccess(
            @UserIdInt int userId, Intent intent, @AppIdInt int callingAppId,
            @UserIdInt int userId, Intent intent, int callingUid,
            @AppIdInt int targetAppId);
            @AppIdInt int targetAppId);


    public abstract boolean isInstantAppInstallerComponent(ComponentName component);
    public abstract boolean isInstantAppInstallerComponent(ComponentName component);
+2 −2
Original line number Original line Diff line number Diff line
@@ -1749,7 +1749,7 @@ public final class ActiveServices {
            // Once the apps have become associated, if one of them is caller is ephemeral
            // Once the apps have become associated, if one of them is caller is ephemeral
            // the target app should now be able to see the calling app
            // the target app should now be able to see the calling app
            mAm.grantImplicitAccess(callerApp.userId, service,
            mAm.grantImplicitAccess(callerApp.userId, service,
                    UserHandle.getAppId(callerApp.uid), UserHandle.getAppId(s.appInfo.uid));
                    callerApp.uid, UserHandle.getAppId(s.appInfo.uid));


            AppBindRecord b = s.retrieveAppBindingLocked(service, callerApp);
            AppBindRecord b = s.retrieveAppBindingLocked(service, callerApp);
            ConnectionRecord c = new ConnectionRecord(b, activity,
            ConnectionRecord c = new ConnectionRecord(b, activity,
@@ -2802,7 +2802,7 @@ public final class ActiveServices {
                mAm.mUgmInternal.grantUriPermissionUncheckedFromIntent(si.neededGrants,
                mAm.mUgmInternal.grantUriPermissionUncheckedFromIntent(si.neededGrants,
                        si.getUriPermissionsLocked());
                        si.getUriPermissionsLocked());
            }
            }
            mAm.grantImplicitAccess(r.userId, si.intent, UserHandle.getAppId(si.callingId),
            mAm.grantImplicitAccess(r.userId, si.intent, si.callingId,
                    UserHandle.getAppId(r.appInfo.uid)
                    UserHandle.getAppId(r.appInfo.uid)
            );
            );
            bumpServiceExecutingLocked(r, execInFg, "start");
            bumpServiceExecutingLocked(r, execInFg, "start");
+2 −2
Original line number Original line Diff line number Diff line
@@ -6118,9 +6118,9 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    }
    @VisibleForTesting
    @VisibleForTesting
    public void grantImplicitAccess(int userId, Intent intent, int callingAppId, int targetAppId) {
    public void grantImplicitAccess(int userId, Intent intent, int callingUid, int targetAppId) {
        getPackageManagerInternalLocked().
        getPackageManagerInternalLocked().
                grantImplicitAccess(userId, intent, callingAppId, targetAppId);
                grantImplicitAccess(userId, intent, callingUid, targetAppId);
    }
    }
    /**
    /**
+16 −10
Original line number Original line Diff line number Diff line
@@ -8375,15 +8375,20 @@ public class PackageManagerService extends IPackageManager.Stub
    @Override
    @Override
    public boolean isInstantApp(String packageName, int userId) {
    public boolean isInstantApp(String packageName, int userId) {
        mPermissionManager.enforceCrossUserPermission(Binder.getCallingUid(), userId,
        final int callingUid = Binder.getCallingUid();
        mPermissionManager.enforceCrossUserPermission(callingUid, userId,
                true /* requireFullPermission */, false /* checkShell */,
                true /* requireFullPermission */, false /* checkShell */,
                "isInstantApp");
                "isInstantApp");
        return isInstantAppInternal(packageName, userId, callingUid);
    }
    private boolean isInstantAppInternal(String packageName, @UserIdInt int userId,
            int callingUid) {
        if (HIDE_EPHEMERAL_APIS) {
        if (HIDE_EPHEMERAL_APIS) {
            return false;
            return false;
        }
        }
        synchronized (mLock) {
        synchronized (mLock) {
            int callingUid = Binder.getCallingUid();
            if (Process.isIsolated(callingUid)) {
            if (Process.isIsolated(callingUid)) {
                callingUid = mIsolatedOwners.get(callingUid);
                callingUid = mIsolatedOwners.get(callingUid);
            }
            }
@@ -23381,19 +23386,20 @@ public class PackageManagerService extends IPackageManager.Stub
        @Override
        @Override
        public void grantImplicitAccess(int userId, Intent intent,
        public void grantImplicitAccess(int userId, Intent intent,
                int callingAppId, int targetAppId) {
                int callingUid, int targetAppId) {
            synchronized (mLock) {
            synchronized (mLock) {
                final PackageParser.Package callingPackage = getPackage(
                final PackageParser.Package callingPackage = getPackage(callingUid);
                        UserHandle.getUid(userId, callingAppId));
                final PackageParser.Package targetPackage =
                final PackageParser.Package targetPackage = getPackage(
                        getPackage(UserHandle.getUid(userId, targetAppId));
                        UserHandle.getUid(userId, targetAppId));
                if (callingPackage == null || targetPackage == null) {
                if (callingPackage == null || targetPackage == null) {
                    return;
                    return;
                }
                }
                if (isInstantApp(callingPackage.packageName, userId)) {
                final boolean instantApp = isInstantAppInternal(callingPackage.packageName, userId,
                        callingUid);
                if (instantApp) {
                    mInstantAppRegistry.grantInstantAccessLPw(userId, intent,
                    mInstantAppRegistry.grantInstantAccessLPw(userId, intent,
                            callingAppId, targetAppId);
                            UserHandle.getAppId(callingUid), targetAppId);
                } else {
                } else {
                    mAppsFilter.grantImplicitAccess(
                    mAppsFilter.grantImplicitAccess(
                            callingPackage.packageName, targetPackage.packageName, userId);
                            callingPackage.packageName, targetPackage.packageName, userId);
+1 −1
Original line number Original line Diff line number Diff line
@@ -1552,7 +1552,7 @@ class ActivityStarter {
                mIntent, mStartActivity.getUriPermissionsLocked(), mStartActivity.mUserId);
                mIntent, mStartActivity.getUriPermissionsLocked(), mStartActivity.mUserId);
        mService.getPackageManagerInternalLocked().grantImplicitAccess(
        mService.getPackageManagerInternalLocked().grantImplicitAccess(
                mStartActivity.mUserId, mIntent,
                mStartActivity.mUserId, mIntent,
                UserHandle.getAppId(mCallingUid),
                mCallingUid,
                UserHandle.getAppId(mStartActivity.info.applicationInfo.uid)
                UserHandle.getAppId(mStartActivity.info.applicationInfo.uid)
        );
        );
        if (newTask) {
        if (newTask) {