diff options
author | Michael Wright <michaelwr@google.com> | 2013-09-06 16:50:52 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2014-01-27 10:31:05 -0800 |
commit | ec4fdec76f2916b91a69d979f400cd69a3812631 (patch) | |
tree | 177e2afd5529a2df4f2c0e2ed4584b83dbd00839 /tools/aapt/Command.cpp | |
parent | 859e19f97d481bf07c768087d8eb3031fac77aad (diff) |
Add support for supports-input element to aapt
Change-Id: Ie8c8c44f126383c351f2ebb9ae7c3694fb0a9b16
Diffstat (limited to 'tools/aapt/Command.cpp')
-rw-r--r-- | tools/aapt/Command.cpp | 273 |
1 files changed, 155 insertions, 118 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 7fa8c9d89b3c..7d21b8d8284c 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -662,6 +662,7 @@ int doDump(Bundle* bundle) bool isLauncherActivity = false; bool isSearchable = false; bool withinApplication = false; + bool withinSupportsInput = false; bool withinReceiver = false; bool withinService = false; bool withinIntentFilter = false; @@ -752,11 +753,26 @@ int doDump(Bundle* bundle) String8 activityIcon; String8 receiverName; String8 serviceName; + Vector<String8> supportedInput; while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { if (code == ResXMLTree::END_TAG) { depth--; if (depth < 2) { + if (withinSupportsInput && !supportedInput.isEmpty()) { + printf("supports-input: '"); + const size_t N = supportedInput.size(); + for (size_t i=0; i<N; i++) { + printf("%s", supportedInput[i].string()); + if (i != N - 1) { + printf("' '"); + } else { + printf("'\n"); + } + } + supportedInput.clear(); + } withinApplication = false; + withinSupportsInput = false; } else if (depth < 3) { if (withinActivity && isMainActivity && isLauncherActivity) { const char *aName = getComponentName(pkg, activityName); @@ -951,6 +967,8 @@ int doDump(Bundle* bundle) printf(" reqFiveWayNav='%d'", reqFiveWayNav); } printf("\n"); + } else if (tag == "supports-input") { + withinSupportsInput = true; } else if (tag == "supports-screens") { smallScreen = getIntegerAttribute(tree, SMALL_SCREEN_ATTR, NULL, 1); @@ -1127,144 +1145,163 @@ int doDump(Bundle* bundle) } } } - } else if (depth == 3 && withinApplication) { + } else if (depth == 3) { withinActivity = false; withinReceiver = false; withinService = false; hasIntentFilter = false; - if(tag == "activity") { - withinActivity = true; - activityName = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string()); - goto bail; - } + if (withinApplication) { + if(tag == "activity") { + withinActivity = true; + activityName = getAttribute(tree, NAME_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", + error.string()); + goto bail; + } - activityLabel = getResolvedAttribute(&res, tree, LABEL_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n", error.string()); - goto bail; - } + activityLabel = getResolvedAttribute(&res, tree, LABEL_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:label' attribute: %s\n", + error.string()); + goto bail; + } - activityIcon = getResolvedAttribute(&res, tree, ICON_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", error.string()); - goto bail; - } + activityIcon = getResolvedAttribute(&res, tree, ICON_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:icon' attribute: %s\n", + error.string()); + goto bail; + } - int32_t orien = getResolvedIntegerAttribute(&res, tree, - SCREEN_ORIENTATION_ATTR, &error); - if (error == "") { - if (orien == 0 || orien == 6 || orien == 8) { - // Requests landscape, sensorLandscape, or reverseLandscape. - reqScreenLandscapeFeature = true; - } else if (orien == 1 || orien == 7 || orien == 9) { - // Requests portrait, sensorPortrait, or reversePortrait. - reqScreenPortraitFeature = true; + int32_t orien = getResolvedIntegerAttribute(&res, tree, + SCREEN_ORIENTATION_ATTR, &error); + if (error == "") { + if (orien == 0 || orien == 6 || orien == 8) { + // Requests landscape, sensorLandscape, or reverseLandscape. + reqScreenLandscapeFeature = true; + } else if (orien == 1 || orien == 7 || orien == 9) { + // Requests portrait, sensorPortrait, or reversePortrait. + reqScreenPortraitFeature = true; + } } - } - } else if (tag == "uses-library") { - String8 libraryName = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:name' attribute for uses-library: %s\n", error.string()); - goto bail; - } - int req = getIntegerAttribute(tree, - REQUIRED_ATTR, NULL, 1); - printf("uses-library%s:'%s'\n", - req ? "" : "-not-required", libraryName.string()); - } else if (tag == "receiver") { - withinReceiver = true; - receiverName = getAttribute(tree, NAME_ATTR, &error); + } else if (tag == "uses-library") { + String8 libraryName = getAttribute(tree, NAME_ATTR, &error); + if (error != "") { + fprintf(stderr, + "ERROR getting 'android:name' attribute for uses-library" + " %s\n", error.string()); + goto bail; + } + int req = getIntegerAttribute(tree, + REQUIRED_ATTR, NULL, 1); + printf("uses-library%s:'%s'\n", + req ? "" : "-not-required", libraryName.string()); + } else if (tag == "receiver") { + withinReceiver = true; + receiverName = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:name' attribute for " - "receiver:%s\n", error.string()); - goto bail; - } - } else if (tag == "service") { - withinService = true; - serviceName = getAttribute(tree, NAME_ATTR, &error); + if (error != "") { + fprintf(stderr, + "ERROR getting 'android:name' attribute for receiver:" + " %s\n", error.string()); + goto bail; + } + } else if (tag == "service") { + withinService = true; + serviceName = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:name' attribute for " - "service:%s\n", error.string()); - goto bail; - } - } else if (bundle->getIncludeMetaData() && tag == "meta-data") { - String8 metaDataName = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:name' attribute for " - "meta-data:%s\n", error.string()); - goto bail; - } - printf("meta-data: name='%s' ", metaDataName.string()); - Res_value value; - getResolvedResourceAttribute(&value, &res, tree, VALUE_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:value' attribute for " - "meta-data:%s\n", error.string()); - goto bail; - } - if (value.dataType == Res_value::TYPE_STRING) { - String8 metaDataValue = getAttribute(tree, value.data, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:name' attribute for " + "service:%s\n", error.string()); + goto bail; + } + } else if (bundle->getIncludeMetaData() && tag == "meta-data") { + String8 metaDataName = getAttribute(tree, NAME_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:name' attribute for " + "meta-data:%s\n", error.string()); + goto bail; + } + printf("meta-data: name='%s' ", metaDataName.string()); + Res_value value; + getResolvedResourceAttribute(&value, &res, tree, VALUE_ATTR, &error); if (error != "") { fprintf(stderr, "ERROR getting 'android:value' attribute for " - "meta-data: %s\n", error.string()); + "meta-data:%s\n", error.string()); + goto bail; + } + if (value.dataType == Res_value::TYPE_STRING) { + String8 metaDataValue = getAttribute(tree, value.data, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:value' attribute for " + "meta-data: %s\n", error.string()); + goto bail; + } + printf("value='%s'\n", metaDataValue.string()); + } else if (Res_value::TYPE_FIRST_INT <= value.dataType && + value.dataType <= Res_value::TYPE_LAST_INT) { + printf("value='%d'\n", value.data); + } else { + printf("value=(type 0x%x)0x%x", + (int)value.dataType, (int)value.data); + } + } else if (withinSupportsInput && tag == "input-type") { + String8 name = getAttribute(tree, NAME_ATTR, &error); + if (name != "" && error == "") { + supportedInput.add(name); + } else { + fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", + error.string()); goto bail; } - printf("value='%s'\n", metaDataValue.string()); - } else if (Res_value::TYPE_FIRST_INT <= value.dataType && - value.dataType <= Res_value::TYPE_LAST_INT) { - printf("value='%d'\n", value.data); - } else { - printf("value=(type 0x%x)0x%x", (int)value.dataType, (int)value.data); - } - } - } else if ((depth == 4) && (tag == "intent-filter")) { - hasIntentFilter = true; - withinIntentFilter = true; - actMainActivity = actWidgetReceivers = actImeService = actWallpaperService = - false; - } else if ((depth == 5) && withinIntentFilter) { - String8 action; - if (tag == "action") { - action = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", - error.string()); - goto bail; } - if (withinActivity) { - if (action == "android.intent.action.MAIN") { - isMainActivity = true; - actMainActivity = true; + } else if ((depth == 4) && (tag == "intent-filter")) { + hasIntentFilter = true; + withinIntentFilter = true; + actMainActivity = actWidgetReceivers = + actImeService = actWallpaperService = false; + } else if ((depth == 5) && withinIntentFilter) { + String8 action; + if (tag == "action") { + action = getAttribute(tree, NAME_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", + error.string()); + goto bail; } - } else if (withinReceiver) { - if (action == "android.appwidget.action.APPWIDGET_UPDATE") { - actWidgetReceivers = true; + if (withinActivity) { + if (action == "android.intent.action.MAIN") { + isMainActivity = true; + actMainActivity = true; + } + } else if (withinReceiver) { + if (action == "android.appwidget.action.APPWIDGET_UPDATE") { + actWidgetReceivers = true; + } + } else if (withinService) { + if (action == "android.view.InputMethod") { + actImeService = true; + } else if (action == "android.service.wallpaper.WallpaperService") { + actWallpaperService = true; + } } - } else if (withinService) { - if (action == "android.view.InputMethod") { - actImeService = true; - } else if (action == "android.service.wallpaper.WallpaperService") { - actWallpaperService = true; + if (action == "android.intent.action.SEARCH") { + isSearchable = true; } } - if (action == "android.intent.action.SEARCH") { - isSearchable = true; - } - } - if (tag == "category") { - String8 category = getAttribute(tree, NAME_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'name' attribute: %s\n", error.string()); - goto bail; - } - if (withinActivity) { - if (category == "android.intent.category.LAUNCHER") { - isLauncherActivity = true; + if (tag == "category") { + String8 category = getAttribute(tree, NAME_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'name' attribute: %s\n", + error.string()); + goto bail; + } + if (withinActivity) { + if (category == "android.intent.category.LAUNCHER") { + isLauncherActivity = true; + } } } } |