summaryrefslogtreecommitdiffstats
path: root/tools/aapt/Command.cpp
diff options
context:
space:
mode:
authorMaurice Chu <mochu@google.com>2013-10-16 18:28:46 -0700
committerAdam Lesinski <adamlesinski@google.com>2014-01-27 10:31:07 -0800
commit76327314d2238e105f8b94909f9c0cf85caca318 (patch)
tree3edf9a46e092a811a2589134721cb52590f4d94e /tools/aapt/Command.cpp
parentf314dc01210d117959ae2a303d0311cd071ee927 (diff)
downloadframeworks_base-76327314d2238e105f8b94909f9c0cf85caca318.zip
frameworks_base-76327314d2238e105f8b94909f9c0cf85caca318.tar.gz
frameworks_base-76327314d2238e105f8b94909f9c0cf85caca318.tar.bz2
Fix aapt when outputting meta-data tag values
This fixes outputting string as well as not crashing when the <meta-data> element has an "android:resource" attribute instead of an "android:value" attribute. Bug: 11255844 Change-Id: Iadb62b5dcb18ea3db8dbd2ba3241f489606d535d
Diffstat (limited to 'tools/aapt/Command.cpp')
-rw-r--r--tools/aapt/Command.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index 7c12949..22b7d35 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -378,6 +378,26 @@ static void getResolvedResourceAttribute(Res_value* value, const ResTable* resTa
}
}
+static void printResolvedResourceAttribute(const ResTable* resTable, const ResXMLTree& tree,
+ uint32_t attrRes, String8 attrLabel, String8* outError)
+{
+ Res_value value;
+ getResolvedResourceAttribute(&value, resTable, tree, attrRes, outError);
+ if (*outError != "") {
+ *outError = "error print resolved resource attribute";
+ return;
+ }
+ if (value.dataType == Res_value::TYPE_STRING) {
+ String8 result = getResolvedAttribute(resTable, tree, attrRes, outError);
+ printf("%s='%s'", attrLabel.string(), result.string());
+ } else if (Res_value::TYPE_FIRST_INT <= value.dataType &&
+ value.dataType <= Res_value::TYPE_LAST_INT) {
+ printf("%s='%d'", attrLabel.string(), value.data);
+ } else {
+ printf("%s='0x%x'", attrLabel.string(), (int)value.data);
+ }
+}
+
// These are attribute resource constants for the platform, as found
// in android.R.attr
enum {
@@ -1348,28 +1368,21 @@ int doDump(Bundle* bundle)
goto bail;
}
printf("meta-data: name='%s' ", metaDataName.string());
- Res_value value;
- getResolvedResourceAttribute(&value, &res, tree, VALUE_ATTR, &error);
+ printResolvedResourceAttribute(&res, tree, VALUE_ATTR, String8("value"),
+ &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);
+ // Try looking for a RESOURCE_ATTR
+ error = "";
+ printResolvedResourceAttribute(&res, tree, RESOURCE_ATTR,
+ String8("resource"), &error);
if (error != "") {
- fprintf(stderr, "ERROR getting 'android:value' attribute for "
- "meta-data: %s\n", error.string());
+ fprintf(stderr, "ERROR getting 'android:value' or "
+ "'android:resource' 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);
}
+ printf("\n");
} else if (withinSupportsInput && tag == "input-type") {
String8 name = getAttribute(tree, NAME_ATTR, &error);
if (name != "" && error == "") {