android_manifest/
uses_library.rs

1use serde::{Deserialize, Serialize};
2
3use crate::VarOrBool;
4/// Specifies a shared library that the application must be linked against.
5///
6/// This element tells the system to include the library's code in the class loader for
7/// the package. All of the android packages (such as [`android.app`],
8/// [`android.content`], [`android.view`], and [`android.widget`]) are in the default
9/// library that all applications are automatically linked against. However,
10/// some packages (such as maps) are in separate libraries that are not
11/// automatically linked. Consult the documentation for the packages you're
12/// using to determine which library contains the package code.
13///
14/// ## Node
15/// Google Play uses the <uses-library> elements declared in your app manifest to filter
16/// your app from devices that don't meet its library requirements. For more information
17/// about filtering, see the topic [`Google Play filters`].
18///
19/// This element also affects the installation of the application on a particular device
20/// and the availability of the application on Google Play:
21///
22/// ## Installation
23/// If this element is present and its android:required attribute is set to true, the
24/// [`PackageManager`] framework won't let the user install the application unless the
25/// library is present on the user's device.
26///
27/// The `android:required` attribute is described in detail in the following
28/// section.
29///
30/// ## XML Syntax
31/// ```xml
32/// <uses-library
33///      android:name="string"
34///      android:required=["true" | "false"] />
35/// ```
36///
37/// ## Contained in
38/// [`<application>`]
39///
40/// ## introduced in
41/// API Level 1
42///
43/// [`android.app`]: https://developer.android.com/reference/android/app/package-summary
44/// [`android.content`]: https://developer.android.com/reference/android/content/package-summary
45/// [`android.view`]: https://developer.android.com/reference/android/view/package-summary
46/// [`android.widget`]: https://developer.android.com/reference/android/widget/package-summary
47/// [`PackageManager`]: https://developer.android.com/reference/android/content/pm/PackageManager
48/// [`Google Play filters`]: https://developer.android.com/google/play/filters
49/// [`<application>`]: crate::Application
50#[derive(
51    Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
52)]
53pub struct UsesLibrary {
54    /// The name of the library. The name is provided by the documentation for the package
55    /// you are using. An example of this is `"android.test.runner"`, a package that
56    /// contains Android test classes.
57    #[yaserde(attribute, prefix = "android")]
58    pub name: Option<String>,
59    /// Boolean value that indicates whether the application requires the library
60    /// specified by android:name:
61    /// * `"true":` The application does not
62    /// function without this library. The system will not allow the application
63    /// on a device that does not have the library.
64    /// * `"false":` The application can use the library if present, but is
65    /// designed to function without it if necessary. The system will allow
66    /// the application to be installed, even if the library is not present.
67    /// If you use `"false"`, you are responsible for checking at runtime that
68    /// the library is available.
69    ///
70    /// To check for a library, you can use reflection to determine if a particular class
71    /// is available.
72    ///
73    /// The default is `"true"`.
74    ///
75    /// Introduced in: API Level 7.
76    #[yaserde(attribute, prefix = "android")]
77    pub required: Option<VarOrBool>,
78}