1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "SdkConstants.h"
18 
19 #include <algorithm>
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 
24 namespace aapt {
25 
26 static const std::vector<std::pair<uint16_t, size_t>> sAttrIdMap = {
27     { 0x021c, 1 },
28     { 0x021d, 2 },
29     { 0x0269, SDK_CUPCAKE },
30     { 0x028d, SDK_DONUT },
31     { 0x02ad, SDK_ECLAIR },
32     { 0x02b3, SDK_ECLAIR_0_1 },
33     { 0x02b5, SDK_ECLAIR_MR1 },
34     { 0x02bd, SDK_FROYO },
35     { 0x02cb, SDK_GINGERBREAD },
36     { 0x0361, SDK_HONEYCOMB },
37     { 0x0366, SDK_HONEYCOMB_MR1 },
38     { 0x03a6, SDK_HONEYCOMB_MR2 },
39     { 0x03ae, SDK_JELLY_BEAN },
40     { 0x03cc, SDK_JELLY_BEAN_MR1 },
41     { 0x03da, SDK_JELLY_BEAN_MR2 },
42     { 0x03f1, SDK_KITKAT },
43     { 0x03f6, SDK_KITKAT_WATCH },
44     { 0x04ce, SDK_LOLLIPOP },
45 };
46 
lessEntryId(const std::pair<uint16_t,size_t> & p,uint16_t entryId)47 static bool lessEntryId(const std::pair<uint16_t, size_t>& p, uint16_t entryId) {
48     return p.first < entryId;
49 }
50 
findAttributeSdkLevel(ResourceId id)51 size_t findAttributeSdkLevel(ResourceId id) {
52     if (id.packageId() != 0x01 && id.typeId() != 0x01) {
53         return 0;
54     }
55     auto iter = std::lower_bound(sAttrIdMap.begin(), sAttrIdMap.end(), id.entryId(), lessEntryId);
56     if (iter == sAttrIdMap.end()) {
57         return SDK_LOLLIPOP_MR1;
58     }
59     return iter->second;
60 }
61 
62 static const std::unordered_map<std::u16string, size_t> sAttrMap = {
63     { u"marqueeRepeatLimit", 2 },
64     { u"windowNoDisplay", 3 },
65     { u"backgroundDimEnabled", 3 },
66     { u"inputType", 3 },
67     { u"isDefault", 3 },
68     { u"windowDisablePreview", 3 },
69     { u"privateImeOptions", 3 },
70     { u"editorExtras", 3 },
71     { u"settingsActivity", 3 },
72     { u"fastScrollEnabled", 3 },
73     { u"reqTouchScreen", 3 },
74     { u"reqKeyboardType", 3 },
75     { u"reqHardKeyboard", 3 },
76     { u"reqNavigation", 3 },
77     { u"windowSoftInputMode", 3 },
78     { u"imeFullscreenBackground", 3 },
79     { u"noHistory", 3 },
80     { u"headerDividersEnabled", 3 },
81     { u"footerDividersEnabled", 3 },
82     { u"candidatesTextStyleSpans", 3 },
83     { u"smoothScrollbar", 3 },
84     { u"reqFiveWayNav", 3 },
85     { u"keyBackground", 3 },
86     { u"keyTextSize", 3 },
87     { u"labelTextSize", 3 },
88     { u"keyTextColor", 3 },
89     { u"keyPreviewLayout", 3 },
90     { u"keyPreviewOffset", 3 },
91     { u"keyPreviewHeight", 3 },
92     { u"verticalCorrection", 3 },
93     { u"popupLayout", 3 },
94     { u"state_long_pressable", 3 },
95     { u"keyWidth", 3 },
96     { u"keyHeight", 3 },
97     { u"horizontalGap", 3 },
98     { u"verticalGap", 3 },
99     { u"rowEdgeFlags", 3 },
100     { u"codes", 3 },
101     { u"popupKeyboard", 3 },
102     { u"popupCharacters", 3 },
103     { u"keyEdgeFlags", 3 },
104     { u"isModifier", 3 },
105     { u"isSticky", 3 },
106     { u"isRepeatable", 3 },
107     { u"iconPreview", 3 },
108     { u"keyOutputText", 3 },
109     { u"keyLabel", 3 },
110     { u"keyIcon", 3 },
111     { u"keyboardMode", 3 },
112     { u"isScrollContainer", 3 },
113     { u"fillEnabled", 3 },
114     { u"updatePeriodMillis", 3 },
115     { u"initialLayout", 3 },
116     { u"voiceSearchMode", 3 },
117     { u"voiceLanguageModel", 3 },
118     { u"voicePromptText", 3 },
119     { u"voiceLanguage", 3 },
120     { u"voiceMaxResults", 3 },
121     { u"bottomOffset", 3 },
122     { u"topOffset", 3 },
123     { u"allowSingleTap", 3 },
124     { u"handle", 3 },
125     { u"content", 3 },
126     { u"animateOnClick", 3 },
127     { u"configure", 3 },
128     { u"hapticFeedbackEnabled", 3 },
129     { u"innerRadius", 3 },
130     { u"thickness", 3 },
131     { u"sharedUserLabel", 3 },
132     { u"dropDownWidth", 3 },
133     { u"dropDownAnchor", 3 },
134     { u"imeOptions", 3 },
135     { u"imeActionLabel", 3 },
136     { u"imeActionId", 3 },
137     { u"imeExtractEnterAnimation", 3 },
138     { u"imeExtractExitAnimation", 3 },
139     { u"tension", 4 },
140     { u"extraTension", 4 },
141     { u"anyDensity", 4 },
142     { u"searchSuggestThreshold", 4 },
143     { u"includeInGlobalSearch", 4 },
144     { u"onClick", 4 },
145     { u"targetSdkVersion", 4 },
146     { u"maxSdkVersion", 4 },
147     { u"testOnly", 4 },
148     { u"contentDescription", 4 },
149     { u"gestureStrokeWidth", 4 },
150     { u"gestureColor", 4 },
151     { u"uncertainGestureColor", 4 },
152     { u"fadeOffset", 4 },
153     { u"fadeDuration", 4 },
154     { u"gestureStrokeType", 4 },
155     { u"gestureStrokeLengthThreshold", 4 },
156     { u"gestureStrokeSquarenessThreshold", 4 },
157     { u"gestureStrokeAngleThreshold", 4 },
158     { u"eventsInterceptionEnabled", 4 },
159     { u"fadeEnabled", 4 },
160     { u"backupAgent", 4 },
161     { u"allowBackup", 4 },
162     { u"glEsVersion", 4 },
163     { u"queryAfterZeroResults", 4 },
164     { u"dropDownHeight", 4 },
165     { u"smallScreens", 4 },
166     { u"normalScreens", 4 },
167     { u"largeScreens", 4 },
168     { u"progressBarStyleInverse", 4 },
169     { u"progressBarStyleSmallInverse", 4 },
170     { u"progressBarStyleLargeInverse", 4 },
171     { u"searchSettingsDescription", 4 },
172     { u"textColorPrimaryInverseDisableOnly", 4 },
173     { u"autoUrlDetect", 4 },
174     { u"resizeable", 4 },
175     { u"required", 5 },
176     { u"accountType", 5 },
177     { u"contentAuthority", 5 },
178     { u"userVisible", 5 },
179     { u"windowShowWallpaper", 5 },
180     { u"wallpaperOpenEnterAnimation", 5 },
181     { u"wallpaperOpenExitAnimation", 5 },
182     { u"wallpaperCloseEnterAnimation", 5 },
183     { u"wallpaperCloseExitAnimation", 5 },
184     { u"wallpaperIntraOpenEnterAnimation", 5 },
185     { u"wallpaperIntraOpenExitAnimation", 5 },
186     { u"wallpaperIntraCloseEnterAnimation", 5 },
187     { u"wallpaperIntraCloseExitAnimation", 5 },
188     { u"supportsUploading", 5 },
189     { u"killAfterRestore", 5 },
190     { u"restoreNeedsApplication", 5 },
191     { u"smallIcon", 5 },
192     { u"accountPreferences", 5 },
193     { u"textAppearanceSearchResultSubtitle", 5 },
194     { u"textAppearanceSearchResultTitle", 5 },
195     { u"summaryColumn", 5 },
196     { u"detailColumn", 5 },
197     { u"detailSocialSummary", 5 },
198     { u"thumbnail", 5 },
199     { u"detachWallpaper", 5 },
200     { u"finishOnCloseSystemDialogs", 5 },
201     { u"scrollbarFadeDuration", 5 },
202     { u"scrollbarDefaultDelayBeforeFade", 5 },
203     { u"fadeScrollbars", 5 },
204     { u"colorBackgroundCacheHint", 5 },
205     { u"dropDownHorizontalOffset", 5 },
206     { u"dropDownVerticalOffset", 5 },
207     { u"quickContactBadgeStyleWindowSmall", 6 },
208     { u"quickContactBadgeStyleWindowMedium", 6 },
209     { u"quickContactBadgeStyleWindowLarge", 6 },
210     { u"quickContactBadgeStyleSmallWindowSmall", 6 },
211     { u"quickContactBadgeStyleSmallWindowMedium", 6 },
212     { u"quickContactBadgeStyleSmallWindowLarge", 6 },
213     { u"author", 7 },
214     { u"autoStart", 7 },
215     { u"expandableListViewWhiteStyle", 8 },
216     { u"installLocation", 8 },
217     { u"vmSafeMode", 8 },
218     { u"webTextViewStyle", 8 },
219     { u"restoreAnyVersion", 8 },
220     { u"tabStripLeft", 8 },
221     { u"tabStripRight", 8 },
222     { u"tabStripEnabled", 8 },
223     { u"logo", 9 },
224     { u"xlargeScreens", 9 },
225     { u"immersive", 9 },
226     { u"overScrollMode", 9 },
227     { u"overScrollHeader", 9 },
228     { u"overScrollFooter", 9 },
229     { u"filterTouchesWhenObscured", 9 },
230     { u"textSelectHandleLeft", 9 },
231     { u"textSelectHandleRight", 9 },
232     { u"textSelectHandle", 9 },
233     { u"textSelectHandleWindowStyle", 9 },
234     { u"popupAnimationStyle", 9 },
235     { u"screenSize", 9 },
236     { u"screenDensity", 9 },
237     { u"allContactsName", 11 },
238     { u"windowActionBar", 11 },
239     { u"actionBarStyle", 11 },
240     { u"navigationMode", 11 },
241     { u"displayOptions", 11 },
242     { u"subtitle", 11 },
243     { u"customNavigationLayout", 11 },
244     { u"hardwareAccelerated", 11 },
245     { u"measureWithLargestChild", 11 },
246     { u"animateFirstView", 11 },
247     { u"dropDownSpinnerStyle", 11 },
248     { u"actionDropDownStyle", 11 },
249     { u"actionButtonStyle", 11 },
250     { u"showAsAction", 11 },
251     { u"previewImage", 11 },
252     { u"actionModeBackground", 11 },
253     { u"actionModeCloseDrawable", 11 },
254     { u"windowActionModeOverlay", 11 },
255     { u"valueFrom", 11 },
256     { u"valueTo", 11 },
257     { u"valueType", 11 },
258     { u"propertyName", 11 },
259     { u"ordering", 11 },
260     { u"fragment", 11 },
261     { u"windowActionBarOverlay", 11 },
262     { u"fragmentOpenEnterAnimation", 11 },
263     { u"fragmentOpenExitAnimation", 11 },
264     { u"fragmentCloseEnterAnimation", 11 },
265     { u"fragmentCloseExitAnimation", 11 },
266     { u"fragmentFadeEnterAnimation", 11 },
267     { u"fragmentFadeExitAnimation", 11 },
268     { u"actionBarSize", 11 },
269     { u"imeSubtypeLocale", 11 },
270     { u"imeSubtypeMode", 11 },
271     { u"imeSubtypeExtraValue", 11 },
272     { u"splitMotionEvents", 11 },
273     { u"listChoiceBackgroundIndicator", 11 },
274     { u"spinnerMode", 11 },
275     { u"animateLayoutChanges", 11 },
276     { u"actionBarTabStyle", 11 },
277     { u"actionBarTabBarStyle", 11 },
278     { u"actionBarTabTextStyle", 11 },
279     { u"actionOverflowButtonStyle", 11 },
280     { u"actionModeCloseButtonStyle", 11 },
281     { u"titleTextStyle", 11 },
282     { u"subtitleTextStyle", 11 },
283     { u"iconifiedByDefault", 11 },
284     { u"actionLayout", 11 },
285     { u"actionViewClass", 11 },
286     { u"activatedBackgroundIndicator", 11 },
287     { u"state_activated", 11 },
288     { u"listPopupWindowStyle", 11 },
289     { u"popupMenuStyle", 11 },
290     { u"textAppearanceLargePopupMenu", 11 },
291     { u"textAppearanceSmallPopupMenu", 11 },
292     { u"breadCrumbTitle", 11 },
293     { u"breadCrumbShortTitle", 11 },
294     { u"listDividerAlertDialog", 11 },
295     { u"textColorAlertDialogListItem", 11 },
296     { u"loopViews", 11 },
297     { u"dialogTheme", 11 },
298     { u"alertDialogTheme", 11 },
299     { u"dividerVertical", 11 },
300     { u"homeAsUpIndicator", 11 },
301     { u"enterFadeDuration", 11 },
302     { u"exitFadeDuration", 11 },
303     { u"selectableItemBackground", 11 },
304     { u"autoAdvanceViewId", 11 },
305     { u"useIntrinsicSizeAsMinimum", 11 },
306     { u"actionModeCutDrawable", 11 },
307     { u"actionModeCopyDrawable", 11 },
308     { u"actionModePasteDrawable", 11 },
309     { u"textEditPasteWindowLayout", 11 },
310     { u"textEditNoPasteWindowLayout", 11 },
311     { u"textIsSelectable", 11 },
312     { u"windowEnableSplitTouch", 11 },
313     { u"indeterminateProgressStyle", 11 },
314     { u"progressBarPadding", 11 },
315     { u"animationResolution", 11 },
316     { u"state_accelerated", 11 },
317     { u"baseline", 11 },
318     { u"homeLayout", 11 },
319     { u"opacity", 11 },
320     { u"alpha", 11 },
321     { u"transformPivotX", 11 },
322     { u"transformPivotY", 11 },
323     { u"translationX", 11 },
324     { u"translationY", 11 },
325     { u"scaleX", 11 },
326     { u"scaleY", 11 },
327     { u"rotation", 11 },
328     { u"rotationX", 11 },
329     { u"rotationY", 11 },
330     { u"showDividers", 11 },
331     { u"dividerPadding", 11 },
332     { u"borderlessButtonStyle", 11 },
333     { u"dividerHorizontal", 11 },
334     { u"itemPadding", 11 },
335     { u"buttonBarStyle", 11 },
336     { u"buttonBarButtonStyle", 11 },
337     { u"segmentedButtonStyle", 11 },
338     { u"staticWallpaperPreview", 11 },
339     { u"allowParallelSyncs", 11 },
340     { u"isAlwaysSyncable", 11 },
341     { u"verticalScrollbarPosition", 11 },
342     { u"fastScrollAlwaysVisible", 11 },
343     { u"fastScrollThumbDrawable", 11 },
344     { u"fastScrollPreviewBackgroundLeft", 11 },
345     { u"fastScrollPreviewBackgroundRight", 11 },
346     { u"fastScrollTrackDrawable", 11 },
347     { u"fastScrollOverlayPosition", 11 },
348     { u"customTokens", 11 },
349     { u"nextFocusForward", 11 },
350     { u"firstDayOfWeek", 11 },
351     { u"showWeekNumber", 11 },
352     { u"minDate", 11 },
353     { u"maxDate", 11 },
354     { u"shownWeekCount", 11 },
355     { u"selectedWeekBackgroundColor", 11 },
356     { u"focusedMonthDateColor", 11 },
357     { u"unfocusedMonthDateColor", 11 },
358     { u"weekNumberColor", 11 },
359     { u"weekSeparatorLineColor", 11 },
360     { u"selectedDateVerticalBar", 11 },
361     { u"weekDayTextAppearance", 11 },
362     { u"dateTextAppearance", 11 },
363     { u"solidColor", 11 },
364     { u"spinnersShown", 11 },
365     { u"calendarViewShown", 11 },
366     { u"state_multiline", 11 },
367     { u"detailsElementBackground", 11 },
368     { u"textColorHighlightInverse", 11 },
369     { u"textColorLinkInverse", 11 },
370     { u"editTextColor", 11 },
371     { u"editTextBackground", 11 },
372     { u"horizontalScrollViewStyle", 11 },
373     { u"layerType", 11 },
374     { u"alertDialogIcon", 11 },
375     { u"windowMinWidthMajor", 11 },
376     { u"windowMinWidthMinor", 11 },
377     { u"queryHint", 11 },
378     { u"fastScrollTextColor", 11 },
379     { u"largeHeap", 11 },
380     { u"windowCloseOnTouchOutside", 11 },
381     { u"datePickerStyle", 11 },
382     { u"calendarViewStyle", 11 },
383     { u"textEditSidePasteWindowLayout", 11 },
384     { u"textEditSideNoPasteWindowLayout", 11 },
385     { u"actionMenuTextAppearance", 11 },
386     { u"actionMenuTextColor", 11 },
387     { u"textCursorDrawable", 12 },
388     { u"resizeMode", 12 },
389     { u"requiresSmallestWidthDp", 12 },
390     { u"compatibleWidthLimitDp", 12 },
391     { u"largestWidthLimitDp", 12 },
392     { u"state_hovered", 13 },
393     { u"state_drag_can_accept", 13 },
394     { u"state_drag_hovered", 13 },
395     { u"stopWithTask", 13 },
396     { u"switchTextOn", 13 },
397     { u"switchTextOff", 13 },
398     { u"switchPreferenceStyle", 13 },
399     { u"switchTextAppearance", 13 },
400     { u"track", 13 },
401     { u"switchMinWidth", 13 },
402     { u"switchPadding", 13 },
403     { u"thumbTextPadding", 13 },
404     { u"textSuggestionsWindowStyle", 13 },
405     { u"textEditSuggestionItemLayout", 13 },
406     { u"rowCount", 13 },
407     { u"rowOrderPreserved", 13 },
408     { u"columnCount", 13 },
409     { u"columnOrderPreserved", 13 },
410     { u"useDefaultMargins", 13 },
411     { u"alignmentMode", 13 },
412     { u"layout_row", 13 },
413     { u"layout_rowSpan", 13 },
414     { u"layout_columnSpan", 13 },
415     { u"actionModeSelectAllDrawable", 13 },
416     { u"isAuxiliary", 13 },
417     { u"accessibilityEventTypes", 13 },
418     { u"packageNames", 13 },
419     { u"accessibilityFeedbackType", 13 },
420     { u"notificationTimeout", 13 },
421     { u"accessibilityFlags", 13 },
422     { u"canRetrieveWindowContent", 13 },
423     { u"listPreferredItemHeightLarge", 13 },
424     { u"listPreferredItemHeightSmall", 13 },
425     { u"actionBarSplitStyle", 13 },
426     { u"actionProviderClass", 13 },
427     { u"backgroundStacked", 13 },
428     { u"backgroundSplit", 13 },
429     { u"textAllCaps", 13 },
430     { u"colorPressedHighlight", 13 },
431     { u"colorLongPressedHighlight", 13 },
432     { u"colorFocusedHighlight", 13 },
433     { u"colorActivatedHighlight", 13 },
434     { u"colorMultiSelectHighlight", 13 },
435     { u"drawableStart", 13 },
436     { u"drawableEnd", 13 },
437     { u"actionModeStyle", 13 },
438     { u"minResizeWidth", 13 },
439     { u"minResizeHeight", 13 },
440     { u"actionBarWidgetTheme", 13 },
441     { u"uiOptions", 13 },
442     { u"subtypeLocale", 13 },
443     { u"subtypeExtraValue", 13 },
444     { u"actionBarDivider", 13 },
445     { u"actionBarItemBackground", 13 },
446     { u"actionModeSplitBackground", 13 },
447     { u"textAppearanceListItem", 13 },
448     { u"textAppearanceListItemSmall", 13 },
449     { u"targetDescriptions", 13 },
450     { u"directionDescriptions", 13 },
451     { u"overridesImplicitlyEnabledSubtype", 13 },
452     { u"listPreferredItemPaddingLeft", 13 },
453     { u"listPreferredItemPaddingRight", 13 },
454     { u"requiresFadingEdge", 13 },
455     { u"publicKey", 13 },
456     { u"parentActivityName", 16 },
457     { u"isolatedProcess", 16 },
458     { u"importantForAccessibility", 16 },
459     { u"keyboardLayout", 16 },
460     { u"fontFamily", 16 },
461     { u"mediaRouteButtonStyle", 16 },
462     { u"mediaRouteTypes", 16 },
463     { u"supportsRtl", 17 },
464     { u"textDirection", 17 },
465     { u"textAlignment", 17 },
466     { u"layoutDirection", 17 },
467     { u"paddingStart", 17 },
468     { u"paddingEnd", 17 },
469     { u"layout_marginStart", 17 },
470     { u"layout_marginEnd", 17 },
471     { u"layout_toStartOf", 17 },
472     { u"layout_toEndOf", 17 },
473     { u"layout_alignStart", 17 },
474     { u"layout_alignEnd", 17 },
475     { u"layout_alignParentStart", 17 },
476     { u"layout_alignParentEnd", 17 },
477     { u"listPreferredItemPaddingStart", 17 },
478     { u"listPreferredItemPaddingEnd", 17 },
479     { u"singleUser", 17 },
480     { u"presentationTheme", 17 },
481     { u"subtypeId", 17 },
482     { u"initialKeyguardLayout", 17 },
483     { u"widgetCategory", 17 },
484     { u"permissionGroupFlags", 17 },
485     { u"labelFor", 17 },
486     { u"permissionFlags", 17 },
487     { u"checkedTextViewStyle", 17 },
488     { u"showOnLockScreen", 17 },
489     { u"format12Hour", 17 },
490     { u"format24Hour", 17 },
491     { u"timeZone", 17 },
492     { u"mipMap", 18 },
493     { u"mirrorForRtl", 18 },
494     { u"windowOverscan", 18 },
495     { u"requiredForAllUsers", 18 },
496     { u"indicatorStart", 18 },
497     { u"indicatorEnd", 18 },
498     { u"childIndicatorStart", 18 },
499     { u"childIndicatorEnd", 18 },
500     { u"restrictedAccountType", 18 },
501     { u"requiredAccountType", 18 },
502     { u"canRequestTouchExplorationMode", 18 },
503     { u"canRequestEnhancedWebAccessibility", 18 },
504     { u"canRequestFilterKeyEvents", 18 },
505     { u"layoutMode", 18 },
506     { u"keySet", 19 },
507     { u"targetId", 19 },
508     { u"fromScene", 19 },
509     { u"toScene", 19 },
510     { u"transition", 19 },
511     { u"transitionOrdering", 19 },
512     { u"fadingMode", 19 },
513     { u"startDelay", 19 },
514     { u"ssp", 19 },
515     { u"sspPrefix", 19 },
516     { u"sspPattern", 19 },
517     { u"addPrintersActivity", 19 },
518     { u"vendor", 19 },
519     { u"category", 19 },
520     { u"isAsciiCapable", 19 },
521     { u"autoMirrored", 19 },
522     { u"supportsSwitchingToNextInputMethod", 19 },
523     { u"requireDeviceUnlock", 19 },
524     { u"apduServiceBanner", 19 },
525     { u"accessibilityLiveRegion", 19 },
526     { u"windowTranslucentStatus", 19 },
527     { u"windowTranslucentNavigation", 19 },
528     { u"advancedPrintOptionsActivity", 19 },
529     { u"banner", 20 },
530     { u"windowSwipeToDismiss", 20 },
531     { u"isGame", 20 },
532     { u"allowEmbedded", 20 },
533     { u"setupActivity", 20 },
534     { u"fastScrollStyle", 21 },
535     { u"windowContentTransitions", 21 },
536     { u"windowContentTransitionManager", 21 },
537     { u"translationZ", 21 },
538     { u"tintMode", 21 },
539     { u"controlX1", 21 },
540     { u"controlY1", 21 },
541     { u"controlX2", 21 },
542     { u"controlY2", 21 },
543     { u"transitionName", 21 },
544     { u"transitionGroup", 21 },
545     { u"viewportWidth", 21 },
546     { u"viewportHeight", 21 },
547     { u"fillColor", 21 },
548     { u"pathData", 21 },
549     { u"strokeColor", 21 },
550     { u"strokeWidth", 21 },
551     { u"trimPathStart", 21 },
552     { u"trimPathEnd", 21 },
553     { u"trimPathOffset", 21 },
554     { u"strokeLineCap", 21 },
555     { u"strokeLineJoin", 21 },
556     { u"strokeMiterLimit", 21 },
557     { u"colorControlNormal", 21 },
558     { u"colorControlActivated", 21 },
559     { u"colorButtonNormal", 21 },
560     { u"colorControlHighlight", 21 },
561     { u"persistableMode", 21 },
562     { u"titleTextAppearance", 21 },
563     { u"subtitleTextAppearance", 21 },
564     { u"slideEdge", 21 },
565     { u"actionBarTheme", 21 },
566     { u"textAppearanceListItemSecondary", 21 },
567     { u"colorPrimary", 21 },
568     { u"colorPrimaryDark", 21 },
569     { u"colorAccent", 21 },
570     { u"nestedScrollingEnabled", 21 },
571     { u"windowEnterTransition", 21 },
572     { u"windowExitTransition", 21 },
573     { u"windowSharedElementEnterTransition", 21 },
574     { u"windowSharedElementExitTransition", 21 },
575     { u"windowAllowReturnTransitionOverlap", 21 },
576     { u"windowAllowEnterTransitionOverlap", 21 },
577     { u"sessionService", 21 },
578     { u"stackViewStyle", 21 },
579     { u"switchStyle", 21 },
580     { u"elevation", 21 },
581     { u"excludeId", 21 },
582     { u"excludeClass", 21 },
583     { u"hideOnContentScroll", 21 },
584     { u"actionOverflowMenuStyle", 21 },
585     { u"documentLaunchMode", 21 },
586     { u"maxRecents", 21 },
587     { u"autoRemoveFromRecents", 21 },
588     { u"stateListAnimator", 21 },
589     { u"toId", 21 },
590     { u"fromId", 21 },
591     { u"reversible", 21 },
592     { u"splitTrack", 21 },
593     { u"targetName", 21 },
594     { u"excludeName", 21 },
595     { u"matchOrder", 21 },
596     { u"windowDrawsSystemBarBackgrounds", 21 },
597     { u"statusBarColor", 21 },
598     { u"navigationBarColor", 21 },
599     { u"contentInsetStart", 21 },
600     { u"contentInsetEnd", 21 },
601     { u"contentInsetLeft", 21 },
602     { u"contentInsetRight", 21 },
603     { u"paddingMode", 21 },
604     { u"layout_rowWeight", 21 },
605     { u"layout_columnWeight", 21 },
606     { u"translateX", 21 },
607     { u"translateY", 21 },
608     { u"selectableItemBackgroundBorderless", 21 },
609     { u"elegantTextHeight", 21 },
610     { u"searchKeyphraseId", 21 },
611     { u"searchKeyphrase", 21 },
612     { u"searchKeyphraseSupportedLocales", 21 },
613     { u"windowTransitionBackgroundFadeDuration", 21 },
614     { u"overlapAnchor", 21 },
615     { u"progressTint", 21 },
616     { u"progressTintMode", 21 },
617     { u"progressBackgroundTint", 21 },
618     { u"progressBackgroundTintMode", 21 },
619     { u"secondaryProgressTint", 21 },
620     { u"secondaryProgressTintMode", 21 },
621     { u"indeterminateTint", 21 },
622     { u"indeterminateTintMode", 21 },
623     { u"backgroundTint", 21 },
624     { u"backgroundTintMode", 21 },
625     { u"foregroundTint", 21 },
626     { u"foregroundTintMode", 21 },
627     { u"buttonTint", 21 },
628     { u"buttonTintMode", 21 },
629     { u"thumbTint", 21 },
630     { u"thumbTintMode", 21 },
631     { u"fullBackupOnly", 21 },
632     { u"propertyXName", 21 },
633     { u"propertyYName", 21 },
634     { u"relinquishTaskIdentity", 21 },
635     { u"tileModeX", 21 },
636     { u"tileModeY", 21 },
637     { u"actionModeShareDrawable", 21 },
638     { u"actionModeFindDrawable", 21 },
639     { u"actionModeWebSearchDrawable", 21 },
640     { u"transitionVisibilityMode", 21 },
641     { u"minimumHorizontalAngle", 21 },
642     { u"minimumVerticalAngle", 21 },
643     { u"maximumAngle", 21 },
644     { u"searchViewStyle", 21 },
645     { u"closeIcon", 21 },
646     { u"goIcon", 21 },
647     { u"searchIcon", 21 },
648     { u"voiceIcon", 21 },
649     { u"commitIcon", 21 },
650     { u"suggestionRowLayout", 21 },
651     { u"queryBackground", 21 },
652     { u"submitBackground", 21 },
653     { u"buttonBarPositiveButtonStyle", 21 },
654     { u"buttonBarNeutralButtonStyle", 21 },
655     { u"buttonBarNegativeButtonStyle", 21 },
656     { u"popupElevation", 21 },
657     { u"actionBarPopupTheme", 21 },
658     { u"multiArch", 21 },
659     { u"touchscreenBlocksFocus", 21 },
660     { u"windowElevation", 21 },
661     { u"launchTaskBehindTargetAnimation", 21 },
662     { u"launchTaskBehindSourceAnimation", 21 },
663     { u"restrictionType", 21 },
664     { u"dayOfWeekBackground", 21 },
665     { u"dayOfWeekTextAppearance", 21 },
666     { u"headerMonthTextAppearance", 21 },
667     { u"headerDayOfMonthTextAppearance", 21 },
668     { u"headerYearTextAppearance", 21 },
669     { u"yearListItemTextAppearance", 21 },
670     { u"yearListSelectorColor", 21 },
671     { u"calendarTextColor", 21 },
672     { u"recognitionService", 21 },
673     { u"timePickerStyle", 21 },
674     { u"timePickerDialogTheme", 21 },
675     { u"headerTimeTextAppearance", 21 },
676     { u"headerAmPmTextAppearance", 21 },
677     { u"numbersTextColor", 21 },
678     { u"numbersBackgroundColor", 21 },
679     { u"numbersSelectorColor", 21 },
680     { u"amPmTextColor", 21 },
681     { u"amPmBackgroundColor", 21 },
682     { u"searchKeyphraseRecognitionFlags", 21 },
683     { u"checkMarkTint", 21 },
684     { u"checkMarkTintMode", 21 },
685     { u"popupTheme", 21 },
686     { u"toolbarStyle", 21 },
687     { u"windowClipToOutline", 21 },
688     { u"datePickerDialogTheme", 21 },
689     { u"showText", 21 },
690     { u"windowReturnTransition", 21 },
691     { u"windowReenterTransition", 21 },
692     { u"windowSharedElementReturnTransition", 21 },
693     { u"windowSharedElementReenterTransition", 21 },
694     { u"resumeWhilePausing", 21 },
695     { u"datePickerMode", 21 },
696     { u"timePickerMode", 21 },
697     { u"inset", 21 },
698     { u"letterSpacing", 21 },
699     { u"fontFeatureSettings", 21 },
700     { u"outlineProvider", 21 },
701     { u"contentAgeHint", 21 },
702     { u"country", 21 },
703     { u"windowSharedElementsUseOverlay", 21 },
704     { u"reparent", 21 },
705     { u"reparentWithOverlay", 21 },
706     { u"ambientShadowAlpha", 21 },
707     { u"spotShadowAlpha", 21 },
708     { u"navigationIcon", 21 },
709     { u"navigationContentDescription", 21 },
710     { u"fragmentExitTransition", 21 },
711     { u"fragmentEnterTransition", 21 },
712     { u"fragmentSharedElementEnterTransition", 21 },
713     { u"fragmentReturnTransition", 21 },
714     { u"fragmentSharedElementReturnTransition", 21 },
715     { u"fragmentReenterTransition", 21 },
716     { u"fragmentAllowEnterTransitionOverlap", 21 },
717     { u"fragmentAllowReturnTransitionOverlap", 21 },
718     { u"patternPathData", 21 },
719     { u"strokeAlpha", 21 },
720     { u"fillAlpha", 21 },
721     { u"windowActivityTransitions", 21 },
722     { u"colorEdgeEffect", 21 }
723 };
724 
findAttributeSdkLevel(const ResourceName & name)725 size_t findAttributeSdkLevel(const ResourceName& name) {
726     if (name.package != u"android" && name.type != ResourceType::kAttr) {
727         return 0;
728     }
729 
730     auto iter = sAttrMap.find(name.entry);
731     if (iter != sAttrMap.end()) {
732         return iter->second;
733     }
734     return SDK_LOLLIPOP_MR1;
735 }
736 
737 } // namespace aapt
738