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

Commit f67d486e authored by Izabela Orlowska's avatar Izabela Orlowska
Browse files

AAPT2: partial files contain only local resources

When writing a partial R file for the compiled file, only include
resources defined locally - meaning those without a package. Do not
write resources from other packages (e.g. "android").

Test: manual
Bug: 73927419
Change-Id: I84241352e643ca1f22a581e6847372e2a4278824
parent a6f3ba1d
Loading
Loading
Loading
Loading
+39 −35
Original line number Diff line number Diff line
@@ -288,6 +288,8 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,

    Printer r_txt_printer(&fout_text);
    for (const auto& package : table.packages) {
      // Only print resources defined locally, e.g. don't write android attributes.
      if (package->name.empty()) {
        for (const auto& type : package->types) {
          for (const auto& entry : type->entries) {
            // Check access modifiers.
@@ -312,7 +314,8 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
              r_txt_printer.Println(entry->name);

              if (!entry->values.empty()) {
              auto styleable = static_cast<const Styleable*>(entry->values.front()->value.get());
                auto styleable =
                    static_cast<const Styleable*>(entry->values.front()->value.get());
                for (const auto& attr : styleable->entries) {
                  // The visibility of the children under the styleable does not matter as they are
                  // nested under their parent and use its visibility.
@@ -333,6 +336,7 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
        }
      }
    }
  }

  return true;
}