summaryrefslogtreecommitdiff
path: root/tools/aapt2/format/binary/BinaryResourceParser.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2021-03-29 14:47:02 -0700
committerRyan Mitchell <rtmitchell@google.com>2021-03-31 23:04:57 -0700
commitca3b4f76335fcb2ecf09a244f8f95baf56969a12 (patch)
treee13eb5c5b966510c0dc37842b007a7b339829051 /tools/aapt2/format/binary/BinaryResourceParser.cpp
parentb50914c52441216f27b7a6d789f00be62f7cd5f2 (diff)
Use staging-public-group in framework SDK
To make S finalization easier, this changes the framework SDK so that apps linking against it will be able to continue working as expected after the first phase of SDK finalization. During the first phase of SDK finalization, the resource ids of resources that have not been removed are finalized. staging-public-group tags are converted to staging-public-group-final tags in order to encode into the framework what the staged resource id of a finalized resource was. When an app recompiles, it will use the finalized resource id. Then after all apps recompile, phase 2 of finalization begins, in which the staging-public-group-final tags are removed so apps can no longer use the staged resource ids. Apps that link against the SDK (provided they are using a recent version of aapt) will encode references to staged resources as TYPE_DYNAMIC_REFERENCE and TYPE_DYNAMIC_ATTRIBUTE. The values of R fields for staged resources are defined out-of-line to prevent them from being inlined into apps linking agsint the SDK. This allows the resource ids to change during phase 1 of API finalization. Bug: 183413192 Test: `aapt2 diff` and resource ids stayed the same Test: `aapt2 dump` of framework-res.apk and observe staged resources Change-Id: Ie2275c608297a5f63dde8b1cf795415112cbcc24
Diffstat (limited to 'tools/aapt2/format/binary/BinaryResourceParser.cpp')
-rw-r--r--tools/aapt2/format/binary/BinaryResourceParser.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/aapt2/format/binary/BinaryResourceParser.cpp b/tools/aapt2/format/binary/BinaryResourceParser.cpp
index bfb8d5854d6d..f1b350fe90f7 100644
--- a/tools/aapt2/format/binary/BinaryResourceParser.cpp
+++ b/tools/aapt2/format/binary/BinaryResourceParser.cpp
@@ -393,8 +393,15 @@ bool BinaryResourceParser::ParseType(const ResourceTablePackage* package,
.SetAllowMangled(true);
if (entry->flags & ResTable_entry::FLAG_PUBLIC) {
- res_builder.SetVisibility(Visibility{Visibility::Level::kPublic});
+ Visibility visibility{Visibility::Level::kPublic};
+ auto spec_flags = entry_type_spec_flags_.find(res_id);
+ if (spec_flags != entry_type_spec_flags_.end() &&
+ spec_flags->second & ResTable_typeSpec::SPEC_STAGED_API) {
+ visibility.staged_api = true;
+ }
+
+ res_builder.SetVisibility(visibility);
// Erase the ID from the map once processed, so that we don't mark the same symbol more than
// once.
entry_type_spec_flags_.erase(res_id);