diff
--git a
/tools/aapt/AaptAssets
.cpp b
/tools/aapt/AaptAssets
.cpp
index d8e113a..68cfcce 100644
--- a
/tools/aapt/AaptAssets
.cpp
+++ b
/tools/aapt/AaptAssets
.cpp
@@ -1976,6 +1976,8 @@ status_t AaptSymbols::applyJavaSymbols(const sp<AaptSymbols>& javaSymbols)
return
err;
}
+bool AaptSymbols::mIgnoreKeywords =
false
;
+
//
=========================================================================
//
=========================================================================
//
=========================================================================
diff
--git a
/tools/aapt/AaptAssets
.h b
/tools/aapt/AaptAssets
.h
index 5cfa913..731acb7 100644
--- a
/tools/aapt/AaptAssets
.h
+++ b
/tools/aapt/AaptAssets
.h
@@ -377,9 +377,18 @@ public:
class AaptSymbols : public RefBase
{
public:
- AaptSymbols() { }
+ AaptSymbols() {
+ const char* p = getenv(
"AAPT_IGNORE_KEYWORDS"
);
+
if
(p && p[0]){
+ setIgnoreKeywords(
true
);
+ }
+ }
virtual ~AaptSymbols() { }
+ static void setIgnoreKeywords(bool value) {
+ mIgnoreKeywords = value;
+ }
+
status_t addSymbol(const String8& name, int32_t value, const SourcePos& pos) {
if
(!check_valid_symbol_name(name, pos,
"symbol"
)) {
return
BAD_VALUE;
@@ -473,7 +482,7 @@ public:
private:
bool check_valid_symbol_name(const String8& symbol, const SourcePos& pos, const char* label) {
-
if
(valid_symbol_name(symbol)) {
+
if
(mIgnoreKeywords || valid_symbol_name(symbol)) {
return
true
;
}
pos.error(
"invalid %s: '%s'\n"
, label, symbol.string());
@@ -498,6 +507,7 @@ private:
return
mDefSymbol;
}
+ static bool mIgnoreKeywords;
KeyedVector<String8, AaptSymbolEntry> mSymbols;
DefaultKeyedVector<String8, sp<AaptSymbols> > mNestedSymbols;
AaptSymbolEntry mDefSymbol;
diff
--git a
/tools/aapt/Main
.cpp b
/tools/aapt/Main
.cpp
index 977226b..fae19b1 100644
--- a
/tools/aapt/Main
.cpp
+++ b
/tools/aapt/Main
.cpp
@@ -59,6 +59,7 @@ void usage(void)
" %s p[ackage] [-d][-f][-m][-u][-v][-x][-z][-M AndroidManifest.xml] \\\n"
" [-0 extension [-0 extension ...]] [-g tolerance] [-j jarfile] \\\n"
" [--debug-mode] [--min-sdk-version VAL] [--target-sdk-version VAL] \\\n"
+
" [--ignore-keywords] \\\n"
" [--app-version VAL] [--app-version-name TEXT] [--custom-package VAL] \\\n"
" [--rename-manifest-package PACKAGE] \\\n"
" [--rename-instrumentation-target-package PACKAGE] \\\n"
@@ -138,6 +139,9 @@ void usage(void)
" --debug-mode\n"
" inserts android:debuggable=\"true\" in to the application node of the\n"
" manifest, making the application debuggable even on production devices.\n"
+
" --ignore-keywords\n"
+
" allows to use Java keywords in resource symbols. Set enviroment\n"
+
" variable \"AAPT_IGNORE_KEYWORDS\" can also enable this feature.\n"
" --min-sdk-version\n"
" inserts android:minSdkVersion in to manifest. If the version is 7 or\n"
" higher, the default encoding for resources will be in UTF-8.\n"
@@ -474,6 +478,8 @@ int main(int argc, char* const argv[])
case
'-'
:
if
(strcmp(
cp
,
"-debug-mode"
) == 0) {
bundle.setDebugMode(
true
);
+ }
else
if
(strcmp(
cp
,
"-ignore-keywords"
) == 0) {
+ AaptSymbols::setIgnoreKeywords(
true
);
}
else
if
(strcmp(
cp
,
"-min-sdk-version"
) == 0) {
argc--;
argv++;