X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/7e029053aff869f4592a2a0cbf2fd98ad3651133..e44f31f5e05de7c970e9bbe61e42577a244c0321:/Command.cpp diff --git a/Command.cpp b/Command.cpp index f4afd7f..4067735 100644 --- a/Command.cpp +++ b/Command.cpp @@ -233,7 +233,7 @@ static ssize_t indexOfAttribute(const ResXMLTree& tree, uint32_t attrRes) return -1; } -static String8 getAttribute(const ResXMLTree& tree, const char* ns, +String8 getAttribute(const ResXMLTree& tree, const char* ns, const char* attr, String8* outError) { ssize_t idx = tree.indexOfAttribute(ns, attr); @@ -401,7 +401,7 @@ int doDump(Bundle* bundle) ResXMLTree tree; asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER); if (asset == NULL) { - fprintf(stderr, "ERROR: dump failed because resource %p found\n", resname); + fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname); goto bail; } @@ -427,7 +427,7 @@ int doDump(Bundle* bundle) ResXMLTree tree; asset = assets.openNonAsset(resname, Asset::ACCESS_BUFFER); if (asset == NULL) { - fprintf(stderr, "ERROR: dump failed because resource %p found\n", resname); + fprintf(stderr, "ERROR: dump failed because resource %s found\n", resname); goto bail; } @@ -712,7 +712,8 @@ int doDump(Bundle* bundle) LARGE_SCREEN_ATTR, NULL, 1); } else if (tag == "uses-feature") { String8 name = getAttribute(tree, NAME_ATTR, &error); - if (error == "") { + + if (name != "" && error == "") { int req = getIntegerAttribute(tree, REQUIRED_ATTR, NULL, 1); if (name == "android.hardware.camera") { @@ -729,9 +730,7 @@ int doDump(Bundle* bundle) } } else if (tag == "uses-permission") { String8 name = getAttribute(tree, NAME_ATTR, &error); - if (error == "") { - int opt = getIntegerAttribute(tree, - REQUIRED_ATTR, NULL, 1); + if (name != "" && error == "") { if (name == "android.permission.CAMERA") { hasCameraPermission = true; } @@ -772,7 +771,10 @@ int doDump(Bundle* bundle) fprintf(stderr, "ERROR getting 'android:name' attribute for uses-library: %s\n", error.string()); goto bail; } - printf("uses-library:'%s'\n", libraryName.string()); + 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); @@ -846,7 +848,7 @@ int doDump(Bundle* bundle) printf("uses-feature:'android.hardware.camera'\n"); printf("uses-feature:'android.hardware.camera.autofocus'\n"); } - + if (hasMainActivity) { printf("main\n"); } @@ -995,8 +997,15 @@ int doAdd(Bundle* bundle) printf(" '%s'... (from gzip)\n", fileName); result = zip->addGzip(fileName, String8(fileName).getBasePath().string(), NULL); } else { - printf(" '%s'...\n", fileName); - result = zip->add(fileName, bundle->getCompressionMethod(), NULL); + if (bundle->getJunkPath()) { + String8 storageName = String8(fileName).getPathLeaf(); + printf(" '%s' as '%s'...\n", fileName, storageName.string()); + result = zip->add(fileName, storageName.string(), + bundle->getCompressionMethod(), NULL); + } else { + printf(" '%s'...\n", fileName); + result = zip->add(fileName, bundle->getCompressionMethod(), NULL); + } } if (result != NO_ERROR) { fprintf(stderr, "Unable to add '%s' to '%s'", bundle->getFileSpecEntry(i), zipFileName); @@ -1157,6 +1166,12 @@ int doPackage(Bundle* bundle) } } + // Write out the ProGuard file + err = writeProguardFile(bundle, assets); + if (err < 0) { + goto bail; + } + // Write the apk if (outputAPKFile) { err = writeAPK(bundle, assets, String8(outputAPKFile));