Have styleable indices be non-final for library projects
Invoking aapt after merging resources from a library project
may yield a different ordering to styleable arrays, so have
the indices be non-final too.
Bug:16842410
Change-Id: I0432bea03dc4312d5908a770fc70a11f0a1596ae
diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp
index 4f1d15e..ec284c5 100644
--- a/tools/aapt/Resource.cpp
+++ b/tools/aapt/Resource.cpp
@@ -1739,7 +1739,7 @@
static status_t writeLayoutClasses(
FILE* fp, const sp<AaptAssets>& assets,
- const sp<AaptSymbols>& symbols, int indent, bool includePrivate)
+ const sp<AaptSymbols>& symbols, int indent, bool includePrivate, bool nonConstantId)
{
const char* indentStr = getIndentSpace(indent);
if (!includePrivate) {
@@ -1957,8 +1957,13 @@
getSymbolName(name8).string());
fprintf(fp, "%s*/\n", indentStr);
ann.printAnnotations(fp, indentStr);
+
+ const char * id_format = nonConstantId ?
+ "%spublic static int %s_%s = %d;\n" :
+ "%spublic static final int %s_%s = %d;\n";
+
fprintf(fp,
- "%spublic static final int %s_%s = %d;\n",
+ id_format,
indentStr, nclassName.string(),
flattenSymbol(name8).string(), (int)pos);
}
@@ -2177,7 +2182,7 @@
}
if (styleableSymbols != NULL) {
- err = writeLayoutClasses(fp, assets, styleableSymbols, indent, includePrivate);
+ err = writeLayoutClasses(fp, assets, styleableSymbols, indent, includePrivate, nonConstantId);
if (err != NO_ERROR) {
return err;
}