android_manifest/uses_native_library.rs
1use serde::{Deserialize, Serialize};
2
3use crate::VarOrBool;
4
5/// Specifies a [`vendor-provided shared native library`] that the application must be
6/// linked against.
7///
8/// This element tells the system to make the native library accessible for the package.
9///
10/// NDK libraries are by default accessible and therefore don't require the
11/// `<uses-native-library>` tag.
12///
13/// Non-NDK native shared libraries that are provided by silicon vendors or device
14/// manufacturers are not accessible by default if the app is targeting Android 12
15/// or higher. The libraries are accessible only when they are explicitly requested
16/// using the `<uses-native-library>` tag.
17///
18/// If the app is targeting Android 11 or lower, the `<uses-native-library>` tag is
19/// not required. n that case, any native shared library is accessible regardless
20/// of whether it is an NDK library.
21///
22/// This element also affects the installation of the application on a particular device:
23///
24/// ## Installation
25/// If this element is present and its android:required attribute is set to true,
26/// the [`PackageManager`] framework won't let the user install the application unless
27/// the library is present on the user's device.
28///
29/// The android:required attribute is described in detail in the following section.
30///
31/// ## XML Syntax
32/// ```xml
33/// <uses-native-library
34/// android:name="string"
35/// android:required=["true" | "false"] />
36/// ```
37///
38/// ## Contained in
39/// * [`<application>`]
40///
41/// ## Introduced in
42/// API Level S
43///
44/// [`vendor-provided shared native library`]: https://source.android.com/devices/tech/config/namespaces_libraries#adding-additional-native-libraries
45/// [`PackageManager`]: https://developer.android.com/reference/android/content/pm/PackageManager
46/// [`<application>`]: crate::Application
47#[derive(
48 Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Default, Clone,
49)]
50pub struct UsesNativeLibrary {
51 /// The name of the library file.
52 #[yaserde(attribute, prefix = "android")]
53 pub name: String,
54 /// Boolean value that indicates whether the application requires the library
55 /// specified by android:name:
56 ///
57 /// * `"true"`: The application does not function without this library. The system
58 /// will
59 /// not allow the application on a device that does not have the library.
60 ///
61 /// * `"false"`: The application can use the library if present, but is designed to
62 /// function
63 /// without it if necessary. The system will allow the application to be installed,
64 /// even if the library is not present. If you use `"false"`, you are responsible
65 /// for gracefully handling the absence of the library.
66 ///
67 /// The default is `"true"`.
68 #[yaserde(attribute, prefix = "android")]
69 pub required: Option<VarOrBool>,
70}