android_manifest/
application.rs

1use crate::VarOrBool;
2
3use super::activity::Activity;
4use super::activity_alias::ActivityAlias;
5use super::meta_data::MetaData;
6use super::profileable::Profileable;
7use super::provider::Provider;
8use super::receiver::Receiver;
9use super::resources::{
10    DrawableResource, MipmapOrDrawableResource, Resource, StringResource, StringResourceOrString,
11    StyleResource, XmlResource,
12};
13use super::service::Service;
14use super::ui_options::UiOptions;
15use super::uses_library::UsesLibrary;
16use super::uses_native_library::UsesNativeLibrary;
17use serde::{Deserialize, Serialize};
18
19/// The declaration of the application.
20///
21/// This element contains subelements that declare each of the application's
22/// components and has attributes that can affect all the components.
23/// Many of these attributes (such as `icon`, `label`, `permission`, `process`,
24/// `taskAffinity`, and `allowTaskReparenting`) set default values for
25/// corresponding attributes of the component elements. Others (such as
26/// `debuggable`, `enabled`, `description`, and `allowClearUserData`) set values
27/// for the application as a whole and cannot be overridden by the components.
28///
29/// ## XML Syntax
30/// ```xml
31/// <application android:allowTaskReparenting=["true" | "false"]
32///              android:allowBackup=["true" | "false"]
33///              android:allowClearUserData=["true" | "false"]
34///              android:allowNativeHeapPointerTagging=["true" | "false"]
35///              android:backupAgent="string"
36///              android:backupInForeground=["true" | "false"]
37///              android:banner="drawable resource"
38///              android:debuggable=["true" | "false"]
39///              android:description="string resource"
40///              android:directBootAware=["true" | "false"]
41///              android:enabled=["true" | "false"]
42///              android:extractNativeLibs=["true" | "false"]
43///              android:fullBackupContent="xml resource"
44///              android:fullBackupOnly=["true" | "false"]
45///              android:gwpAsanMode=["always" | "never"]
46///              android:hasCode=["true" | "false"]
47///              android:hasFragileUserData=["true" | "false"]
48///              android:hardwareAccelerated=["true" | "false"]
49///              android:icon="drawable resource"
50///              android:isGame=["true" | "false"]
51///              android:killAfterRestore=["true" | "false"]
52///              android:largeHeap=["true" | "false"]
53///              android:label="string resource"
54///              android:logo="drawable resource"
55///              android:manageSpaceActivity="string"
56///              android:name="string"
57///              android:networkSecurityConfig="xml resource"
58///              android:permission="string"
59///              android:persistent=["true" | "false"]
60///              android:process="string"
61///              android:restoreAnyVersion=["true" | "false"]
62///              android:requestLegacyExternalStorage=["true" | "false"]
63///              android:requiredAccountType="string"
64///              android:resizeableActivity=["true" | "false"]
65///              android:restrictedAccountType="string"
66///              android:supportsRtl=["true" | "false"]
67///              android:taskAffinity="string"
68///              android:testOnly=["true" | "false"]
69///              android:theme="resource or theme"
70///              android:uiOptions=["none" | "splitActionBarWhenNarrow"]
71///              android:usesCleartextTraffic=["true" | "false"]
72///              android:vmSafeMode=["true" | "false"] >
73///       ...
74/// </application>
75/// ```
76///
77/// ## Contained in
78/// * [`<manifest>`]
79///
80/// ## Can contain
81/// * [`<activity>`]
82/// * [`<activity-alias>`]
83/// * [`<meta-data>`]
84/// * [`<service>`]
85/// * [`<receiver>`]
86/// * [`<provider>`]
87/// * [`<uses-library>`]
88///
89/// ## Introduced in
90/// API Level 1
91///
92/// [`<manifest>`]: crate::AndroidManifest
93/// [`<activity>`]: crate::Activity
94/// [`<activity-alias>`]: crate::ActivityAlias
95/// [`<meta-data>`]: crate::MetaData
96/// [`<service>`]: crate::Service
97/// [`<receiver>`]: crate::Receiver
98/// [`<provider>`]: crate::Provider
99/// [`<uses-library>`]: crate::UsesLibrary
100#[derive(Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Default, Clone)]
101pub struct Application {
102    /// Whether or not activities that the application defines can move from the task that
103    /// started them to the task they have an affinity for when that task is next
104    /// brought to the front — "`true`" if they can move, and "`false`" if they must
105    /// remain with the task where they started.
106    ///
107    /// The default value is "`false`".
108    ///
109    /// The [`<activity>`] element has its own [`allowTaskReparenting`] attribute that can
110    /// override the value set here. See that attribute for more information.
111    ///
112    /// [`<activity>`]: crate::Activity
113    /// [`allowTaskReparenting`]: crate::Activity#structfield.allow_task_reparenting
114    #[yaserde(attribute, prefix = "android", rename = "allowTaskReparenting")]
115    pub allow_task_reparenting: Option<VarOrBool>,
116    /// Whether to allow the application to participate in the backup and restore
117    /// infrastructure. If this attribute is set to false, no backup or restore of the
118    /// application will ever be performed, even by a full-system backup that would
119    /// otherwise cause all application data to be saved via adb.
120    ///
121    /// The default value of this attribute is "`true`".
122    ///
123    /// ## Note
124    /// If your app targets Android 11 (API level 30) or higher, you cannot disable
125    /// device-to-device migration of your app's files. The system automatically
126    /// allows this functionality.
127    ///
128    /// You can still disable cloud-based backup and restore of your app's files by
129    /// setting this attribute to "`false`", even if your app targets Android 11 (API
130    /// level 30) or higher.
131    #[yaserde(attribute, prefix = "android", rename = "allowBackup")]
132    pub allow_backup: Option<VarOrBool>,
133    /// Whether to allow the application to reset user data. This data includes flags—such
134    /// as whether the user has seen introductory tooltips—as well as user-customizable
135    /// settings and preferences.
136    ///
137    /// The default value of this attribute is "`true`".
138    ///
139    /// For more information, see [`Restoring User Data on New Devices`].
140    ///
141    /// ## Note
142    /// Only apps that are part of the system image can declare this attribute explicitly.
143    /// Third-party apps cannot include this attribute in their manifest files.
144    ///
145    /// [`Restoring User Data on New Devices`]: https://developer.android.com/guide/topics/data/backup
146    #[yaserde(attribute, prefix = "android", rename = "allowClearUserData")]
147    pub allow_clear_user_data: Option<VarOrBool>,
148    /// Whether or not the app has the Heap pointer tagging feature enabled.
149    ///
150    /// The default value of this attribute is `true`.
151    ///
152    /// ## Note
153    /// Disabling this feature does `not` address the underlying code health issue.
154    /// Future hardware devices may not support this manifest tag.
155    ///
156    /// For more information, see [`Tagged Pointers`].
157    ///
158    /// [`Tagged Pointers`]: https://source.android.com/devices/tech/debug/tagged-pointers
159    #[yaserde(
160        attribute,
161        prefix = "android",
162        rename = "allowNativeHeapPointerTagging"
163    )]
164    pub allow_native_heap_pointer_tagging: Option<VarOrBool>,
165    /// The name of the class that implements the application's backup agent, a subclass
166    /// of [`BackupAgent`]. The attribute value should be a fully qualified class name
167    /// (such as, `"com.example.project.MyBackupAgent"`). However, as a shorthand, if
168    /// the first character of the name is a period (for example, `".MyBackupAgent"`),
169    /// it is appended to the package name specified in the [`<manifest>`] element.
170    ///
171    /// There is no default. The name must be specified.
172    ///
173    /// [`BackupAgent`]: https://developer.android.com/reference/android/app/backup/BackupAgent
174    /// [`<manifest>`]: crate::AndroidManifest
175    #[yaserde(attribute, prefix = "android", rename = "backupAgent")]
176    pub backup_agent: Option<String>,
177    /// Indicates that [`Auto Backup`] operations may be performed on this app even if the
178    /// app is in a foreground-equivalent state. The system shuts down an app during
179    /// auto backup operation, so use this attribute with caution. Setting this flag
180    /// to true can impact app behavior while the app is active.
181    ///
182    /// The default value is "`false`", which means that the OS will avoid backing up the
183    /// app while it is running in the foreground (such as a music app that is
184    /// actively playing music via a service in the [`startForeground()`] state).
185    ///
186    /// [`Auto Backup`]: https://developer.android.com/guide/topics/data/autobackup
187    /// [`startForeground()`]: https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification)
188    #[yaserde(attribute, prefix = "android", rename = "backupInForeground")]
189    pub backup_in_foreground: Option<VarOrBool>,
190    /// A [`drawable resource`] providing an extended graphical banner for its associated
191    /// item. Use with the `<application>` tag to supply a default banner for all
192    /// application activities, or with the [`<activity>`] tag to supply a banner for
193    /// a specific activity.
194    ///
195    /// The system uses the banner to represent an app in the Android TV home screen.
196    /// Since the banner is displayed only in the home screen, it should only be
197    /// specified by applications with an activity that handles the
198    /// [`CATEGORY_LEANBACK_LAUNCHER`] intent.
199    ///
200    /// This attribute must be set as a reference to a drawable resource containing the
201    /// image (for example `"@drawable/banner"`). There is no default banner.
202    ///
203    /// See [`Provide a home screen banner`] in Get Started with TV Apps for more
204    /// information.
205    ///
206    /// [`drawable resource`]: https://developer.android.com/guide/topics/resources/drawable-resource
207    /// [`<activity>`]: crate::Activity
208    /// [`CATEGORY_LEANBACK_LAUNCHER`]: https://developer.android.com/reference/android/content/Intent#CATEGORY_LEANBACK_LAUNCHER
209    /// [`Provide a home screen banner`]: https://developer.android.com/training/tv/start/start#banner
210    #[yaserde(attribute, prefix = "android")]
211    pub banner: Option<Resource<DrawableResource>>,
212    /// Whether or not the application can be debugged, even when running on a device in
213    /// user mode — "`true`" if it can be, and "`false`" if not. The default value is
214    /// "`false`".
215    #[yaserde(attribute, prefix = "android")]
216    pub debuggable: Option<VarOrBool>,
217    /// User-readable text about the application, longer and more descriptive than the
218    /// application label. The value must be set as a reference to a string resource.
219    /// Unlike the label, it cannot be a raw string.
220    ///
221    /// There is no default value.
222    #[yaserde(attribute, prefix = "android")]
223    pub description: Option<Resource<StringResource>>,
224    /// Whether or not the application is direct-boot aware; that is, whether or
225    /// not it can run before the user unlocks the device. If you're using a
226    /// custom subclass of [`Application`], and if any component inside your
227    /// application is direct-boot aware, then your entire custom
228    /// applicationis considered to be direct-boot aware.
229    ///
230    /// The default value is "`false`".
231    ///
232    /// ## Note
233    /// During [`Direct Boot`], your application can only access the data that is stored
234    /// in device protected storage.
235    ///
236    /// [`Application`]: https://developer.android.com/reference/android/app/Application
237    /// [`Direct Boot`]: https://developer.android.com/training/articles/direct-boot
238    #[yaserde(attribute, prefix = "android", rename = "directBootAware")]
239    pub direct_boot_aware: Option<VarOrBool>,
240    /// Whether or not the Android system can instantiate components of the
241    /// application — "`true`" if it can, and "`false`" if not. If the value
242    /// is "`true`", each component's enabled attribute determines whether that
243    /// component is enabled or not. If the value is "`false`", it overrides the
244    /// component-specific values; all components are disabled.
245    ///
246    /// The default value is "`true`".
247    #[yaserde(attribute, prefix = "android")]
248    pub enabled: Option<VarOrBool>,
249    /// Whether or not the package installer extracts native libraries from the APK to the
250    /// filesystem. If set to "`false`", then your native libraries must be page aligned
251    /// and stored uncompressed in the APK. Although your APK might be larger, your
252    /// application should load faster because the libraries are directly loaded from the
253    /// APK at runtime. On the other hand, if set to "`true`", native libraries in the APK
254    /// can be compressed. During installation, the installer decompresses the libraries,
255    /// and the linker loads the decompressed libraries at runtime; in this case, the APK
256    /// would be smaller, but installation time might be slightly longer.
257    ///
258    /// The default value is "`true`" if extractNativeLibs is not configured in
259    /// `AndroidManifest.xml`. However, when building your app using [`Android Gradle
260    /// plugin 3.6.0`] or higher, this property is reset to "`false`" if it is `NOT`
261    /// configured in `AndroidManifest.xml`; so if your native libraries in the APK
262    /// are compressed, you must explicitly set it to "`true`" in
263    /// `AndroidManifest.xml`.
264    ///
265    /// [`Android Gradle plugin 3.6.0`]: https://developer.android.com/studio/releases/gradle-plugin#3-6-0
266    #[yaserde(attribute, prefix = "android", rename = "extractNativeLibs")]
267    pub extract_native_libs: Option<VarOrBool>,
268    /// This attribute points to an XML file that contains full backup rules for [`Auto
269    /// Backup`]. These rules determine what files get backed up. For more information,
270    /// see [`XML Config Syntax`] for Auto Backup.
271    ///
272    /// This attribute is optional. If it is not specified, by default, Auto Backup
273    /// includes most of your app's files. For more information, see [`Files that are
274    /// backed`] up.
275    ///
276    /// [`Auto Backup`]: https://developer.android.com/guide/topics/data/autobackup
277    /// [`XML Config Syntax`]: https://developer.android.com/guide/topics/data/autobackup#XMLSyntax
278    /// [`Files that are backed`]: https://developer.android.com/guide/topics/data/autobackup#Files
279    #[yaserde(attribute, prefix = "android", rename = "fullBackupContent")]
280    pub full_backup_content: Option<Resource<XmlResource>>,
281    /// This attribute indicates whether or not to use [`Auto Backup`] on devices where it
282    /// is available. If set to "`true`", then your app performs Auto Backup when
283    /// installed on a device running Android 6.0 (API level 23) or higher. On older
284    /// devices, your app ignores this attribute and performs [`Key/Value Backups`].
285    ///
286    /// The default value is "`false`".
287    ///
288    /// [`Auto Backup`]: https://developer.android.com/guide/topics/data/autobackup
289    /// [`Key/Value Backups`]: https://developer.android.com/guide/topics/data/keyvaluebackup
290    #[yaserde(attribute, prefix = "android", rename = "fullBackupOnly")]
291    pub full_backup_only: Option<VarOrBool>,
292    /// This attribute indicates whether or not to use [`GWP-ASan`], which is a native
293    /// memory allocator feature that helps find use-after-free and
294    /// heap-buffer-overflow bugs.
295    ///
296    /// The default value is "`never`".
297    ///
298    /// [`GWP-ASan`]: https://developer.android.com/ndk/guides/gwp-asan
299    #[yaserde(attribute, prefix = "android", rename = "gwpAsanMode")]
300    pub gwp_asan_mode: Option<GwpAsanMode>,
301    /// Whether or not the application contains any code — "`true`" if it does, and
302    /// "`false`" if not. When the value is "`false`", the system does not try to load
303    /// any application code when launching components.
304    ///
305    /// The default value is "`true`".
306    ///
307    /// For example, if your app supports [`Play Feature Delivery`] and includes feature
308    /// modules that do not generate any DEX files—which is bytecode optimized for the
309    /// Android platform—you need to set this property to "`false`" in the module's
310    /// manifest file. Otherwise, you may get runtime errors.
311    ///
312    /// [`Play Feature Delivery`]: https://developer.android.com/platform/technology/app-bundle
313    #[yaserde(attribute, prefix = "android", rename = "hasCode")]
314    pub has_code: Option<VarOrBool>,
315    /// When the user uninstalls an app, whether or not to show the user a prompt to keep
316    /// the app's data.
317    ///
318    /// The default value is "`false`".
319    #[yaserde(attribute, prefix = "android", rename = "hasFragileUserData")]
320    pub has_fragile_user_data: Option<VarOrBool>,
321    /// Whether or not hardware-accelerated rendering should be enabled for all activities
322    /// and views in this application — "`true`" if it should be enabled, and
323    /// "`false`" if not. The default value is "`true`" if you've set either
324    /// [`minSdkVersion`] or [`targetSdkVersion`] to "14" or higher; otherwise, it's
325    /// "`false`".
326    ///
327    /// Starting from Android 3.0 (API level 11), a hardware-accelerated OpenGL renderer
328    /// is available to applications, to improve performance for many common 2D graphics
329    /// operations. When the hardware-accelerated renderer is enabled, most operations in
330    /// Canvas, Paint, Xfermode, ColorFilter, Shader, and Camera are accelerated. This
331    /// results in smoother animations, smoother scrolling, and improved responsiveness
332    /// overall, even for applications that do not explicitly make use the framework's
333    /// OpenGL libraries.
334    ///
335    /// For more information, read the [`Hardware Acceleration`] guide.
336    ///
337    /// ## Note
338    /// Not all of the OpenGL 2D operations are accelerated. If you enable the
339    /// hardware-accelerated renderer, test your application to ensure that it can
340    /// make use of the renderer without errors.
341    ///
342    /// [`minSdkVersion`]: crate::UsesSdk#structfield.min_sdk_version
343    /// [`targetSdkVersion`]: crate::UsesSdk#structfield.target_sdk_version
344    /// [`Hardware Acceleration`]: https://developer.android.com/guide/topics/graphics/hardware-accel
345    #[yaserde(attribute, prefix = "android", rename = "hardwareAccelerated")]
346    pub hardware_accelerated: Option<VarOrBool>,
347    /// An icon for the application as whole, and the default icon for each of the
348    /// application's components. See the individual icon attributes for [`<activity>`],
349    /// [`<activity-alias>`], [`<service>`], [`<receiver>`], and [`<provider>`] elements.
350    ///
351    /// This attribute must be set as a reference to a drawable resource containing the
352    /// image (for example `"@drawable/icon"`).
353    ///
354    /// There is no default icon.
355    ///
356    /// [`<activity>`]: crate::Activity
357    /// [`<activity-alias>`]: crate::ActivityAlias
358    /// [`<service>`]: crate::Service
359    /// [`<receiver>`]: crate::Receiver
360    /// [`<provider>`]: crate::Provider
361    #[yaserde(attribute, prefix = "android")]
362    pub icon: Option<MipmapOrDrawableResource>,
363    /// Whether or not the application is a game. The system may group together
364    /// applications classifed as games or display them separately from other
365    /// applications.
366    ///
367    /// The default is `false`.
368    #[yaserde(attribute, prefix = "android", rename = "isGame")]
369    pub is_game: Option<VarOrBool>,
370    /// Whether the application in question should be terminated after its settings have
371    /// been restored during a full-system restore operation. Single-package restore
372    /// operations will never cause the application to be shut down. Full-system restore
373    /// operations typically only occur once, when the phone is first set up. Third-party
374    /// applications will not normally need to use this attribute.
375    ///
376    /// The default is "`true`", which means that after the application has finished
377    /// processing its data during a full-system restore, it will be terminated.
378    #[yaserde(attribute, prefix = "android", rename = "killAfterRestore")]
379    pub kill_after_restore: Option<VarOrBool>,
380    /// Whether your application's processes should be created with a large Dalvik heap.
381    /// This applies to all processes created for the application. It only applies to the
382    /// first application loaded into a process; if you're using a shared user ID to allow
383    /// multiple applications to use a process, they all must use this option consistently
384    /// or they will have unpredictable results.
385    ///
386    /// Most apps should not need this and should instead focus on reducing their overall
387    /// memory usage for improved performance. Enabling this also does not guarantee a
388    /// fixed increase in available memory, because some devices are constrained by their
389    /// total available memory.
390    ///
391    /// To query the available memory size at runtime, use the methods
392    /// [`getMemoryClass()`] or [`getLargeMemoryClass()`].
393    ///
394    /// [`getMemoryClass()`]: https://developer.android.com/reference/android/app/ActivityManager#getMemoryClass()
395    /// [`getLargeMemoryClass()`]: https://developer.android.com/reference/android/app/ActivityManager#getLargeMemoryClass()
396    #[yaserde(attribute, prefix = "android", rename = "largeHeap")]
397    pub large_heap: Option<VarOrBool>,
398    /// A user-readable label for the application as a whole, and a default label for each
399    /// of the application's components. See the individual label attributes for
400    /// [`<activity>`], [`<activity-alias>`], [`<service>`], [`<receiver>`], and
401    /// [`<provider>`] elements.
402    ///
403    /// The label should be set as a reference to a string resource, so that it can be
404    /// localized like other strings in the user interface. However, as a convenience
405    /// while you're developing the application, it can also be set as a raw string.
406    ///
407    /// [`<activity>`]: crate::Activity
408    /// [`<activity-alias>`]: crate::ActivityAlias
409    /// [`<service>`]: crate::Service
410    /// [`<receiver>`]: crate::Receiver
411    /// [`<provider>`]: crate::Provider
412    #[yaserde(attribute, prefix = "android")]
413    pub label: Option<StringResourceOrString>,
414    /// A logo for the application as whole, and the default logo for activities. This
415    /// attribute must be set as a reference to a drawable resource containing the
416    /// image (for example `"@drawable/logo"`).
417    ///
418    /// There is no default logo.
419    #[yaserde(attribute, prefix = "android")]
420    pub logo: Option<Resource<DrawableResource>>,
421    /// The fully qualified name of an Activity subclass that the system can launch to let
422    /// users manage the memory occupied by the application on the device. The
423    /// activity should also be declared with an [`<activity>`] element.
424    ///
425    /// [`<activity>`]: crate::Activity
426    #[yaserde(attribute, prefix = "android", rename = "manageSpaceActivity")]
427    pub manage_space_activity: Option<String>,
428    /// The fully qualified name of an [`Application`] subclass implemented for the
429    /// application. When the application process is started, this class is instantiated
430    /// before any of the application's components.
431    ///
432    /// The subclass is optional; most applications won't need one. In the absence of a
433    /// subclass, Android uses an instance of the base Application class.
434    ///
435    /// [`Application`]: https://developer.android.com/reference/android/app/Application
436    #[yaserde(attribute, prefix = "android")]
437    pub name: Option<String>,
438    /// Specifies the name of the XML file that contains your application's [`Network
439    /// Security Configuration`]. The value must be a reference to the XML resource file
440    /// containing the configuration.
441    ///
442    /// This attribute was added in API level 24.
443    ///
444    /// [`Network Security Configuration`]: https://developer.android.com/training/articles/security-config
445    #[yaserde(attribute, prefix = "android", rename = "networkSecurityConfig")]
446    pub network_security_config: Option<Resource<XmlResource>>,
447    /// The name of a permission that clients must have in order to interact with the
448    /// application. This attribute is a convenient way to set a permission that applies
449    /// to all of the application's components. It can be overwritten by setting the
450    /// `permission` attributes of individual components.
451    ///
452    /// For more information on permissions, see the [`Permissions`] section in the
453    /// introduction and another document, [`Security and Permissions`].
454    ///
455    /// [`Permissions`]: https://developer.android.com/guide/topics/manifest/manifest-intro#perms
456    /// [`Security and Permissions`]: https://developer.android.com/training/articles/security-tips
457    #[yaserde(attribute, prefix = "android")]
458    pub permission: Option<String>,
459    /// Whether or not the application should remain running at all times — "`true`" if it
460    /// should, and "`false`" if not. The default value is "`false`". Applications
461    /// should not normally set this flag; persistence mode is intended only for
462    /// certain system applications.
463    #[yaserde(attribute, prefix = "android")]
464    pub persistent: Option<VarOrBool>,
465    /// The name of a process where all components of the application should run. Each
466    /// component can override this default by setting its own `process` attribute.
467    ///
468    /// By default, Android creates a process for an application when the first of its
469    /// components needs to run. All components then run in that process. The name of the
470    /// default process matches the package name set by the [`<manifest>`] element.
471    ///
472    /// By setting this attribute to a process name that's shared with another
473    /// application, you can arrange for components of both applications to run in the
474    /// same process — but only if the two applications also share a user ID and be signed
475    /// with the same certificate.
476    ///
477    /// If the name assigned to this attribute begins with a colon (':'), a new process,
478    /// private to the application, is created when it's needed. If the process name
479    /// begins with a lowercase character, a global process of that name is created. A
480    /// global process can be shared with other applications, reducing resource usage.
481    ///
482    /// [`<manifest>`]: crate::AndroidManifest
483    #[yaserde(attribute, prefix = "android")]
484    pub process: Option<String>,
485    /// Indicates that the application is prepared to attempt a restore of any backed-up
486    /// data set, even if the backup was stored by a newer version of the application
487    /// than is currently installed on the device. Setting this attribute to "`true`"
488    /// will permit the Backup Manager to attempt restore even when a version mismatch
489    /// suggests that the data are incompatible. Use with caution!
490    ///
491    /// The default value of this attribute is `false`.
492    #[yaserde(attribute, prefix = "android", rename = "restoreAnyVersion")]
493    pub restore_any_version: Option<VarOrBool>,
494    /// Whether or not the application wants to opt out of [`scoped storage`].
495    ///
496    /// ## Note
497    /// Depending on changes related to policy or app compatibility, the system might not
498    /// honor this opt-out request.
499    ///
500    /// [`scoped storage`]: https://developer.android.com/training/data-storage#scoped-storage
501    #[yaserde(attribute, prefix = "android", rename = "requestLegacyExternalStorage")]
502    pub request_legacy_external_storage: Option<VarOrBool>,
503    /// Specifies the account type required by the application in order to function. If
504    /// your app requires an [`Account`], the value for this attribute must correspond to
505    /// the account authenticator type used by your app (as defined by
506    /// [`AuthenticatorDescription`]), such as "com.google".
507    ///
508    /// The default value is null and indicates that the application can work without any
509    /// accounts.
510    ///
511    /// Because restricted profiles currently cannot add accounts, specifying this
512    /// attribute `makes your app unavailable from a restricted profile` unless you also
513    /// declare [`android:restrictedAccountType`] with the same value.
514    ///
515    /// This attribute was added in API level 18.
516    ///
517    /// ## Caution
518    /// If the account data may reveal personally identifiable information, it's important
519    /// that you declare this attribute and leave [`android:restrictedAccountType`] null,
520    /// so that restricted profiles cannot use your app to access personal information
521    /// that belongs to the owner user.
522    ///
523    /// [`Account`]: https://developer.android.com/reference/android/accounts/Account
524    /// [`AuthenticatorDescription`]: https://developer.android.com/reference/android/accounts/AuthenticatorDescription
525    /// [`android:restrictedAccountType`]:
526    /// crate::Application#structfield.restricted_account_type
527    #[yaserde(attribute, prefix = "android", rename = "requiredAccountType")]
528    pub required_account_type: Option<String>,
529    /// Specifies whether the app supports [`multi-window display`]. You can set this
530    /// attribute in either the [`<activity>`] or `<application>` element.
531    ///
532    /// If you set this attribute to true, the user can launch the activity in
533    /// split-screen and freeform modes. If you set the attribute to false, the activity
534    /// does not support multi-window mode. If this value is false, and the user attempts
535    /// to launch the activity in multi-window mode, the activity takes over the full
536    /// screen.
537    ///
538    /// If your app targets API level 24 or higher, but you do not specify a value for
539    /// this attribute, the attribute's value defaults to true.
540    ///
541    /// This attribute was added in API level 24.
542    ///
543    /// ## Note
544    /// A task's root activity value is applied to all additional activities launched in
545    /// the task. That is, if the root activity of a task is resizable then the system
546    /// treats all other activities in the task as resizable. If the root activity is not
547    /// resizable, the other activities in the task are not resizable
548    ///
549    /// [`multi-window display`]: https://developer.android.com/guide/topics/ui/multi-window
550    /// [`<activity>`]: crate::Activity
551    #[yaserde(attribute, prefix = "android", rename = "resizeableActivity")]
552    pub resizeable_activity: Option<VarOrBool>,
553    /// Specifies the account type required by this application and indicates that
554    /// restricted profiles are allowed to access such accounts that belong to the owner
555    /// user. If your app requires an [`Account`] and restricted profiles `are allowed to
556    /// access` the primary user's accounts, the value for this attribute must correspond
557    /// to the account authenticator type used by your app (as defined by
558    /// [`AuthenticatorDescription`]), such as "com.google".
559    ///
560    /// The default value is null and indicates that the application can work without any
561    /// accounts.
562    ///
563    /// ## Caution
564    /// Specifying this attribute allows restricted profiles to use your app with accounts
565    /// that belong to the owner user, which may reveal personally identifiable
566    /// information. If the account may reveal personal details, you `should not` use this
567    /// attribute and you should instead declare the [`android:requiredAccountType`]
568    /// attribute to make your app unavailable to restricted profiles.
569    ///
570    /// This attribute was added in API level 18.
571    ///
572    /// [`Account`]: https://developer.android.com/reference/android/accounts/Account
573    /// [`AuthenticatorDescription`]: https://developer.android.com/reference/android/accounts/AuthenticatorDescription
574    /// [`android:requiredAccountType`]:
575    /// crate::Application#structfield.required_account_type
576    #[yaserde(attribute, prefix = "android", rename = "restrictedAccountType")]
577    pub restricted_account_type: Option<String>,
578    /// Declares whether your application is willing to support right-to-left (RTL)
579    /// layouts. If set to "`true`" and [`targetSdkVersion`] is set to 17 or higher,
580    /// various RTL APIs will be activated and used by the system so your app can
581    /// display RTL layouts. If set to "`false`" or if [`targetSdkVersion`] is set to
582    /// 16 or lower, the RTL APIs will be ignored or will have no effect and your app
583    /// will behave the same regardless of the layout direction associated to the
584    /// user's Locale choice (your layouts will always be left-to-right).
585    ///
586    /// The default value of this attribute is "`false`".
587    ///
588    /// This attribute was added in API level 17.
589    ///
590    /// [`targetSdkVersion`]: crate::UsesSdk#structfield.target_sdk_version
591    #[yaserde(attribute, prefix = "android", rename = "supportsRtl")]
592    pub supports_rtl: Option<VarOrBool>,
593    /// An affinity name that applies to all activities within the application, except for
594    /// those that set a different affinity with their own [`taskAffinity`] attributes.
595    /// See that attribute for more information.
596    ///
597    /// By default, all activities within an application share the same affinity. The name
598    /// of that affinity is the same as the package name set by the [`<manifest>`]
599    /// element.
600    ///
601    /// [`taskAffinity`]: crate::Activity#structfield.task_affinity
602    /// [`<manifest>`]: crate::AndroidManifest
603    #[yaserde(attribute, prefix = "android", rename = "taskAffinity")]
604    pub task_affinity: Option<String>,
605    /// Indicates whether this application is only for testing purposes. For example, it
606    /// may expose functionality or data outside of itself that would cause a security
607    /// hole, but is useful for testing. This kind of APK can be installed only through
608    /// [`adb`] — you cannot publish it to Google Play.
609    ///
610    /// Android Studio automatically adds this attribute when you click `Run`.
611    ///
612    /// [`adb`]: https://developer.android.com/studio/command-line/adb
613    #[yaserde(attribute, prefix = "android", rename = "testOnly")]
614    pub test_only: Option<VarOrBool>,
615    /// A reference to a style resource defining a default theme for all activities in the
616    /// application. Individual activities can override the default by setting their own
617    /// [`theme`] attributes. For more information, see the [`Styles and Themes`]
618    /// developer guide.
619    ///
620    /// [`theme`]: crate::Activity#structfield.theme
621    /// [`Styles and Themes`]: https://developer.android.com/guide/topics/ui/look-and-feel/themes
622    #[yaserde(attribute, prefix = "android")]
623    pub theme: Option<Resource<StyleResource>>,
624    /// Extra options for an activity's UI.
625    ///
626    /// For more information about the app bar, see the [`Adding the App Bar`] training
627    /// class.
628    ///
629    /// This attribute was added in API level 14.
630    ///
631    /// [`Adding the App Bar`]: https://developer.android.com/training/appbar
632    #[yaserde(attribute, prefix = "android", rename = "uiOptions")]
633    pub ui_options: Option<UiOptions>,
634    /// Indicates whether the app intends to use cleartext network traffic, such as
635    /// cleartext HTTP. The default value for apps that target API level 27 or lower is
636    /// "`true`". Apps that target API level 28 or higher default to "`false`".
637    ///
638    /// When the attribute is set to "`false`", platform components (for example, HTTP and
639    /// FTP stacks, [`DownloadManager`], and [`MediaPlayer`]) will refuse the app's
640    /// requests to use cleartext traffic. Third-party libraries are strongly
641    /// encouraged to honor this setting as well. The key reason for avoiding
642    /// cleartext traffic is the lack of confidentiality, authenticity, and
643    /// protections against tampering; a network attacker can eavesdrop on transmitted
644    /// data and also modify it without being detected.
645    ///
646    /// This flag is honored on a best-effort basis because it's impossible to prevent all
647    /// cleartext traffic from Android applications given the level of access provided to
648    /// them. For example, there's no expectation that the [`Socket`] API will honor this
649    /// flag because it cannot determine whether its traffic is in cleartext. However,
650    /// most network traffic from applications is handled by higher-level network
651    /// stacks/components, which can honor this flag by either reading it from
652    /// [`ApplicationInfo.flags`] or
653    /// [`NetworkSecurityPolicy.isCleartextTrafficPermitted()`].
654    ///
655    /// ## Note
656    /// [`WebView`] honors this attribute for applications targeting API level 26 and
657    /// higher.
658    ///
659    /// During app development, StrictMode can be used to identify any cleartext traffic
660    /// from the app. See [`StrictMode.VmPolicy.Builder.detectCleartextNetwork()`] for
661    /// more information.
662    ///
663    /// This attribute was added in API level 23.
664    ///
665    /// This flag is ignored on Android 7.0 (API level 24) and above if an Android Network
666    /// Security Config is present.
667    ///
668    /// [`DownloadManager`]: https://developer.android.com/reference/android/app/DownloadManager
669    /// [`MediaPlayer`]: https://developer.android.com/reference/android/media/MediaPlayer
670    /// [`Socket`]: https://developer.android.com/reference/java/net/Socket
671    /// [`ApplicationInfo.flags`]: https://developer.android.com/reference/android/content/pm/ApplicationInfo#flags
672    /// [`NetworkSecurityPolicy.isCleartextTrafficPermitted()`]: https://developer.android.com/reference/android/security/NetworkSecurityPolicy#isCleartextTrafficPermitted()
673    /// [`WebView`]: https://developer.android.com/reference/android/webkit/WebView
674    /// [`StrictMode.VmPolicy.Builder.detectCleartextNetwork()`]: https://developer.android.com/reference/android/os/StrictMode.VmPolicy.Builder#detectCleartextNetwork()
675    #[yaserde(attribute, prefix = "android", rename = "usesCleartextTraffic")]
676    pub uses_cleartext_traffic: Option<VarOrBool>,
677    /// Indicates whether the app would like the virtual machine (VM) to operate in safe
678    /// mode. The default value is "`false`".
679    ///
680    /// This attribute was added in API level 8 where a value of "`true`" disabled the
681    /// Dalvik just-in-time (JIT) compiler.
682    ///
683    /// This attribute was adapted in API level 22 where a value of "`true`" disabled the
684    /// ART ahead-of-time (AOT) compiler.
685    #[yaserde(attribute, prefix = "android", rename = "vmSafeMode")]
686    pub vm_safe_mode: Option<VarOrBool>,
687    /// Optional `<profileable>` tag.
688    pub profileable: Option<Profileable>,
689    /// List of `<activity>` tags.
690    #[serde(default, skip_serializing_if = "Vec::is_empty")]
691    pub activity: Vec<Activity>,
692    /// List of `<service>` tags.
693    #[serde(default, skip_serializing_if = "Vec::is_empty")]
694    pub service: Vec<Service>,
695    /// List of `<receiver>` tags.
696    #[serde(default, skip_serializing_if = "Vec::is_empty")]
697    pub receiver: Vec<Receiver>,
698    /// List of `<provider>` tags.
699    #[serde(default, skip_serializing_if = "Vec::is_empty")]
700    pub provider: Vec<Provider>,
701    /// List of `<activity-alias>` tags.
702    #[yaserde(rename = "activity-alias")]
703    #[serde(default, skip_serializing_if = "Vec::is_empty")]
704    pub activity_alias: Vec<ActivityAlias>,
705    /// List of `<meta-data>` tags.
706    #[yaserde(rename = "meta-data")]
707    #[serde(default, skip_serializing_if = "Vec::is_empty")]
708    pub meta_data: Vec<MetaData>,
709    /// List of `<uses-library>` tags.
710    #[yaserde(rename = "uses-library")]
711    #[serde(default, skip_serializing_if = "Vec::is_empty")]
712    pub uses_library: Vec<UsesLibrary>,
713    /// List of `<uses-native-library>` tags.
714    #[yaserde(rename = "uses-native-library")]
715    #[serde(default, skip_serializing_if = "Vec::is_empty")]
716    pub uses_native_library: Vec<UsesNativeLibrary>,
717}
718
719impl Application {
720    pub fn is_default(&self) -> bool {
721        self == &Application::default()
722    }
723}
724
725/// GWP-ASan is a native memory allocator feature that helps find [`use-after-free`] and
726/// [`heap-buffer-overflow`] bugs.
727///
728/// [`use-after-free`]: https://cwe.mitre.org/data/definitions/416.html
729/// [`heap-buffer-overflow`]: https://cwe.mitre.org/data/definitions/122.html
730#[derive(Debug, Deserialize, Serialize, YaSerialize, YaDeserialize, PartialEq, Eq, Clone)]
731#[serde(rename_all = "camelCase")]
732#[derive(Default)]
733pub enum GwpAsanMode {
734    /// Always disabled: This setting completely disables GWP-ASan in your app and is the
735    /// default for non-system apps.
736    #[yaserde(rename = "never")]
737    #[default]
738    Never,
739    /// Always enabled: This setting enables GWP-ASan in your app, which includes the
740    /// following:
741    /// 1. The operating system reserves a fixed amount of RAM for GWP-ASan operations,
742    ///   approximately ~70KiB for each affected process. (Enable GWP-ASan if your app is
743    ///   not critically sensitive to increases in memory usage.)
744    /// 2. GWP-ASan intercepts a randomly-chosen subset of heap allocations and places
745    /// them   into a special region that reliably detects memory safety violations.
746    /// 3. When a memory safety violation occurs in the special region, GWP-ASan
747    /// terminates   the process.
748    /// 4. GWP-ASan provides additional information about the fault in the crash report.
749    #[yaserde(rename = "always")]
750    Always,
751}