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

Commit 74effb01 authored by Brandon Liu's avatar Brandon Liu Committed by Android (Google) Code Review
Browse files

Merge "Aapt2 Optimize: Exempt particular resources from path shortening"

parents aa5b8486 f1ed5239
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -364,7 +364,8 @@ bool ExtractResourceConfig(const std::string& path, IAaptContext* context,
  }
  std::unordered_set<ResourceName> resources_exclude_list;
  bool result = ParseResourceConfig(content, context, resources_exclude_list,
                                    out_options.name_collapse_exemptions);
                                    out_options.name_collapse_exemptions,
                                    out_options.path_shorten_exemptions);
  if (!result) {
    return false;
  }
+2 −1
Original line number Diff line number Diff line
@@ -322,7 +322,8 @@ bool ExtractConfig(const std::string& path, IAaptContext* context, OptimizeOptio
    return false;
  }
  return ParseResourceConfig(content, context, options->resources_exclude_list,
                             options->table_flattener_options.name_collapse_exemptions);
                             options->table_flattener_options.name_collapse_exemptions,
                             options->table_flattener_options.path_shorten_exemptions);
}

bool ExtractAppDataFromManifest(OptimizeContext* context, const LoadedApk* apk,
+2 −1
Original line number Diff line number Diff line
@@ -122,7 +122,8 @@ class OptimizeCommand : public Command {
            "--resources-config-path.",
        &options_.table_flattener_options.collapse_key_stringpool);
    AddOptionalSwitch("--shorten-resource-paths",
        "Shortens the paths of resources inside the APK.",
        "Shortens the paths of resources inside the APK. Resources can be exempted using the \n"
        "\"no_path_shorten\" directive in a file specified by --resources-config-path.",
        &options_.shorten_resource_paths);
    // TODO(b/246489170): keep the old option and format until transform to the new one
    AddOptionalFlag("--resource-path-shortening-map",
+4 −1
Original line number Diff line number Diff line
@@ -448,7 +448,8 @@ std::regex GetRegularExpression(const std::string &input) {

bool ParseResourceConfig(const std::string& content, IAaptContext* context,
                         std::unordered_set<ResourceName>& out_resource_exclude_list,
                         std::set<ResourceName>& out_name_collapse_exemptions) {
                         std::set<ResourceName>& out_name_collapse_exemptions,
                         std::set<ResourceName>& out_path_shorten_exemptions) {
  for (StringPiece line : util::Tokenize(content, '\n')) {
    line = util::TrimWhitespace(line);
    if (line.empty()) {
@@ -477,6 +478,8 @@ bool ParseResourceConfig(const std::string& content, IAaptContext* context,
        out_resource_exclude_list.insert(resource_name.ToResourceName());
      } else if (directive == "no_collapse" || directive == "no_obfuscate") {
        out_name_collapse_exemptions.insert(resource_name.ToResourceName());
      } else if (directive == "no_path_shorten") {
        out_path_shorten_exemptions.insert(resource_name.ToResourceName());
      }
    }
  }
+2 −1
Original line number Diff line number Diff line
@@ -81,7 +81,8 @@ std::regex GetRegularExpression(const std::string &input);

bool ParseResourceConfig(const std::string& content, IAaptContext* context,
                         std::unordered_set<ResourceName>& out_resource_exclude_list,
                         std::set<ResourceName>& out_name_collapse_exemptions);
                         std::set<ResourceName>& out_name_collapse_exemptions,
                         std::set<ResourceName>& out_path_shorten_exemptions);

}  // namespace aapt

Loading