AAPT2: normalize Manifest java identifiers.
Currently AAPT2 does not allow permissions which last piece contains the
"-" symbol (since it is an illegal character for a java identifier).
AAPT1 would normalize the last piece, therefore creating a valid java
identifier.
This CL makes AAPT2 behave in a similar way to AAPT1, but instead of
modifying the original value of the permission string, modifies only the
java identifier part, leaving the permission string unchanged.
Fixes: 72980877
Test: updated
Change-Id: Ie44317e07407341ba3e91a84d9b06980547b3448
diff --git a/tools/aapt2/java/ManifestClassGenerator.cpp b/tools/aapt2/java/ManifestClassGenerator.cpp
index c4b3617..be67c9c 100644
--- a/tools/aapt2/java/ManifestClassGenerator.cpp
+++ b/tools/aapt2/java/ManifestClassGenerator.cpp
@@ -21,6 +21,7 @@
#include "Source.h"
#include "java/AnnotationProcessor.h"
#include "java/ClassDefinition.h"
+#include "java/JavaClassGenerator.h"
#include "text/Unicode.h"
#include "util/Maybe.h"
#include "xml/XmlDom.h"
@@ -38,6 +39,11 @@
result = result.substr(pos + 1);
}
+ // Normalize only the java identifier, leave the original value unchanged.
+ if (result.contains("-")) {
+ result = JavaClassGenerator::TransformToFieldName(result);
+ }
+
if (result.empty()) {
diag->Error(DiagMessage(source) << "empty symbol");
return {};