Add support for supports-input element to aapt
Change-Id: Ie8c8c44f126383c351f2ebb9ae7c3694fb0a9b16
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 7fa8c9d..7d21b8d 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -662,6 +662,7 @@
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 @@
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 @@
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 @@
}
}
}
- } 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;
- }
-
- 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;
- }
-
- 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);
-
- 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 (withinApplication) {
+ if(tag == "activity") {
+ withinActivity = true;
+ activityName = getAttribute(tree, NAME_ATTR, &error);
if (error != "") {
- fprintf(stderr, "ERROR getting 'android:value' attribute for "
- "meta-data: %s\n", error.string());
+ 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 (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;
- }
- }
- 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;
+ 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;
+ }
+
+ 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);
+
+ 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: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;
+ }
}
- if (withinActivity) {
- if (category == "android.intent.category.LAUNCHER") {
- isLauncherActivity = 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;
+ }
+ 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;
+ }
+ }
+ 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;
+ }
}
}
}