summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Link.cpp
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2021-04-10 00:27:34 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-04-10 00:27:34 +0000
commit01da99e3e562d93c902419316b2f6aa464777e16 (patch)
tree2fe6d242f8218ab669e2a98f757a85005ff88088 /tools/aapt2/cmd/Link.cpp
parent80bf29781b44a4c22692a3a1a1e60a371471c25a (diff)
parent6560a5b465795d6922ccd0c83693fa04be2910a6 (diff)
Merge changes from topic "SP1A.210407.002" into s-keystone-qcom-dev
* changes: Adapt to new ranking logic from upstream. Revert "Initial data pipeline for Smartspace media recommendations data in media carousel." Merge SP1A.210407.002
Diffstat (limited to 'tools/aapt2/cmd/Link.cpp')
-rw-r--r--tools/aapt2/cmd/Link.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp
index ee6a764966f0..2a8923d927f6 100644
--- a/tools/aapt2/cmd/Link.cpp
+++ b/tools/aapt2/cmd/Link.cpp
@@ -1764,7 +1764,7 @@ class Linker {
// anything else being generated, which includes the Java classes.
// If required, the package name is modifed before flattening, and then modified back
// to its original name.
- std::optional<ResourceTablePackageView> package_to_rewrite;
+ ResourceTablePackage* package_to_rewrite = nullptr;
// Pre-O, the platform treats negative resource IDs [those with a package ID of 0x80
// or higher] as invalid. In order to work around this limitation, we allow the use
// of traditionally reserved resource IDs [those between 0x02 and 0x7E]. Allow the
@@ -1773,16 +1773,13 @@ class Linker {
context_->GetPackageId() != kAppPackageId &&
context_->GetPackageId() != kFrameworkPackageId)
|| (!options_.allow_reserved_package_id && context_->GetPackageId() > kAppPackageId);
- if (isSplitPackage &&
- included_feature_base_ == make_value(context_->GetCompilationPackage())) {
+ if (isSplitPackage && included_feature_base_ == context_->GetCompilationPackage()) {
// The base APK is included, and this is a feature split. If the base package is
// the same as this package, then we are building an old style Android Instant Apps feature
// split and must apply this workaround to avoid requiring namespaces support.
- auto table_view = table->GetPartitionedView();
- if (!table_view.packages.empty() &&
- table_view.packages.back().name == context_->GetCompilationPackage()) {
- package_to_rewrite = std::move(table_view.packages.back());
- CHECK_EQ(1u, table->packages.size()) << "can't change name of package when > 1 package";
+ if (!table->packages.empty() &&
+ table->packages.back()->name == context_->GetCompilationPackage()) {
+ package_to_rewrite = table->packages.back().get();
std::string new_package_name =
StringPrintf("%s.%s", package_to_rewrite->name.c_str(),
app_info_.split_name.value_or_default("feature").c_str());
@@ -1798,12 +1795,15 @@ class Linker {
bool success = FlattenTable(table, options_.output_format, writer);
- if (package_to_rewrite.has_value()) {
+ if (package_to_rewrite != nullptr) {
// Change the name back.
package_to_rewrite->name = context_->GetCompilationPackage();
- if (package_to_rewrite->id) {
- table->included_packages_.erase(package_to_rewrite->id.value());
- }
+
+ // TableFlattener creates an `included_packages_` mapping entry for each package with a
+ // non-standard package id (not 0x01 or 0x7f). Since this is a feature split and not a shared
+ // library, do not include a mapping from the feature package name to the feature package id
+ // in the feature's dynamic reference table.
+ table->included_packages_.erase(context_->GetPackageId());
}
if (!success) {