PermissionInfo

public class PermissionInfo
extends PackageItemInfo implements Parcelable

java.lang.Object
   ↳ android.content.pm.PackageItemInfo
     ↳ android.content.pm.PermissionInfo


Information you can retrieve about a particular security permission known to the system. This corresponds to information collected from the AndroidManifest.xml's <permission> tags.

Summary

Constants

int FLAG_COSTS_MONEY

Flag for flags, corresponding to costsMoney value of R.attr.permissionFlags.

int FLAG_INSTALLED

Flag for flags, indicating that this permission has been installed into the system's globally defined permissions.

int PROTECTION_DANGEROUS

Dangerous value for protectionLevel, corresponding to the dangerous value of R.attr.protectionLevel.

int PROTECTION_FLAG_APPOP

Additional flag for protectionLevel, corresponding to the appop value of R.attr.protectionLevel.

int PROTECTION_FLAG_DEVELOPMENT

Additional flag for protectionLevel, corresponding to the development value of R.attr.protectionLevel.

int PROTECTION_FLAG_INSTALLER

Additional flag for protectionLevel, corresponding to the installer value of R.attr.protectionLevel.

int PROTECTION_FLAG_INSTANT

Additional flag for protectionLevel, corresponding to the instant value of R.attr.protectionLevel.

int PROTECTION_FLAG_PRE23

Additional flag for protectionLevel, corresponding to the pre23 value of R.attr.protectionLevel.

int PROTECTION_FLAG_PREINSTALLED

Additional flag for protectionLevel, corresponding to the preinstalled value of R.attr.protectionLevel.

int PROTECTION_FLAG_PRIVILEGED

Additional flag for protectionLevel, corresponding to the privileged value of R.attr.protectionLevel.

int PROTECTION_FLAG_RUNTIME_ONLY

Additional flag for protectionLevel, corresponding to the runtime value of R.attr.protectionLevel.

int PROTECTION_FLAG_SETUP

Additional flag for protectionLevel, corresponding to the setup value of R.attr.protectionLevel.

int PROTECTION_FLAG_SYSTEM

This constant was deprecated in API level 23. Old name for PROTECTION_FLAG_PRIVILEGED, which is now very confusing because it only applies to privileged apps, not all apps on the system image.

int PROTECTION_FLAG_VERIFIER

Additional flag for protectionLevel, corresponding to the verifier value of R.attr.protectionLevel.

int PROTECTION_MASK_BASE

This constant was deprecated in API level 28. Use #getProtection() instead.

int PROTECTION_MASK_FLAGS

This constant was deprecated in API level 28. Use #getProtectionFlags() instead.

int PROTECTION_NORMAL

A normal application value for protectionLevel, corresponding to the normal value of R.attr.protectionLevel.

int PROTECTION_SIGNATURE

System-level value for protectionLevel, corresponding to the signature value of R.attr.protectionLevel.

int PROTECTION_SIGNATURE_OR_SYSTEM

This constant was deprecated in API level 23. Use PROTECTION_SIGNATURE|PROTECTION_FLAG_PRIVILEGED instead.

Inherited constants

Fields

public static final Creator<PermissionInfo> CREATOR

public int descriptionRes

A string resource identifier (in the package's resources) of this permission's description.

public int flags

Additional flags about this permission as given by R.attr.permissionFlags.

public String group

The group this permission is a part of, as per R.attr.permissionGroup.

public CharSequence nonLocalizedDescription

The description string provided in the AndroidManifest file, if any.

public int protectionLevel

This field was deprecated in API level 28. Use #getProtection() and #getProtectionFlags() instead.

Inherited fields

Public constructors

PermissionInfo()
PermissionInfo(PermissionInfo orig)

Public methods

int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

int getProtection()

Return the base permission type.

int getProtectionFlags()

Return the additional flags in protectionLevel.

CharSequence loadDescription(PackageManager pm)

Retrieve the textual description of this permission.

String toString()

Returns a string representation of the object.

void writeToParcel(Parcel dest, int parcelableFlags)

Inherited methods

Constants

FLAG_COSTS_MONEY

added in API level 17
public static final int FLAG_COSTS_MONEY

Flag for flags, corresponding to costsMoney value of R.attr.permissionFlags.

Constant Value: 1 (0x00000001)

FLAG_INSTALLED

added in API level 23
public static final int FLAG_INSTALLED

Flag for flags, indicating that this permission has been installed into the system's globally defined permissions.

Constant Value: 1073741824 (0x40000000)

PROTECTION_DANGEROUS

added in API level 1
public static final int PROTECTION_DANGEROUS

Dangerous value for protectionLevel, corresponding to the dangerous value of R.attr.protectionLevel.

Constant Value: 1 (0x00000001)

PROTECTION_FLAG_APPOP

added in API level 21
public static final int PROTECTION_FLAG_APPOP

Additional flag for protectionLevel, corresponding to the appop value of R.attr.protectionLevel.

Constant Value: 64 (0x00000040)

PROTECTION_FLAG_DEVELOPMENT

added in API level 16
public static final int PROTECTION_FLAG_DEVELOPMENT

Additional flag for protectionLevel, corresponding to the development value of R.attr.protectionLevel.

Constant Value: 32 (0x00000020)

PROTECTION_FLAG_INSTALLER

added in API level 23
public static final int PROTECTION_FLAG_INSTALLER

Additional flag for protectionLevel, corresponding to the installer value of R.attr.protectionLevel.

Constant Value: 256 (0x00000100)

PROTECTION_FLAG_INSTANT

added in API level 27
public static final int PROTECTION_FLAG_INSTANT

Additional flag for protectionLevel, corresponding to the instant value of R.attr.protectionLevel.

Constant Value: 4096 (0x00001000)

PROTECTION_FLAG_PRE23

added in API level 23
public static final int PROTECTION_FLAG_PRE23

Additional flag for protectionLevel, corresponding to the pre23 value of R.attr.protectionLevel.

Constant Value: 128 (0x00000080)

PROTECTION_FLAG_PREINSTALLED

added in API level 23
public static final int PROTECTION_FLAG_PREINSTALLED

Additional flag for protectionLevel, corresponding to the preinstalled value of R.attr.protectionLevel.

Constant Value: 1024 (0x00000400)

PROTECTION_FLAG_PRIVILEGED

added in API level 23
public static final int PROTECTION_FLAG_PRIVILEGED

Additional flag for protectionLevel, corresponding to the privileged value of R.attr.protectionLevel.

Constant Value: 16 (0x00000010)

PROTECTION_FLAG_RUNTIME_ONLY

added in API level 26
public static final int PROTECTION_FLAG_RUNTIME_ONLY

Additional flag for protectionLevel, corresponding to the runtime value of R.attr.protectionLevel.

Constant Value: 8192 (0x00002000)

PROTECTION_FLAG_SETUP

added in API level 24
public static final int PROTECTION_FLAG_SETUP

Additional flag for protectionLevel, corresponding to the setup value of R.attr.protectionLevel.

Constant Value: 2048 (0x00000800)

PROTECTION_FLAG_SYSTEM

added in API level 16
public static final int PROTECTION_FLAG_SYSTEM

This constant was deprecated in API level 23.
Old name for PROTECTION_FLAG_PRIVILEGED, which is now very confusing because it only applies to privileged apps, not all apps on the system image.

Constant Value: 16 (0x00000010)

PROTECTION_FLAG_VERIFIER

added in API level 23
public static final int PROTECTION_FLAG_VERIFIER

Additional flag for protectionLevel, corresponding to the verifier value of R.attr.protectionLevel.

Constant Value: 512 (0x00000200)

PROTECTION_MASK_BASE

added in API level 16
public static final int PROTECTION_MASK_BASE

This constant was deprecated in API level 28.
Use #getProtection() instead.

Mask for protectionLevel: the basic protection type.

Constant Value: 15 (0x0000000f)

PROTECTION_MASK_FLAGS

added in API level 16
public static final int PROTECTION_MASK_FLAGS

This constant was deprecated in API level 28.
Use #getProtectionFlags() instead.

Mask for protectionLevel: additional flag bits.

Constant Value: 65520 (0x0000fff0)

PROTECTION_NORMAL

added in API level 1
public static final int PROTECTION_NORMAL

A normal application value for protectionLevel, corresponding to the normal value of R.attr.protectionLevel.

Constant Value: 0 (0x00000000)

PROTECTION_SIGNATURE

added in API level 1
public static final int PROTECTION_SIGNATURE

System-level value for protectionLevel, corresponding to the signature value of R.attr.protectionLevel.

Constant Value: 2 (0x00000002)

PROTECTION_SIGNATURE_OR_SYSTEM

added in API level 1
public static final int PROTECTION_SIGNATURE_OR_SYSTEM

This constant was deprecated in API level 23.
Use PROTECTION_SIGNATURE|PROTECTION_FLAG_PRIVILEGED instead.

Constant Value: 3 (0x00000003)

Fields

CREATOR

added in API level 1
public static final Creator<PermissionInfo> CREATOR

descriptionRes

added in API level 1
public int descriptionRes

A string resource identifier (in the package's resources) of this permission's description. From the "description" attribute or, if not set, 0.

flags

added in API level 17
public int flags

Additional flags about this permission as given by R.attr.permissionFlags.

group

added in API level 1
public String group

The group this permission is a part of, as per R.attr.permissionGroup.

nonLocalizedDescription

added in API level 1
public CharSequence nonLocalizedDescription

The description string provided in the AndroidManifest file, if any. You probably don't want to use this, since it will be null if the description is in a resource. You probably want loadDescription(PackageManager) instead.

protectionLevel

added in API level 1
public int protectionLevel

This field was deprecated in API level 28.
Use #getProtection() and #getProtectionFlags() instead.

The level of access this permission is protecting, as per R.attr.protectionLevel. Consists of a base permission type and zero or more flags. Use the following functions to extract them.

 int basePermissionType = permissionInfo.getProtection();
 int permissionFlags = permissionInfo.getProtectionFlags();
 

Base permission types are PROTECTION_NORMAL, PROTECTION_DANGEROUS, PROTECTION_SIGNATURE and the deprecated PROTECTION_SIGNATURE_OR_SYSTEM. Flags are listed under R.attr.protectionLevel.

Public constructors

PermissionInfo

added in API level 1
public PermissionInfo ()

PermissionInfo

added in API level 1
public PermissionInfo (PermissionInfo orig)

Parameters
orig PermissionInfo

Public methods

describeContents

added in API level 1
public int describeContents ()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(Parcel, int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

getProtection

added in API level 28
public int getProtection ()

Return the base permission type.

Returns
int

Value is PROTECTION_NORMAL, PROTECTION_DANGEROUS, PROTECTION_SIGNATURE or PROTECTION_SIGNATURE_OR_SYSTEM.

loadDescription

added in API level 1
public CharSequence loadDescription (PackageManager pm)

Retrieve the textual description of this permission. This will call back on the given PackageManager to load the description from the application.

Parameters
pm PackageManager: A PackageManager from which the label can be loaded; usually the PackageManager from which you originally retrieved this item.

Returns
CharSequence Returns a CharSequence containing the permission's description. If there is no description, null is returned.

toString

added in API level 1
public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
String a string representation of the object.

writeToParcel

added in API level 1
public void writeToParcel (Parcel dest, 
                int parcelableFlags)

Parameters
dest Parcel

parcelableFlags int