[aapt2] Add resource table chunk dumping
Add a dump command to aapt2 to examine the structure of the resource
table structure. This dump command will be kept up-to-date as changes to
the resource table structure are made.
Bug: 193144097
Test: manual run on APK
Change-Id: I75e47d363cace2b1bafe320085a6b38b7bdee5ae
diff --git a/tools/aapt2/cmd/Dump.cpp b/tools/aapt2/cmd/Dump.cpp
index 0a1e021..bcce3e5 100644
--- a/tools/aapt2/cmd/Dump.cpp
+++ b/tools/aapt2/cmd/Dump.cpp
@@ -560,4 +560,21 @@
32, 32, 32, 32, 32, 32, 32, 32, 32, 46, 32, 32, 46, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10};
+int DumpChunks::Dump(LoadedApk* apk) {
+ auto file = apk->GetFileCollection()->FindFile("resources.arsc");
+ if (!file) {
+ GetDiagnostics()->Error(DiagMessage() << "Failed to find resources.arsc in APK");
+ return 1;
+ }
+
+ auto data = file->OpenAsData();
+ if (!data) {
+ GetDiagnostics()->Error(DiagMessage() << "Failed to open resources.arsc ");
+ return 1;
+ }
+
+ Debug::DumpChunks(data->data(), data->size(), GetPrinter(), GetDiagnostics());
+ return 0;
+}
+
} // namespace aapt