AAPT2: Process <java-symbols> and private symbol package
Need to introduce the idea of multiple levels of visibility to support <java-symbol>.
Public, Private, Undefined.
Public means it is accessible from outside and requires an ID assigned.
Private means that we explicitly want this to be a symbol (show up in R.java), but not visible
to other packages. No ID required.
Undefined is any normal resource. When --private-symbols is specified in the link phase,
these resources will not show up in R.java.
Change-Id: Icba89221e08e685dee7683786aa7112baf28c856
diff --git a/tools/aapt2/unflatten/BinaryResourceParser.cpp b/tools/aapt2/unflatten/BinaryResourceParser.cpp
index ac91865..c7a715e 100644
--- a/tools/aapt2/unflatten/BinaryResourceParser.cpp
+++ b/tools/aapt2/unflatten/BinaryResourceParser.cpp
@@ -429,7 +429,19 @@
source.line = util::deviceToHost32(entry->sourceLine);
}
- if (!mTable->markPublicAllowMangled(name, resId, source, mContext->getDiagnostics())) {
+ SymbolState state = SymbolState::kUndefined;
+ switch (util::deviceToHost16(entry->state)) {
+ case Public_entry::kPrivate:
+ state = SymbolState::kPrivate;
+ break;
+
+ case Public_entry::kPublic:
+ state = SymbolState::kPublic;
+ break;
+ }
+
+ if (!mTable->setSymbolStateAllowMangled(name, resId, source, state,
+ mContext->getDiagnostics())) {
return false;
}
@@ -564,8 +576,9 @@
}
if ((entry->flags & ResTable_entry::FLAG_PUBLIC) != 0) {
- if (!mTable->markPublicAllowMangled(name, resId, mSource.withLine(0),
- mContext->getDiagnostics())) {
+ if (!mTable->setSymbolStateAllowMangled(name, resId, mSource.withLine(0),
+ SymbolState::kPublic,
+ mContext->getDiagnostics())) {
return false;
}
}