diff options
author | Scott Lobdell <slobdell@google.com> | 2021-04-08 04:27:11 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-04-09 17:32:37 +0000 |
commit | 5f1da148b08c14445ce83ca151a84f75e489d274 (patch) | |
tree | df59b2056d1fe2dbe09f6c85463ddf1769daf4e6 /tools/aapt2/cmd/Link.cpp | |
parent | 702f04add003ce3e490a2f0bdff083a7e6f5979e (diff) | |
parent | 851218af5f83cdb89c02d680fb22212318150068 (diff) |
Merge SP1A.210407.002
Change-Id: Iaad2b7cc2aeba166f003d0d460bc8ce29d1caab3
Diffstat (limited to 'tools/aapt2/cmd/Link.cpp')
-rw-r--r-- | tools/aapt2/cmd/Link.cpp | 24 |
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) { |