axmldecoder/
xml.rs

1use indexmap::IndexMap;
2use std::rc::Rc;
3
4use crate::binaryxml::{
5    BinaryXmlDocument, XmlCdata, XmlNodeType, XmlStartElement, XmlStartNameSpace,
6};
7use crate::stringpool::StringPool;
8use crate::ParseError;
9
10///Struct representing a parsed XML document.
11#[derive(Debug)]
12pub struct XmlDocument {
13    root: Option<Node>,
14}
15
16impl XmlDocument {
17    pub(crate) fn new(binaryxml: BinaryXmlDocument) -> Result<Self, ParseError> {
18        let string_pool = binaryxml.string_pool;
19        let resource_map = binaryxml.resource_map;
20
21        let mut namespaces = IndexMap::new();
22
23        // There are some files without the XmlStartNameSpace element.
24        // We should assume that the android namespace is always present even
25        // if not explicitly defined in the document.
26        //
27        // examples/AndroidManifestNoNamespace.xml
28        namespaces.insert(
29            Rc::new("http://schemas.android.com/apk/res/android".to_string()),
30            Rc::new("android".to_string()),
31        );
32
33        let mut element_tracker: Vec<Element> = Vec::new();
34        for node in binaryxml.elements {
35            match node.element {
36                XmlNodeType::XmlStartNameSpace(e) => {
37                    let (uri, prefix) = Self::process_start_namespace(&e, &string_pool)?;
38                    namespaces.insert(uri.clone(), prefix.clone());
39                }
40                XmlNodeType::XmlEndNameSpace(_) => {}
41                XmlNodeType::XmlStartElement(e) => {
42                    element_tracker.push(Self::process_start_element(
43                        &e,
44                        &string_pool,
45                        &namespaces,
46                        &resource_map.resource_ids,
47                    )?);
48                }
49                XmlNodeType::XmlEndElement(_) => {
50                    let e = element_tracker.pop().unwrap();
51
52                    if element_tracker.is_empty() {
53                        return Ok(XmlDocument {
54                            root: Some(Node::Element(e)),
55                        });
56                    }
57
58                    element_tracker
59                        .last_mut()
60                        .unwrap()
61                        .insert_children(Node::Element(e));
62                }
63                XmlNodeType::XmlCdata(e) => {
64                    let cdata = Self::process_cdata(&e, &string_pool)?;
65                    element_tracker
66                        .last_mut()
67                        .unwrap()
68                        .insert_children(Node::Cdata(cdata));
69                }
70            };
71        }
72
73        Ok(Self { root: None })
74    }
75
76    ///Returns the root [Element] of the XML document.
77    #[must_use]
78    pub fn get_root(&self) -> &Option<Node> {
79        &self.root
80    }
81
82    fn process_cdata(e: &XmlCdata, string_pool: &StringPool) -> Result<Cdata, ParseError> {
83        Ok(Cdata {
84            data: string_pool
85                .get(usize::try_from(e.data).unwrap())
86                .ok_or(ParseError::StringNotFound(e.data))?
87                .to_string(),
88        })
89    }
90
91    fn process_start_namespace(
92        e: &XmlStartNameSpace,
93        string_pool: &StringPool,
94    ) -> Result<(Rc<String>, Rc<String>), ParseError> {
95        let uri = string_pool
96            .get(usize::try_from(e.uri).unwrap())
97            .ok_or(ParseError::StringNotFound(e.uri))?;
98        let prefix = string_pool
99            .get(usize::try_from(e.prefix).unwrap())
100            .ok_or(ParseError::StringNotFound(e.prefix))?;
101
102        Ok((uri, prefix))
103    }
104
105    fn process_start_element(
106        e: &XmlStartElement,
107        string_pool: &StringPool,
108        namespaces: &IndexMap<Rc<String>, Rc<String>>,
109        resource_map: &[u32],
110    ) -> Result<Element, ParseError> {
111        let name = string_pool
112            .get(usize::try_from(e.attr_ext.name).unwrap())
113            .ok_or(ParseError::StringNotFound(e.attr_ext.name))?;
114        let name = (*name).clone();
115
116        let mut attributes: IndexMap<String, String> = IndexMap::new();
117
118        // Specially handle the <manifest> element by adding the namespace
119        // attributes to it.
120        if name == "manifest" {
121            for (url, name) in namespaces.iter() {
122                attributes.insert(format!("xmlns:{}", name), url.to_string());
123            }
124        }
125
126        for attr in &e.attributes {
127            let ns = string_pool.get(usize::try_from(attr.ns).unwrap());
128            let name = string_pool
129                .get(usize::try_from(attr.name).unwrap())
130                .ok_or(ParseError::StringNotFound(attr.name))?;
131            let value = attr.typed_value.get_value(string_pool);
132
133            let mut final_name = String::new();
134            if name.is_empty() {
135                let resource_id = resource_map
136                    .get(usize::try_from(attr.name).unwrap())
137                    .ok_or(ParseError::ResourceIdNotFound(attr.name))?;
138                let resource_str = get_resource_string(*resource_id)
139                    .ok_or(ParseError::UnknownResourceString(*resource_id))?;
140                final_name.push_str(&resource_str);
141            } else {
142                if let Some(n) = ns {
143                    // There are samples where the namespace value is the
144                    // raw string instead of a URI found in a namespace chunk.
145                    // For now, skip appending the namespace for those cases.
146                    //
147                    // examples/AndroidManifestUnknownNamespace
148                    if let Some(n) = namespaces.get(&n) {
149                        final_name.push_str(n);
150                        final_name.push(':');
151                    };
152                }
153                final_name.push_str(&name);
154            }
155
156            attributes.insert(final_name, value.to_string());
157        }
158
159        Ok(Element {
160            attributes,
161            tag: name,
162            children: Vec::new(),
163        })
164    }
165}
166
167///Enum representing possible nodes within the parsed XML document.
168#[derive(Debug)]
169pub enum Node {
170    Element(Element),
171    Cdata(Cdata),
172}
173
174///Struct representing an element within the parsed XML document.
175#[derive(Debug)]
176pub struct Element {
177    attributes: IndexMap<String, String>,
178    tag: String,
179    children: Vec<Node>,
180}
181
182impl Element {
183    ///Returns a map of attributes associated with the element.
184    #[must_use]
185    pub fn get_attributes(&self) -> &IndexMap<String, String> {
186        &self.attributes
187    }
188
189    ///Returns the element tag.
190    #[must_use]
191    pub fn get_tag(&self) -> &str {
192        &self.tag
193    }
194
195    ///Returns a list of child nodes.
196    #[must_use]
197    pub fn get_children(&self) -> &Vec<Node> {
198        &self.children
199    }
200
201    fn insert_children(&mut self, child: Node) {
202        self.children.push(child);
203    }
204}
205
206///Struct representing a Cdata element within the parsed XML document.
207#[derive(Debug)]
208pub struct Cdata {
209    data: String,
210}
211
212impl Cdata {
213    #[must_use]
214    pub fn get_data(&self) -> &str {
215        &self.data
216    }
217}
218
219// Logic borrowed from:
220// https://github.com/ytsutano/axmldec/blob/master/lib/jitana/util/axml_parser.cpp#L504
221fn get_resource_string(resource_id: u32) -> Option<String> {
222    const RESOURCE_STRINGS: &[&str] = &[
223        "theme",
224        "label",
225        "icon",
226        "name",
227        "manageSpaceActivity",
228        "allowClearUserData",
229        "permission",
230        "readPermission",
231        "writePermission",
232        "protectionLevel",
233        "permissionGroup",
234        "sharedUserId",
235        "hasCode",
236        "persistent",
237        "enabled",
238        "debuggable",
239        "exported",
240        "process",
241        "taskAffinity",
242        "multiprocess",
243        "finishOnTaskLaunch",
244        "clearTaskOnLaunch",
245        "stateNotNeeded",
246        "excludeFromRecents",
247        "authorities",
248        "syncable",
249        "initOrder",
250        "grantUriPermissions",
251        "priority",
252        "launchMode",
253        "screenOrientation",
254        "configChanges",
255        "description",
256        "targetPackage",
257        "handleProfiling",
258        "functionalTest",
259        "value",
260        "resource",
261        "mimeType",
262        "scheme",
263        "host",
264        "port",
265        "path",
266        "pathPrefix",
267        "pathPattern",
268        "action",
269        "data",
270        "targetClass",
271        "colorForeground",
272        "colorBackground",
273        "backgroundDimAmount",
274        "disabledAlpha",
275        "textAppearance",
276        "textAppearanceInverse",
277        "textColorPrimary",
278        "textColorPrimaryDisableOnly",
279        "textColorSecondary",
280        "textColorPrimaryInverse",
281        "textColorSecondaryInverse",
282        "textColorPrimaryNoDisable",
283        "textColorSecondaryNoDisable",
284        "textColorPrimaryInverseNoDisable",
285        "textColorSecondaryInverseNoDisable",
286        "textColorHintInverse",
287        "textAppearanceLarge",
288        "textAppearanceMedium",
289        "textAppearanceSmall",
290        "textAppearanceLargeInverse",
291        "textAppearanceMediumInverse",
292        "textAppearanceSmallInverse",
293        "textCheckMark",
294        "textCheckMarkInverse",
295        "buttonStyle",
296        "buttonStyleSmall",
297        "buttonStyleInset",
298        "buttonStyleToggle",
299        "galleryItemBackground",
300        "listPreferredItemHeight",
301        "expandableListPreferredItemPaddingLeft",
302        "expandableListPreferredChildPaddingLeft",
303        "expandableListPreferredItemIndicatorLeft",
304        "expandableListPreferredItemIndicatorRight",
305        "expandableListPreferredChildIndicatorLeft",
306        "expandableListPreferredChildIndicatorRight",
307        "windowBackground",
308        "windowFrame",
309        "windowNoTitle",
310        "windowIsFloating",
311        "windowIsTranslucent",
312        "windowContentOverlay",
313        "windowTitleSize",
314        "windowTitleStyle",
315        "windowTitleBackgroundStyle",
316        "alertDialogStyle",
317        "panelBackground",
318        "panelFullBackground",
319        "panelColorForeground",
320        "panelColorBackground",
321        "panelTextAppearance",
322        "scrollbarSize",
323        "scrollbarThumbHorizontal",
324        "scrollbarThumbVertical",
325        "scrollbarTrackHorizontal",
326        "scrollbarTrackVertical",
327        "scrollbarAlwaysDrawHorizontalTrack",
328        "scrollbarAlwaysDrawVerticalTrack",
329        "absListViewStyle",
330        "autoCompleteTextViewStyle",
331        "checkboxStyle",
332        "dropDownListViewStyle",
333        "editTextStyle",
334        "expandableListViewStyle",
335        "galleryStyle",
336        "gridViewStyle",
337        "imageButtonStyle",
338        "imageWellStyle",
339        "listViewStyle",
340        "listViewWhiteStyle",
341        "popupWindowStyle",
342        "progressBarStyle",
343        "progressBarStyleHorizontal",
344        "progressBarStyleSmall",
345        "progressBarStyleLarge",
346        "seekBarStyle",
347        "ratingBarStyle",
348        "ratingBarStyleSmall",
349        "radioButtonStyle",
350        "scrollbarStyle",
351        "scrollViewStyle",
352        "spinnerStyle",
353        "starStyle",
354        "tabWidgetStyle",
355        "textViewStyle",
356        "webViewStyle",
357        "dropDownItemStyle",
358        "spinnerDropDownItemStyle",
359        "dropDownHintAppearance",
360        "spinnerItemStyle",
361        "mapViewStyle",
362        "preferenceScreenStyle",
363        "preferenceCategoryStyle",
364        "preferenceInformationStyle",
365        "preferenceStyle",
366        "checkBoxPreferenceStyle",
367        "yesNoPreferenceStyle",
368        "dialogPreferenceStyle",
369        "editTextPreferenceStyle",
370        "ringtonePreferenceStyle",
371        "preferenceLayoutChild",
372        "textSize",
373        "typeface",
374        "textStyle",
375        "textColor",
376        "textColorHighlight",
377        "textColorHint",
378        "textColorLink",
379        "state_focused",
380        "state_window_focused",
381        "state_enabled",
382        "state_checkable",
383        "state_checked",
384        "state_selected",
385        "state_active",
386        "state_single",
387        "state_first",
388        "state_middle",
389        "state_last",
390        "state_pressed",
391        "state_expanded",
392        "state_empty",
393        "state_above_anchor",
394        "ellipsize",
395        "x",
396        "y",
397        "windowAnimationStyle",
398        "gravity",
399        "autoLink",
400        "linksClickable",
401        "entries",
402        "layout_gravity",
403        "windowEnterAnimation",
404        "windowExitAnimation",
405        "windowShowAnimation",
406        "windowHideAnimation",
407        "activityOpenEnterAnimation",
408        "activityOpenExitAnimation",
409        "activityCloseEnterAnimation",
410        "activityCloseExitAnimation",
411        "taskOpenEnterAnimation",
412        "taskOpenExitAnimation",
413        "taskCloseEnterAnimation",
414        "taskCloseExitAnimation",
415        "taskToFrontEnterAnimation",
416        "taskToFrontExitAnimation",
417        "taskToBackEnterAnimation",
418        "taskToBackExitAnimation",
419        "orientation",
420        "keycode",
421        "fullDark",
422        "topDark",
423        "centerDark",
424        "bottomDark",
425        "fullBright",
426        "topBright",
427        "centerBright",
428        "bottomBright",
429        "bottomMedium",
430        "centerMedium",
431        "id",
432        "tag",
433        "scrollX",
434        "scrollY",
435        "background",
436        "padding",
437        "paddingLeft",
438        "paddingTop",
439        "paddingRight",
440        "paddingBottom",
441        "focusable",
442        "focusableInTouchMode",
443        "visibility",
444        "fitsSystemWindows",
445        "scrollbars",
446        "fadingEdge",
447        "fadingEdgeLength",
448        "nextFocusLeft",
449        "nextFocusRight",
450        "nextFocusUp",
451        "nextFocusDown",
452        "clickable",
453        "longClickable",
454        "saveEnabled",
455        "drawingCacheQuality",
456        "duplicateParentState",
457        "clipChildren",
458        "clipToPadding",
459        "layoutAnimation",
460        "animationCache",
461        "persistentDrawingCache",
462        "alwaysDrawnWithCache",
463        "addStatesFromChildren",
464        "descendantFocusability",
465        "layout",
466        "inflatedId",
467        "layout_width",
468        "layout_height",
469        "layout_margin",
470        "layout_marginLeft",
471        "layout_marginTop",
472        "layout_marginRight",
473        "layout_marginBottom",
474        "listSelector",
475        "drawSelectorOnTop",
476        "stackFromBottom",
477        "scrollingCache",
478        "textFilterEnabled",
479        "transcriptMode",
480        "cacheColorHint",
481        "dial",
482        "hand_hour",
483        "hand_minute",
484        "format",
485        "checked",
486        "button",
487        "checkMark",
488        "foreground",
489        "measureAllChildren",
490        "groupIndicator",
491        "childIndicator",
492        "indicatorLeft",
493        "indicatorRight",
494        "childIndicatorLeft",
495        "childIndicatorRight",
496        "childDivider",
497        "animationDuration",
498        "spacing",
499        "horizontalSpacing",
500        "verticalSpacing",
501        "stretchMode",
502        "columnWidth",
503        "numColumns",
504        "src",
505        "antialias",
506        "filter",
507        "dither",
508        "scaleType",
509        "adjustViewBounds",
510        "maxWidth",
511        "maxHeight",
512        "tint",
513        "baselineAlignBottom",
514        "cropToPadding",
515        "textOn",
516        "textOff",
517        "baselineAligned",
518        "baselineAlignedChildIndex",
519        "weightSum",
520        "divider",
521        "dividerHeight",
522        "choiceMode",
523        "itemTextAppearance",
524        "horizontalDivider",
525        "verticalDivider",
526        "headerBackground",
527        "itemBackground",
528        "itemIconDisabledAlpha",
529        "rowHeight",
530        "maxRows",
531        "maxItemsPerRow",
532        "moreIcon",
533        "max",
534        "progress",
535        "secondaryProgress",
536        "indeterminate",
537        "indeterminateOnly",
538        "indeterminateDrawable",
539        "progressDrawable",
540        "indeterminateDuration",
541        "indeterminateBehavior",
542        "minWidth",
543        "minHeight",
544        "interpolator",
545        "thumb",
546        "thumbOffset",
547        "numStars",
548        "rating",
549        "stepSize",
550        "isIndicator",
551        "checkedButton",
552        "stretchColumns",
553        "shrinkColumns",
554        "collapseColumns",
555        "layout_column",
556        "layout_span",
557        "bufferType",
558        "text",
559        "hint",
560        "textScaleX",
561        "cursorVisible",
562        "maxLines",
563        "lines",
564        "height",
565        "minLines",
566        "maxEms",
567        "ems",
568        "width",
569        "minEms",
570        "scrollHorizontally",
571        "password",
572        "singleLine",
573        "selectAllOnFocus",
574        "includeFontPadding",
575        "maxLength",
576        "shadowColor",
577        "shadowDx",
578        "shadowDy",
579        "shadowRadius",
580        "numeric",
581        "digits",
582        "phoneNumber",
583        "inputMethod",
584        "capitalize",
585        "autoText",
586        "editable",
587        "freezesText",
588        "drawableTop",
589        "drawableBottom",
590        "drawableLeft",
591        "drawableRight",
592        "drawablePadding",
593        "completionHint",
594        "completionHintView",
595        "completionThreshold",
596        "dropDownSelector",
597        "popupBackground",
598        "inAnimation",
599        "outAnimation",
600        "flipInterval",
601        "fillViewport",
602        "prompt",
603        "startYear",
604        "endYear",
605        "mode",
606        "layout_x",
607        "layout_y",
608        "layout_weight",
609        "layout_toLeftOf",
610        "layout_toRightOf",
611        "layout_above",
612        "layout_below",
613        "layout_alignBaseline",
614        "layout_alignLeft",
615        "layout_alignTop",
616        "layout_alignRight",
617        "layout_alignBottom",
618        "layout_alignParentLeft",
619        "layout_alignParentTop",
620        "layout_alignParentRight",
621        "layout_alignParentBottom",
622        "layout_centerInParent",
623        "layout_centerHorizontal",
624        "layout_centerVertical",
625        "layout_alignWithParentIfMissing",
626        "layout_scale",
627        "visible",
628        "variablePadding",
629        "constantSize",
630        "oneshot",
631        "duration",
632        "drawable",
633        "shape",
634        "innerRadiusRatio",
635        "thicknessRatio",
636        "startColor",
637        "endColor",
638        "useLevel",
639        "angle",
640        "type",
641        "centerX",
642        "centerY",
643        "gradientRadius",
644        "color",
645        "dashWidth",
646        "dashGap",
647        "radius",
648        "topLeftRadius",
649        "topRightRadius",
650        "bottomLeftRadius",
651        "bottomRightRadius",
652        "left",
653        "top",
654        "right",
655        "bottom",
656        "minLevel",
657        "maxLevel",
658        "fromDegrees",
659        "toDegrees",
660        "pivotX",
661        "pivotY",
662        "insetLeft",
663        "insetRight",
664        "insetTop",
665        "insetBottom",
666        "shareInterpolator",
667        "fillBefore",
668        "fillAfter",
669        "startOffset",
670        "repeatCount",
671        "repeatMode",
672        "zAdjustment",
673        "fromXScale",
674        "toXScale",
675        "fromYScale",
676        "toYScale",
677        "fromXDelta",
678        "toXDelta",
679        "fromYDelta",
680        "toYDelta",
681        "fromAlpha",
682        "toAlpha",
683        "delay",
684        "animation",
685        "animationOrder",
686        "columnDelay",
687        "rowDelay",
688        "direction",
689        "directionPriority",
690        "factor",
691        "cycles",
692        "searchMode",
693        "searchSuggestAuthority",
694        "searchSuggestPath",
695        "searchSuggestSelection",
696        "searchSuggestIntentAction",
697        "searchSuggestIntentData",
698        "queryActionMsg",
699        "suggestActionMsg",
700        "suggestActionMsgColumn",
701        "menuCategory",
702        "orderInCategory",
703        "checkableBehavior",
704        "title",
705        "titleCondensed",
706        "alphabeticShortcut",
707        "numericShortcut",
708        "checkable",
709        "selectable",
710        "orderingFromXml",
711        "key",
712        "summary",
713        "order",
714        "widgetLayout",
715        "dependency",
716        "defaultValue",
717        "shouldDisableView",
718        "summaryOn",
719        "summaryOff",
720        "disableDependentsState",
721        "dialogTitle",
722        "dialogMessage",
723        "dialogIcon",
724        "positiveButtonText",
725        "negativeButtonText",
726        "dialogLayout",
727        "entryValues",
728        "ringtoneType",
729        "showDefault",
730        "showSilent",
731        "scaleWidth",
732        "scaleHeight",
733        "scaleGravity",
734        "ignoreGravity",
735        "foregroundGravity",
736        "tileMode",
737        "targetActivity",
738        "alwaysRetainTaskState",
739        "allowTaskReparenting",
740        "searchButtonText",
741        "colorForegroundInverse",
742        "textAppearanceButton",
743        "listSeparatorTextViewStyle",
744        "streamType",
745        "clipOrientation",
746        "centerColor",
747        "minSdkVersion",
748        "windowFullscreen",
749        "unselectedAlpha",
750        "progressBarStyleSmallTitle",
751        "ratingBarStyleIndicator",
752        "apiKey",
753        "textColorTertiary",
754        "textColorTertiaryInverse",
755        "listDivider",
756        "soundEffectsEnabled",
757        "keepScreenOn",
758        "lineSpacingExtra",
759        "lineSpacingMultiplier",
760        "listChoiceIndicatorSingle",
761        "listChoiceIndicatorMultiple",
762        "versionCode",
763        "versionName",
764        "marqueeRepeatLimit",
765        "windowNoDisplay",
766        "backgroundDimEnabled",
767        "inputType",
768        "isDefault",
769        "windowDisablePreview",
770        "privateImeOptions",
771        "editorExtras",
772        "settingsActivity",
773        "fastScrollEnabled",
774        "reqTouchScreen",
775        "reqKeyboardType",
776        "reqHardKeyboard",
777        "reqNavigation",
778        "windowSoftInputMode",
779        "imeFullscreenBackground",
780        "noHistory",
781        "headerDividersEnabled",
782        "footerDividersEnabled",
783        "candidatesTextStyleSpans",
784        "smoothScrollbar",
785        "reqFiveWayNav",
786        "keyBackground",
787        "keyTextSize",
788        "labelTextSize",
789        "keyTextColor",
790        "keyPreviewLayout",
791        "keyPreviewOffset",
792        "keyPreviewHeight",
793        "verticalCorrection",
794        "popupLayout",
795        "state_long_pressable",
796        "keyWidth",
797        "keyHeight",
798        "horizontalGap",
799        "verticalGap",
800        "rowEdgeFlags",
801        "codes",
802        "popupKeyboard",
803        "popupCharacters",
804        "keyEdgeFlags",
805        "isModifier",
806        "isSticky",
807        "isRepeatable",
808        "iconPreview",
809        "keyOutputText",
810        "keyLabel",
811        "keyIcon",
812        "keyboardMode",
813        "isScrollContainer",
814        "fillEnabled",
815        "updatePeriodMillis",
816        "initialLayout",
817        "voiceSearchMode",
818        "voiceLanguageModel",
819        "voicePromptText",
820        "voiceLanguage",
821        "voiceMaxResults",
822        "bottomOffset",
823        "topOffset",
824        "allowSingleTap",
825        "handle",
826        "content",
827        "animateOnClick",
828        "configure",
829        "hapticFeedbackEnabled",
830        "innerRadius",
831        "thickness",
832        "sharedUserLabel",
833        "dropDownWidth",
834        "dropDownAnchor",
835        "imeOptions",
836        "imeActionLabel",
837        "imeActionId",
838        "UNKNOWN",
839        "imeExtractEnterAnimation",
840        "imeExtractExitAnimation",
841        "tension",
842        "extraTension",
843        "anyDensity",
844        "searchSuggestThreshold",
845        "includeInGlobalSearch",
846        "onClick",
847        "targetSdkVersion",
848        "maxSdkVersion",
849        "testOnly",
850        "contentDescription",
851        "gestureStrokeWidth",
852        "gestureColor",
853        "uncertainGestureColor",
854        "fadeOffset",
855        "fadeDuration",
856        "gestureStrokeType",
857        "gestureStrokeLengthThreshold",
858        "gestureStrokeSquarenessThreshold",
859        "gestureStrokeAngleThreshold",
860        "eventsInterceptionEnabled",
861        "fadeEnabled",
862        "backupAgent",
863        "allowBackup",
864        "glEsVersion",
865        "queryAfterZeroResults",
866        "dropDownHeight",
867        "smallScreens",
868        "normalScreens",
869        "largeScreens",
870        "progressBarStyleInverse",
871        "progressBarStyleSmallInverse",
872        "progressBarStyleLargeInverse",
873        "searchSettingsDescription",
874        "textColorPrimaryInverseDisableOnly",
875        "autoUrlDetect",
876        "resizeable",
877        "required",
878        "accountType",
879        "contentAuthority",
880        "userVisible",
881        "windowShowWallpaper",
882        "wallpaperOpenEnterAnimation",
883        "wallpaperOpenExitAnimation",
884        "wallpaperCloseEnterAnimation",
885        "wallpaperCloseExitAnimation",
886        "wallpaperIntraOpenEnterAnimation",
887        "wallpaperIntraOpenExitAnimation",
888        "wallpaperIntraCloseEnterAnimation",
889        "wallpaperIntraCloseExitAnimation",
890        "supportsUploading",
891        "killAfterRestore",
892        "restoreNeedsApplication",
893        "smallIcon",
894        "accountPreferences",
895        "textAppearanceSearchResultSubtitle",
896        "textAppearanceSearchResultTitle",
897        "summaryColumn",
898        "detailColumn",
899        "detailSocialSummary",
900        "thumbnail",
901        "detachWallpaper",
902        "finishOnCloseSystemDialogs",
903        "scrollbarFadeDuration",
904        "scrollbarDefaultDelayBeforeFade",
905        "fadeScrollbars",
906        "colorBackgroundCacheHint",
907        "dropDownHorizontalOffset",
908        "dropDownVerticalOffset",
909        "quickContactBadgeStyleWindowSmall",
910        "quickContactBadgeStyleWindowMedium",
911        "quickContactBadgeStyleWindowLarge",
912        "quickContactBadgeStyleSmallWindowSmall",
913        "quickContactBadgeStyleSmallWindowMedium",
914        "quickContactBadgeStyleSmallWindowLarge",
915        "author",
916        "autoStart",
917        "expandableListViewWhiteStyle",
918        "installLocation",
919        "vmSafeMode",
920        "webTextViewStyle",
921        "restoreAnyVersion",
922        "tabStripLeft",
923        "tabStripRight",
924        "tabStripEnabled",
925        "logo",
926        "xlargeScreens",
927        "immersive",
928        "overScrollMode",
929        "overScrollHeader",
930        "overScrollFooter",
931        "filterTouchesWhenObscured",
932        "textSelectHandleLeft",
933        "textSelectHandleRight",
934        "textSelectHandle",
935        "textSelectHandleWindowStyle",
936        "popupAnimationStyle",
937        "screenSize",
938        "screenDensity",
939        "allContactsName",
940        "windowActionBar",
941        "actionBarStyle",
942        "navigationMode",
943        "displayOptions",
944        "subtitle",
945        "customNavigationLayout",
946        "hardwareAccelerated",
947        "measureWithLargestChild",
948        "animateFirstView",
949        "dropDownSpinnerStyle",
950        "actionDropDownStyle",
951        "actionButtonStyle",
952        "showAsAction",
953        "previewImage",
954        "actionModeBackground",
955        "actionModeCloseDrawable",
956        "windowActionModeOverlay",
957        "valueFrom",
958        "valueTo",
959        "valueType",
960        "propertyName",
961        "ordering",
962        "fragment",
963        "windowActionBarOverlay",
964        "fragmentOpenEnterAnimation",
965        "fragmentOpenExitAnimation",
966        "fragmentCloseEnterAnimation",
967        "fragmentCloseExitAnimation",
968        "fragmentFadeEnterAnimation",
969        "fragmentFadeExitAnimation",
970        "actionBarSize",
971        "imeSubtypeLocale",
972        "imeSubtypeMode",
973        "imeSubtypeExtraValue",
974        "splitMotionEvents",
975        "listChoiceBackgroundIndicator",
976        "spinnerMode",
977        "animateLayoutChanges",
978        "actionBarTabStyle",
979        "actionBarTabBarStyle",
980        "actionBarTabTextStyle",
981        "actionOverflowButtonStyle",
982        "actionModeCloseButtonStyle",
983        "titleTextStyle",
984        "subtitleTextStyle",
985        "iconifiedByDefault",
986        "actionLayout",
987        "actionViewClass",
988        "activatedBackgroundIndicator",
989        "state_activated",
990        "listPopupWindowStyle",
991        "popupMenuStyle",
992        "textAppearanceLargePopupMenu",
993        "textAppearanceSmallPopupMenu",
994        "breadCrumbTitle",
995        "breadCrumbShortTitle",
996        "listDividerAlertDialog",
997        "textColorAlertDialogListItem",
998        "loopViews",
999        "dialogTheme",
1000        "alertDialogTheme",
1001        "dividerVertical",
1002        "homeAsUpIndicator",
1003        "enterFadeDuration",
1004        "exitFadeDuration",
1005        "selectableItemBackground",
1006        "autoAdvanceViewId",
1007        "useIntrinsicSizeAsMinimum",
1008        "actionModeCutDrawable",
1009        "actionModeCopyDrawable",
1010        "actionModePasteDrawable",
1011        "textEditPasteWindowLayout",
1012        "textEditNoPasteWindowLayout",
1013        "textIsSelectable",
1014        "windowEnableSplitTouch",
1015        "indeterminateProgressStyle",
1016        "progressBarPadding",
1017        "animationResolution",
1018        "state_accelerated",
1019        "baseline",
1020        "homeLayout",
1021        "opacity",
1022        "alpha",
1023        "transformPivotX",
1024        "transformPivotY",
1025        "translationX",
1026        "translationY",
1027        "scaleX",
1028        "scaleY",
1029        "rotation",
1030        "rotationX",
1031        "rotationY",
1032        "showDividers",
1033        "dividerPadding",
1034        "borderlessButtonStyle",
1035        "dividerHorizontal",
1036        "itemPadding",
1037        "buttonBarStyle",
1038        "buttonBarButtonStyle",
1039        "segmentedButtonStyle",
1040        "staticWallpaperPreview",
1041        "allowParallelSyncs",
1042        "isAlwaysSyncable",
1043        "verticalScrollbarPosition",
1044        "fastScrollAlwaysVisible",
1045        "fastScrollThumbDrawable",
1046        "fastScrollPreviewBackgroundLeft",
1047        "fastScrollPreviewBackgroundRight",
1048        "fastScrollTrackDrawable",
1049        "fastScrollOverlayPosition",
1050        "customTokens",
1051        "nextFocusForward",
1052        "firstDayOfWeek",
1053        "showWeekNumber",
1054        "minDate",
1055        "maxDate",
1056        "shownWeekCount",
1057        "selectedWeekBackgroundColor",
1058        "focusedMonthDateColor",
1059        "unfocusedMonthDateColor",
1060        "weekNumberColor",
1061        "weekSeparatorLineColor",
1062        "selectedDateVerticalBar",
1063        "weekDayTextAppearance",
1064        "dateTextAppearance",
1065        "UNKNOWN",
1066        "spinnersShown",
1067        "calendarViewShown",
1068        "state_multiline",
1069        "detailsElementBackground",
1070        "textColorHighlightInverse",
1071        "textColorLinkInverse",
1072        "editTextColor",
1073        "editTextBackground",
1074        "horizontalScrollViewStyle",
1075        "layerType",
1076        "alertDialogIcon",
1077        "windowMinWidthMajor",
1078        "windowMinWidthMinor",
1079        "queryHint",
1080        "fastScrollTextColor",
1081        "largeHeap",
1082        "windowCloseOnTouchOutside",
1083        "datePickerStyle",
1084        "calendarViewStyle",
1085        "textEditSidePasteWindowLayout",
1086        "textEditSideNoPasteWindowLayout",
1087        "actionMenuTextAppearance",
1088        "actionMenuTextColor",
1089        "textCursorDrawable",
1090        "resizeMode",
1091        "requiresSmallestWidthDp",
1092        "compatibleWidthLimitDp",
1093        "largestWidthLimitDp",
1094        "state_hovered",
1095        "state_drag_can_accept",
1096        "state_drag_hovered",
1097        "stopWithTask",
1098        "switchTextOn",
1099        "switchTextOff",
1100        "switchPreferenceStyle",
1101        "switchTextAppearance",
1102        "track",
1103        "switchMinWidth",
1104        "switchPadding",
1105        "thumbTextPadding",
1106        "textSuggestionsWindowStyle",
1107        "textEditSuggestionItemLayout",
1108        "rowCount",
1109        "rowOrderPreserved",
1110        "columnCount",
1111        "columnOrderPreserved",
1112        "useDefaultMargins",
1113        "alignmentMode",
1114        "layout_row",
1115        "layout_rowSpan",
1116        "layout_columnSpan",
1117        "actionModeSelectAllDrawable",
1118        "isAuxiliary",
1119        "accessibilityEventTypes",
1120        "packageNames",
1121        "accessibilityFeedbackType",
1122        "notificationTimeout",
1123        "accessibilityFlags",
1124        "canRetrieveWindowContent",
1125        "listPreferredItemHeightLarge",
1126        "listPreferredItemHeightSmall",
1127        "actionBarSplitStyle",
1128        "actionProviderClass",
1129        "backgroundStacked",
1130        "backgroundSplit",
1131        "textAllCaps",
1132        "colorPressedHighlight",
1133        "colorLongPressedHighlight",
1134        "colorFocusedHighlight",
1135        "colorActivatedHighlight",
1136        "colorMultiSelectHighlight",
1137        "drawableStart",
1138        "drawableEnd",
1139        "actionModeStyle",
1140        "minResizeWidth",
1141        "minResizeHeight",
1142        "actionBarWidgetTheme",
1143        "uiOptions",
1144        "subtypeLocale",
1145        "subtypeExtraValue",
1146        "actionBarDivider",
1147        "actionBarItemBackground",
1148        "actionModeSplitBackground",
1149        "textAppearanceListItem",
1150        "textAppearanceListItemSmall",
1151        "targetDescriptions",
1152        "directionDescriptions",
1153        "overridesImplicitlyEnabledSubtype",
1154        "listPreferredItemPaddingLeft",
1155        "listPreferredItemPaddingRight",
1156        "requiresFadingEdge",
1157        "publicKey",
1158        "parentActivityName",
1159        "UNKNOWN",
1160        "isolatedProcess",
1161        "importantForAccessibility",
1162        "keyboardLayout",
1163        "fontFamily",
1164        "mediaRouteButtonStyle",
1165        "mediaRouteTypes",
1166        "supportsRtl",
1167        "textDirection",
1168        "textAlignment",
1169        "layoutDirection",
1170        "paddingStart",
1171        "paddingEnd",
1172        "layout_marginStart",
1173        "layout_marginEnd",
1174        "layout_toStartOf",
1175        "layout_toEndOf",
1176        "layout_alignStart",
1177        "layout_alignEnd",
1178        "layout_alignParentStart",
1179        "layout_alignParentEnd",
1180        "listPreferredItemPaddingStart",
1181        "listPreferredItemPaddingEnd",
1182        "singleUser",
1183        "presentationTheme",
1184        "subtypeId",
1185        "initialKeyguardLayout",
1186        "UNKNOWN",
1187        "widgetCategory",
1188        "permissionGroupFlags",
1189        "labelFor",
1190        "permissionFlags",
1191        "checkedTextViewStyle",
1192        "showOnLockScreen",
1193        "format12Hour",
1194        "format24Hour",
1195        "timeZone",
1196        "mipMap",
1197        "mirrorForRtl",
1198        "windowOverscan",
1199        "requiredForAllUsers",
1200        "indicatorStart",
1201        "indicatorEnd",
1202        "childIndicatorStart",
1203        "childIndicatorEnd",
1204        "restrictedAccountType",
1205        "requiredAccountType",
1206        "canRequestTouchExplorationMode",
1207        "canRequestEnhancedWebAccessibility",
1208        "canRequestFilterKeyEvents",
1209        "layoutMode",
1210        "keySet",
1211        "targetId",
1212        "fromScene",
1213        "toScene",
1214        "transition",
1215        "transitionOrdering",
1216        "fadingMode",
1217        "startDelay",
1218        "ssp",
1219        "sspPrefix",
1220        "sspPattern",
1221        "addPrintersActivity",
1222        "vendor",
1223        "category",
1224        "isAsciiCapable",
1225        "autoMirrored",
1226        "supportsSwitchingToNextInputMethod",
1227        "requireDeviceUnlock",
1228        "apduServiceBanner",
1229        "accessibilityLiveRegion",
1230        "windowTranslucentStatus",
1231        "windowTranslucentNavigation",
1232        "advancedPrintOptionsActivity",
1233        "banner",
1234        "windowSwipeToDismiss",
1235        "isGame",
1236        "allowEmbedded",
1237        "setupActivity",
1238        "fastScrollStyle",
1239        "windowContentTransitions",
1240        "windowContentTransitionManager",
1241        "translationZ",
1242        "tintMode",
1243        "controlX1",
1244        "controlY1",
1245        "controlX2",
1246        "controlY2",
1247        "transitionName",
1248        "transitionGroup",
1249        "viewportWidth",
1250        "viewportHeight",
1251        "fillColor",
1252        "pathData",
1253        "strokeColor",
1254        "strokeWidth",
1255        "trimPathStart",
1256        "trimPathEnd",
1257        "trimPathOffset",
1258        "strokeLineCap",
1259        "strokeLineJoin",
1260        "strokeMiterLimit",
1261        "UNKNOWN",
1262        "UNKNOWN",
1263        "UNKNOWN",
1264        "UNKNOWN",
1265        "UNKNOWN",
1266        "UNKNOWN",
1267        "UNKNOWN",
1268        "UNKNOWN",
1269        "UNKNOWN",
1270        "UNKNOWN",
1271        "UNKNOWN",
1272        "UNKNOWN",
1273        "UNKNOWN",
1274        "UNKNOWN",
1275        "UNKNOWN",
1276        "UNKNOWN",
1277        "UNKNOWN",
1278        "UNKNOWN",
1279        "UNKNOWN",
1280        "UNKNOWN",
1281        "UNKNOWN",
1282        "UNKNOWN",
1283        "UNKNOWN",
1284        "UNKNOWN",
1285        "UNKNOWN",
1286        "UNKNOWN",
1287        "UNKNOWN",
1288        "colorControlNormal",
1289        "colorControlActivated",
1290        "colorButtonNormal",
1291        "colorControlHighlight",
1292        "persistableMode",
1293        "titleTextAppearance",
1294        "subtitleTextAppearance",
1295        "slideEdge",
1296        "actionBarTheme",
1297        "textAppearanceListItemSecondary",
1298        "colorPrimary",
1299        "colorPrimaryDark",
1300        "colorAccent",
1301        "nestedScrollingEnabled",
1302        "windowEnterTransition",
1303        "windowExitTransition",
1304        "windowSharedElementEnterTransition",
1305        "windowSharedElementExitTransition",
1306        "windowAllowReturnTransitionOverlap",
1307        "windowAllowEnterTransitionOverlap",
1308        "sessionService",
1309        "stackViewStyle",
1310        "switchStyle",
1311        "elevation",
1312        "excludeId",
1313        "excludeClass",
1314        "hideOnContentScroll",
1315        "actionOverflowMenuStyle",
1316        "documentLaunchMode",
1317        "maxRecents",
1318        "autoRemoveFromRecents",
1319        "stateListAnimator",
1320        "toId",
1321        "fromId",
1322        "reversible",
1323        "splitTrack",
1324        "targetName",
1325        "excludeName",
1326        "matchOrder",
1327        "windowDrawsSystemBarBackgrounds",
1328        "statusBarColor",
1329        "navigationBarColor",
1330        "contentInsetStart",
1331        "contentInsetEnd",
1332        "contentInsetLeft",
1333        "contentInsetRight",
1334        "paddingMode",
1335        "layout_rowWeight",
1336        "layout_columnWeight",
1337        "translateX",
1338        "translateY",
1339        "selectableItemBackgroundBorderless",
1340        "elegantTextHeight",
1341        "UNKNOWN",
1342        "UNKNOWN",
1343        "UNKNOWN",
1344        "windowTransitionBackgroundFadeDuration",
1345        "overlapAnchor",
1346        "progressTint",
1347        "progressTintMode",
1348        "progressBackgroundTint",
1349        "progressBackgroundTintMode",
1350        "secondaryProgressTint",
1351        "secondaryProgressTintMode",
1352        "indeterminateTint",
1353        "indeterminateTintMode",
1354        "backgroundTint",
1355        "backgroundTintMode",
1356        "foregroundTint",
1357        "foregroundTintMode",
1358        "buttonTint",
1359        "buttonTintMode",
1360        "thumbTint",
1361        "thumbTintMode",
1362        "fullBackupOnly",
1363        "propertyXName",
1364        "propertyYName",
1365        "relinquishTaskIdentity",
1366        "tileModeX",
1367        "tileModeY",
1368        "actionModeShareDrawable",
1369        "actionModeFindDrawable",
1370        "actionModeWebSearchDrawable",
1371        "transitionVisibilityMode",
1372        "minimumHorizontalAngle",
1373        "minimumVerticalAngle",
1374        "maximumAngle",
1375        "searchViewStyle",
1376        "closeIcon",
1377        "goIcon",
1378        "searchIcon",
1379        "voiceIcon",
1380        "commitIcon",
1381        "suggestionRowLayout",
1382        "queryBackground",
1383        "submitBackground",
1384        "buttonBarPositiveButtonStyle",
1385        "buttonBarNeutralButtonStyle",
1386        "buttonBarNegativeButtonStyle",
1387        "popupElevation",
1388        "actionBarPopupTheme",
1389        "multiArch",
1390        "touchscreenBlocksFocus",
1391        "windowElevation",
1392        "launchTaskBehindTargetAnimation",
1393        "launchTaskBehindSourceAnimation",
1394        "restrictionType",
1395        "dayOfWeekBackground",
1396        "dayOfWeekTextAppearance",
1397        "headerMonthTextAppearance",
1398        "headerDayOfMonthTextAppearance",
1399        "headerYearTextAppearance",
1400        "yearListItemTextAppearance",
1401        "yearListSelectorColor",
1402        "calendarTextColor",
1403        "recognitionService",
1404        "timePickerStyle",
1405        "timePickerDialogTheme",
1406        "headerTimeTextAppearance",
1407        "headerAmPmTextAppearance",
1408        "numbersTextColor",
1409        "numbersBackgroundColor",
1410        "numbersSelectorColor",
1411        "amPmTextColor",
1412        "amPmBackgroundColor",
1413        "UNKNOWN",
1414        "checkMarkTint",
1415        "checkMarkTintMode",
1416        "popupTheme",
1417        "toolbarStyle",
1418        "windowClipToOutline",
1419        "datePickerDialogTheme",
1420        "showText",
1421        "windowReturnTransition",
1422        "windowReenterTransition",
1423        "windowSharedElementReturnTransition",
1424        "windowSharedElementReenterTransition",
1425        "resumeWhilePausing",
1426        "datePickerMode",
1427        "timePickerMode",
1428        "inset",
1429        "letterSpacing",
1430        "fontFeatureSettings",
1431        "outlineProvider",
1432        "contentAgeHint",
1433        "country",
1434        "windowSharedElementsUseOverlay",
1435        "reparent",
1436        "reparentWithOverlay",
1437        "ambientShadowAlpha",
1438        "spotShadowAlpha",
1439        "navigationIcon",
1440        "navigationContentDescription",
1441        "fragmentExitTransition",
1442        "fragmentEnterTransition",
1443        "fragmentSharedElementEnterTransition",
1444        "fragmentReturnTransition",
1445        "fragmentSharedElementReturnTransition",
1446        "fragmentReenterTransition",
1447        "fragmentAllowEnterTransitionOverlap",
1448        "fragmentAllowReturnTransitionOverlap",
1449        "patternPathData",
1450        "strokeAlpha",
1451        "fillAlpha",
1452        "windowActivityTransitions",
1453        "colorEdgeEffect",
1454        "resizeClip",
1455        "collapseContentDescription",
1456        "accessibilityTraversalBefore",
1457        "accessibilityTraversalAfter",
1458        "dialogPreferredPadding",
1459        "searchHintIcon",
1460        "revisionCode",
1461        "drawableTint",
1462        "drawableTintMode",
1463        "fraction",
1464        "trackTint",
1465        "trackTintMode",
1466        "start",
1467        "end",
1468        "breakStrategy",
1469        "hyphenationFrequency",
1470        "allowUndo",
1471        "windowLightStatusBar",
1472        "numbersInnerTextColor",
1473        "colorBackgroundFloating",
1474        "titleTextColor",
1475        "subtitleTextColor",
1476        "thumbPosition",
1477        "scrollIndicators",
1478        "contextClickable",
1479        "fingerprintAuthDrawable",
1480        "logoDescription",
1481        "extractNativeLibs",
1482        "fullBackupContent",
1483        "usesCleartextTraffic",
1484        "lockTaskMode",
1485        "autoVerify",
1486        "showForAllUsers",
1487        "supportsAssist",
1488        "supportsLaunchVoiceAssistFromKeyguard",
1489        "listMenuViewStyle",
1490        "subMenuArrow",
1491        "defaultWidth",
1492        "defaultHeight",
1493        "resizeableActivity",
1494        "supportsPictureInPicture",
1495        "titleMargin",
1496        "titleMarginStart",
1497        "titleMarginEnd",
1498        "titleMarginTop",
1499        "titleMarginBottom",
1500        "maxButtonHeight",
1501        "buttonGravity",
1502        "collapseIcon",
1503        "level",
1504        "contextPopupMenuStyle",
1505        "textAppearancePopupMenuHeader",
1506        "windowBackgroundFallback",
1507        "defaultToDeviceProtectedStorage",
1508        "directBootAware",
1509        "preferenceFragmentStyle",
1510        "canControlMagnification",
1511        "languageTag",
1512        "pointerIcon",
1513        "tickMark",
1514        "tickMarkTint",
1515        "tickMarkTintMode",
1516        "canPerformGestures",
1517        "externalService",
1518        "supportsLocalInteraction",
1519        "startX",
1520        "startY",
1521        "endX",
1522        "endY",
1523        "offset",
1524        "use32bitAbi",
1525        "bitmap",
1526        "hotSpotX",
1527        "hotSpotY",
1528        "version",
1529        "backupInForeground",
1530        "countDown",
1531        "canRecord",
1532        "tunerCount",
1533        "fillType",
1534        "popupEnterTransition",
1535        "popupExitTransition",
1536        "forceHasOverlappingRendering",
1537        "contentInsetStartWithNavigation",
1538        "contentInsetEndWithActions",
1539        "numberPickerStyle",
1540        "enableVrMode",
1541        "UNKNOWN",
1542        "networkSecurityConfig",
1543        "shortcutId",
1544        "shortcutShortLabel",
1545        "shortcutLongLabel",
1546        "shortcutDisabledMessage",
1547        "roundIcon",
1548        "contextUri",
1549        "contextDescription",
1550        "showMetadataInPreview",
1551        "colorSecondary",
1552    ];
1553
1554    let i = resource_id - 0x0101_0000;
1555
1556    Some((*RESOURCE_STRINGS.get(usize::try_from(i).unwrap())?).to_string())
1557}