xref: /aosp_15_r20/external/cronet/components/cronet/android/cronet_impl_native_proguard.cfg (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Proguard config for apps that depend on cronet_impl_native_java.jar.
2
3# This constructor is called using the reflection from Cronet API (cronet_api.jar).
4-keep class org.chromium.net.impl.NativeCronetProvider {
5    public <init>(android.content.Context);
6}
7
8# While Chrome doesn't need to keep these with their version of R8, some cronet
9# users may be on other optimizers which still require the annotation to be
10# kept in order for the keep rules to work.
11-keep @interface org.chromium.build.annotations.DoNotInline
12-keep @interface org.chromium.build.annotations.UsedByReflection
13-keep @interface org.chromium.build.annotations.IdentifierNameString
14-keep @interface org.jni_zero.AccessedByNative
15-keep @interface org.jni_zero.CalledByNative
16-keep @interface org.jni_zero.CalledByNativeUnchecked
17
18# Suppress unnecessary warnings.
19-dontnote org.chromium.net.ProxyChangeListener$ProxyReceiver
20-dontnote org.chromium.net.AndroidKeyStore
21# Needs 'void setTextAppearance(int)' (API level 23).
22-dontwarn org.chromium.base.ApiCompatibilityUtils
23# Needs 'boolean onSearchRequested(android.view.SearchEvent)' (API level 23).
24-dontwarn org.chromium.base.WindowCallbackWrapper
25
26# Generated for chrome apk and not included into cronet.
27-dontwarn org.chromium.base.multidex.ChromiumMultiDexInstaller
28-dontwarn org.chromium.base.library_loader.LibraryLoader
29-dontwarn org.chromium.base.SysUtils
30-dontwarn org.chromium.build.NativeLibraries
31
32# Objects of this type are passed around by native code, but the class
33# is never used directly by native code. Since the class is not loaded, it does
34# not need to be preserved as an entry point.
35-dontnote org.chromium.net.UrlRequest$ResponseHeadersMap
36# https://android.googlesource.com/platform/sdk/+/marshmallow-mr1-release/files/proguard-android.txt#54
37-dontwarn android.support.**
38
39# This class should be explicitly kept to avoid failure if
40# class/merging/horizontal proguard optimization is enabled.
41-keep class org.chromium.base.CollectionUtil
42
43# Skip protobuf runtime check for isOnAndroidDevice().
44# A nice-to-have optimization shamelessly stolen from //third_party/protobuf/java/lite/proguard.pgcfg.
45-assumevalues class com.google.protobuf.Android {
46    static boolean ASSUME_ANDROID return true;
47}
48
49# See crbug.com/1440987. We must keep every native that we are manually
50# registering. If Cronet bumps its min-sdk past 21, we may be able to move to
51# automatic JNI registration.
52-keepclasseswithmembers,includedescriptorclasses,allowaccessmodification class org.chromium.**,J.N {
53  native <methods>;
54}
55
56# Protobuf builder uses reflection so make sure ProGuard leaves it alone. See
57# https://crbug.com/1395764.
58# Note that we can't simply use the rule from
59# //third_party/protobuf/java/lite/proguard.pgcfg, because some users who
60# consume our ProGuard rules do not want all their protos to be kept. Instead,
61# use a more specific rule that covers Chromium protos only.
62-keepclassmembers class org.chromium.** extends com.google.protobuf.GeneratedMessageLite {
63  <fields>;
64}
65