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

Commit 5ae4e73e authored by Andrei Stingaceanu's avatar Andrei Stingaceanu Committed by Android (Google) Code Review
Browse files

Merge "Suspend packages - new API for retrieving the suspended status" into nyc-dev

parents 804d6481 355b232d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1916,6 +1916,16 @@ public class ApplicationPackageManager extends PackageManager {
        return false;
    }

    @Override
    public boolean isPackageSuspendedForUser(String packageName, int userId) {
        try {
            return mPM.isPackageSuspendedForUser(packageName, userId);
        } catch (RemoteException e) {
            // Should never happen!
        }
        return false;
    }

    @Override
    public void getPackageSizeInfoAsUser(String packageName, int userHandle,
            IPackageStatsObserver observer) {
+2 −1
Original line number Diff line number Diff line
@@ -3500,7 +3500,8 @@ public class DevicePolicyManager {
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param packageName The name of the package to retrieve the suspended status of.
     * @return boolean {@code true} if the package is suspended, {@code false} otherwise.
     * @return {@code true} if the package is suspended or {@code false} if the package is not
     * suspended, could not be found or an error occured.
     */
    public boolean getPackageSuspended(@NonNull ComponentName admin, String packageName) {
        if (mService != null) {
+1 −0
Original line number Diff line number Diff line
@@ -284,6 +284,7 @@ interface IPackageManager {
    void clearCrossProfileIntentFilters(int sourceUserId, String ownerPackage);

    boolean setPackageSuspendedAsUser(String packageName, boolean suspended, int userId);
    boolean isPackageSuspendedForUser(String packageName, int userId);

    /**
     * Backup/restore support - only the system uid may use these.
+10 −0
Original line number Diff line number Diff line
@@ -5316,6 +5316,16 @@ public abstract class PackageManager {
    public abstract boolean setPackageSuspendedAsUser(
            String packageName, boolean suspended, @UserIdInt int userId);

    /**
     * @see #setPackageSuspendedAsUser(String, boolean, int)
     * @param packageName The name of the package to get the suspended status of.
     * @param userId The user id.
     * @return {@code true} if the package is suspended or {@code false} if the package is not
     * suspended or could not be found.
     * @hide
     */
    public abstract boolean isPackageSuspendedForUser(String packageName, int userId);

    /** {@hide} */
    public static boolean isMoveStatusFinished(int status) {
        return (status < 0 || status > 100);
+1 −4
Original line number Diff line number Diff line
@@ -21,10 +21,8 @@ import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager;
import android.content.pm.UserInfo;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.RemoteException;
@@ -227,8 +225,7 @@ public class RestrictedLockUtils {
            int userId) {
        IPackageManager ipm = AppGlobals.getPackageManager();
        try {
            ApplicationInfo ai = ipm.getApplicationInfo(packageName, 0, userId);
            if (ai != null && ((ai.flags & ApplicationInfo.FLAG_SUSPENDED) != 0)) {
            if (ipm.isPackageSuspendedForUser(packageName, userId)) {
                return getProfileOrDeviceOwner(context, userId);
            }
        } catch (RemoteException e) {
Loading