Add "no-proguard-location-reference" flag to aapt2

This fixes relocatability issues with the code shrinkers.

Bug: 144529940
Test: None
Change-Id: I65e08e850193e67dcdf4c533d9e66332714f0c8c
diff --git a/tools/aapt2/java/ProguardRules.cpp b/tools/aapt2/java/ProguardRules.cpp
index 806f4e3..b06607e 100644
--- a/tools/aapt2/java/ProguardRules.cpp
+++ b/tools/aapt2/java/ProguardRules.cpp
@@ -393,11 +393,15 @@
   return true;
 }
 
-void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep) {
+void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep,
+                  bool no_location_reference) {
+
   Printer printer(out);
   for (const auto& entry : keep_set.manifest_class_set_) {
-    for (const UsageLocation& location : entry.second) {
-      printer.Print("# Referenced at ").Println(location.source.to_string());
+    if (!no_location_reference) {
+      for (const UsageLocation& location : entry.second) {
+        printer.Print("# Referenced at ").Println(location.source.to_string());
+      }
     }
     printer.Print("-keep class ").Print(entry.first).Println(" { <init>(); }");
   }
@@ -414,7 +418,9 @@
 
     if (can_be_conditional) {
       for (const UsageLocation& location : locations) {
-        printer.Print("# Referenced at ").Println(location.source.to_string());
+        if (!no_location_reference) {
+          printer.Print("# Referenced at ").Println(location.source.to_string());
+        }
         printer.Print("-if class **.R$layout { int ")
             .Print(JavaClassGenerator::TransformToFieldName(location.name.entry))
             .Println("; }");
@@ -424,8 +430,10 @@
         printer.Println("); }");
       }
     } else {
-      for (const UsageLocation& location : entry.second) {
-        printer.Print("# Referenced at ").Println(location.source.to_string());
+      if (!no_location_reference) {
+        for (const UsageLocation& location : entry.second) {
+          printer.Print("# Referenced at ").Println(location.source.to_string());
+        }
       }
 
       printer.Print("-keep class ").Print(entry.first.name).Print(" { <init>(");
@@ -436,8 +444,10 @@
   }
 
   for (const auto& entry : keep_set.method_set_) {
-    for (const UsageLocation& location : entry.second) {
-      printer.Print("# Referenced at ").Println(location.source.to_string());
+    if (!no_location_reference) {
+      for (const UsageLocation& location : entry.second) {
+        printer.Print("# Referenced at ").Println(location.source.to_string());
+      }
     }
     printer.Print("-keepclassmembers class * { *** ").Print(entry.first.name)
         .Print("(").Print(entry.first.signature).Println("); }");