X-Git-Url: https://git.saurik.com/android/aapt.git/blobdiff_plain/1f18df61cc6c370866e8dbb3fdac78ce18a2574e..b5a473dad502a67a09d3978b455dc4cbfafcc920:/Command.cpp diff --git a/Command.cpp b/Command.cpp index 873ebac..8447d74 100644 --- a/Command.cpp +++ b/Command.cpp @@ -332,13 +332,15 @@ enum { REQ_FIVE_WAY_NAV_ATTR = 0x01010232, TARGET_SDK_VERSION_ATTR = 0x01010270, TEST_ONLY_ATTR = 0x01010272, - DENSITY_ATTR = 0x0101026c, + ANY_DENSITY_ATTR = 0x0101026c, GL_ES_VERSION_ATTR = 0x01010281, SMALL_SCREEN_ATTR = 0x01010284, NORMAL_SCREEN_ATTR = 0x01010285, LARGE_SCREEN_ATTR = 0x01010286, XLARGE_SCREEN_ATTR = 0x010102bf, REQUIRED_ATTR = 0x0101028e, + SCREEN_SIZE_ATTR = 0x010102ca, + SCREEN_DENSITY_ATTR = 0x010102cb, }; const char *getComponentName(String8 &pkgName, String8 &componentName) { @@ -355,6 +357,42 @@ const char *getComponentName(String8 &pkgName, String8 &componentName) { return retStr.string(); } +static void printCompatibleScreens(ResXMLTree& tree) { + size_t len; + ResXMLTree::event_code_t code; + int depth = 0; + bool first = true; + printf("compatible-screens:"); + while ((code=tree.next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { + if (code == ResXMLTree::END_TAG) { + depth--; + if (depth < 0) { + break; + } + continue; + } + if (code != ResXMLTree::START_TAG) { + continue; + } + depth++; + String8 tag(tree.getElementName(&len)); + if (tag == "screen") { + int32_t screenSize = getIntegerAttribute(tree, + SCREEN_SIZE_ATTR, NULL, -1); + int32_t screenDensity = getIntegerAttribute(tree, + SCREEN_DENSITY_ATTR, NULL, -1); + if (screenSize > 0 && screenDensity > 0) { + if (!first) { + printf(","); + } + first = false; + printf("'%d/%d'", screenSize, screenDensity); + } + } + } + printf("\n"); +} + /* * Handle the "dump" command, to extract select data from an archive. */ @@ -572,6 +610,7 @@ int doDump(Bundle* bundle) int normalScreen = 1; int largeScreen = 1; int xlargeScreen = 1; + int anyDensity = 1; String8 pkg; String8 activityName; String8 activityLabel; @@ -739,14 +778,6 @@ int doDump(Bundle* bundle) printf(" reqFiveWayNav='%d'", reqFiveWayNav); } printf("\n"); - } else if (tag == "supports-density") { - int32_t dens = getIntegerAttribute(tree, DENSITY_ATTR, &error); - if (error != "") { - fprintf(stderr, "ERROR getting 'android:density' attribute: %s\n", - error.string()); - goto bail; - } - printf("supports-density:'%d'\n", dens); } else if (tag == "supports-screens") { smallScreen = getIntegerAttribute(tree, SMALL_SCREEN_ATTR, NULL, 1); @@ -756,6 +787,8 @@ int doDump(Bundle* bundle) LARGE_SCREEN_ATTR, NULL, 1); xlargeScreen = getIntegerAttribute(tree, XLARGE_SCREEN_ATTR, NULL, 1); + anyDensity = getIntegerAttribute(tree, + ANY_DENSITY_ATTR, NULL, 1); } else if (tag == "uses-feature") { String8 name = getAttribute(tree, NAME_ATTR, &error); @@ -871,15 +904,18 @@ int doDump(Bundle* bundle) error.string()); goto bail; } - } else if (tag == "uses-gl-texture") { + } else if (tag == "supports-gl-texture") { String8 name = getAttribute(tree, NAME_ATTR, &error); if (name != "" && error == "") { - printf("uses-gl-texture:'%s'\n", name.string()); + printf("supports-gl-texture:'%s'\n", name.string()); } else { fprintf(stderr, "ERROR getting 'android:name' attribute: %s\n", error.string()); goto bail; } + } else if (tag == "compatible-screens") { + printCompatibleScreens(tree); + depth--; } } else if (depth == 3 && withinApplication) { withinActivity = false; @@ -1103,8 +1139,11 @@ int doDump(Bundle* bundle) largeScreen = targetSdk >= 4 ? -1 : 0; } if (xlargeScreen > 0) { - // Introduced in Honeycomb. - xlargeScreen = targetSdk >= 10 ? -1 : 0; + // Introduced in Gingerbread. + xlargeScreen = targetSdk >= 9 ? -1 : 0; + } + if (anyDensity > 0) { + anyDensity = targetSdk >= 4 ? -1 : 0; } printf("supports-screens:"); if (smallScreen != 0) printf(" 'small'"); @@ -1113,6 +1152,8 @@ int doDump(Bundle* bundle) if (xlargeScreen != 0) printf(" 'xlarge'"); printf("\n"); + printf("supports-any-density: '%s'\n", anyDensity ? "true" : "false"); + printf("locales:"); Vector locales; res.getLocales(&locales); @@ -1312,6 +1353,8 @@ int doPackage(Bundle* bundle) status_t err; sp assets; int N; + FILE* fp; + String8 dependencyFile; // -c zz_ZZ means do pseudolocalization ResourceFilter filter; @@ -1346,6 +1389,16 @@ int doPackage(Bundle* bundle) // Load the assets. assets = new AaptAssets(); + + // Set up the resource gathering in assets if we're going to generate + // dependency files + if (bundle->getGenDependencies()) { + sp resPathStore = new FilePathStore; + assets->setFullResPaths(resPathStore); + sp assetPathStore = new FilePathStore; + assets->setFullAssetPaths(assetPathStore); + } + err = assets->slurpFromArgs(bundle); if (err < 0) { goto bail; @@ -1355,7 +1408,7 @@ int doPackage(Bundle* bundle) assets->print(); } - // If they asked for any files that need to be compiled, do so. + // If they asked for any fileAs that need to be compiled, do so. if (bundle->getResourceSourceDirs().size() || bundle->getAndroidManifestFile()) { err = buildResources(bundle, assets); if (err != 0) { @@ -1369,10 +1422,36 @@ int doPackage(Bundle* bundle) goto bail; } + if (bundle->getGenDependencies()) { + if (outputAPKFile) { + dependencyFile = String8(outputAPKFile); + // Strip the extension and add new one + dependencyFile = dependencyFile.getBasePath(); + dependencyFile.append(".d"); + } else { + dependencyFile = String8(bundle->getRClassDir()); + dependencyFile.appendPath("R.d"); + } + // Make sure we have a clean dependency file to start with + fp = fopen(dependencyFile, "w"); + fclose(fp); + } + // Write out R.java constants if (assets->getPackage() == assets->getSymbolsPrivatePackage()) { if (bundle->getCustomPackage() == NULL) { err = writeResourceSymbols(bundle, assets, assets->getPackage(), true); + // Copy R.java for libraries + if (bundle->getExtraPackages() != NULL) { + // Split on colon + String8 libs(bundle->getExtraPackages()); + char* packageString = strtok(libs.lockBuffer(libs.length()), ":"); + while (packageString != NULL) { + err = writeResourceSymbols(bundle, assets, String8(packageString), true); + packageString = strtok(NULL, ":"); + } + libs.unlockBuffer(); + } } else { const String8 customPkg(bundle->getCustomPackage()); err = writeResourceSymbols(bundle, assets, customPkg, true); @@ -1406,6 +1485,18 @@ int doPackage(Bundle* bundle) } } + if (bundle->getGenDependencies()) { + // Now that writeResourceSymbols or writeAPK has taken care of writing + // the targets to our dependency file, we'll write the prereqs + fp = fopen(dependencyFile, "a+"); + fprintf(fp, " : "); + bool includeRaw = (outputAPKFile != NULL); + err = writeDependencyPreReqs(bundle, assets, fp, includeRaw); + // Also manually add the AndroidManifeset since it's a non-asset + fprintf(fp, "%s \\\n", bundle->getAndroidManifestFile()); + fclose(fp); + } + retVal = 0; bail: if (SourcePos::hasErrors()) {