From 2fedba9a32d9e92344eaf6e9faf5b43e1bc2ae70 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 23 Apr 2021 07:47:38 -0700 Subject: Add to aapt2 To allow apps that compiled against a pre-release SDK to continue working for a period of time after API finalization, a new tag, , has been added to aapt2. When finalizing the framework resource API, converting tags to will cause aapt2 to generate the resource table so that there is a resource entry for the old non-finalized (staged) resource ID and another entry for the finalized resource ID of newly finalized resources. This allows an application that compiled against the pre-release SDK to continue resolving resources using pre-release resource IDs. All references to pre-release resource IDs will be rewritten to their finalized resource IDs through the information stored in the new staged alias chunk. This allows applications compiled against resources to use the newly finalized resource ID without re-compilation. When an application is re-compiled against the SDK with tags, the application will use the finalized resource IDs. This change limits the use of the alias chunk to the framework for S. Bug: 183411356 Test: aapt2_test Change-Id: Iba1c3033c3c2f32de8e4a19b58d3921c971092c4 --- tools/aapt2/Debug.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'tools/aapt2/Debug.cpp') diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index 77c0872037ac..ef3a62f4efcc 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -278,17 +278,19 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& printer->Println(StringPrintf(" entryCount=%zd", type.entries.size())); printer->Indent(); - for (const ResourceEntry* entry : type.entries) { + for (const ResourceTableEntryView& entry : type.entries) { printer->Print("resource "); - printer->Print(entry->id.value_or_default(0).to_string()); + printer->Print(ResourceId(package.id.value_or_default(0), type.id.value_or_default(0), + entry.id.value_or_default(0)) + .to_string()); printer->Print(" "); // Write the name without the package (this is obvious and too verbose). printer->Print(to_string(type.type)); printer->Print("/"); - printer->Print(entry->name); + printer->Print(entry.name); - switch (entry->visibility.level) { + switch (entry.visibility.level) { case Visibility::Level::kPublic: printer->Print(" PUBLIC"); break; @@ -300,19 +302,24 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& break; } - if (entry->visibility.staged_api) { + if (entry.visibility.staged_api) { printer->Print(" STAGED"); } - if (entry->overlayable_item) { + if (entry.overlayable_item) { printer->Print(" OVERLAYABLE"); } + if (entry.staged_id) { + printer->Print(" STAGED_ID="); + printer->Print(entry.staged_id.value().id.to_string()); + } + printer->Println(); if (options.show_values) { printer->Indent(); - for (const auto& value : entry->values) { + for (const auto& value : entry.values) { printer->Print("("); printer->Print(value->config.to_string()); printer->Print(") "); -- cgit v1.2.3-59-g8ed1b