diff options
author | Adam Koski <adamkoski@google.com> | 2017-11-15 12:48:49 -0800 |
---|---|---|
committer | Adam Koski <adamkoski@google.com> | 2017-11-20 14:54:28 -0800 |
commit | f85eec8403226be8cb7584b95ea185616d2e017b (patch) | |
tree | 7bdb41112e8a2d97dd9f1e64e690385dcf823e6a /tools/aapt2/java | |
parent | de3766e95d880ea6c9f3e9280a8ac921effe47a8 (diff) |
Fix conditional keep rules for new semantics
New conditional syntax is a logical AND, not OR. This means if a
resource should be conditionally kept by multiple ids, we need to
generate a separate rule for each condition (which will be interpreted
as OR).
Test: unit tests
Bug: 69341430
Change-Id: I0786c65561d36fbf43d181a2dfd0c7eaf1d96b8c
Diffstat (limited to 'tools/aapt2/java')
-rw-r--r-- | tools/aapt2/java/ProguardRules.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/tools/aapt2/java/ProguardRules.cpp b/tools/aapt2/java/ProguardRules.cpp index 132b234ab1e4..ffcef8966654 100644 --- a/tools/aapt2/java/ProguardRules.cpp +++ b/tools/aapt2/java/ProguardRules.cpp @@ -346,22 +346,20 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out) { can_be_conditional &= CollectLocations(location, keep_set, &locations); } - for (const UsageLocation& location : entry.second) { - printer.Print("# Referenced at ").Println(location.source.to_string()); - } if (keep_set.conditional_keep_rules_ && can_be_conditional) { - printer.Println("-if class **.R$layout {"); - printer.Indent(); for (const UsageLocation& location : locations) { - printer.Print("int ") + printer.Print("# Referenced at ").Println(location.source.to_string()); + printer.Print("-if class **.R$layout { int ") .Print(JavaClassGenerator::TransformToFieldName(location.name.entry)) - .Println(";"); + .Println("; }"); + printer.Print("-keep class ").Print(entry.first).Println(" { <init>(...); }"); } - printer.Undent(); - printer.Println("}"); - printer.Println(); + } else { + for (const UsageLocation& location : entry.second) { + printer.Print("# Referenced at ").Println(location.source.to_string()); + } + printer.Print("-keep class ").Print(entry.first).Println(" { <init>(...); }"); } - printer.Print("-keep class ").Print(entry.first).Println(" { <init>(...); }"); printer.Println(); } |