PackageManagerCompat
public final class PackageManagerCompat
Helper for accessing features in PackageManager.
Summary
Constants |
|
|---|---|
static final String |
ACTION_PERMISSION_REVOCATION_SETTINGS = "android.intent.action.AUTO_REVOKE_PERMISSIONS"Activity action: creates an intent to redirect the user to UI to turn on/off their permission revocation settings. |
Public methods |
|
|---|---|
static @NonNull ListenableFuture<Integer> |
getUnusedAppRestrictionsStatus(@NonNull Context context)Returns the status of Unused App Restrictions for the current application. |
Constants
ACTION_PERMISSION_REVOCATION_SETTINGS
public static final String ACTION_PERMISSION_REVOCATION_SETTINGS = "android.intent.action.AUTO_REVOKE_PERMISSIONS"
Activity action: creates an intent to redirect the user to UI to turn on/off their permission revocation settings.
Public methods
getUnusedAppRestrictionsStatus
public static @NonNull ListenableFuture<Integer> getUnusedAppRestrictionsStatus(@NonNull Context context)
Returns the status of Unused App Restrictions for the current application. In other words, whether the features are available and if so, enabled for the application. The returned value is a ListenableFuture with an Integer corresponding to a value in UnusedAppRestrictionsConstants. The possible values are as follows:
ERROR: an error occurred when fetching the availability and status of Unused App Restrictions. Check the logs for the reason (e.g. if the app's target SDK version <30 or the user is in locked device boot mode).FEATURE_NOT_AVAILABLE: there are no available Unused App Restrictions for this app.DISABLED: any available Unused App Restrictions on the device are disabled for this app.API_30_BACKPORT: Unused App Restrictions introduced by Android API 30, and since made available on earlier (API 23-29) devices are enabled for this app: permission auto-reset.API_30: Unused App Restrictions introduced by Android API 30 are enabled for this app: permission auto-reset.API_31: Unused App Restrictions introduced by Android API 31 are enabled for this app: permission auto-reset and app hibernation.
- SDK 31 and above, if
isAutoRevokeWhitelistedis true, this API will returnDISABLED. Else, it will returnAPI_31. - SDK 30, if
isAutoRevokeWhitelistedis true, this API will returnDISABLED. Else, it will returnAPI_30. - SDK 23 through 29, if there exists an app with the Verifier role that can resolve the
Intent.ACTION_AUTO_REVOKE_PERMISSIONSaction, then this API will returnAPI_30_BACKPORTif Unused App Restrictions are enabled andDISABLEDif disabled. Else, it will returnFEATURE_NOT_AVAILABLE. - SDK 22 and below, this method always returns
FEATURE_NOT_AVAILABLEas runtime permissions did not exist yet.