resand 0.3.0

Read and write ARSC and AXML binary files used for Android Resources
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
use crate::{
    self as resand,
    defs::ResTableRef,
    impl_enum,
    traits::{FromResValue, FromResValueError, IntoResValue, Mergeable, Referenced},
};
use resand_derive::{FromNode, IntoNode};

macro_rules! push_name {
    ($field:ident, $other:ident, $self:ident) => {
        for _other_val in $other.$field {
            if $self
                .$field
                .iter()
                .find(|p| p.name == _other_val.name)
                .is_none()
            {
                $self.$field.push(_other_val);
            }
        }
    };
}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ColorMode(u32);

impl_enum! {ColorMode, default => 0, wide_color_gamut => 1, hdr => 2}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ConfigChanges(u32);

impl_enum! {ConfigChanges,
    mcc => 0x0001,
    mnc => 0x0002,
    locale => 0x0004,
    touchscreen => 0x0008,
    keyboard => 0x0010,
    keyboard_hidden => 0x0020,
    navigation => 0x0040,
    orientation => 0x0080,
    screen_layout => 0x100,
    ui_mode => 0x0200,
    screen_size => 0x0400,
    smallest_screen_size => 0x0800,
    density => 0x1000,
    layout_direction => 0x2000,
    color_mode => 0x4000,
    grammatical_gender => 0x8000,
    font_scale => 0x40000000,
    font_weight_adjustment => 0x10000000,
    assets_path => 0x80000000,
    resources_unused => 0x8000000
}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct DocumentLaunchMode(u32);

impl_enum! {DocumentLaunchMode, none => 0, into_existing => 1, always => 2, never => 3}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct LaunchMode(u32);

impl_enum! {LaunchMode,
    standard => 0,
    single_top => 1,
    single_task => 2,
    single_instance => 3,
    single_instance_per_task => 4
}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct LockTaskMode(u32);

impl_enum! {LockTaskMode, normal => 0, never => 1, always => 2, if_whitelisted => 3}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct PersistableMode(u32);

impl_enum! {PersistableMode, persist_root_only => 0, persist_never => 1, persist_across_reboots => 2}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct RequireContentUriPermissionFromCaller(u32);

impl_enum! {RequireContentUriPermissionFromCaller, none => 0, read => 1, write => 2, read_or_write => 3, read_and_write => 4}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ScreenOrientation(i32);

impl_enum! {ScreenOrientation,
    unspecified => -1,
    landscape => 0,
    portrait => 1,
    user => 2,
    behind => 3,
    sensor => 4,
    nosensor => 5,
    sensor_landscape => 6,
    sensor_portrait => 7,
    reverse_landscape => 8,
    reverse_portrait => 9,
    full_sensor => 10,
    user_landscape => 11,
    user_portrait => 12,
    full_user => 13,
    locked => 14
}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct WindowSoftInputMode(u32);

impl_enum! {WindowSoftInputMode,
    state_unspecified => 0,
    state_unchanged => 1,
    state_hidden => 2,
    state_always_hidden => 3,
    state_visible => 4,
    state_always_visible => 5,
    adjust_unspecified => 0x00,
    adjust_resize => 0x10,
    adjust_pan => 0x20,
    adjust_nothing => 0x30
}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct Gravity(u32);

impl_enum! {Gravity,
    top => 0x30,
    bottom => 0x50,
    left => 0x03,
    right => 0x05,
    center_vertical => 0x10,
    fill_vertical => 0x70,
    center_horizontal => 0x01,
    fill_horizontal => 0x07,
    center => 0x11,
    fill => 0x77,
    clip_vertical => 0x80,
    clip_horizontal => 0x08,
    start => 0x00800003,
    end => 0x00800005
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 1, android)]
pub struct Layout {
    #[resand(attr, android, table_ref = 0x010104f4)]
    pub default_width: u32, // dimension|fraction
    #[resand(attr, android, table_ref = 0x010104f5)]
    pub default_height: u32, // dimension|fraction
    #[resand(attr, android, table_ref = 0x010100af)]
    pub gravity: Gravity,
    #[resand(attr, android, table_ref = 0x0101013f)]
    pub min_width: u32,
    #[resand(attr, android, table_ref = 0x01010140)]
    pub min_height: u32,
    #[resand(attr, android, table_ref = 0x01010619)]
    pub window_layout_affinity: String,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 2, android)]
pub struct Activity {
    #[resand(attr, android, table_ref = 0x01010000, optional)]
    pub theme: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010020, optional)]
    pub description: Option<String>,
    #[resand(attr, android, table_ref = 0x01020006, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101052c, optional)]
    pub round_icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x010103f2, optional)]
    pub banner: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x010102be, optional)]
    pub logo: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101000e, optional)]
    pub enabled: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010010, optional)]
    pub exported: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010012, optional)]
    pub task_affinity: Option<String>,
    #[resand(attr, android, table_ref = 0x01010017, optional)]
    pub exclude_from_recents: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101001d, optional)]
    pub launch_mode: Option<LaunchMode>,
    #[resand(attr, android, table_ref = 0x0101001e, optional)]
    pub screen_orientation: Option<ScreenOrientation>,
    #[resand(attr, android, table_ref = 0x0101001f, optional)]
    pub config_changes: Option<ConfigChanges>,
    #[resand(child, android, many)]
    pub intent_filter: Vec<IntentFilter>,
    #[resand(child, android, many)]
    pub meta_data: Vec<MetaData>,
    #[resand(child, android, many)]
    pub layout: Vec<Layout>,
    #[resand(attr, android, table_ref = 0x10103f5, optional)]
    pub allow_embedded: Option<bool>,
    #[resand(attr, android, table_ref = 0x010204, optional)]
    pub allow_task_reparenting: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010203, optional)]
    pub always_retain_task_state: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010447, optional)]
    pub auto_remove_from_recents: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010650, optional)]
    pub can_display_on_remote_devices: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010015, optional)]
    pub clear_task_on_launch: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101054a, optional)]
    pub color_mode: Option<ColorMode>,
    #[resand(attr, android, table_ref = 0x01010505, optional)]
    pub direct_boot_aware: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010445, optional)]
    pub document_launch_mode: Option<DocumentLaunchMode>,
    #[resand(attr, android, table_ref = 0x0101066c, optional)]
    pub enable_on_back_invoked_callback: Option<bool>,
    #[resand(attr, android, table_ref = 0x010100dd, optional)]
    pub fits_system_windows: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010014, optional)]
    pub finish_on_task_launch: Option<bool>,
    #[resand(attr, android, table_ref = 0x010102d3, optional)]
    pub hardware_accelerated: Option<bool>,
    #[resand(attr, android, table_ref = 0x010102c0, optional)]
    pub immersive: Option<bool>,
    #[resand(attr, android, table_ref = 0x010104ed, optional)]
    pub lock_task_mode: Option<LockTaskMode>,
    #[resand(attr, android, table_ref = 0x01010446, optional)]
    pub max_recents: Option<u32>,
    #[resand(attr, android, table_ref = 0x01010560, optional)]
    pub max_aspect_ratio: Option<f32>,
    #[resand(attr, android, table_ref = 0x0101059b, optional)]
    pub min_aspect_ratio: Option<f32>,
    #[resand(attr, android, table_ref = 0x01010013, optional)]
    pub multiprocess: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101022d, optional)]
    pub no_history: Option<bool>,
    #[resand(attr, android, table_ref = 0x010103a7, optional)]
    pub parent_activity_name: Option<String>,
    #[resand(attr, android, table_ref = 0x0101042d, optional)]
    pub persistable_mode: Option<PersistableMode>,
    #[resand(attr, android, table_ref = 0x01010006, optional)]
    pub permission: Option<String>,
    #[resand(attr, android, table_ref = 0x01010011, optional)]
    pub process: Option<String>,
    #[resand(attr, android, table_ref = 0x01010476, optional)]
    pub relinquish_task_identity: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101069b, optional)]
    pub require_content_uri_permission_from_caller: Option<RequireContentUriPermissionFromCaller>,
    #[resand(attr, android, table_ref = 0x010104f6, optional)]
    pub resizeable_activity: Option<bool>,
    #[resand(attr, android, table_ref = 0x010104ef, optional)]
    pub show_for_all_users: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010016, optional)]
    pub state_not_needed: Option<bool>,
    #[resand(attr, android, table_ref = 0x010104f7, optional)]
    pub supports_picture_in_picture: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010398, optional)]
    pub ui_options: Option<UiOptions>,
    #[resand(attr, android, table_ref = 0x0101022b, optional)]
    pub window_soft_input_mode: Option<WindowSoftInputMode>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 3, android)]
pub struct ActivityAlias {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(child, android, many)]
    pub intent_filter: Vec<IntentFilter>,
    #[resand(child, android, many)]
    pub meta_data: Vec<MetaData>,
    #[resand(attr, android, table_ref = 0x0101000e)]
    pub enabled: bool,
    #[resand(attr, android, table_ref = 0x01010010)]
    pub exported: bool,
    #[resand(attr, android, table_ref = 0x01010002)]
    pub icon: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010001)]
    pub label: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010006)]
    pub permission: String,
    #[resand(attr, android, table_ref = 0x01010202)]
    pub target_activity: String,
}

#[derive(Debug, PartialEq, Clone)]
pub enum MetaDataValue {
    Float(f32),
    String(String),
    TableRef(ResTableRef),
    Bool(bool),
    Int(u32),
}

impl Default for MetaDataValue {
    fn default() -> Self {
        Self::String(String::default())
    }
}

impl IntoResValue for MetaDataValue {
    fn into_res_value(
        self,
        string_pool: &mut crate::string_pool::StringPoolHandler,
    ) -> crate::res_value::ResValue {
        match self {
            MetaDataValue::Float(f) => f.into_res_value(string_pool),
            MetaDataValue::String(s) => s.into_res_value(string_pool),
            MetaDataValue::TableRef(res_table_ref) => res_table_ref.into_res_value(string_pool),
            MetaDataValue::Bool(b) => b.into_res_value(string_pool),
            MetaDataValue::Int(i) => i.into_res_value(string_pool),
        }
    }
}

impl FromResValue for MetaDataValue {
    type Error = FromResValueError;
    fn from_res_value(
        value: crate::res_value::ResValue,
        string_pool: &crate::string_pool::StringPoolHandler,
    ) -> Result<Self, Self::Error> {
        match value.data {
            crate::res_value::ResValueType::String(_) => {
                Ok(Self::String(String::from_res_value(value, string_pool)?))
            }
            crate::res_value::ResValueType::Float(f) => Ok(Self::Float(f)),
            crate::res_value::ResValueType::Reference(f) => Ok(Self::TableRef(f)),
            crate::res_value::ResValueType::IntBoolean(b) => Ok(Self::Bool(b.into())),
            crate::res_value::ResValueType::IntDec(i) => Ok(Self::Int(i.into())),
            crate::res_value::ResValueType::IntHex(h) => Ok(Self::Int(h.into())),
            _ => {
                return Err(FromResValueError::InvalidType(
                    "Float or String or Reference or IntBoolean or IntDec or IntHex",
                    value.data,
                ));
            }
        }
    }
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 4, android)]
pub struct MetaData {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010025, optional)]
    pub resource: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010024, optional)]
    pub value: Option<MetaDataValue>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 5, android)]
pub struct Profileable {
    #[resand(attr, android, table_ref = 0x01010594)]
    pub shell: bool,
    #[resand(attr, android, table_ref = 0x0101000e)]
    pub enabled: bool,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 6, android)]
pub struct UsesLibrary {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x0101028e)]
    pub required: bool,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 7, android)]
pub struct UsesNativeLibrary {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x0101028e)]
    pub required: bool,
}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ForegroundServiceType(u32);

impl_enum! {ForegroundServiceType,
    data_sync => 0x01,
    media_playback => 0x02,
    phone_call => 0x04,
    location => 0x08,
    connected_device => 0x10,
    media_projection => 0x20,
    camera => 0x40,
    microphone => 0x80,
    health => 0x100,
    remote_messaging => 0x200,
    system_exempted => 0x400,
    short_service => 0x800,
    media_processing => 0x2000,
    special_use => 0x40000000
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 8, android)]
pub struct Service {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(child, android, many)]
    pub intent_filter: Vec<IntentFilter>,
    #[resand(child, android, many)]
    pub meta_data: Vec<MetaData>,
    #[resand(attr, android, table_ref = 0x01010020, optional)]
    pub description: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010006, optional)]
    pub permission: Option<String>,
    #[resand(attr, android, table_ref = 0x0101000e, optional)]
    pub enabled: Option<Referenced<bool>>,
    #[resand(attr, android, table_ref = 0x01010010, optional)]
    pub exported: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010505, optional)]
    pub direct_boot_aware: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010599, optional)]
    pub foreground_service_type: Option<ForegroundServiceType>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x010103a9, optional)]
    pub isolated_process: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010011, optional)]
    pub process: Option<String>,
    #[resand(attr, android, table_ref = 0x0101036a, optional)]
    pub stop_with_task: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010531, optional)]
    pub visible_to_instant_apps: Option<bool>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 9, android)]
pub struct BroadcastReceiver {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(child, android, many)]
    pub intent_filter: Vec<IntentFilter>,
    #[resand(child, android, many)]
    pub meta_data: Vec<MetaData>,
    #[resand(attr, android, table_ref = 0x01010006, optional)]
    pub permission: Option<String>,
    #[resand(attr, android, table_ref = 0x0101000e, optional)]
    pub enabled: Option<Referenced<bool>>,
    #[resand(attr, android, table_ref = 0x01010010, optional)]
    pub exported: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010011, optional)]
    pub process: Option<String>,
    #[resand(attr, android, table_ref = 0x01010505, optional)]
    pub direct_boot_aware: Option<bool>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 10, android)]
pub struct GrantUriPermission {
    #[resand(attr, android, table_ref = 0x0101002a)]
    pub path: String,
    #[resand(attr, android, table_ref = 0x0101002d)]
    pub path_pattern: String,
    #[resand(attr, android, table_ref = 0x0101002b)]
    pub path_prefix: String,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 11, android)]
pub struct PathPermission {
    #[resand(attr, android, table_ref = 0x0101002a)]
    pub path: String,
    #[resand(attr, android, table_ref = 0x0101002d)]
    pub path_pattern: String,
    #[resand(attr, android, table_ref = 0x0101002b)]
    pub path_prefix: String,
    #[resand(attr, android, table_ref = 0x01010006)]
    pub permission: String,
    #[resand(attr, android, table_ref = 0x01010007)]
    pub read_permission: String,
    #[resand(attr, android, table_ref = 0x01010008)]
    pub write_permission: String,
}
// FIXME: most structs are missing fields not documented publicly

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 12, android)]
pub struct ContentProvider {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010011, optional)]
    pub process: Option<String>,
    #[resand(attr, android, table_ref = 0x01010010)]
    pub exported: bool,
    #[resand(attr, android, table_ref = 0x01010018)]
    pub authorities: Referenced<String>,
    #[resand(attr, android, table_ref = 0x01010019, optional)]
    pub syncable: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010007, optional)]
    pub read_permission: Option<String>,
    #[resand(attr, android, table_ref = 0x01010008, optional)]
    pub write_permission: Option<String>,
    #[resand(child, android, many)]
    pub grant_uri_permission: Vec<GrantUriPermission>,
    #[resand(attr, android, table_ref = 0x0101001b, optional)]
    pub grant_uri_permissions: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010006, optional)]
    pub permission: Option<String>,
    #[resand(attr, android, table_ref = 0x01010013, optional)]
    pub multiprocess: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101001a, optional)]
    pub init_order: Option<u32>,
    #[resand(attr, android, table_ref = 0x0101000e, optional)]
    pub enabled: Option<bool>,
    #[resand(child, android, many)]
    pub intent_filter: Vec<IntentFilter>,
    #[resand(child, android, many)]
    pub meta_data: Vec<MetaData>,
    #[resand(child, android, many)]
    pub path_permission: Vec<PathPermission>,
    #[resand(attr, android, table_ref = 0x01010505, optional)]
    pub direct_boot_aware: Option<bool>,
}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct AppCategory(u32);

impl_enum! {AppCategory,
    game => 0,
    audio => 1,
    video => 2,
    image => 3,
    social => 4,
    news => 5,
    maps => 6,
    productivity => 7,
    accessibility => 8
}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct GwpAsanMode(i32);

impl_enum! {GwpAsanMode, default => -1, never => 0, always => 1}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct IsMonitoringTool(u32);

// Just guessing here, can't find where the values are specified
impl_enum! {IsMonitoringTool, parental_control => 0, enterprise_management => 1, other => 2}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct UiOptions(u32);

impl_enum! {UiOptions, none => 0, split_action_bar_when_narrow => 1}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 13, android)]
pub struct Property {
    #[resand(attr, android, table_ref = 0x010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010025)]
    pub resource: ResTableRef,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 14, android)]
pub struct Application {
    #[resand(attr, android, table_ref = 0x010003, optional)]
    pub name: Option<String>,
    #[resand(child, android, many)]
    pub activity: Vec<Activity>,
    #[resand(child, android, many)]
    pub activity_alias: Vec<ActivityAlias>,
    #[resand(child, android, many)]
    pub meta_data: Vec<MetaData>,
    #[resand(child, android, many)]
    pub service: Vec<Service>,
    #[resand(child, android, many)]
    pub receiver: Vec<BroadcastReceiver>,
    #[resand(child, android, many)]
    pub profileable: Vec<Profileable>,
    #[resand(child, android, many)]
    pub provider: Vec<ContentProvider>,
    #[resand(child, android, many)]
    pub property: Vec<Property>,
    #[resand(child, android, many)]
    pub uses_library: Vec<UsesLibrary>,
    #[resand(child, android, many)]
    pub uses_native_library: Vec<UsesNativeLibrary>,
    #[resand(attr, android, table_ref = 0x01010204, optional)]
    pub allow_task_reparenting: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010000, optional)]
    pub theme: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010280, optional)]
    pub allow_backup: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010005, optional)]
    pub allow_clear_user_data: Option<bool>,
    #[resand(attr, android, table_ref = 0x010102d3, optional)]
    pub hardware_accelerated: Option<bool>,
    #[resand(attr, android, table_ref = 0x010103af, optional)]
    pub supports_rtl: Option<bool>,
    #[resand(attr, android, table_ref = 0x010104ea, optional)]
    pub extract_native_libs: Option<bool>,
    #[resand(attr, android, table_ref = 0x010104eb, optional)]
    pub full_backup_content: Option<bool>,
    #[resand(attr, android, table_ref = 0x010104f6, optional)]
    pub resizeable_activity: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010527, optional)]
    pub network_security_config: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010545, optional)]
    pub app_category: Option<AppCategory>,
    #[resand(attr, android, table_ref = 0x0101057a, optional)]
    pub app_component_factory: Option<String>,
    #[resand(attr, android, table_ref = 0x0101027f, optional)]
    pub backup_agent: Option<String>,
    #[resand(attr, android, table_ref = 0x0101051a, optional)]
    pub backup_in_foreground: Option<bool>,
    #[resand(attr, android, table_ref = 0x010103f2, optional)]
    pub banner: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010612, optional)]
    pub allow_native_heap_pointer_tagging: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010616, optional)]
    pub gwp_asan_mode: Option<GwpAsanMode>,
    #[resand(attr, android, table_ref = 0x0101063e, optional)]
    pub data_extraction_rules: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101000f, optional)]
    pub debuggable: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010020, optional)]
    pub description: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101000e, optional)]
    pub enabled: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101066c, optional)]
    pub enable_on_back_invoked_callback: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010473, optional)]
    pub full_backup_only: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101000c, optional)]
    pub has_code: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101059a, optional)]
    pub has_fragile_user_data: Option<bool>,
    #[resand(attr, android, table_ref = 0x10103f4, optional)]
    pub is_game: Option<bool>,
    // can't find res id
    #[resand(attr, android, optional)]
    pub is_monitoring_tool: Option<IsMonitoringTool>,
    #[resand(attr, android, table_ref = 0x0101029c, optional)]
    pub kill_after_restore: Option<bool>,
    #[resand(attr, android, table_ref = 0x0101035a, optional)]
    pub large_heap: Option<bool>,
    #[resand(attr, android, table_ref = 0x010102be, optional)]
    pub logo: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010004, optional)]
    pub manage_space_activity: Option<String>,
    #[resand(attr, android, table_ref = 0x01010006, optional)]
    pub permission: Option<String>,
    #[resand(attr, android, table_ref = 0x0101000e, optional)]
    pub persistent: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010011, optional)]
    pub process: Option<String>,
    #[resand(attr, android, table_ref = 0x010102ba, optional)]
    pub restore_any_version: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010603, optional)]
    pub request_legacy_external_storage: Option<bool>,
    #[resand(attr, android, table_ref = 0x010103d6, optional)]
    pub required_account_type: Option<String>,
    #[resand(attr, android, table_ref = 0x010103d5, optional)]
    pub restricted_account_type: Option<String>,
    #[resand(attr, android, table_ref = 0x01010012, optional)]
    pub task_affinity: Option<String>,
    #[resand(attr, android, table_ref = 0x01010272, optional)]
    pub test_only: Option<bool>,
    #[resand(attr, android, table_ref = 0x01010398, optional)]
    pub ui_options: Option<UiOptions>,
    #[resand(attr, android, table_ref = 0x010104ec, optional)]
    pub uses_cleartext_traffic: Option<bool>,
    #[resand(attr, android, table_ref = 0x010102b8, optional)]
    pub vm_safe_mode: Option<bool>,
}

impl Mergeable for Application {
    type Returns = ();
    fn merge(&mut self, other: Self) {
        push_name!(activity, other, self);
        push_name!(activity_alias, other, self);
        push_name!(meta_data, other, self);
        push_name!(service, other, self);
        push_name!(receiver, other, self);
        push_name!(provider, other, self);
        push_name!(property, other, self);
        push_name!(uses_library, other, self);
        push_name!(uses_native_library, other, self);
    }
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 15, android)]
pub struct Attribution {
    #[resand(attr, android, table_ref = 0x010100d1)]
    pub tag: String,
    #[resand(attr, android, table_ref = 0x01010001)]
    pub label: String,
}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct ScreenSize(u32);

impl_enum! {ScreenSize, small => 200, normal => 300, large => 400, xlarge => 500}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct ScreenDensity(u32);

impl_enum! {ScreenDensity, ldpi => 120, mdpi => 160, hdpi => 240, xhdpi => 320, xxhdpi => 480, xxxhpi => 640}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 16, android)]
pub struct Screen {
    #[resand(attr, android, table_ref = 0x010102ca)]
    pub screen_size: ScreenSize,
    #[resand(attr, android, table_ref = 0x010102cb)]
    pub screen_density: ScreenDensity,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 17, android)]
pub struct CompatibleScreens {
    #[resand(child, android, many)]
    pub screens: Vec<Screen>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 18, android)]
pub struct Instrumentation {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010023)]
    pub functional_test: bool,
    #[resand(attr, android, table_ref = 0x01010022)]
    pub handle_profiling: bool,
    #[resand(attr, android, table_ref = 0x01010002)]
    pub icon: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010001)]
    pub label: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010021)]
    pub target_package: String,
    #[resand(attr, android, table_ref = 0x01010541)]
    pub target_processes: String,
}

#[derive(Debug, PartialEq, Copy, Clone, Default)]
pub struct ProtectionLevel(u32);

impl_enum! {ProtectionLevel,
    normal => 0,
    dangerous => 1,
    signature => 2,
    signature_or_system => 3,
    internal => 4,
    privileged => 0x10,
    system => 0x10,
    development => 0x20,
    appop => 0x40,
    pre23 => 0x80,
    installer => 0x100,
    verifier => 0x200,
    pre_installed => 0x400,
    setup => 0x800,
    instant => 0x1000,
    runtime => 0x2000,
    oem => 0x4000,
    vendor_privileged => 0x8000,
    text_classifier => 0x10000,
    configurator => 0x80000,
    incident_report_approver => 0x100000,
    app_predictor => 0x200000,
    module => 0x400000,
    companion => 0x800000,
    retail_demo => 0x1000000,
    recents => 0x2000000,
    role => 0x4000000,
    known_signer => 0x8000000
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 18, android)]
pub struct Permission {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: Referenced<String>,
    #[resand(attr, android, table_ref = 0x01010020, optional)]
    pub description: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101000a, optional)]
    pub permission_group: Option<String>,
    #[resand(attr, android, table_ref = 0x01010009)]
    pub protection_level: ProtectionLevel,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 19, android)]
pub struct PermissionGroup {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010020)]
    pub description: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010002)]
    pub icon: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010001)]
    pub label: ResTableRef,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 20, android)]
pub struct PermissionTree {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010002)]
    pub icon: ResTableRef,
    #[resand(attr, android, table_ref = 0x01010001)]
    pub label: ResTableRef,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 21, android)]
pub struct Package {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
}
#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 22, android)]
pub struct Category {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 23, android)]
pub struct DataIntent {
    #[resand(attr, android, table_ref = 0x01010027, optional)]
    pub scheme: Option<String>,
    #[resand(attr, android, table_ref = 0x01010028, optional)]
    pub host: Option<String>,
    #[resand(attr, android, table_ref = 0x0101061e, optional)]
    pub path_suffix: Option<String>,
    #[resand(attr, android, table_ref = 0x01010620, optional)]
    pub path_advanced_pattern: Option<String>,
    #[resand(attr, android, table_ref = 0x01010026, optional)]
    pub mime_type: Option<String>,
    #[resand(attr, android, table_ref = 0x0101002a, optional)]
    pub path: Option<String>,
}
#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 24, android)]
pub struct Data {
    #[resand(attr, android, table_ref = 0x01010027)]
    pub scheme: String,
    #[resand(attr, android, table_ref = 0x01010028, optional)]
    pub host: Option<String>,
    #[resand(attr, android, table_ref = 0x01010029, optional)]
    pub port: Option<String>,
    #[resand(attr, android, table_ref = 0x0101002a, optional)]
    pub path: Option<String>,
    #[resand(attr, android, table_ref = 0x0101002c, optional)]
    pub path_pattern: Option<String>,
    #[resand(attr, android, table_ref = 0x0101002b, optional)]
    pub path_prefix: Option<String>,
    #[resand(attr, android, table_ref = 0x0101061e, optional)]
    pub path_suffix: Option<String>,
    #[resand(attr, android, table_ref = 0x01010620, optional)]
    pub path_advanced_pattern: Option<String>,
    #[resand(attr, android, table_ref = 0x01010026, optional)]
    pub mime_type: Option<String>,
}
#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 25, android)]
pub struct DataUriRelativeFilterGroup {
    #[resand(attr, android, table_ref = 0x0101002a)]
    pub path: String,
    #[resand(attr, android, table_ref = 0x0101002c)]
    pub path_pattern: String,
    #[resand(attr, android, table_ref = 0x0101002b)]
    pub path_prefix: String,
    #[resand(attr, android, table_ref = 0x0101061e)]
    pub path_suffix: String,
    #[resand(attr, android, table_ref = 0x01010620)]
    pub path_advanced_pattern: String,
    #[resand(attr, android, table_ref = 0x010102e3)]
    pub fragment: String,
    #[resand(attr, android, table_ref = 0x01010695)]
    pub fragment_pattern: String,
    #[resand(attr, android, table_ref = 0x01010694)]
    pub fragment_prefix: String,
    #[resand(attr, android, table_ref = 0x01010697)]
    pub fragment_suffix: String,
    #[resand(attr, android, table_ref = 0x01010696)]
    pub fragment_advanced_pattern: String,
    #[resand(attr, android, table_ref = 0x0101068f)]
    pub query: String,
    #[resand(attr, android, table_ref = 0x01010691)]
    pub query_pattern: String,
    #[resand(attr, android, table_ref = 0x01010690)]
    pub query_prefix: String,
    #[resand(attr, android, table_ref = 0x01010693)]
    pub query_suffix: String,
    #[resand(attr, android, table_ref = 0x01010692)]
    pub query_advanced_pattern: String,
}
#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 26, android)]
pub struct UriRelativeFilterGroup {
    #[resand(attr, android, table_ref = 0x0101068e)]
    pub allow: bool,
    #[resand(child, android, many)]
    pub data: Vec<DataUriRelativeFilterGroup>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 27, android)]
pub struct IntentFilter {
    #[resand(child, android, many)]
    pub action: Vec<Action>,
    #[resand(child, android, many)]
    pub category: Vec<Category>,
    #[resand(child, android, many)]
    pub data: Vec<Data>,
    #[resand(child, android, optional)]
    pub uri_relative_filter_group: Option<UriRelativeFilterGroup>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101001c, optional)]
    pub priority: Option<u32>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 28, android)]
pub struct Action {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 29, android)]
pub struct Intent {
    #[resand(child, android)]
    pub action: Action,
    #[resand(child, android, many)]
    pub category: Vec<Category>,
    #[resand(child, android, many)]
    pub data: Vec<DataIntent>,
    #[resand(child, android, optional)]
    pub uri_relative_filter_group: Option<UriRelativeFilterGroup>,
    #[resand(attr, android, table_ref = 0x01010002, optional)]
    pub icon: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x01010001, optional)]
    pub label: Option<ResTableRef>,
    #[resand(attr, android, table_ref = 0x0101001c, optional)]
    pub priority: Option<u32>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 30, android)]
pub struct Queries {
    #[resand(child, android, many)]
    pub package: Vec<Package>,
    #[resand(child, android, many)]
    pub intent: Vec<Intent>,
}

impl Mergeable for Queries {
    type Returns = ();
    fn merge(&mut self, other: Self) {
        push_name!(package, other, self);
    }
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 31, android)]
pub struct SupportsGlTexture {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 32, android)]
pub struct SupportsScreens {
    #[resand(attr, android, table_ref = 0x0101028d)]
    pub resizeable: bool,
    #[resand(attr, android, table_ref = 0x01010284)]
    pub small_screens: bool,
    #[resand(attr, android, table_ref = 0x0101028d)]
    pub normal_screens: bool,
    #[resand(attr, android, table_ref = 0x01010285)]
    pub large_screens: bool,
    #[resand(attr, android, table_ref = 0x010102bf)]
    pub xlarge_screens: bool,
    #[resand(attr, android, table_ref = 0x0101026c)]
    pub any_density: bool,
    #[resand(attr, android, table_ref = 0x01010364)]
    pub requires_smallest_width_dp: u32,
    #[resand(attr, android, table_ref = 0x01010365)]
    pub compatible_width_limit_dp: u32,
    #[resand(attr, android, table_ref = 0x010366)]
    pub largest_width_limit_dp: u32,
}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ReqNavigation(u32);

impl_enum! {ReqNavigation, undefined => 0, nonav => 1, dpad => 2, trackball => 3, wheel => 4}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ReqTouchScreen(u32);

impl_enum! {ReqTouchScreen, undefined => 0, notouch => 1, stylus => 2, finger => 3}

#[derive(Debug, PartialEq, Clone, Copy, Default)]
pub struct ReqKeyboardType(u32);

impl_enum! {ReqKeyboardType, undefined => 0, nokeys => 1, qwerty => 2, twelvekey => 3}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 33, android)]
pub struct UsesConfiguration {
    #[resand(attr, android, table_ref = 0x01010232)]
    pub req_five_way_nav: bool,
    #[resand(attr, android, table_ref = 0x01010229)]
    pub req_hard_keyboard: bool,
    #[resand(attr, android, table_ref = 0x01010228)]
    pub req_keyboard_type: ReqKeyboardType,
    #[resand(attr, android, table_ref = 0x0101022a)]
    pub req_navigation: ReqNavigation,
    #[resand(attr, android, table_ref = 0x01010227)]
    pub req_touch_screen: ReqTouchScreen,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 34, android)]
pub struct UsesFeature {
    #[resand(attr, android, table_ref = 0x01010003, optional)]
    pub name: Option<String>,
    #[resand(attr, android, table_ref = 0x01010281, optional)]
    pub gl_es_version: Option<u32>,
    #[resand(attr, android, table_ref = 0x0101028e)]
    pub required: bool,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 35, android)]
pub struct UsesPermission {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: Referenced<String>,
    #[resand(attr, android, table_ref = 0x01010271, optional)]
    pub max_sdk_version: Option<u32>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 36, android)]
pub struct UsesPermissionSdk23 {
    #[resand(attr, android, table_ref = 0x01010003)]
    pub name: String,
    #[resand(attr, android, table_ref = 0x01010271)]
    pub max_sdk_version: u32,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 37, android)]
pub struct UsesSdk {
    #[resand(attr, android, table_ref = 0x0101020c)]
    pub min_sdk_version: u32,
    #[resand(attr, android, table_ref = 0x01010270)]
    pub target_sdk_version: u32,
    #[resand(attr, android, table_ref = 0x01010271, optional)]
    pub max_sdk_version: Option<u32>,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 38, dist)]
pub struct Module {
    #[resand(child, dist, many)]
    pub fusing: Vec<Fusing>,
    #[resand(child, dist, many)]
    pub delivery: Vec<Delivery>,
    #[resand(attr, dist, name = "type")]
    pub r#type: String,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 39, dist)]
pub struct Fusing {
    #[resand(attr, dist)]
    pub include: bool,
}

#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 40, dist)]
pub struct Delivery {
    #[resand(child, dist, many)]
    pub install_time: Vec<InstallTime>,
}
#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 41, dist)]
pub struct InstallTime {}

// TODO / FIXME: correct the order of attributes for all structs here because for some reason that
// actually matters (maybe not for all attributes??? idk), you'd think android would just use the
// name of the attributes to identify them but no that would make too much sense
#[derive(Debug, PartialEq, Clone, IntoNode, Default, FromNode)]
#[resand(line_number = 42)]
#[resand(name = "manifest", android)]
pub struct AndroidManifest {
    #[resand(child, android, many)]
    pub uses_sdk: Vec<UsesSdk>,
    #[resand(child, android, many)]
    pub uses_permission: Vec<UsesPermission>,
    #[resand(child, android)]
    pub application: Application,
    #[resand(child, android, optional)]
    pub attribution: Option<Attribution>,
    #[resand(child, android, optional)]
    pub compatible_screens: Option<CompatibleScreens>,
    #[resand(child, android, many)]
    pub instrumentation: Vec<Instrumentation>,
    #[resand(child, android, many)]
    pub permission: Vec<Permission>,
    #[resand(child, android, many)]
    pub permission_group: Vec<PermissionGroup>,
    #[resand(child, android, many)]
    pub permission_tree: Vec<PermissionTree>,
    #[resand(child, android, many)]
    pub queries: Vec<Queries>,
    #[resand(child, android, many)]
    pub supports_gl_texture: Vec<SupportsGlTexture>,
    #[resand(child, android, many)]
    pub supports_screens: Vec<SupportsScreens>,
    #[resand(child, android, many)]
    pub uses_configuration: Vec<UsesConfiguration>,
    #[resand(child, android, many)]
    pub uses_feature: Vec<UsesFeature>,
    #[resand(child, android, many)]
    pub uses_permission_sdk_23: Vec<UsesPermissionSdk23>,
    #[resand(child, android, many)]
    pub module: Vec<Module>,
    #[resand(attr, android, table_ref = 0x0101021b)]
    pub version_code: u32,
    #[resand(attr, android, table_ref = 0x0101021c, optional)]
    pub version_name: Option<String>,
    #[resand(attr, android, table_ref = 0x01010572, optional)]
    pub compile_sdk_version: Option<u32>,
    #[resand(attr, android, table_ref = 0x01010573, optional)]
    pub compile_sdk_version_codename: Option<String>,
    #[resand(attr)]
    pub package: String,
    #[resand(attr, optional)]
    pub platform_build_version_code: Option<u32>,
    #[resand(attr, optional)]
    pub platform_build_version_name: Option<u32>,
    #[resand(attr, android, table_ref = 0x0101000b, optional)]
    pub shared_user_id: Option<String>,
    #[resand(attr, android, table_ref = 0x0101054c, optional)]
    pub target_sandbox_version: Option<u32>,
    #[resand(attr, android, table_ref = 0x01010261, optional)]
    pub shared_user_label: Option<String>,
    #[resand(attr, android, table_ref = 0x0101064d, optional)]
    pub shared_user_max_sdk_version: Option<u32>,
    #[resand(attr, android, table_ref = 0x010102b7, optional)]
    pub install_location: Option<String>,
    #[resand(attr, android, table_ref = 0x0101064e, optional)]
    pub required_split_types: Option<String>,
    #[resand(attr, android, table_ref = 0x0101064f, optional)]
    pub split_types: Option<String>,
    #[resand(attr, android, table_ref = 0x0101055b, optional)]
    pub is_feature_split: Option<bool>,
    #[resand(attr, optional)]
    pub split: Option<String>,
}

impl Mergeable for AndroidManifest {
    type Returns = ();
    fn merge(&mut self, other: Self) {
        self.application.merge(other.application);
        self.queries.extend(other.queries); // FIXME: probably wrong

        push_name!(uses_permission, other, self);
        push_name!(instrumentation, other, self);
        push_name!(permission, other, self);
        push_name!(permission_group, other, self);
        push_name!(permission_tree, other, self);
        push_name!(supports_gl_texture, other, self);
        push_name!(uses_feature, other, self);
        push_name!(uses_permission_sdk_23, other, self);
    }
}