android_manifest/
permission_tree.rs

1use super::resources::{MipmapOrDrawableResource, StringResourceOrString};
2use serde::{Deserialize, Serialize};
3
4/// Declares the base name for a tree of permissions.
5///
6/// The application takes ownership of all names within the tree. It can dynamically add
7/// new permissions to the tree by calling [`PackageManager.addPermission()`] Names within
8/// the tree are separated by periods `('.')`. For example, if the base name is
9/// com.example.project.taxes.
10///
11/// Permissions like the following might be added:
12///
13/// * `com.example.project.taxes.CALCULATE`
14/// * `com.example.project.taxes.deductions.MAKE_SOME_UP`
15/// * `com.example.project.taxes.deductions.EXAGGERATE`
16///
17/// Note that this element does not declare a permission itself, only a
18/// namespace in which further permissions can be placed. See the [`<permission>`]
19/// element for information on declaring permissions.
20///
21/// ## XML Syntax
22/// ```xml
23/// <permission-tree android:icon="drawable resource"
24///                  android:label="string resource" ]
25///                  android:name="string" />
26/// ```
27///
28/// ## Contained in
29/// * [`<manifest>`]
30///
31/// ## Introduced in
32/// API Level 1
33///
34/// [`PackageManager.addPermission()`]: https://developer.android.com/reference/android/content/pm/PackageManager#addPermission(android.content.pm.PermissionInfo)
35/// [`<permission>`]: crate::Permission
36/// [`<manifest>`]: crate::AndroidManifest
37#[derive(
38    Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
39)]
40pub struct PermissionTree {
41    /// An icon representing all the permissions in the tree. This attribute must be set
42    /// as a reference to a drawable resource containing the image definition.
43    #[yaserde(attribute, prefix = "android")]
44    pub icon: Option<MipmapOrDrawableResource>,
45    /// A user-readable name for the group. As a convenience, the label can be directly
46    /// set as a raw string for quick and dirty programming. However, when the
47    /// application is ready to be published, it should be set as a reference to a
48    /// string resource, so that it can be localized like other strings in the user
49    /// interface.
50    #[yaserde(attribute, prefix = "android")]
51    pub label: Option<StringResourceOrString>,
52    /// The name that's at the base of the permission tree.  It serves as a prefix to all
53    /// permission names in the tree. Java-style scoping should be used to ensure that
54    /// the name is unique. The name must have more than two period-separated segments
55    /// in its path — for example, `com.example.base` is OK, but `com.example` is not.
56    #[yaserde(attribute, prefix = "android")]
57    pub name: Option<String>,
58}