Permission

#include <permission_manager.h>

Structures and functions related to permission checks in native code.

Summary

Enumerations

Anonymous Enum 62{
  PERMISSION_MANAGER_PERMISSION_GRANTED = 0,
  PERMISSION_MANAGER_PERMISSION_DENIED = -1
}
enum
Permission check results.
Anonymous Enum 63{
  PERMISSION_MANAGER_STATUS_OK = 0,
  PERMISSION_MANAGER_STATUS_ERROR_UNKNOWN = -1,
  PERMISSION_MANAGER_STATUS_SERVICE_UNAVAILABLE = -2
}
enum
Permission check return status values.

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 62

 Anonymous Enum 62

Permission check results.

Introduced in API 31.

Properties
PERMISSION_MANAGER_PERMISSION_DENIED

This is returned by APermissionManager_checkPermission() if the permission has not been granted to the given package.

PERMISSION_MANAGER_PERMISSION_GRANTED

This is returned by APermissionManager_checkPermission() if the permission has been granted to the given package.

Anonymous Enum 63

 Anonymous Enum 63

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

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.