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

Commit 5aa4106f authored by Alex Buynytskyy's avatar Alex Buynytskyy
Browse files

Helper API for: QAS/suspension precedence validation.

Fixes: 311305567
Test: adb shell device_config put package_manager_service android.content.pm.quarantined_enabled true && atest PackageManagerTest
Change-Id: Icaaedaf272ecd1b3ec86daf94c9cfb5ead8eac31
parent 7b8bd667
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2933,6 +2933,15 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public String getSuspendingPackage(String suspendedPackage) {
        try {
            return mPM.getSuspendingPackage(suspendedPackage, getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    public boolean isPackageSuspendedForUser(String packageName, int userId) {
        try {
+2 −0
Original line number Diff line number Diff line
@@ -312,6 +312,8 @@ interface IPackageManager {

    Bundle getSuspendedPackageAppExtras(String packageName, int userId);

    String getSuspendingPackage(String packageName, int userId);

    /**
     * Backup/restore support - only the system uid may use these.
     */
+15 −0
Original line number Diff line number Diff line
@@ -9964,6 +9964,21 @@ public abstract class PackageManager {
        throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented");
    }

    /**
     * Get the name of the package that suspended the given package. Packages can be suspended by
     * device administrators or apps holding {@link android.Manifest.permission#MANAGE_USERS} or
     * {@link android.Manifest.permission#SUSPEND_APPS}.
     *
     * @param suspendedPackage The package that has been suspended.
     * @return Name of the package that suspended the given package. Returns {@code null} if the
     * given package is not currently suspended and the platform package name - i.e.
     * {@code "android"} - if the package was suspended by a device admin.
     * @hide
     */
    public @Nullable String getSuspendingPackage(@NonNull String suspendedPackage) {
        throw new UnsupportedOperationException("getSuspendingPackage not implemented");
    }

    /**
     * Query if an app is currently stopped.
     *
+12 −0
Original line number Diff line number Diff line
@@ -5215,6 +5215,18 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                    .getSuspendedPackageAppExtras(snapshot, packageName, userId, callingUid);
        }

        @Override
        public String getSuspendingPackage(String packageName, int userId) {
            final int callingUid = Binder.getCallingUid();
            final Computer snapshot = snapshot();
            // This will do visibility checks as well.
            if (!snapshot.isPackageSuspendedForUser(packageName, userId)) {
                return null;
            }
            return mSuspendPackageHelper.getSuspendingPackage(snapshot, packageName, userId,
                    callingUid);
        }

        @Override
        public @NonNull ParceledListSlice<FeatureInfo> getSystemAvailableFeatures() {
            // allow instant applications