| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # Contains flags that can be safely shared with Cronet, and thus would be | 5 # Contains flags that can be safely shared with Cronet, and thus would be |
| 6 # appropriate for third-party apps to include. | 6 # appropriate for third-party apps to include. |
| 7 | 7 |
| 8 # Keep all annotation related attributes that can affect runtime | 8 # Keep all annotation related attributes that can affect runtime |
| 9 -keepattributes RuntimeVisible*Annotations | 9 -keepattributes RuntimeVisible*Annotations |
| 10 -keepattributes AnnotationDefault | 10 -keepattributes AnnotationDefault |
| 11 | 11 |
| 12 # Keep the annotations, because if we don't, the ProGuard rules that use them | 12 # Keep the annotations, because if we don't, the ProGuard rules that use them |
| 13 # will not be respected. These classes then show up in our final dex, which we | 13 # will not be respected. These classes then show up in our final dex, which we |
| 14 # do not want - see crbug.com/628226. | 14 # do not want - see crbug.com/628226. |
| 15 -keep @interface org.chromium.base.annotations.AccessedByNative | 15 -keep @interface org.chromium.base.annotations.AccessedByNative |
| 16 -keep @interface org.chromium.base.annotations.CalledByNative | 16 -keep @interface org.chromium.base.annotations.CalledByNative |
| 17 -keep @interface org.chromium.base.annotations.CalledByNativeUnchecked | 17 -keep @interface org.chromium.base.annotations.CalledByNativeUnchecked |
| 18 -keep @interface org.chromium.base.annotations.RemovableInRelease | 18 -keep @interface org.chromium.base.annotations.RemovableInRelease |
| 19 -keep @interface org.chromium.base.annotations.UsedByReflection | 19 -keep @interface org.chromium.base.annotations.UsedByReflection |
| 20 | 20 |
| 21 # Keeps for class level annotations. | 21 # Keeps for class level annotations. |
| 22 -keep @org.chromium.base.annotations.UsedByReflection class * | 22 -keep @org.chromium.base.annotations.UsedByReflection class * |
| 23 | 23 |
| 24 # Keeps for method level annotations. | 24 # Keeps for method level annotations. |
| 25 -keepclasseswithmembers class * { | 25 -keepclasseswithmembers class * { |
| 26 @org.chromium.base.annotations.AccessedByNative <fields>; | 26 @org.chromium.base.annotations.AccessedByNative <fields>; |
| 27 } | 27 } |
| 28 # -includedescriptorclasses tells it to also keep return types and parameter |
| 29 # types. |
| 28 -keepclasseswithmembers,includedescriptorclasses class * { | 30 -keepclasseswithmembers,includedescriptorclasses class * { |
| 29 @org.chromium.base.annotations.CalledByNative <methods>; | 31 @org.chromium.base.annotations.CalledByNative <methods>; |
| 30 } | 32 } |
| 31 -keepclasseswithmembers,includedescriptorclasses class * { | 33 -keepclasseswithmembers,includedescriptorclasses class * { |
| 32 @org.chromium.base.annotations.CalledByNativeUnchecked <methods>; | 34 @org.chromium.base.annotations.CalledByNativeUnchecked <methods>; |
| 33 } | 35 } |
| 34 -keepclasseswithmembers class * { | 36 -keepclasseswithmembers class * { |
| 35 @org.chromium.base.annotations.UsedByReflection <methods>; | 37 @org.chromium.base.annotations.UsedByReflection <methods>; |
| 36 } | 38 } |
| 37 -keepclasseswithmembers class * { | 39 -keepclasseswithmembers class * { |
| 38 @org.chromium.base.annotations.UsedByReflection <fields>; | 40 @org.chromium.base.annotations.UsedByReflection <fields>; |
| 39 } | 41 } |
| 40 -keepclasseswithmembers,includedescriptorclasses class * { | 42 # -keepclasseswithmembernames rather than -keepclasseswithmembers to allow |
| 43 # shrinking if it contains native methods but no @CalledByNative. |
| 44 -keepclasseswithmembernames,includedescriptorclasses class * { |
| 41 native <methods>; | 45 native <methods>; |
| 42 } | 46 } |
| 43 | 47 |
| 44 # Remove methods annotated with this if their return value is unused. | 48 # Remove methods annotated with this if their return value is unused. |
| 45 -assumenosideeffects class ** { | 49 -assumenosideeffects class ** { |
| 46 @org.chromium.base.annotations.RemovableInRelease <methods>; | 50 @org.chromium.base.annotations.RemovableInRelease <methods>; |
| 47 } | 51 } |
| 48 | 52 |
| 49 # Keep all CREATOR fields within Parcelable that are kept. | 53 # Keep all CREATOR fields within Parcelable that are kept. |
| 50 -keepclassmembers class org.chromium.** implements android.os.Parcelable { | 54 -keepclassmembers class org.chromium.** implements android.os.Parcelable { |
| 51 public static *** CREATOR; | 55 public static *** CREATOR; |
| 52 } | 56 } |
| 53 | 57 |
| 54 # Don't obfuscate Parcelables as they might be marshalled outside Chrome. | 58 # Don't obfuscate Parcelables as they might be marshalled outside Chrome. |
| 55 # If we annotated all Parcelables that get put into Bundles other than | 59 # If we annotated all Parcelables that get put into Bundles other than |
| 56 # for saveInstanceState (e.g. PendingIntents), then we could actually keep the | 60 # for saveInstanceState (e.g. PendingIntents), then we could actually keep the |
| 57 # names of just those ones. For now, we'll just keep them all. | 61 # names of just those ones. For now, we'll just keep them all. |
| 58 -keepnames class org.chromium.** implements android.os.Parcelable | 62 -keepnames class org.chromium.** implements android.os.Parcelable |
| 59 | 63 |
| 60 # Keep all enum values and valueOf methods. See | 64 # Keep all enum values and valueOf methods. See |
| 61 # http://proguard.sourceforge.net/index.html#manual/examples.html | 65 # http://proguard.sourceforge.net/index.html#manual/examples.html |
| 62 # for the reason for this. Also, see http://crbug.com/248037. | 66 # for the reason for this. Also, see http://crbug.com/248037. |
| 63 -keepclassmembers enum org.chromium.** { | 67 -keepclassmembers enum org.chromium.** { |
| 64 public static **[] values(); | 68 public static **[] values(); |
| 65 } | 69 } |
| OLD | NEW |