pub struct Permission {
    pub description: Option<Resource<StringResource>>,
    pub icon: Option<MipmapOrDrawableResource>,
    pub label: Option<StringResourceOrString>,
    pub name: Option<String>,
    pub permission_group: Option<String>,
    pub protection_level: Option<ProtectionLevel>,
}
Expand description

Declares a security permission.

That can be used to limit access to specific components or features of this or other applications. See the Permissions section in the introduction, and the Security and Permissions document for more information on how permissions work.

XML Syntax

<permission android:description="string resource"
            android:icon="drawable resource"
            android:label="string resource"
            android:name="string"
            android:permissionGroup="string"
            android:protectionLevel=["normal" | "dangerous" |
                        "signature" | ...] />

Contained in

Introduced in

API Level 1

Fields§

§description: Option<Resource<StringResource>>

A user-readable description of the permission, longer and more informative than the label. It may be displayed to explain the permission to the user — for example, when the user is asked whether to grant the permission to another application.

This attribute must be set as a reference to a string resource; unlike the label unlike the label attribute, it cannot be a raw string.

§icon: Option<MipmapOrDrawableResource>

A reference to a drawable resource for an icon that represents the permission.

§label: Option<StringResourceOrString>

A name for the permission, one that can be displayed to users. As a convenience, the label can be directly set as a raw string while you’re developing the application. However, when the application is ready to be published, it should be set as a reference to a string resource, so that it can be localized like other strings in the user interface.

§name: Option<String>

The name of the permission. This is the name that will be used in code to refer to the permission — for example, in a <uses-permission> element and the permission attributes of application components.

Note

The system does not allow multiple packages to declare a permission with the same name, unless all the packages are signed with the same certificate. If a package declares a permission, the system does not permit the user to install other packages with the same permission name, unless those packages are signed with the same certificate as the first package. To avoid naming collisions, we recommend using reverse-domain-style naming for custom permissions, for example com.example.myapp.ENGAGE_HYPERSPACE.

§permission_group: Option<String>

Assigns this permission to a group. The value of this attribute is the name of the group, which must be declared with the <permission-group> element in this or another application. If this attribute is not set, the permission does not belong to a group.

§protection_level: Option<ProtectionLevel>

Characterizes the potential risk implied in the permission and indicates the procedure the system should follow when determining whether or not to grant the permission to an application requesting it.

Each protection level consists of a base permission type and zero or more flags. For example, the "dangerous" protection level has no flags. In contrast, the protection level "signature|privileged" is a combination of the "signature" base permission type and the "privileged" flag.

Trait Implementations§

source§

impl Clone for Permission

source§

fn clone(&self) -> Permission

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Permission

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Permission

source§

fn default() -> Permission

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Permission

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<Permission> for Permission

source§

fn eq(&self, other: &Permission) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Permission

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl YaDeserialize for Permission

source§

fn deserialize<R: Read>(reader: &mut Deserializer<R>) -> Result<Self, String>

source§

impl YaSerialize for Permission

source§

fn serialize<W: Write>(&self, writer: &mut Serializer<W>) -> Result<(), String>

source§

fn serialize_attributes( &self, source_attributes: Vec<OwnedAttribute>, source_namespace: Namespace ) -> Result<(Vec<OwnedAttribute>, Namespace), String>

source§

impl Eq for Permission

source§

impl StructuralEq for Permission

source§

impl StructuralPartialEq for Permission

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,