Change conditional keep rule syntax

Google's ProGuard fork is migrating to a new syntax that upstream
ProGuard 6.0 will also support.

Test: unit tests
Bug: 69162105
Change-Id: I3b6d7e82eb99c2e2af6c4d851a4f97ec3e471b55
diff --git a/tools/aapt2/java/ProguardRules.cpp b/tools/aapt2/java/ProguardRules.cpp
index b9ae654..b214d21 100644
--- a/tools/aapt2/java/ProguardRules.cpp
+++ b/tools/aapt2/java/ProguardRules.cpp
@@ -345,15 +345,14 @@
       *out << "# Referenced at " << location.source << "\n";
     }
     if (keep_set.conditional_keep_rules_ && can_be_conditional) {
-      *out << "-keep class " << entry.first << " {\n  ifused class **.R$layout {\n";
+      *out << "-if class **.R$layout {\n";
       for (const UsageLocation& location : locations) {
         auto transformed_name = JavaClassGenerator::TransformToFieldName(location.name.entry);
-        *out << "    int " << transformed_name << ";\n";
+        *out << "  int " << transformed_name << ";\n";
       }
-      *out << "  };\n  <init>(...);\n}\n" << std::endl;
-    } else {
-      *out << "-keep class " << entry.first << " { <init>(...); }\n" << std::endl;
+      *out << "}\n";
     }
+    *out << "-keep class " << entry.first << " { <init>(...); }\n" << std::endl;
   }
 
   for (const auto& entry : keep_set.method_set_) {