Skip to main content

android_manifest/
application.rs

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