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

Commit 948ae422 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Add public API to check if current app is auto-revoke exempt am: 2ac02b0d

Change-Id: Ia1e4e88584764c25627033fdfbcbc40886df42fd
parents 0118940b 2ac02b0d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12025,6 +12025,7 @@ package android.content.pm {
    method public boolean hasSigningCertificate(int, @NonNull byte[], int);
    method public abstract boolean hasSystemFeature(@NonNull String);
    method public abstract boolean hasSystemFeature(@NonNull String, int);
    method public boolean isAutoRevokeWhitelisted();
    method public boolean isDefaultApplicationIcon(@NonNull android.graphics.drawable.Drawable);
    method public boolean isDeviceUpgrading();
    method public abstract boolean isInstantApp();
+9 −0
Original line number Diff line number Diff line
@@ -3337,6 +3337,15 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    @Override
    public boolean isAutoRevokeWhitelisted() {
        try {
            return mPM.isAutoRevokeWhitelisted(mContext.getPackageName());
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    public void setMimeGroup(String mimeGroup, Set<String> mimeTypes) {
        try {
            mPM.setMimeGroup(mContext.getPackageName(), mimeGroup,
+2 −0
Original line number Diff line number Diff line
@@ -748,4 +748,6 @@ interface IPackageManager {
    void clearMimeGroup(String packageName, String group);

    List<String> getMimeGroup(String packageName, String group);

    boolean isAutoRevokeWhitelisted(String packageName);
}
+9 −0
Original line number Diff line number Diff line
@@ -7834,6 +7834,15 @@ public abstract class PackageManager {
            "sendDeviceCustomizationReadyBroadcast not implemented in subclass");
    }

    /**
     * @return whether this package is whitelisted from having its runtime permission be
     *         auto-revoked if unused for an extended period of time.
     */
    public boolean isAutoRevokeWhitelisted() {
        throw new UnsupportedOperationException(
                "isAutoRevokeWhitelisted not implemented in subclass");
    }

    /**
     * Returns if the provided drawable represents the default activity icon provided by the system.
     *
+20 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.REQUEST_DELETE_PACKAGES;
import static android.Manifest.permission.SET_HARMFUL_APP_WARNINGS;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_IGNORED;
import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.CATEGORY_DEFAULT;
import static android.content.Intent.CATEGORY_HOME;
@@ -24360,6 +24362,24 @@ public class PackageManagerService extends IPackageManager.Stub
        mCompilerStats.deletePackageStats(pkgName);
    }
    @Override
    public boolean isAutoRevokeWhitelisted(String packageName) {
        int mode = mInjector.getAppOpsManager().checkOpNoThrow(
                AppOpsManager.OP_AUTO_REVOKE_PERMISSIONS_IF_UNUSED,
                Binder.getCallingUid(), packageName);
        if (mode == MODE_ALLOWED) {
            return false;
        } else if (mode == MODE_IGNORED) {
            return true;
        } else {
            synchronized (mLock) {
                boolean manifestWhitelisted =
                        mPackages.get(packageName).isAllowDontAutoRevokePermmissions();
                return manifestWhitelisted;
            }
        }
    }
    @Override
    public int getInstallReason(String packageName, int userId) {
        final int callingUid = Binder.getCallingUid();