Add style parents dump command.

This command prints out the parent graph of a given style

Test: out/host/linux-x86/bin/aapt2 dump styleparents \
    --style Widget.MaterialComponents.TextInputLayout.FilledBox \
    out/target/product/generic_x86/system/priv-app/SystemUIGoogle/SystemUIGoogle.apk
Change-Id: Ib2ace7e90bee6f1c4b6a184edc591b1a3993db75
diff --git a/tools/aapt2/cmd/Dump.cpp b/tools/aapt2/cmd/Dump.cpp
index 06e4622..a23a6a4 100644
--- a/tools/aapt2/cmd/Dump.cpp
+++ b/tools/aapt2/cmd/Dump.cpp
@@ -251,19 +251,12 @@
 }
 
 int DumpPackageNameCommand::Dump(LoadedApk* apk) {
-  xml::Element* manifest_el = apk->GetManifest()->root.get();
-  if (!manifest_el) {
-    GetDiagnostics()->Error(DiagMessage() << "No AndroidManifest");
+  Maybe<std::string> package_name = GetPackageName(apk);
+  if (!package_name) {
     return 1;
   }
 
-  xml::Attribute* attr = manifest_el->FindAttribute({}, "package");
-  if (!attr) {
-    GetDiagnostics()->Error(DiagMessage() << "No package name");
-    return 1;
-  }
-
-  GetPrinter()->Println(StringPrintf("%s", attr->value.c_str()));
+  GetPrinter()->Println(package_name.value());
   return 0;
 }
 
@@ -283,6 +276,31 @@
   return 0;
 }
 
+int DumpStyleParentCommand::Dump(LoadedApk* apk) {
+  Maybe<std::string> package_name = GetPackageName(apk);
+  if (!package_name) {
+    return 1;
+  }
+
+  const auto target_style = ResourceName(package_name.value(), ResourceType::kStyle, style_);
+  const auto table = apk->GetResourceTable();
+
+  if (!table) {
+    GetDiagnostics()->Error(DiagMessage() << "Failed to retrieve resource table");
+    return 1;
+  }
+
+  Maybe<ResourceTable::SearchResult> target = table->FindResource(target_style);
+  if (!target) {
+    GetDiagnostics()->Error(
+        DiagMessage() << "Target style \"" << target_style.entry << "\" does not exist");
+    return 1;
+  }
+
+  Debug::PrintStyleGraph(table, target_style);
+  return 0;
+}
+
 int DumpTableCommand::Dump(LoadedApk* apk) {
   if (apk->GetApkFormat() == ApkFormat::kProto) {
     GetPrinter()->Println("Proto APK");