summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceParser.cpp
diff options
context:
space:
mode:
authorDonald Chai <dchai@google.com>2020-01-06 13:52:41 -0800
committerDonald Chai <dchai@google.com>2020-01-07 21:17:59 -0800
commitf80d0ae89b118414e4c2f994fd684f4a47323b1a (patch)
tree3698709b2e5366acc8ac25bb948724ef8b57df22 /tools/aapt2/ResourceParser.cpp
parent8ab35ca19d8db831a61c7c0c720ab42aadc7ff52 (diff)
Add option to avoid clobbering visibility of <declare-styleable>
"aapt2 compile" marks styleables as public instead of preserving information from <public/> or --visibility options. This behavior can now be disabled via --preserve-visibility-of-styleables. Bug: 146649511 Change-Id: Ifb8ab396573d1393df737a59625e79e9cf2494a7 Tested: aapt2_tests
Diffstat (limited to 'tools/aapt2/ResourceParser.cpp')
-rw-r--r--tools/aapt2/ResourceParser.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 45cea8190844..40eae545c06b 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -1643,8 +1643,14 @@ bool ResourceParser::ParseDeclareStyleable(xml::XmlPullParser* parser,
ParsedResource* out_resource) {
out_resource->name.type = ResourceType::kStyleable;
- // Declare-styleable is kPrivate by default, because it technically only exists in R.java.
- out_resource->visibility_level = Visibility::Level::kPublic;
+ if (!options_.preserve_visibility_of_styleables) {
+ // This was added in change Idd21b5de4d20be06c6f8c8eb5a22ccd68afc4927 to mimic aapt1, but no one
+ // knows exactly what for.
+ //
+ // FWIW, styleables only appear in generated R classes. For custom views these should always be
+ // package-private (to be used only by the view class); themes are a different story.
+ out_resource->visibility_level = Visibility::Level::kPublic;
+ }
// Declare-styleable only ends up in default config;
if (out_resource->config != ConfigDescription::DefaultConfig()) {