rusty_axml/chunks/
resource_map.rs

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