From 22dc5310a4bb88b5f539677156493722bb9a9447 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 1 Jun 2020 12:17:07 -0700 Subject: [PATCH] Only move private attrs when building framework When aapt was changed to move private attributes into a different type (9b624c186cb6059dfb3ec24bfb6386a0fc17b88c), attributes only were moved when building the framework. When this functionality was ported to aapt2, all apps using the public tag would have their private attributes moved. The change does not appear to be intentional and thus is a parity issue. This change only moves private attributes when building a package with an id of 0x01. Bug: 151683505 Test: manual Change-Id: Ic9843f99e428f94cb6a55988a3881b8a91c7d7e2 --- tools/aapt2/cmd/Link.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/aapt2/cmd/Link.cpp b/tools/aapt2/cmd/Link.cpp index a7febdc0db5ca..b37b74f8aa8ff 100644 --- a/tools/aapt2/cmd/Link.cpp +++ b/tools/aapt2/cmd/Link.cpp @@ -78,6 +78,8 @@ using ::android::base::StringPrintf; namespace aapt { +constexpr uint8_t kAndroidPackageId = 0x01; + class LinkContext : public IAaptContext { public: explicit LinkContext(IDiagnostics* diagnostics) @@ -1804,7 +1806,7 @@ class Linker { // Override the package ID when it is "android". if (context_->GetCompilationPackage() == "android") { - context_->SetPackageId(0x01); + context_->SetPackageId(kAndroidPackageId); // Verify we're building a regular app. if (context_->GetPackageType() != PackageType::kApp) { @@ -1861,7 +1863,8 @@ class Linker { if (context_->GetPackageType() != PackageType::kStaticLib) { PrivateAttributeMover mover; - if (!mover.Consume(context_, &final_table_)) { + if (context_->GetPackageId() == kAndroidPackageId && + !mover.Consume(context_, &final_table_)) { context_->GetDiagnostics()->Error(DiagMessage() << "failed moving private attributes"); return 1; }