Stay organized with collections
Save and categorize content based on your preferences.
Permission
Structures and functions related to permission checks in native code.
Summary
Functions
|
APermissionManager_checkPermission(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 56
Declared in android/permission_manager.h
Anonymous Enum 56
Permission check results.
Introduced in API 31.
Anonymous Enum 57
Declared in android/permission_manager.h
Anonymous Enum 57
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, PERMISSION_MANAGER_PERMISSION_DENIED}.
|
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
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.
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.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-11-19 UTC.
[null,null,["Last updated 2024-11-19 UTC."],[],[],null,["# Permission\n==========\n\nStructures and functions related to permission checks in native code.\n\nSummary\n-------\n\n| ### Enumerations ||\n|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------|\n| [Anonymous Enum 56](#group___permission_1gac9420823bfeba78fce625fc105e3b01d)`{` ` `[PERMISSION_MANAGER_PERMISSION_GRANTED](#group___permission_1ggac9420823bfeba78fce625fc105e3b01dae2937d1dd34d6e7ebc1c85c35657c64d)` = 0,` ` `[PERMISSION_MANAGER_PERMISSION_DENIED](#group___permission_1ggac9420823bfeba78fce625fc105e3b01da0963aea04bd1680089df39e8a75b192e)` = -1` `}` | enum Permission check results. |\n| [Anonymous Enum 57](#group___permission_1gafa9be5679ab03d785820f2474c5ccc6e)`{` ` `[PERMISSION_MANAGER_STATUS_OK](#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6eab0d928b4bd40e4429077eaefa0bcaf6f)` = 0,` ` `[PERMISSION_MANAGER_STATUS_ERROR_UNKNOWN](#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6eaf41f50b58d711fc6cde4d96834774c8d)` = -1,` ` `[PERMISSION_MANAGER_STATUS_SERVICE_UNAVAILABLE](#group___permission_1ggafa9be5679ab03d785820f2474c5ccc6ea5fe09136b90e0e1d1cfc63dfb5139087)` = -2` `}` | enum Permission check return status values. |\n\n| ### Functions ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|\n| [APermissionManager_checkPermission](#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. |\n\nEnumerations\n------------\n\n### Anonymous Enum 56\n\nDeclared in `android/permission_manager.h` \n\n```text\n Anonymous Enum 56\n``` \nPermission check results.\n\nIntroduced in API 31.\n\n| Properties ||\n|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `PERMISSION_MANAGER_PERMISSION_DENIED` | This is returned by [APermissionManager_checkPermission()](/ndk/reference/group/permission#group___permission_1ga578353bb2d86fb181c929cf0378576d6) if the permission has not been granted to the given package. |\n| `PERMISSION_MANAGER_PERMISSION_GRANTED` | This is returned by [APermissionManager_checkPermission()](/ndk/reference/group/permission#group___permission_1ga578353bb2d86fb181c929cf0378576d6) if the permission has been granted to the given package. |\n\n### Anonymous Enum 57\n\nDeclared in `android/permission_manager.h` \n\n```text\n Anonymous Enum 57\n``` \nPermission check return status values.\n\nIntroduced in API 31.\n\n| Properties ||\n|-------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `PERMISSION_MANAGER_STATUS_ERROR_UNKNOWN` | This is returned if the permission check encountered an unspecified error. The output result is unmodified. |\n| `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](/ndk/reference/group/permission#group___permission_1ggac9420823bfeba78fce625fc105e3b01dae2937d1dd34d6e7ebc1c85c35657c64d), [PERMISSION_MANAGER_PERMISSION_DENIED](/ndk/reference/group/permission#group___permission_1ggac9420823bfeba78fce625fc105e3b01da0963aea04bd1680089df39e8a75b192e)}. |\n| `PERMISSION_MANAGER_STATUS_SERVICE_UNAVAILABLE` | This is returned if the permission check failed because the service is unavailable. The output result is unmodified. |\n\nFunctions\n---------\n\n### APermissionManager_checkPermission\n\nDeclared in `android/permission_manager.h` \n\n```gdscript\nint32_t APermissionManager_checkPermission(\n const char *permission,\n pid_t pid,\n uid_t uid,\n int32_t *outResult\n)\n``` \nChecks whether the package with the given pid/uid has been granted a permission.\n\nNote that the Java API of Context::checkPermission() is usually faster due to caching, thus is preferred over this API wherever possible.\n\n\u003cbr /\u003e\n\n| Details ||\n|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 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. | |\n| **Returns** | error codes if any error happened during the check. |"]]