Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fc225b21 authored by Ryan Mitchell's avatar Ryan Mitchell
Browse files

AAPT2: Added badging and permission

Added the remaining dump commands to aapt2.
aapt2 dump badging [apk]
aapt2 dump permissions [apk]

Bug: 73351292
Test: Diffing aapt and aapt2 output across apps from the Android tree
Change-Id: Idee820db410ad8d777d0d250c2657e7b83112a00
parent a1a74cb4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ cc_library_host_static {
        "compile/Pseudolocalizer.cpp",
        "compile/XmlIdCollector.cpp",
        "configuration/ConfigurationParser.cpp",
        "dump/DumpManifest.cpp",
        "filter/AbiFilter.cpp",
        "filter/ConfigFilter.cpp",
        "format/Archive.cpp",
+1 −1
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ bool LoadedApk::WriteToArchive(IAaptContext* context, ResourceTable* split_table
}

std::unique_ptr<xml::XmlResource> LoadedApk::LoadXml(const std::string& file_path,
                                                     IDiagnostics* diag) {
                                                     IDiagnostics* diag) const {
  io::IFile* file = apk_->FindFile(file_path);
  if (file == nullptr) {
    diag->Error(DiagMessage() << "failed to find file");
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ class LoadedApk {
                              IArchiveWriter* writer, xml::XmlResource* manifest = nullptr);

  /** Loads the file as an xml document. */
  std::unique_ptr<xml::XmlResource> LoadXml(const std::string& file_path, IDiagnostics* diag);
  std::unique_ptr<xml::XmlResource> LoadXml(const std::string& file_path, IDiagnostics* diag) const;

 private:
  DISALLOW_COPY_AND_ASSIGN(LoadedApk);
+21 −4
Original line number Diff line number Diff line
@@ -223,6 +223,12 @@ int DumpConfigsCommand::Action(const std::vector<std::string>& args) {
    return 1;
  }

  ResourceTable* table = loaded_apk->GetResourceTable();
  if (!table) {
    diag_->Error(DiagMessage() << "Failed to retrieve resource table.");
    return 1;
  }

  io::FileOutputStream fout(STDOUT_FILENO, kStdOutBufferSize);
  Printer printer(&fout);

@@ -233,7 +239,7 @@ int DumpConfigsCommand::Action(const std::vector<std::string>& args) {

  // Insert the configurations into a set in order to keep every configuarion seen
  std::set<ConfigDescription, decltype(compare)> configs(compare);
  for (auto& package : loaded_apk->GetResourceTable()->packages) {
  for (auto& package : table->packages) {
    for (auto& type : package->types) {
      for (auto& entry : type->entries) {
        for (auto& value : entry->values) {
@@ -267,10 +273,15 @@ int DumpStringsCommand::Action(const std::vector<std::string>& args) {
      return 1;
    }

    ResourceTable* table = loaded_apk->GetResourceTable();
    if (!table) {
      diag_->Error(DiagMessage() << "Failed to retrieve resource table.");
      return 1;
    }

    // Load the run-time xml string pool using the flattened data
    BigBuffer buffer(4096);
    StringPool::FlattenUtf8(&buffer, loaded_apk->GetResourceTable()->string_pool,
                            context.GetDiagnostics());
    StringPool::FlattenUtf8(&buffer, table->string_pool, context.GetDiagnostics());
    auto data = buffer.to_string();
    android::ResStringPool pool(data.data(), data.size(), false);
    Debug::DumpResStringPool(&pool, &printer);
@@ -304,7 +315,13 @@ int DumpTableCommand::Action(const std::vector<std::string>& args) {
      printer.Println("Binary APK");
    }

    Debug::PrintTable(*loaded_apk->GetResourceTable(), print_options, &printer);
    ResourceTable* table = loaded_apk->GetResourceTable();
    if (!table) {
      diag_->Error(DiagMessage() << "Failed to retrieve resource table.");
      return 1;
    }

    Debug::PrintTable(*table, print_options, &printer);
  }

  return 0;
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include "Command.h"
#include "Debug.h"
#include "dump/DumpManifest.h"

namespace aapt {

@@ -133,8 +134,10 @@ class DumpCommand : public Command {
 public:
  explicit DumpCommand(IDiagnostics* diag) : Command("dump", "d"), diag_(diag) {
    AddOptionalSubcommand(util::make_unique<DumpAPCCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpBadgingCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpConfigsCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpPackageNameCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpPermissionsCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpStringsCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpTableCommand>(diag_));
    AddOptionalSubcommand(util::make_unique<DumpXmlStringsCommand>(diag_));
Loading