diff options
Diffstat (limited to 'tools/aapt')
-rw-r--r-- | tools/aapt/AaptAssets.cpp | 50 | ||||
-rw-r--r-- | tools/aapt/AaptAssets.h | 8 | ||||
-rw-r--r-- | tools/aapt/Android.mk | 7 | ||||
-rw-r--r-- | tools/aapt/Bundle.h | 6 | ||||
-rw-r--r-- | tools/aapt/Command.cpp | 44 | ||||
-rw-r--r-- | tools/aapt/Images.cpp | 48 | ||||
-rw-r--r-- | tools/aapt/Main.cpp | 2 | ||||
-rw-r--r-- | tools/aapt/Resource.cpp | 44 | ||||
-rw-r--r-- | tools/aapt/ResourceTable.cpp | 18 |
9 files changed, 141 insertions, 86 deletions
diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp index d8e113a..729a048 100644 --- a/tools/aapt/AaptAssets.cpp +++ b/tools/aapt/AaptAssets.cpp @@ -1117,6 +1117,11 @@ bool AaptGroupEntry::getUiModeTypeName(const char* name, (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE) | ResTable_config::UI_MODE_TYPE_APPLIANCE; return true; + } else if (strcmp(name, "watch") == 0) { + if (out) out->uiMode = + (out->uiMode&~ResTable_config::MASK_UI_MODE_TYPE) + | ResTable_config::UI_MODE_TYPE_WATCH; + return true; } return false; @@ -1631,9 +1636,18 @@ String8 AaptFile::getPrintableSource() const // ========================================================================= // ========================================================================= -status_t AaptGroup::addFile(const sp<AaptFile>& file) +status_t AaptGroup::addFile(const sp<AaptFile>& file, const bool overwriteDuplicate) { - if (mFiles.indexOfKey(file->getGroupEntry()) < 0) { + ssize_t index = mFiles.indexOfKey(file->getGroupEntry()); + if (index >= 0 && overwriteDuplicate) { + fprintf(stderr, "warning: overwriting '%s' with '%s'\n", + mFiles[index]->getSourceFile().string(), + file->getSourceFile().string()); + removeFile(index); + index = -1; + } + + if (index < 0) { file->mPath = mPath; mFiles.add(file->getGroupEntry(), file); return NO_ERROR; @@ -1739,7 +1753,8 @@ void AaptDir::removeDir(const String8& name) mDirs.removeItem(name); } -status_t AaptDir::addLeafFile(const String8& leafName, const sp<AaptFile>& file) +status_t AaptDir::addLeafFile(const String8& leafName, const sp<AaptFile>& file, + const bool overwrite) { sp<AaptGroup> group; if (mFiles.indexOfKey(leafName) >= 0) { @@ -1749,12 +1764,12 @@ status_t AaptDir::addLeafFile(const String8& leafName, const sp<AaptFile>& file) mFiles.add(leafName, group); } - return group->addFile(file); + return group->addFile(file, overwrite); } ssize_t AaptDir::slurpFullTree(Bundle* bundle, const String8& srcDir, const AaptGroupEntry& kind, const String8& resType, - sp<FilePathStore>& fullResPaths) + sp<FilePathStore>& fullResPaths, const bool overwrite) { Vector<String8> fileNames; { @@ -1813,7 +1828,7 @@ ssize_t AaptDir::slurpFullTree(Bundle* bundle, const String8& srcDir, notAdded = true; } ssize_t res = subdir->slurpFullTree(bundle, pathName, kind, - resType, fullResPaths); + resType, fullResPaths, overwrite); if (res < NO_ERROR) { return res; } @@ -1823,7 +1838,7 @@ ssize_t AaptDir::slurpFullTree(Bundle* bundle, const String8& srcDir, count += res; } else if (type == kFileTypeRegular) { sp<AaptFile> file = new AaptFile(pathName, kind, resType); - status_t err = addLeafFile(fileNames[i], file); + status_t err = addLeafFile(fileNames[i], file, overwrite); if (err != NO_ERROR) { return err; } @@ -2089,24 +2104,24 @@ ssize_t AaptAssets::slurpFromArgs(Bundle* bundle) /* * If a directory of custom assets was supplied, slurp 'em up. */ - if (bundle->getAssetSourceDir()) { - const char* assetDir = bundle->getAssetSourceDir(); - - FileType type = getFileType(assetDir); + const Vector<const char*>& assetDirs = bundle->getAssetSourceDirs(); + const int AN = assetDirs.size(); + for (int i = 0; i < AN; i++) { + FileType type = getFileType(assetDirs[i]); if (type == kFileTypeNonexistent) { - fprintf(stderr, "ERROR: asset directory '%s' does not exist\n", assetDir); + fprintf(stderr, "ERROR: asset directory '%s' does not exist\n", assetDirs[i]); return UNKNOWN_ERROR; } if (type != kFileTypeDirectory) { - fprintf(stderr, "ERROR: '%s' is not a directory\n", assetDir); + fprintf(stderr, "ERROR: '%s' is not a directory\n", assetDirs[i]); return UNKNOWN_ERROR; } - String8 assetRoot(assetDir); + String8 assetRoot(assetDirs[i]); sp<AaptDir> assetAaptDir = makeDir(String8(kAssetDir)); AaptGroupEntry group; count = assetAaptDir->slurpFullTree(bundle, assetRoot, group, - String8(), mFullAssetPaths); + String8(), mFullAssetPaths, true); if (count < 0) { totalCount = count; goto bail; @@ -2116,9 +2131,10 @@ ssize_t AaptAssets::slurpFromArgs(Bundle* bundle) } totalCount += count; - if (bundle->getVerbose()) + if (bundle->getVerbose()) { printf("Found %d custom asset file%s in %s\n", - count, (count==1) ? "" : "s", assetDir); + count, (count==1) ? "" : "s", assetDirs[i]); + } } /* diff --git a/tools/aapt/AaptAssets.h b/tools/aapt/AaptAssets.h index 5cfa913..9cc9007 100644 --- a/tools/aapt/AaptAssets.h +++ b/tools/aapt/AaptAssets.h @@ -235,7 +235,7 @@ public: const DefaultKeyedVector<AaptGroupEntry, sp<AaptFile> >& getFiles() const { return mFiles; } - status_t addFile(const sp<AaptFile>& file); + status_t addFile(const sp<AaptFile>& file, const bool overwriteDuplicate=false); void removeFile(size_t index); void print(const String8& prefix) const; @@ -301,12 +301,14 @@ private: status_t addDir(const String8& name, const sp<AaptDir>& dir); sp<AaptDir> makeDir(const String8& name); status_t addLeafFile(const String8& leafName, - const sp<AaptFile>& file); + const sp<AaptFile>& file, + const bool overwrite=false); virtual ssize_t slurpFullTree(Bundle* bundle, const String8& srcDir, const AaptGroupEntry& kind, const String8& resType, - sp<FilePathStore>& fullResPaths); + sp<FilePathStore>& fullResPaths, + const bool overwrite=false); String8 mLeaf; String8 mPath; diff --git a/tools/aapt/Android.mk b/tools/aapt/Android.mk index 452c60a..806f8ff 100644 --- a/tools/aapt/Android.mk +++ b/tools/aapt/Android.mk @@ -5,7 +5,7 @@ # # This tool is prebuilt if we're doing an app-only build. -ifeq ($(TARGET_BUILD_APPS),) +ifeq ($(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)),) aapt_src_files := \ @@ -50,7 +50,8 @@ LOCAL_STATIC_LIBRARIES := \ libcutils \ libexpat \ libpng \ - liblog + liblog \ + libziparchive-host ifeq ($(HOST_OS),linux) LOCAL_LDLIBS += -lrt -ldl -lpthread @@ -100,4 +101,4 @@ LOCAL_STATIC_LIBRARIES := \ include $(BUILD_EXECUTABLE) endif -endif # TARGET_BUILD_APPS +endif # No TARGET_BUILD_APPS or TARGET_BUILD_PDK diff --git a/tools/aapt/Bundle.h b/tools/aapt/Bundle.h index 5089b9d..26b10a6 100644 --- a/tools/aapt/Bundle.h +++ b/tools/aapt/Bundle.h @@ -55,7 +55,6 @@ public: mCompressionMethod(0), mJunkPath(false), mOutputAPKFile(NULL), mManifestPackageNameOverride(NULL), mInstrumentationPackageNameOverride(NULL), mAutoAddOverlay(false), mGenDependencies(false), - mAssetSourceDir(NULL), mCrunchedOutputDir(NULL), mProguardFile(NULL), mAndroidManifestFile(NULL), mPublicOutputFile(NULL), mRClassDir(NULL), mResourceIntermediatesDir(NULL), mManifestMinSdkVersion(NULL), @@ -123,8 +122,8 @@ public: /* * Input options. */ - const char* getAssetSourceDir() const { return mAssetSourceDir; } - void setAssetSourceDir(const char* dir) { mAssetSourceDir = dir; } + const android::Vector<const char*>& getAssetSourceDirs() const { return mAssetSourceDirs; } + void addAssetSourceDir(const char* dir) { mAssetSourceDirs.insertAt(dir,0); } const char* getCrunchedOutputDir() const { return mCrunchedOutputDir; } void setCrunchedOutputDir(const char* dir) { mCrunchedOutputDir = dir; } const char* getProguardFile() const { return mProguardFile; } @@ -272,6 +271,7 @@ private: android::Vector<const char*> mPackageIncludes; android::Vector<const char*> mJarFiles; android::Vector<const char*> mNoCompressExtensions; + android::Vector<const char*> mAssetSourceDirs; android::Vector<const char*> mResourceSourceDirs; const char* mManifestMinSdkVersion; diff --git a/tools/aapt/Command.cpp b/tools/aapt/Command.cpp index 632efe0..d9e2dc5 100644 --- a/tools/aapt/Command.cpp +++ b/tools/aapt/Command.cpp @@ -375,6 +375,7 @@ enum { LARGEST_WIDTH_LIMIT_DP_ATTR = 0x01010366, PUBLIC_KEY_ATTR = 0x010103a6, CATEGORY_ATTR = 0x010103e8, + BANNER_ATTR = 0x10103f2, }; const char *getComponentName(String8 &pkgName, String8 &componentName) { @@ -505,7 +506,7 @@ int doDump(Bundle* bundle) const char* filename = bundle->getFileSpecEntry(1); AssetManager assets; - void* assetsCookie; + int32_t assetsCookie; if (!assets.addAssetPath(String8(filename), &assetsCookie)) { fprintf(stderr, "ERROR: dump failed because assets could not be loaded\n"); return 1; @@ -677,6 +678,7 @@ int doDump(Bundle* bundle) bool withinActivity = false; bool isMainActivity = false; bool isLauncherActivity = false; + bool isLeanbackLauncherActivity = false; bool isSearchable = false; bool withinApplication = false; bool withinSupportsInput = false; @@ -787,6 +789,7 @@ int doDump(Bundle* bundle) String8 activityName; String8 activityLabel; String8 activityIcon; + String8 activityBanner; String8 receiverName; String8 serviceName; Vector<String8> supportedInput; @@ -810,15 +813,27 @@ int doDump(Bundle* bundle) withinApplication = false; withinSupportsInput = false; } else if (depth < 3) { - if (withinActivity && isMainActivity && isLauncherActivity) { + if (withinActivity && isMainActivity) { const char *aName = getComponentName(pkg, activityName); - printf("launchable-activity:"); - if (aName != NULL) { - printf(" name='%s' ", aName); + if (isLauncherActivity) { + printf("launchable-activity:"); + if (aName != NULL) { + printf(" name='%s' ", aName); + } + printf(" label='%s' icon='%s'\n", + activityLabel.string(), + activityIcon.string()); + } + if (isLeanbackLauncherActivity) { + printf("leanback-launchable-activity:"); + if (aName != NULL) { + printf(" name='%s' ", aName); + } + printf(" label='%s' icon='%s' banner='%s'\n", + activityLabel.string(), + activityIcon.string(), + activityBanner.string()); } - printf(" label='%s' icon='%s'\n", - activityLabel.string(), - activityIcon.string()); } if (!hasIntentFilter) { hasOtherActivities |= withinActivity; @@ -836,7 +851,7 @@ int doDump(Bundle* bundle) withinService = false; withinReceiver = false; hasIntentFilter = false; - isMainActivity = isLauncherActivity = false; + isMainActivity = isLauncherActivity = isLeanbackLauncherActivity = false; } else if (depth < 4) { if (withinIntentFilter) { if (withinActivity) { @@ -1231,6 +1246,13 @@ int doDump(Bundle* bundle) goto bail; } + activityBanner = getResolvedAttribute(&res, tree, BANNER_ATTR, &error); + if (error != "") { + fprintf(stderr, "ERROR getting 'android:banner' attribute: %s\n", + error.string()); + goto bail; + } + int32_t orien = getResolvedIntegerAttribute(&res, tree, SCREEN_ORIENTATION_ATTR, &error); if (error == "") { @@ -1412,6 +1434,8 @@ int doDump(Bundle* bundle) if (withinActivity) { if (category == "android.intent.category.LAUNCHER") { isLauncherActivity = true; + } else if (category == "android.intent.category.LEANBACK_LAUNCHER") { + isLeanbackLauncherActivity = true; } } } @@ -1896,7 +1920,7 @@ int doPackage(Bundle* bundle) N = bundle->getFileSpecCount(); if (N < 1 && bundle->getResourceSourceDirs().size() == 0 && bundle->getJarFiles().size() == 0 - && bundle->getAndroidManifestFile() == NULL && bundle->getAssetSourceDir() == NULL) { + && bundle->getAndroidManifestFile() == NULL && bundle->getAssetSourceDirs().size() == 0) { fprintf(stderr, "ERROR: no input files\n"); goto bail; } diff --git a/tools/aapt/Images.cpp b/tools/aapt/Images.cpp index 9de685a..25a948d 100644 --- a/tools/aapt/Images.cpp +++ b/tools/aapt/Images.cpp @@ -12,13 +12,15 @@ #include <utils/ByteOrder.h> #include <png.h> +#include <zlib.h> #define NOISY(x) //x static void png_write_aapt_file(png_structp png_ptr, png_bytep data, png_size_t length) { - status_t err = ((AaptFile*)png_ptr->io_ptr)->writeData(data, length); + AaptFile* aaptfile = (AaptFile*) png_get_io_ptr(png_ptr); + status_t err = aaptfile->writeData(data, length); if (err != NO_ERROR) { png_error(png_ptr, "Write Error"); } @@ -90,7 +92,7 @@ static void read_png(const char* imageName, png_set_palette_to_rgb(read_ptr); if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(read_ptr); + png_set_expand_gray_1_2_4_to_8(read_ptr); if (png_get_valid(read_ptr, read_info, PNG_INFO_tRNS)) { //printf("Has PNG_INFO_tRNS!\n"); @@ -109,7 +111,7 @@ static void read_png(const char* imageName, png_read_update_info(read_ptr, read_info); outImageInfo->rows = (png_bytepp)malloc( - outImageInfo->height * png_sizeof(png_bytep)); + outImageInfo->height * sizeof(png_bytep)); outImageInfo->allocHeight = outImageInfo->height; outImageInfo->allocRows = outImageInfo->rows; @@ -450,10 +452,11 @@ static status_t do_9patch(const char* imageName, image_info* image) int maxSizeXDivs = W * sizeof(int32_t); int maxSizeYDivs = H * sizeof(int32_t); - int32_t* xDivs = (int32_t*) malloc(maxSizeXDivs); - int32_t* yDivs = (int32_t*) malloc(maxSizeYDivs); - uint8_t numXDivs = 0; - uint8_t numYDivs = 0; + int32_t* xDivs = image->info9Patch.xDivs = (int32_t*) malloc(maxSizeXDivs); + int32_t* yDivs = image->info9Patch.yDivs = (int32_t*) malloc(maxSizeYDivs); + uint8_t numXDivs = 0; + uint8_t numYDivs = 0; + int8_t numColors; int numRows; int numCols; @@ -508,6 +511,10 @@ static status_t do_9patch(const char* imageName, image_info* image) goto getout; } + // Copy patch size data into image... + image->info9Patch.numXDivs = numXDivs; + image->info9Patch.numYDivs = numYDivs; + // Find left and right of padding area... if (get_horizontal_ticks(image->rows[H-1], W, transparent, false, &image->info9Patch.paddingLeft, &image->info9Patch.paddingRight, &errorMsg, NULL, false) != NO_ERROR) { @@ -543,12 +550,6 @@ static status_t do_9patch(const char* imageName, image_info* image) image->layoutBoundsRight, image->layoutBoundsBottom)); } - // Copy patch data into image - image->info9Patch.numXDivs = numXDivs; - image->info9Patch.numYDivs = numYDivs; - image->info9Patch.xDivs = xDivs; - image->info9Patch.yDivs = yDivs; - // If padding is not yet specified, take values from size. if (image->info9Patch.paddingLeft < 0) { image->info9Patch.paddingLeft = xDivs[0]; @@ -573,7 +574,7 @@ static status_t do_9patch(const char* imageName, image_info* image) image->info9Patch.paddingTop, image->info9Patch.paddingBottom)); // Remove frame from image. - image->rows = (png_bytepp)malloc((H-2) * png_sizeof(png_bytep)); + image->rows = (png_bytepp)malloc((H-2) * sizeof(png_bytep)); for (i=0; i<(H-2); i++) { image->rows[i] = image->allocRows[i+1]; memmove(image->rows[i], image->rows[i]+4, (W-2)*4); @@ -955,7 +956,7 @@ static void analyze_image(const char *imageName, image_info &imageInfo, int gray gg = *row++; bb = *row++; aa = *row++; - + if (isGrayscale) { *out++ = rr; } else { @@ -984,7 +985,7 @@ static void write_png(const char* imageName, unknowns[0].data = NULL; unknowns[1].data = NULL; - png_bytepp outRows = (png_bytepp) malloc((int) imageInfo.height * png_sizeof(png_bytep)); + png_bytepp outRows = (png_bytepp) malloc((int) imageInfo.height * sizeof(png_bytep)); if (outRows == (png_bytepp) 0) { printf("Can't allocate output buffer!\n"); exit(1); @@ -1073,18 +1074,19 @@ static void write_png(const char* imageName, unknowns[b_index].size = chunk_size; } + for (int i = 0; i < chunk_count; i++) { + unknowns[i].location = PNG_HAVE_PLTE; + } png_set_keep_unknown_chunks(write_ptr, PNG_HANDLE_CHUNK_ALWAYS, chunk_names, chunk_count); png_set_unknown_chunks(write_ptr, write_info, unknowns, chunk_count); - // XXX I can't get this to work without forcibly changing - // the location to what I want... which apparently is supposed - // to be a private API, but everything else I have tried results - // in the location being set to what I -last- wrote so I never - // get written. :p +#if PNG_LIBPNG_VER < 10600 + /* Deal with unknown chunk location bug in 1.5.x and earlier */ png_set_unknown_chunk_location(write_ptr, write_info, 0, PNG_HAVE_PLTE); if (imageInfo.haveLayoutBounds) { png_set_unknown_chunk_location(write_ptr, write_info, 1, PNG_HAVE_PLTE); } +#endif } @@ -1092,7 +1094,9 @@ static void write_png(const char* imageName, png_bytepp rows; if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) { - png_set_filler(write_ptr, 0, PNG_FILLER_AFTER); + if (color_type == PNG_COLOR_TYPE_RGB) { + png_set_filler(write_ptr, 0, PNG_FILLER_AFTER); + } rows = imageInfo.rows; } else { rows = outRows; diff --git a/tools/aapt/Main.cpp b/tools/aapt/Main.cpp index 977226b..d1d3deb 100644 --- a/tools/aapt/Main.cpp +++ b/tools/aapt/Main.cpp @@ -345,7 +345,7 @@ int main(int argc, char* const argv[]) goto bail; } convertPath(argv[0]); - bundle.setAssetSourceDir(argv[0]); + bundle.addAssetSourceDir(argv[0]); break; case 'G': argc--; diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index 822bfa5..5865b00 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -469,7 +469,7 @@ static int validateAttr(const String8& path, const ResTable& table, value.data); return ATTR_NOT_FOUND; } - + pool = table.getTableStringBlock(strIdx); #if 0 if (pool != NULL) { @@ -705,7 +705,7 @@ bool addTagAttribute(const sp<XMLNode>& node, const char* ns8, // don't stop the build. return true; } - + node->addAttribute(ns, attr, String16(value)); return true; } @@ -756,7 +756,7 @@ status_t massageManifest(Bundle* bundle, sp<XMLNode> root) bundle->getVersionName(), errorOnFailedInsert)) { return UNKNOWN_ERROR; } - + if (bundle->getMinSdkVersion() != NULL || bundle->getTargetSdkVersion() != NULL || bundle->getMaxSdkVersion() != NULL) { @@ -765,7 +765,7 @@ status_t massageManifest(Bundle* bundle, sp<XMLNode> root) vers = XMLNode::newElement(root->getFilename(), String16(), String16("uses-sdk")); root->insertChildAt(vers, 0); } - + if (!addTagAttribute(vers, RESOURCES_ANDROID_NAMESPACE, "minSdkVersion", bundle->getMinSdkVersion(), errorOnFailedInsert)) { return UNKNOWN_ERROR; @@ -840,7 +840,7 @@ status_t massageManifest(Bundle* bundle, sp<XMLNode> root) } } } - + return NO_ERROR; } @@ -924,7 +924,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) // -------------------------------------------------------------- // resType -> leafName -> group - KeyedVector<String8, sp<ResourceTypeSet> > *resources = + KeyedVector<String8, sp<ResourceTypeSet> > *resources = new KeyedVector<String8, sp<ResourceTypeSet> >; collect_files(assets, resources); @@ -956,7 +956,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) // now go through any resource overlays and collect their files sp<AaptAssets> current = assets->getOverlay(); while(current.get()) { - KeyedVector<String8, sp<ResourceTypeSet> > *resources = + KeyedVector<String8, sp<ResourceTypeSet> > *resources = new KeyedVector<String8, sp<ResourceTypeSet> >; current->setResources(resources); collect_files(current, resources); @@ -1059,7 +1059,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) // compile resources current = assets; while(current.get()) { - KeyedVector<String8, sp<ResourceTypeSet> > *resources = + KeyedVector<String8, sp<ResourceTypeSet> > *resources = current->getResources(); ssize_t index = resources->indexOfKey(String8("values")); @@ -1068,7 +1068,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) ssize_t res; while ((res=it.next()) == NO_ERROR) { sp<AaptFile> file = it.getFile(); - res = compileResourceFile(bundle, assets, file, it.getParams(), + res = compileResourceFile(bundle, assets, file, it.getParams(), (current!=assets), &table); if (res != NO_ERROR) { hasErrors = true; @@ -1254,7 +1254,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) if (table.validateLocalizations()) { hasErrors = true; } - + if (hasErrors) { return UNKNOWN_ERROR; } @@ -1287,7 +1287,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) ResTable finalResTable; sp<AaptFile> resFile; - + if (table.hasResources()) { sp<AaptSymbols> symbols = assets->getSymbolsFor(String8("R")); err = table.addSymbols(symbols); @@ -1319,10 +1319,10 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) table.writePublicDefinitions(String16(assets->getPackage()), fp); fclose(fp); } - + // Read resources back in, finalResTable.add(resFile->getData(), resFile->getSize(), NULL); - + #if 0 NOISY( printf("Generated resources:\n"); @@ -1330,7 +1330,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) ) #endif } - + // Perform a basic validation of the manifest file. This time we // parse it with the comments intact, so that we can use them to // generate java docs... so we are not going to write this one @@ -1425,7 +1425,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) ssize_t index = block.indexOfAttribute(RESOURCES_ANDROID_NAMESPACE, "name"); const uint16_t* id = block.getAttributeStringValue(index, &len); if (id == NULL) { - fprintf(stderr, "%s:%d: missing name attribute in element <%s>.\n", + fprintf(stderr, "%s:%d: missing name attribute in element <%s>.\n", manifestPath.string(), block.getLineNumber(), String8(block.getElementName(&len)).string()); hasErrors = true; @@ -1583,7 +1583,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) return err; } } - + return err; } @@ -1705,7 +1705,7 @@ static status_t writeLayoutClasses( NA = idents.size(); bool deprecated = false; - + String16 comment = symbols->getComment(realClassName); fprintf(fp, "%s/** ", indentStr); if (comment.size() > 0) { @@ -1788,7 +1788,7 @@ static status_t writeLayoutClasses( if (deprecated) { fprintf(fp, "%s@Deprecated\n", indentStr); } - + fprintf(fp, "%spublic static final int[] %s = {\n" "%s", @@ -1833,9 +1833,9 @@ static status_t writeLayoutClasses( //printf("%s:%s/%s: 0x%08x\n", String8(package16).string(), // String8(attr16).string(), String8(name16).string(), typeSpecFlags); const bool pub = (typeSpecFlags&ResTable_typeSpec::SPEC_PUBLIC) != 0; - + bool deprecated = false; - + fprintf(fp, "%s/**\n", indentStr); if (comment.size() > 0) { String8 cmt(comment); @@ -2220,10 +2220,10 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets, status_t err = writeSymbolClass(fp, assets, includePrivate, symbols, className, 0, bundle->getNonConstantId()); + fclose(fp); if (err != NO_ERROR) { return err; } - fclose(fp); if (textSymbolsDest != NULL && R == className) { String8 textDest(textSymbolsDest); @@ -2242,10 +2242,10 @@ status_t writeResourceSymbols(Bundle* bundle, const sp<AaptAssets>& assets, status_t err = writeTextSymbolClass(fp, assets, includePrivate, symbols, className); + fclose(fp); if (err != NO_ERROR) { return err; } - fclose(fp); } // If we were asked to generate a dependency file, we'll go ahead and add this R.java diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp index f2e5254..6ced8b3 100644 --- a/tools/aapt/ResourceTable.cpp +++ b/tools/aapt/ResourceTable.cpp @@ -1342,7 +1342,7 @@ status_t compileResourceFile(Bundle* bundle, curType = string16; curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_STRING; curIsStyled = true; - curIsPseudolocalizable = true; + curIsPseudolocalizable = (translatable != false16); } else if (strcmp16(block.getElementName(&len), drawable16.string()) == 0) { curTag = &drawable16; curType = drawable16; @@ -1408,15 +1408,24 @@ status_t compileResourceFile(Bundle* bundle, // Check whether these strings need valid formats. // (simplified form of what string16 does above) size_t n = block.getAttributeCount(); + + // Pseudolocalizable by default, unless this string array isn't + // translatable. + curIsPseudolocalizable = true; for (size_t i = 0; i < n; i++) { size_t length; const uint16_t* attr = block.getAttributeName(i, &length); - if (strcmp16(attr, translatable16.string()) == 0 - || strcmp16(attr, formatted16.string()) == 0) { + if (strcmp16(attr, translatable16.string()) == 0) { + const uint16_t* value = block.getAttributeStringValue(i, &length); + if (strcmp16(value, false16.string()) == 0) { + curIsPseudolocalizable = false; + } + } + + if (strcmp16(attr, formatted16.string()) == 0) { const uint16_t* value = block.getAttributeStringValue(i, &length); if (strcmp16(value, false16.string()) == 0) { curIsFormatted = false; - break; } } } @@ -1426,7 +1435,6 @@ status_t compileResourceFile(Bundle* bundle, curFormat = ResTable_map::TYPE_REFERENCE|ResTable_map::TYPE_STRING; curIsBag = true; curIsBagReplaceOnOverwrite = true; - curIsPseudolocalizable = true; } else if (strcmp16(block.getElementName(&len), integer_array16.string()) == 0) { curTag = &integer_array16; curType = array16; |