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.cpp b/tools/aapt2/cmd/Optimize.cpp
index f7f2f22..d7a39bf 100644
--- a/tools/aapt2/cmd/Optimize.cpp
+++ b/tools/aapt2/cmd/Optimize.cpp
@@ -161,6 +161,15 @@
                                           << "failed shortening resource paths");
         return 1;
       }
+
+      if (options_.obfuscation_map_path &&
+          !obfuscator.WriteObfuscationMap(options_.obfuscation_map_path.value())) {
+        context_->GetDiagnostics()->Error(android::DiagMessage()
+                                          << "failed to write the obfuscation map to file");
+        return 1;
+      }
+
+      // TODO(b/246489170): keep the old option and format until transform to the new one
       if (options_.shortened_paths_map_path
           && !WriteShortenedPathsMap(options_.table_flattener_options.shortened_path_map,
                                       options_.shortened_paths_map_path.value())) {
@@ -292,6 +301,7 @@
                                         ArchiveEntry::kAlign, writer);
   }
 
+  // TODO(b/246489170): keep the old option and format until transform to the new one
   bool WriteShortenedPathsMap(const std::map<std::string, std::string> &path_map,
                                const std::string &file_path) {
     std::stringstream ss;