[aapt2] Add DynamicRefTable to dump resources

aapt used to print the referenced packages table
in the dump resources command, add the same to aapt2

Bug: 279529151
Test: unit tests

Change-Id: If1d577ae85ab76f2a7cbcfe4b9087e49bd540572
diff --git a/tools/aapt2/Debug.cpp b/tools/aapt2/Debug.cpp
index df87889..cac4edd 100644
--- a/tools/aapt2/Debug.cpp
+++ b/tools/aapt2/Debug.cpp
@@ -265,6 +265,16 @@
     ValueHeadlinePrinter headline_printer(package.name, printer);
     ValueBodyPrinter body_printer(package.name, printer);
 
+    auto& dynamicRefTable = table.GetReferencedPackages();
+    if (!dynamicRefTable.empty()) {
+      printer->Println(StringPrintf("DynamicRefTable entryCount=%d", int(dynamicRefTable.size())));
+      printer->Indent();
+      for (auto&& [id, name] : dynamicRefTable) {
+        printer->Println(StringPrintf("0x%02x -> %s", id, name.c_str()));
+      }
+      printer->Undent();
+    }
+
     printer->Print("Package name=");
     printer->Print(package.name);
     if (package.id) {