summaryrefslogtreecommitdiffstats
path: root/mobile/android/geckoview/proguard-rules.txt
blob: 52c221ca6de3ffee006fc86100178db7778cd165 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# Modified from https://robotsandpencils.com/blog/use-proguard-android-library/.

# Preserve all annotations.

-keepattributes *Annotation*

# Preserve all .class method names.

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

# Preserve all native method names and the names of their classes.

-keepclasseswithmembernames,includedescriptorclasses class * {
    native <methods>;
}

# Preserve the special static methods that are required in all enumeration
# classes.

-keepclassmembers class * extends java.lang.Enum {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
# You can comment this out if your library doesn't use serialization.
# If your code contains serializable classes that have to be backward
# compatible, please refer to the manual.

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Preserve all View implementations and their special context constructors.

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet);
    public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}

# Keep setters in Views so that animations can still work.
# See http://proguard.sourceforge.net/manual/examples.html#beans
# From tools/proguard/proguard-android.txt.
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# Preserve all classes that have special context constructors, and the
# constructors themselves.

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

# Preserve the special fields of all Parcelable implementations.

-keepclassmembers class * implements android.os.Parcelable {
    static android.os.Parcelable$Creator CREATOR;
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.

-keepclassmembers class **.R$* {
  public static <fields>;
}

# GeckoView specific rules.

# Keep everthing in org.mozilla.geckoview
-keep class org.mozilla.geckoview.** { *; }

-keep class org.mozilla.gecko.SysInfo {
    *;
}

-keep class org.mozilla.gecko.mozglue.JNIObject {
    *;
}

-keep class * extends org.mozilla.gecko.mozglue.JNIObject {
    *;
}

# Keep the annotation.
-keep @interface org.mozilla.gecko.annotation.JNITarget

# Keep classes tagged with the annotation.
-keep @org.mozilla.gecko.annotation.JNITarget class *

# Keep all members of an annotated class.
-keepclassmembers @org.mozilla.gecko.annotation.JNITarget class * {
    *;
}

# Keep annotated members of any class.
-keepclassmembers class * {
    @org.mozilla.gecko.annotation.JNITarget *;
}

# Keep classes which contain at least one annotated element. Split over two directives
# because, according to the developer of ProGuard, "the option -keepclasseswithmembers
# doesn't combine well with the '*' wildcard" (And, indeed, using it causes things to
# be deleted that we want to keep.)
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.JNITarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.JNITarget <fields>;
}

# Keep WebRTC targets.
-keep @interface org.mozilla.gecko.annotation.WebRTCJNITarget
-keep @org.mozilla.gecko.annotation.WebRTCJNITarget class *
-keepclassmembers class * {
    @org.mozilla.gecko.annotation.WebRTCJNITarget *;
}
-keepclassmembers @org.mozilla.gecko.annotation.WebRTCJNITarget class * {
    *;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.WebRTCJNITarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.WebRTCJNITarget <fields>;
}

# Keep generator-targeted entry points.
-keep @interface org.mozilla.gecko.annotation.WrapForJNI
-keep @org.mozilla.gecko.annotation.WrapForJNI class *
-keepclassmembers,includedescriptorclasses class * {
    @org.mozilla.gecko.annotation.WrapForJNI *;
}
-keepclasseswithmembers,includedescriptorclasses class * {
    @org.mozilla.gecko.annotation.WrapForJNI <methods>;
}
-keepclasseswithmembers,includedescriptorclasses class * {
    @org.mozilla.gecko.annotation.WrapForJNI <fields>;
}

# Keep all members of an annotated class.
-keepclassmembers,includedescriptorclasses @org.mozilla.gecko.annotation.WrapForJNI class * {
    *;
}

# Keep Reflection targets.
-keep @interface org.mozilla.gecko.annotation.ReflectionTarget
-keep @org.mozilla.gecko.annotation.ReflectionTarget class *
-keepclassmembers class * {
    @org.mozilla.gecko.annotation.ReflectionTarget *;
}
-keepclassmembers @org.mozilla.gecko.annotation.ReflectionTarget class * {
    *;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.ReflectionTarget <methods>;
}
-keepclasseswithmembers class * {
    @org.mozilla.gecko.annotation.ReflectionTarget <fields>;
}

# Avoid "Warning: org.yaml.snakeyaml.scanner.ScannerImpl: can't find
# referenced method 'java.nio.ByteBuffer flip()' in library class
# java.nio.ByteBuffer".
# Between Java 1.8 and 1.9, the signature of `flip()` changed, which
# trips up proguard.

-dontwarn org.yaml.snakeyaml.scanner.ScannerImpl