diff options
author | 2024-07-02 15:31:01 -0700 | |
---|---|---|
committer | 2024-07-03 03:15:36 +0000 | |
commit | 97f0f1e4ea9232e86ee839d5d9e5e6d029f3700c (patch) | |
tree | 4c779d7f7b1ad32087a2cc558f2418fda94a6a26 /tools/aapt2/Debug.cpp | |
parent | 92a51cacc06ada68e9a54a165d104bc32efcff77 (diff) |
[aapt2] Improve dump chunks for string pools, fix diff
- `dump chunks` command now prints extra header data for the
string pool, and outputs all style information for styled
strings.
- `diff` command used to only correctly compare the first span
in the StyledString data type, making them appear different
if there was a string with more than one span
Flag: EXEMPT bugfix
Test: atest aapt2_tests
Change-Id: I377718c03d6a464cb4db22399b0f067e6a6e04d6
Diffstat (limited to 'tools/aapt2/Debug.cpp')
-rw-r--r-- | tools/aapt2/Debug.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index 6a17ef85a755..df1d51e37660 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -763,10 +763,35 @@ class ChunkPrinter { pool->setTo(chunk, android::util::DeviceToHost32( (reinterpret_cast<const ResChunk_header*>(chunk))->size)); - printer_->Print("\n"); + printer_->Print(StringPrintf(" strings: %zd styles %zd flags: %s|%s\n", pool->size(), + pool->styleCount(), pool->isUTF8() ? "UTF-8" : "UTF-16", + pool->isSorted() ? "SORTED" : "NON-SORTED")); for (size_t i = 0; i < pool->size(); i++) { printer_->Print(StringPrintf("#%zd : %s\n", i, android::util::GetString(*pool, i).c_str())); + if (i < pool->styleCount()) { + printer_->Print(" [Style] "); + auto maybe_style = pool->styleAt(i); + if (!maybe_style) { + printer_->Print("??? missing\n"); + } else { + std::vector<const ResStringPool_span*> spans; + for (auto style = maybe_style.value().unsafe_ptr(); + style->name.index != android::ResStringPool_span::END; ++style) { + spans.push_back(style); + } + printer_->Print(StringPrintf("(%zd)", spans.size())); + if (!spans.empty()) { + printer_->Print(" :"); + for (const auto& span : spans) { + printer_->Print(StringPrintf( + " %s:%u,%u", android::util::GetString(*pool, span->name.index).c_str(), + span->firstChar, span->lastChar)); + } + printer_->Print("\n"); + } + } + } } } |