Dump the deobfuscate data using Protocol buffers
Using Google Protocol buffers to dump the obfuscating mapping
information of being used to deobfuscate items.
* shortened file path -> original file path
* resource id -> original resource name
This patch add a new option --save-obfuscating-map to deprecate
--resource-path-shortening-map. The option
--resource-path-shortening-map is kept until no one to use it.
Bug: 246489170
Bug: 228192695
b/228192695#comment2
Test: make WITH_TIDY=1 aapt2
Test: atest aapt2_test
Change-Id: I29733c4dbae9f6dd2f0e9b2c87b0d2046662fc59
diff --git a/tools/aapt2/cmd/Optimize.h b/tools/aapt2/cmd/Optimize.h
index 794a87b..1879f25 100644
--- a/tools/aapt2/cmd/Optimize.h
+++ b/tools/aapt2/cmd/Optimize.h
@@ -58,6 +58,7 @@
bool shorten_resource_paths = false;
// Path to the output map of original resource paths to shortened paths.
+ // TODO(b/246489170): keep the old option and format until transform to the new one
std::optional<std::string> shortened_paths_map_path;
// Whether sparse encoding should be used for O+ resources.
@@ -65,6 +66,9 @@
// Whether sparse encoding should be used for all resources.
bool force_sparse_encoding = false;
+
+ // Path to the output map of original resource paths/names to obfuscated paths/names.
+ std::optional<std::string> obfuscation_map_path;
};
class OptimizeCommand : public Command {
@@ -120,9 +124,13 @@
AddOptionalSwitch("--shorten-resource-paths",
"Shortens the paths of resources inside the APK.",
&options_.shorten_resource_paths);
+ // TODO(b/246489170): keep the old option and format until transform to the new one
AddOptionalFlag("--resource-path-shortening-map",
- "Path to output the map of old resource paths to shortened paths.",
- &options_.shortened_paths_map_path);
+ "[Deprecated]Path to output the map of old resource paths to shortened paths.",
+ &options_.shortened_paths_map_path);
+ AddOptionalFlag("--save-obfuscation-map",
+ "Path to output the map of original paths/names to obfuscated paths/names.",
+ &options_.obfuscation_map_path);
AddOptionalSwitch(
"--deduplicate-entry-values",
"Whether to deduplicate pairs of resource entry and value for simple resources.\n"