summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2014-07-30 11:40:39 -0700
committerAdam Lesinski <adamlesinski@google.com>2014-07-30 21:53:48 +0000
commit63e646eed5a8d7f5d04544ac8628f65b0173cf3a (patch)
tree06461d85d0b53e9ed5e50724f64e7e670ac44c24
parent805f6ebf17e2791624bb1a30834b4c1cc65583bf (diff)
downloadframeworks_base-63e646eed5a8d7f5d04544ac8628f65b0173cf3a.zip
frameworks_base-63e646eed5a8d7f5d04544ac8628f65b0173cf3a.tar.gz
frameworks_base-63e646eed5a8d7f5d04544ac8628f65b0173cf3a.tar.bz2
Add shared library support to aapt dump
AAPT dump should be able to handle dynamic references that often come with shared library resources. Bug:16678251 Change-Id: I6c8cd943145aab20ca9db9694c8c433b3c64279b
-rw-r--r--tests/SharedLibrary/lib/AndroidManifest.xml3
-rw-r--r--tests/SharedLibrary/lib/res/drawable/size_48x48.jpgbin0 -> 1572 bytes
-rw-r--r--tools/aapt/Command.cpp27
3 files changed, 19 insertions, 11 deletions
diff --git a/tests/SharedLibrary/lib/AndroidManifest.xml b/tests/SharedLibrary/lib/AndroidManifest.xml
index 31fac20..bb939dd 100644
--- a/tests/SharedLibrary/lib/AndroidManifest.xml
+++ b/tests/SharedLibrary/lib/AndroidManifest.xml
@@ -19,7 +19,8 @@
android:versionCode="2">
<application android:label="SharedLibrary">
<library android:name="com.google.android.test.shared_library" />
- <activity android:name="ActivityMain">
+ <activity android:name="ActivityMain"
+ android:icon="@drawable/size_48x48">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/tests/SharedLibrary/lib/res/drawable/size_48x48.jpg b/tests/SharedLibrary/lib/res/drawable/size_48x48.jpg
new file mode 100644
index 0000000..5c2291e
--- /dev/null
+++ b/tests/SharedLibrary/lib/res/drawable/size_48x48.jpg
Binary files differ
diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp
index afeb546..755a77a 100644
--- a/tools/aapt/Command.cpp
+++ b/tools/aapt/Command.cpp
@@ -714,7 +714,6 @@ extern char CONSOLE_DATA[2925]; // see EOF
int doDump(Bundle* bundle)
{
status_t result = UNKNOWN_ERROR;
- Asset* asset = NULL;
if (bundle->getFileSpecCount() < 1) {
fprintf(stderr, "ERROR: no dump option specified\n");
@@ -758,12 +757,21 @@ int doDump(Bundle* bundle)
const ResTable& res = assets.getResources(false);
if (&res == NULL) {
fprintf(stderr, "ERROR: dump failed because no resource table was found\n");
- goto bail;
+ return 1;
} else if (res.getError() != NO_ERROR) {
fprintf(stderr, "ERROR: dump failed because the resource table is invalid/corrupt.\n");
- goto bail;
+ return 1;
+ }
+
+ const DynamicRefTable* dynamicRefTable = res.getDynamicRefTableForCookie(assetsCookie);
+ if (dynamicRefTable == NULL) {
+ fprintf(stderr, "ERROR: failed to find dynamic reference table for asset cookie %d\n",
+ assetsCookie);
+ return 1;
}
+ Asset* asset = NULL;
+
if (strcmp("resources", option) == 0) {
#ifndef HAVE_ANDROID_OS
res.print(bundle->getValues());
@@ -781,8 +789,8 @@ int doDump(Bundle* bundle)
for (int i=2; i<bundle->getFileSpecCount(); i++) {
const char* resname = bundle->getFileSpecEntry(i);
- ResXMLTree tree;
- asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER);
+ ResXMLTree tree(dynamicRefTable);
+ asset = assets.openNonAsset(assetsCookie, resname, Asset::ACCESS_BUFFER);
if (asset == NULL) {
fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname);
goto bail;
@@ -808,13 +816,13 @@ int doDump(Bundle* bundle)
for (int i=2; i<bundle->getFileSpecCount(); i++) {
const char* resname = bundle->getFileSpecEntry(i);
- ResXMLTree tree;
- asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER);
+ asset = assets.openNonAsset(assetsCookie, resname, Asset::ACCESS_BUFFER);
if (asset == NULL) {
fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname);
goto bail;
}
+ ResXMLTree tree(dynamicRefTable);
if (tree.setTo(asset->getBuffer(true),
asset->getLength()) != NO_ERROR) {
fprintf(stderr, "ERROR: Resource %s is corrupt\n", resname);
@@ -826,14 +834,13 @@ int doDump(Bundle* bundle)
}
} else {
- ResXMLTree tree;
- asset = assets.openNonAsset("AndroidManifest.xml",
- Asset::ACCESS_BUFFER);
+ asset = assets.openNonAsset(assetsCookie, "AndroidManifest.xml", Asset::ACCESS_BUFFER);
if (asset == NULL) {
fprintf(stderr, "ERROR: dump failed because no AndroidManifest.xml found\n");
goto bail;
}
+ ResXMLTree tree(dynamicRefTable);
if (tree.setTo(asset->getBuffer(true),
asset->getLength()) != NO_ERROR) {
fprintf(stderr, "ERROR: AndroidManifest.xml is corrupt\n");