From 5d2755129dae6ff6f0061da0abe634f44054b23e Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Thu, 19 Jul 2018 14:29:00 -0700 Subject: AAPT2: Reformatted dump command invocations Use with: aapt2 dump apc [apc] aapt2 dump configurations [apk] aapt2 dump strings [apk] aapt2 dump resources [apk] aapt2 dump xmlstrings [apk] --file [file] aapt2 dump xmltree [apk] --file [file] Will add permissions and badging in a later commit. Bug: 73351292 Test: Manual tests of the commands Change-Id: I97eec01222af14053a98bd70255f1bfecd16b1c4 --- tools/aapt2/Debug.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tools/aapt2/Debug.cpp') diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp index f064cb14248f..0a517ab8a2de 100644 --- a/tools/aapt2/Debug.cpp +++ b/tools/aapt2/Debug.cpp @@ -408,6 +408,41 @@ void Debug::DumpHex(const void* data, size_t len) { } } +void Debug::DumpResStringPool(const android::ResStringPool* pool, text::Printer* printer) { + using namespace android; + + if (pool->getError() == NO_INIT) { + printer->Print("String pool is unitialized.\n"); + return; + } else if (pool->getError() != NO_ERROR) { + printer->Print("String pool is corrupt/invalid.\n"); + return; + } + + SortedVector uniqueStrings; + const size_t N = pool->size(); + for (size_t i=0; iisUTF8()) { + uniqueStrings.add(pool->string8At(i, &len)); + } else { + uniqueStrings.add(pool->stringAt(i, &len)); + } + } + + printer->Print(StringPrintf("String pool of %zd unique %s %s strings, %zd entries and %zd styles " + "using %zd bytes:\n", uniqueStrings.size(), + pool->isUTF8() ? "UTF-8" : "UTF-16", + pool->isSorted() ? "sorted" : "non-sorted", N, pool->styleCount(), + pool->bytes())); + + const size_t NS = pool->size(); + for (size_t s=0; sstring8ObjectAt(s); + printer->Print(StringPrintf("String #%zd : %s\n", s, str.string())); + } +} + namespace { class XmlPrinter : public xml::ConstVisitor { -- cgit v1.2.3-59-g8ed1b