| # Copyright 2022 The Chromium Authors |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # Contains flags related to annotations in //build/android that can be safely |
| # shared with Cronet, and thus would be appropriate for third-party apps to |
| # include. |
| |
| # Keep all annotation related attributes that can affect runtime |
| -keepattributes RuntimeVisible*Annotations |
| -keepattributes AnnotationDefault |
| |
| # Keep the annotations, because if we don't, the ProGuard rules that use them |
| # will not be respected. These classes then show up in our final dex, which we |
| # do not want - see crbug.com/628226. |
| -keep @interface org.chromium.base.annotations.AccessedByNative |
| -keep @interface org.chromium.base.annotations.CalledByNative |
| -keep @interface org.chromium.base.annotations.CalledByNativeUnchecked |
| -keep @interface org.chromium.build.annotations.DoNotInline |
| -keep @interface org.chromium.build.annotations.UsedByReflection |
| -keep @interface org.chromium.build.annotations.IdentifierNameString |
| |
| # Keeps for class level annotations. |
| -keep,allowaccessmodification @org.chromium.build.annotations.UsedByReflection class ** {} |
| |
| # Keeps for method level annotations. |
| -keepclasseswithmembers,allowaccessmodification class ** { |
| @org.chromium.base.annotations.AccessedByNative <fields>; |
| } |
| -keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** { |
| @org.chromium.base.annotations.CalledByNative <methods>; |
| } |
| -keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class ** { |
| @org.chromium.base.annotations.CalledByNativeUnchecked <methods>; |
| } |
| -keepclasseswithmembers,allowaccessmodification class ** { |
| @org.chromium.build.annotations.UsedByReflection <methods>; |
| } |
| -keepclasseswithmembers,allowaccessmodification class ** { |
| @org.chromium.build.annotations.UsedByReflection <fields>; |
| } |
| |
| # Never inline classes, methods, or fields with this annotation, but allow |
| # shrinking and obfuscation. |
| # Relevant to fields when they are needed to store strong references to objects |
| # that are held as weak references by native code. |
| -if @org.chromium.build.annotations.DoNotInline class * { |
| *** *(...); |
| } |
| -keep,allowobfuscation,allowaccessmodification class <1> { |
| *** <2>(...); |
| } |
| -keepclassmembers,allowobfuscation,allowaccessmodification class * { |
| @org.chromium.build.annotations.DoNotInline <methods>; |
| } |
| -keepclassmembers,allowobfuscation,allowaccessmodification class * { |
| @org.chromium.build.annotations.DoNotInline <fields>; |
| } |
| |
| -alwaysinline class * { |
| @org.chromium.build.annotations.AlwaysInline *; |
| } |
| |
| # Keep all logs (Log.VERBOSE = 2). R8 does not allow setting to 0. |
| -maximumremovedandroidloglevel 1 class ** { |
| @org.chromium.build.annotations.DoNotStripLogs <methods>; |
| } |
| -maximumremovedandroidloglevel 1 @org.chromium.build.annotations.DoNotStripLogs class ** { |
| <methods>; |
| } |
| |
| # Never merge classes horizontally or vertically with this annotation. |
| # Relevant to classes being used as a key in maps or sets. |
| -keep,allowaccessmodification,allowobfuscation,allowshrinking @org.chromium.build.annotations.DoNotClassMerge class * |
| |
| # Mark members annotated with IdentifierNameString as identifier name strings |
| -identifiernamestring class * { |
| @org.chromium.build.annotations.IdentifierNameString *; |
| } |