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

Commit e0298368 authored by Adam Lesinski's avatar Adam Lesinski Committed by Android (Google) Code Review
Browse files

Merge changes Id8bdb14e,I573a6735,Ia804777f,Ia68122cb,Ia1997800, ... into oc-mr1-dev

* changes:
  AAPT2: Bump to version 2.19
  AAPT2: Fix issue with resource deduping
  AAPT: Dump badging should pickup strings from the right package
  AAPT2: Change the daemon mode to be line based
  AAPT2: better error handling for daemon mode
  AAPT2: Fix regression in Manifest.java permissions
  AAPT2: Define intermediate compiled XML proto
  AAPT2: Add a daemon mode
  AAPT2: Fix mkdirs implementation
  AAPT2: Change XmlDom to exclude Namespace as a node
  AAPT2: Fix windows unicode path issues
  AAPT2: Fix typo in Config parsing
  AAPT2: Change proto format to reduce usage of StringPool
  AAPT2: Add navigation type
  AAPT2: Document Format.proto
parents 293e2f99 689ce3f6
Loading
Loading
Loading
Loading
+29 −13
Original line number Diff line number Diff line
@@ -99,24 +99,40 @@ String8 getResolvedAttribute(const ResTable& resTable, const ResXMLTree& tree,
    if (idx < 0) {
        return String8();
    }

    Res_value value;
    if (tree.getAttributeValue(idx, &value) != NO_ERROR) {
    if (tree.getAttributeValue(idx, &value) == BAD_TYPE) {
        if (outError != NULL) {
            *outError = "attribute value is corrupt";
        }
        return String8();
    }

    // Check if the string is inline in the XML.
    if (value.dataType == Res_value::TYPE_STRING) {
        size_t len;
        const char16_t* str = tree.getAttributeStringValue(idx, &len);
        return str ? String8(str, len) : String8();
    }
        resTable.resolveReference(&value, 0);

    // Resolve the reference if there is one.
    ssize_t block = resTable.resolveReference(&value, 0);
    if (block < 0) {
        if (outError != NULL) {
            *outError = "attribute value reference does not exist";
        }
        return String8();
    }

    if (value.dataType != Res_value::TYPE_STRING) {
        if (outError != NULL) {
            *outError = "attribute is not a string value";
        }
        return String8();
    }
    }

    size_t len;
    const Res_value* value2 = &value;
    const char16_t* str = resTable.valueToString(value2, 0, NULL, &len);
    const char16_t* str = resTable.valueToString(&value, static_cast<size_t>(block), NULL, &len);
    return str ? String8(str, len) : String8();
}

+5 −1
Original line number Diff line number Diff line
@@ -92,7 +92,9 @@ cc_library_host_static {
        "flatten/XmlFlattener.cpp",
        "io/BigBufferStreams.cpp",
        "io/File.cpp",
        "io/FileInputStream.cpp",
        "io/FileSystem.cpp",
        "io/StringInputStream.cpp",
        "io/Util.cpp",
        "io/ZipArchive.cpp",
        "link/AutoVersioner.cpp",
@@ -140,7 +142,8 @@ cc_library_host_static {
        "xml/XmlDom.cpp",
        "xml/XmlPullParser.cpp",
        "xml/XmlUtil.cpp",
        "Format.proto",
        "Resources.proto",
        "ResourcesInternal.proto",
    ],
    proto: {
        export_proto_headers: true,
@@ -164,6 +167,7 @@ cc_library_host_shared {
cc_test_host {
    name: "aapt2_tests",
    srcs: [
        "test/Builders.cpp",
        "test/Common.cpp",
        "**/*_test.cpp",
    ],
+1 −3
Original line number Diff line number Diff line
@@ -70,7 +70,7 @@ static bool parseMcc(const char* name, ResTable_config* out) {

static bool parseMnc(const char* name, ResTable_config* out) {
  if (strcmp(name, kWildcardName) == 0) {
    if (out) out->mcc = 0;
    if (out) out->mnc = 0;
    return true;
  }
  const char* c = name;
@@ -967,8 +967,6 @@ bool ConfigDescription::ConflictsWith(const ConfigDescription& o) const {
               o.screenLayout & MASK_LAYOUTDIR) ||
         !pred(screenLayout & MASK_SCREENLONG,
               o.screenLayout & MASK_SCREENLONG) ||
         !pred(screenLayout & MASK_UI_MODE_TYPE,
               o.screenLayout & MASK_UI_MODE_TYPE) ||
         !pred(uiMode & MASK_UI_MODE_TYPE, o.uiMode & MASK_UI_MODE_TYPE) ||
         !pred(uiMode & MASK_UI_MODE_NIGHT, o.uiMode & MASK_UI_MODE_NIGHT) ||
         !pred(screenLayout2 & MASK_SCREENROUND,
+12 −0
Original line number Diff line number Diff line
@@ -140,4 +140,16 @@ TEST(ConfigDescriptionTest, ParseVrAttribute) {
  EXPECT_EQ(std::string("vrheadset-v26"), config.toString().string());
}

TEST(ConfigDescriptionTest, RangeQualifiersDoNotConflict) {
  using test::ParseConfigOrDie;

  EXPECT_FALSE(ParseConfigOrDie("large").ConflictsWith(ParseConfigOrDie("normal-land")));
  EXPECT_FALSE(ParseConfigOrDie("long-hdpi").ConflictsWith(ParseConfigOrDie("xhdpi")));
  EXPECT_FALSE(ParseConfigOrDie("sw600dp").ConflictsWith(ParseConfigOrDie("sw700dp")));
  EXPECT_FALSE(ParseConfigOrDie("v11").ConflictsWith(ParseConfigOrDie("v21")));
  EXPECT_FALSE(ParseConfigOrDie("h600dp").ConflictsWith(ParseConfigOrDie("h300dp")));
  EXPECT_FALSE(ParseConfigOrDie("w400dp").ConflictsWith(ParseConfigOrDie("w300dp")));
  EXPECT_FALSE(ParseConfigOrDie("600x400").ConflictsWith(ParseConfigOrDie("300x200")));
}

}  // namespace aapt
+31 −33
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@

namespace aapt {

namespace {

class PrintVisitor : public ValueVisitor {
 public:
  using ValueVisitor::Visit;
@@ -88,9 +90,13 @@ class PrintVisitor : public ValueVisitor {
    }
  }

  void Visit(Array* array) override { array->Print(&std::cout); }
  void Visit(Array* array) override {
    array->Print(&std::cout);
  }

  void Visit(Plural* plural) override { plural->Print(&std::cout); }
  void Visit(Plural* plural) override {
    plural->Print(&std::cout);
  }

  void Visit(Styleable* styleable) override {
    std::cout << "(styleable)";
@@ -110,11 +116,14 @@ class PrintVisitor : public ValueVisitor {
    }
  }

  void VisitItem(Item* item) override { item->Print(&std::cout); }
  void VisitItem(Item* item) override {
    item->Print(&std::cout);
  }
};

void Debug::PrintTable(ResourceTable* table,
                       const DebugPrintTableOptions& options) {
}  // namespace

void Debug::PrintTable(ResourceTable* table, const DebugPrintTableOptions& options) {
  PrintVisitor visitor;

  for (auto& package : table->packages) {
@@ -148,10 +157,9 @@ void Debug::PrintTable(ResourceTable* table,
      }

      for (const ResourceEntry* entry : sorted_entries) {
        ResourceId id(package->id ? package->id.value() : uint8_t(0),
                      type->id ? type->id.value() : uint8_t(0),
                      entry->id ? entry->id.value() : uint16_t(0));
        ResourceName name(package->name, type->type, entry->name);
        const ResourceId id(package->id.value_or_default(0), type->id.value_or_default(0),
                            entry->id.value_or_default(0));
        const ResourceName name(package->name, type->type, entry->name);

        std::cout << "    spec resource " << id << " " << name;
        switch (entry->symbol_status.state) {
@@ -180,16 +188,14 @@ void Debug::PrintTable(ResourceTable* table,
  }
}

static size_t GetNodeIndex(const std::vector<ResourceName>& names,
                           const ResourceName& name) {
static size_t GetNodeIndex(const std::vector<ResourceName>& names, const ResourceName& name) {
  auto iter = std::lower_bound(names.begin(), names.end(), name);
  CHECK(iter != names.end());
  CHECK(*iter == name);
  return std::distance(names.begin(), iter);
}

void Debug::PrintStyleGraph(ResourceTable* table,
                            const ResourceName& target_style) {
void Debug::PrintStyleGraph(ResourceTable* table, const ResourceName& target_style) {
  std::map<ResourceName, std::set<ResourceName>> graph;

  std::queue<ResourceName> styles_to_visit;
@@ -223,8 +229,7 @@ void Debug::PrintStyleGraph(ResourceTable* table,

  std::cout << "digraph styles {\n";
  for (const auto& name : names) {
    std::cout << "  node_" << GetNodeIndex(names, name) << " [label=\"" << name
              << "\"];\n";
    std::cout << "  node_" << GetNodeIndex(names, name) << " [label=\"" << name << "\"];\n";
  }

  for (const auto& entry : graph) {
@@ -243,8 +248,7 @@ void Debug::PrintStyleGraph(ResourceTable* table,
void Debug::DumpHex(const void* data, size_t len) {
  const uint8_t* d = (const uint8_t*)data;
  for (size_t i = 0; i < len; i++) {
    std::cerr << std::hex << std::setfill('0') << std::setw(2) << (uint32_t)d[i]
              << " ";
    std::cerr << std::hex << std::setfill('0') << std::setw(2) << (uint32_t)d[i] << " ";
    if (i % 8 == 7) {
      std::cerr << "\n";
    }
@@ -262,8 +266,15 @@ class XmlPrinter : public xml::Visitor {
  using xml::Visitor::Visit;

  void Visit(xml::Element* el) override {
    std::cerr << prefix_;
    std::cerr << "E: ";
    const size_t previous_size = prefix_.size();

    for (const xml::NamespaceDecl& decl : el->namespace_decls) {
      std::cerr << prefix_ << "N: " << decl.prefix << "=" << decl.uri
                << " (line=" << decl.line_number << ")\n";
      prefix_ += "  ";
    }

    std::cerr << prefix_ << "E: ";
    if (!el->namespace_uri.empty()) {
      std::cerr << el->namespace_uri << ":";
    }
@@ -283,26 +294,13 @@ class XmlPrinter : public xml::Visitor {
      std::cerr << "=" << attr.value << "\n";
    }

    const size_t previous_size = prefix_.size();
    prefix_ += "  ";
    xml::Visitor::Visit(el);
    prefix_.resize(previous_size);
  }

  void Visit(xml::Namespace* ns) override {
    std::cerr << prefix_;
    std::cerr << "N: " << ns->namespace_prefix << "=" << ns->namespace_uri
              << " (line=" << ns->line_number << ")\n";

    const size_t previous_size = prefix_.size();
    prefix_ += "  ";
    xml::Visitor::Visit(ns);
    prefix_.resize(previous_size);
  }

  void Visit(xml::Text* text) override {
    std::cerr << prefix_;
    std::cerr << "T: '" << text->text << "'\n";
    std::cerr << prefix_ << "T: '" << text->text << "'\n";
  }

 private:
Loading