From 3d8d4a18c2bd4d697692ea30471852c90e7a3775 Mon Sep 17 00:00:00 2001 From: Jeremy Meyer Date: Fri, 23 Aug 2024 17:29:03 -0700 Subject: Error on duplicate resource with same disabled flag Also realized I hadn't handled flag negation so added that as well. Test: Automated Bug: 329436914 Flag: EXEMPT Aconfig not supported on host tools Change-Id: If90ae71070306f8e0c367be7e652da9c7bd0bb22 --- tools/aapt2/Debug.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tools/aapt2/Debug.cpp') diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index df1d51e37660..064b4617b0a2 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -346,6 +346,21 @@ void Debug::PrintTable(const ResourceTable& table, const DebugPrintTableOptions& value->value->Accept(&body_printer); printer->Undent(); } + printer->Println("Flag disabled values:"); + for (const auto& value : entry.flag_disabled_values) { + printer->Print("("); + printer->Print(value->config.to_string()); + printer->Print(") "); + value->value->Accept(&headline_printer); + if (options.show_sources && !value->value->GetSource().path.empty()) { + printer->Print(" src="); + printer->Print(value->value->GetSource().to_string()); + } + printer->Println(); + printer->Indent(); + value->value->Accept(&body_printer); + printer->Undent(); + } printer->Undent(); } } -- cgit v1.2.3-59-g8ed1b From f1e23eac8bcc604335d94c18ca1575bd2128f092 Mon Sep 17 00:00:00 2001 From: Adam Soutar Date: Thu, 3 Oct 2024 13:23:00 +0000 Subject: Fix typo in AAPT2 error message AAPT2 - and 1 - print "String pool is unitialized." I found this out when I saw the error and tried to look for it in Code Search only to get no results because it's spelled wrong. Change-Id: I66e2dcada0b1441d9f21aebded1ef95af09e7ac1 Flag: EXEMPT log only update --- tools/aapt/StringPool.cpp | 2 +- tools/aapt2/Debug.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/aapt2/Debug.cpp') diff --git a/tools/aapt/StringPool.cpp b/tools/aapt/StringPool.cpp index 1af8d6f67bd3..b2e48bd74e8a 100644 --- a/tools/aapt/StringPool.cpp +++ b/tools/aapt/StringPool.cpp @@ -40,7 +40,7 @@ void strcpy16_htod(uint16_t* dst, const char16_t* src) void printStringPool(const ResStringPool* pool) { if (pool->getError() == NO_INIT) { - printf("String pool is unitialized.\n"); + printf("String pool is uninitialized.\n"); return; } else if (pool->getError() != NO_ERROR) { printf("String pool is corrupt/invalid.\n"); diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index 064b4617b0a2..2527dcd26382 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -445,7 +445,7 @@ void Debug::DumpResStringPool(const android::ResStringPool* pool, text::Printer* using namespace android; if (pool->getError() == NO_INIT) { - printer->Print("String pool is unitialized.\n"); + printer->Print("String pool is uninitialized.\n"); return; } else if (pool->getError() != NO_ERROR) { printer->Print("String pool is corrupt/invalid.\n"); -- cgit v1.2.3-59-g8ed1b From 7e1b124173c87f66281cb63270219ff8da899acf Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Wed, 24 Jul 2024 15:50:05 -0700 Subject: [aapt2] Print type specs in 'dump chunks' 'aapt2 dump chunks' command used to skip the type specs completely, but those contain important information about the types' configuration masks and flags Flag: EXEMPT host tool Test: build Change-Id: Id562e7bdca2347ea39d1dbc3b7dc74be34e98d08 --- tools/aapt2/Debug.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'tools/aapt2/Debug.cpp') diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index 2527dcd26382..661df4d0fe33 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -21,10 +21,13 @@ #include #include +#include #include #include #include #include +#include +#include #include #include "ResourceTable.h" @@ -684,6 +687,80 @@ class ChunkPrinter { printer_->Print("\n"); } + void PrintQualifiers(uint32_t qualifiers) const { + if (qualifiers == 0) { + printer_->Print("0"); + return; + } + + printer_->Print(StringPrintf("0x%04x: ", qualifiers)); + static constinit std::array kValues = { + std::pair{ResTable_config::CONFIG_MCC, "mcc"}, + std::pair{ResTable_config::CONFIG_MNC, "mnc"}, + std::pair{ResTable_config::CONFIG_LOCALE, "locale"}, + std::pair{ResTable_config::CONFIG_TOUCHSCREEN, "touchscreen"}, + std::pair{ResTable_config::CONFIG_KEYBOARD, "keyboard"}, + std::pair{ResTable_config::CONFIG_KEYBOARD_HIDDEN, "keyboard_hidden"}, + std::pair{ResTable_config::CONFIG_NAVIGATION, "navigation"}, + std::pair{ResTable_config::CONFIG_ORIENTATION, "orientation"}, + std::pair{ResTable_config::CONFIG_DENSITY, "screen_density"}, + std::pair{ResTable_config::CONFIG_SCREEN_SIZE, "screen_size"}, + std::pair{ResTable_config::CONFIG_SMALLEST_SCREEN_SIZE, "screen_smallest_size"}, + std::pair{ResTable_config::CONFIG_VERSION, "version"}, + std::pair{ResTable_config::CONFIG_SCREEN_LAYOUT, "screen_layout"}, + std::pair{ResTable_config::CONFIG_UI_MODE, "ui_mode"}, + std::pair{ResTable_config::CONFIG_LAYOUTDIR, "layout_dir"}, + std::pair{ResTable_config::CONFIG_SCREEN_ROUND, "screen_round"}, + std::pair{ResTable_config::CONFIG_COLOR_MODE, "color_mode"}, + std::pair{ResTable_config::CONFIG_GRAMMATICAL_GENDER, "grammatical_gender"}}; + const char* delimiter = ""; + for (auto&& pair : kValues) { + if (qualifiers & pair.first) { + printer_->Print(StringPrintf("%s%s", delimiter, pair.second)); + delimiter = "|"; + } + } + } + + bool PrintTypeSpec(const ResTable_typeSpec* chunk) const { + printer_->Print(StringPrintf(" id: 0x%02x", android::util::DeviceToHost32(chunk->id))); + printer_->Print(StringPrintf(" types: %u", android::util::DeviceToHost16(chunk->typesCount))); + printer_->Print( + StringPrintf(" entry configs: %u\n", android::util::DeviceToHost32(chunk->entryCount))); + printer_->Print("Entry qualifier masks:\n"); + printer_->Indent(); + std::span masks(reinterpret_cast(GetChunkData(&chunk->header)), + GetChunkDataLen(&chunk->header) / sizeof(uint32_t)); + int i = 0; + int non_empty_count = 0; + for (auto dev_mask : masks) { + auto mask = android::util::DeviceToHost32(dev_mask); + if (mask == 0) { + i++; + continue; + } + ++non_empty_count; + printer_->Print(StringPrintf("#0x%02x = ", i++)); + if (mask & ResTable_typeSpec::SPEC_PUBLIC) { + mask &= ~ResTable_typeSpec::SPEC_PUBLIC; + printer_->Print("(PUBLIC) "); + } + if (mask & ResTable_typeSpec::SPEC_STAGED_API) { + mask &= ~ResTable_typeSpec::SPEC_STAGED_API; + printer_->Print("(STAGED) "); + } + PrintQualifiers(mask); + printer_->Print("\n"); + } + if (non_empty_count > 0) { + printer_->Print("\n"); + } else { + printer_->Print("(all empty)\n"); + } + printer_->Undent(); + return true; + } + bool PrintTableType(const ResTable_type* chunk) { printer_->Print(StringPrintf(" id: 0x%02x", android::util::DeviceToHost32(chunk->id))); printer_->Print(StringPrintf( @@ -864,6 +941,10 @@ class ChunkPrinter { PrintTableType(reinterpret_cast(chunk)); break; + case RES_TABLE_TYPE_SPEC_TYPE: + PrintTypeSpec(reinterpret_cast(chunk)); + break; + default: printer_->Print("\n"); break; -- cgit v1.2.3-59-g8ed1b