# Permission

Structures and functions related to permission checks in native code.

## Summary

| ### Enumerations ||
|---|---|
| `https://developer.android.com/ndk/reference/group/permission#group___permission_1gafa9be5679ab03d785820f2474c5ccc6e{ https://developer.android.com/ndk/reference/group/permission#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6eae2937d1dd34d6e7ebc1c85c35657c64d = 0, https://developer.android.com/ndk/reference/group/permission#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6ea0963aea04bd1680089df39e8a75b192e = -1 }` | enumPermission check results. |
| `https://developer.android.com/ndk/reference/group/permission#group___permission_1gae6dceca96ec2c7a1b4aa211264a87ef6{ https://developer.android.com/ndk/reference/group/permission#group___permission_1ggae6dceca96ec2c7a1b4aa211264a87ef6ab0d928b4bd40e4429077eaefa0bcaf6f = 0, https://developer.android.com/ndk/reference/group/permission#group___permission_1ggae6dceca96ec2c7a1b4aa211264a87ef6af41f50b58d711fc6cde4d96834774c8d = -1, https://developer.android.com/ndk/reference/group/permission#group___permission_1ggae6dceca96ec2c7a1b4aa211264a87ef6a5fe09136b90e0e1d1cfc63dfb5139087 = -2 }` | enumPermission check return status values. |

| ### Functions ||
|---|---|
| `https://developer.android.com/ndk/reference/group/permission#group___permission_1ga578353bb2d86fb181c929cf0378576d6(const char *permission, pid_t pid, uid_t uid, int32_t *outResult)` | `int32_t` Checks whether the package with the given pid/uid has been granted a permission. |

## Enumerations

### Anonymous Enum 57

Declared in `android/permission_manager.h`

```text
 Anonymous Enum 57
```
Permission check results.

Introduced in API 31.

| Properties ||
|---|---|
| `PERMISSION_MANAGER_PERMISSION_DENIED` | This is returned by [APermissionManager_checkPermission()](https://developer.android.com/ndk/reference/group/permission#group___permission_1ga578353bb2d86fb181c929cf0378576d6) if the permission has not been granted to the given package. |
| `PERMISSION_MANAGER_PERMISSION_GRANTED` | This is returned by [APermissionManager_checkPermission()](https://developer.android.com/ndk/reference/group/permission#group___permission_1ga578353bb2d86fb181c929cf0378576d6) if the permission has been granted to the given package. |

### Anonymous Enum 58

Declared in `android/permission_manager.h`

```text
 Anonymous Enum 58
```
Permission check return status values.

Introduced in API 31.

| Properties ||
|---|---|
| `PERMISSION_MANAGER_STATUS_ERROR_UNKNOWN` | This is returned if the permission check encountered an unspecified error. The output result is unmodified. |
| `PERMISSION_MANAGER_STATUS_OK` | This is returned if the permission check completed without errors. The output result is valid and contains one of {[PERMISSION_MANAGER_PERMISSION_GRANTED](https://developer.android.com/ndk/reference/group/permission#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6eae2937d1dd34d6e7ebc1c85c35657c64d), [PERMISSION_MANAGER_PERMISSION_DENIED](https://developer.android.com/ndk/reference/group/permission#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6ea0963aea04bd1680089df39e8a75b192e)}. |
| `PERMISSION_MANAGER_STATUS_SERVICE_UNAVAILABLE` | This is returned if the permission check failed because the service is unavailable. The output result is unmodified. |

## Functions

### APermissionManager_checkPermission

Declared in `android/permission_manager.h`

```gdscript
int32_t APermissionManager_checkPermission(
  const char *permission,
  pid_t pid,
  uid_t uid,
  int32_t *outResult
)
```
Checks whether the package with the given pid/uid has been granted a permission.

Note that the Java API of Context::checkPermission() is usually faster due to caching, thus is preferred over this API wherever possible.

<br />

| Details ||
|---|---|
| Parameters | |---|---| | `permission` | the permission to be checked. | | `pid` | the process id of the package to be checked. | | `uid` | the uid of the package to be checked. | | `outResult` | output of the permission check result. | |
| **Returns** | error codes if any error happened during the check. |