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

Commit da66634d authored by George Hodulik's avatar George Hodulik
Browse files

Allow system app prediction service to view instant apps.

Since the app prediction service may predict instant apps,
it needs be able to view instant apps.

Test: tested manually.
Bug: 119824113
Change-Id: I4ff6c5763d95d44ac75789479f1364573a476392
parent becdfa7a
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -1343,6 +1343,7 @@ public class PackageManagerService extends IPackageManager.Stub
    final @Nullable String mWellbeingPackage;
    final @Nullable String mDocumenterPackage;
    final @Nullable String mConfiguratorPackage;
    final @Nullable String mAppPredictionServicePackage;
    final @NonNull String mServicesSystemSharedLibraryPackageName;
    final @NonNull String mSharedSystemSharedLibraryPackageName;
@@ -2868,6 +2869,7 @@ public class PackageManagerService extends IPackageManager.Stub
            mDocumenterPackage = getDocumenterPackageName();
            mConfiguratorPackage =
                    mContext.getString(R.string.config_deviceConfiguratorPackageName);
            mAppPredictionServicePackage = getAppPredictionServicePackageName();
            // Now that we know all of the shared libraries, update all clients to have
            // the correct library paths.
@@ -3750,7 +3752,7 @@ public class PackageManagerService extends IPackageManager.Stub
    /**
     * Returns whether or not a full application can see an instant application.
     * <p>
     * Currently, there are three cases in which this can occur:
     * Currently, there are four cases in which this can occur:
     * <ol>
     * <li>The calling application is a "special" process. Special processes
     *     are those with a UID < {@link Process#FIRST_APPLICATION_UID}.</li>
@@ -3758,6 +3760,7 @@ public class PackageManagerService extends IPackageManager.Stub
     *     {@link android.Manifest.permission#ACCESS_INSTANT_APPS}.</li>
     * <li>The calling application is the default launcher on the
     *     system partition.</li>
     * <li>The calling application is the default app prediction service.</li>
     * </ol>
     */
    private boolean canViewInstantApps(int callingUid, int userId) {
@@ -3775,6 +3778,11 @@ public class PackageManagerService extends IPackageManager.Stub
                    && isCallerSameApp(homeComponent.getPackageName(), callingUid)) {
                return true;
            }
            // TODO(b/122900055) Change/Remove this and replace with new permission role.
            if (mAppPredictionServicePackage != null
                    && isCallerSameApp(mAppPredictionServicePackage, callingUid)) {
                return true;
            }
        }
        return false;
    }
@@ -19963,6 +19971,20 @@ public class PackageManagerService extends IPackageManager.Stub
        return mContext.getString(R.string.config_defaultWellbeingPackage);
    }
    private String getAppPredictionServicePackageName() {
        String flattenedAppPredictionServiceComponentName =
                mContext.getString(R.string.config_defaultAppPredictionService);
        if (flattenedAppPredictionServiceComponentName == null) {
            return null;
        }
        ComponentName appPredictionServiceComponentName =
                ComponentName.unflattenFromString(flattenedAppPredictionServiceComponentName);
        if (appPredictionServiceComponentName == null) {
            return null;
        }
        return appPredictionServiceComponentName.getPackageName();
    }
    @Override
    public void setApplicationEnabledSetting(String appPackageName,
            int newState, int flags, int userId, String callingPackage) {