# PackageManagerCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/content/PackageManagerCompat.java+class:androidx.core.content.PackageManagerCompat) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

*** ** * ** ***

<br />

```
public final class PackageManagerCompat
```

<br />

*** ** * ** ***

Helper for accessing features in `https://developer.android.com/reference/android/content/pm/PackageManager.html`.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/content/PackageManagerCompat#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 @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/java/lang/Integer.html>` | `https://developer.android.com/reference/androidx/core/content/PackageManagerCompat#getUnusedAppRestrictionsStatus(android.content.Context)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html context)` Returns the status of Unused App Restrictions for the current application. |

## Constants

### ACTION_PERMISSION_REVOCATION_SETTINGS

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
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

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/core#1.7.0)

```
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 `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants`. The possible values are as follows:

- `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#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).
- `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#FEATURE_NOT_AVAILABLE()`: there are no available Unused App Restrictions for this app.
- `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#DISABLED()`: any available Unused App Restrictions on the device are disabled for this app.
- `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#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](https://developer.android.com/training/permissions/requesting#auto-reset-permissions-unused-apps).
- `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#API_30()`: Unused App Restrictions introduced by Android API 30 are enabled for this app: [permission auto-reset](https://developer.android.com/training/permissions/requesting#auto-reset-permissions-unused-apps).
- `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#API_31()`: Unused App Restrictions introduced by Android API 31 are enabled for this app: [permission auto-reset](https://developer.android.com/training/permissions/requesting#auto-reset-permissions-unused-apps) and [app hibernation](https://developer.android.com/about/versions/12/behavior-changes-12#app-hibernation).

Compatibility behavior:

<!-- -->

- SDK 31 and above, if `https://developer.android.com/reference/android/content/pm/PackageManager.html#isAutoRevokeWhitelisted()` is true, this API will return `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#DISABLED()`. Else, it will return `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#API_31()`.
- SDK 30, if `https://developer.android.com/reference/android/content/pm/PackageManager.html#isAutoRevokeWhitelisted()` is true, this API will return `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#DISABLED()`. Else, it will return `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#API_30()`.
- SDK 23 through 29, if there exists an app with the Verifier role that can resolve the `Intent.ACTION_AUTO_REVOKE_PERMISSIONS` action, then this API will return `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#API_30_BACKPORT()` if Unused App Restrictions are enabled and `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#DISABLED()` if disabled. Else, it will return `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#FEATURE_NOT_AVAILABLE()`.
- SDK 22 and below, this method always returns `https://developer.android.com/reference/androidx/core/content/UnusedAppRestrictionsConstants#FEATURE_NOT_AVAILABLE()` as runtime permissions did not exist yet.