| # appropriate for third-party apps to include. |
| 7 |
| 8 | # Keep all annotation related attributes that can affect runtime |
| 9 | -keepattributes RuntimeVisible*Annotations |
| 10 | -keepattributes AnnotationDefault |
| 11 |
| 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 |
| 14 | # do not want - see crbug.com/628226. |
| 15 | -keep @interface org.chromium.base.annotations.AccessedByNative |
| 16 | -keep @interface org.chromium.base.annotations.CalledByNative |
| 17 | -keep @interface org.chromium.base.annotations.CalledByNativeUnchecked |
| 18 | -keep @interface org.chromium.base.annotations.DoNotInline |
| 19 | -keep @interface org.chromium.base.annotations.RemovableInRelease |
| 20 | -keep @interface org.chromium.base.annotations.UsedByReflection |
| 21 |
| 22 | # Android support library annotations will get converted to androidx ones |
| 23 | # which we want to keep. |
| 24 | -keep @interface androidx.annotation.Keep |
| 25 | -keep @androidx.annotation.Keep class * |
| 26 | -keepclasseswithmembers class * { |
| 27 | @androidx.annotation.Keep <fields>; |
| 28 | } |
| 29 | -keepclasseswithmembers class * { |
| 30 | @androidx.annotation.Keep <methods>; |
| 31 | } |
| 32 |
| 33 | # Keeps for class level annotations. |
| 34 | -keep @org.chromium.base.annotations.UsedByReflection class ** {} |
| 35 |
| 36 | # Keeps for method level annotations. |
| 37 | -keepclasseswithmembers class ** { |
| 38 | @org.chromium.base.annotations.AccessedByNative <fields>; |
| 39 | } |
| 40 | -keepclasseswithmembers,includedescriptorclasses class ** { |
| 41 | @org.chromium.base.annotations.CalledByNative <methods>; |
| 42 | } |
| 43 | -keepclasseswithmembers,includedescriptorclasses class ** { |
| 44 | @org.chromium.base.annotations.CalledByNativeUnchecked <methods>; |
| 45 | } |
| 46 | -keepclasseswithmembers class ** { |
| 47 | @org.chromium.base.annotations.UsedByReflection <methods>; |
| 48 | } |
| 49 | -keepclasseswithmembers class ** { |
| 50 | @org.chromium.base.annotations.UsedByReflection <fields>; |
| 51 | } |
| 52 | # Even unused methods kept due to explicit jni registration: |
| 53 | # https://crbug.com/688465. |
| 54 | -keepclasseswithmembers,includedescriptorclasses class !org.chromium.base.library_loader.**,** { |
| 55 | native <methods>; |
| 56 | } |
| 57 | -keepclasseswithmembernames,includedescriptorclasses class org.chromium.base.library_loader.** { |
| 58 | native <methods>; |
| 59 | } |
| 60 |
| 61 | -assumenosideeffects class ** { |
| 62 | # Remove @RemovableInRelease methods so long as return values are unused. |
| 63 | @org.chromium.base.annotations.RemovableInRelease <methods>; |
| 64 | # Remove object @RemovableInRelease methods even when return value is used. |
| 65 | # Note: * in return type does not match primitives. |
| 66 | @org.chromium.base.annotations.RemovableInRelease * *(...) return null; |
| 67 | # Remove boolean @RemovableInRelease methods even when return value is used. |
| 68 | @org.chromium.base.annotations.RemovableInRelease boolean *(...) return false; |
| 69 | } |
| 70 |
| 71 | # Never inline classes or methods with this annotation, but allow shrinking and |
| 72 | # obfuscation. |
| 73 | -keep,allowobfuscation,allowoptimization @org.chromium.base.annotations.DoNotInline class ** { |
| 74 | <methods>; |
| 75 | } |
| 76 | -keepclassmembers,allowobfuscation,allowoptimization class ** { |
| 77 | @org.chromium.base.annotations.DoNotInline <methods>; |
| 78 | } |
| 79 |
| 80 | # Keep all CREATOR fields within Parcelable that are kept. |
| 81 | -keepclassmembers class org.chromium.** implements android.os.Parcelable { |
| 82 | public static *** CREATOR; |
| 83 | } |
| 84 |
| 85 | # Don't obfuscate Parcelables as they might be marshalled outside Chrome. |
| 86 | # If we annotated all Parcelables that get put into Bundles other than |
| 87 | # for saveInstanceState (e.g. PendingIntents), then we could actually keep the |
| 88 | # names of just those ones. For now, we'll just keep them all. |
| 89 | -keepnames class org.chromium.** implements android.os.Parcelable {} |
| 90 |
| 91 | # Keep all enum values and valueOf methods. See |
| 92 | # http://proguard.sourceforge.net/index.html#manual/examples.html |
| 93 | # for the reason for this. Also, see http://crbug.com/248037. |
| 94 | -keepclassmembers enum org.chromium.** { |
| 95 | public static **[] values(); |
| 96 | } |
| 97 |