blob: 1e7e9b01b1530b0230bf5c34710ab990c2f8ca27 [file] [log] [blame]
Jared Duke0504e562022-02-02 15:25:22 -08001# TODO(b/210510433): Refine and optimize this configuration. Note that this
Jared Duke4514bdf2021-11-18 13:18:21 -08002# configuration is only used when `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA=true`.
Jared Duke4514bdf2021-11-18 13:18:21 -08003
Jared Duke0504e562022-02-02 15:25:22 -08004# Preserve line number information for debugging stack traces.
5-keepattributes SourceFile,LineNumberTable
Jared Dukeedb13392021-12-14 11:10:20 -08006
7# Allows making private and protected methods/fields public as part of
8# optimization. This enables inlining of trivial getter/setter methods.
9-allowaccessmodification
10
Jared Duke0504e562022-02-02 15:25:22 -080011# Process entrypoint
12-keep class com.android.server.SystemServer {
13 public static void main(java.lang.String[]);
Jared Dukeedb13392021-12-14 11:10:20 -080014}
Jared Duke0504e562022-02-02 15:25:22 -080015
16# APIs referenced by dependent JAR files and modules
Jared Duked7769ef2023-11-03 02:02:49 +000017# TODO(b/300514883): Pull @SystemApi keep rules from system-api.pro.
18-keep interface android.annotation.SystemApi
Jared Duke0504e562022-02-02 15:25:22 -080019-keep @android.annotation.SystemApi class * {
20 public protected *;
21}
22-keepclasseswithmembers class * {
23 @android.annotation.SystemApi *;
24}
Jared Duked7769ef2023-11-03 02:02:49 +000025# Also ensure nested classes are kept. This is overly conservative, but handles
26# cases where such classes aren't explicitly marked @SystemApi.
27-if @android.annotation.SystemApi class *
28-keep public class <1>$** {
29 public protected *;
30}
Jared Duke0504e562022-02-02 15:25:22 -080031
32# Derivatives of SystemService and other services created via reflection
33-keep,allowoptimization,allowaccessmodification class * extends com.android.server.SystemService {
34 public <methods>;
35}
Jared Duke0504e562022-02-02 15:25:22 -080036
Alan Stokes8c9302c2022-05-06 18:35:12 +010037# Accessed from com.android.compos APEX
38-keep,allowoptimization,allowaccessmodification class com.android.internal.art.ArtStatsLog {
39 public static void write(...);
40}
41
Jared Duke0504e562022-02-02 15:25:22 -080042# Various classes subclassed in or referenced via JNI in ethernet-service
43-keep public class android.net.** { *; }
44-keep,allowoptimization,allowaccessmodification class com.android.net.module.util.* { *; }
45-keep,allowoptimization,allowaccessmodification public class com.android.server.net.IpConfigStore { *; }
46-keep,allowoptimization,allowaccessmodification public class com.android.server.net.BaseNetworkObserver { *; }
tyiud5dd07c2023-10-27 00:08:37 +000047-keep,allowoptimization,allowaccessmodification class com.android.server.display.feature.DisplayManagerFlags { *; }
48-keep,allowoptimization,allowaccessmodification class android.app.admin.flags.FeatureFlagsImpl { *; }
49-keep,allowoptimization,allowaccessmodification class com.android.server.input.NativeInputManagerService$NativeImpl { *; }
50-keep,allowoptimization,allowaccessmodification class com.android.server.ThreadPriorityBooster { *; }
Timothy Yiu1149dbb2024-03-19 02:56:06 +000051
52# Keep all aconfig Flag class as they might be statically referenced by other packages
53# An merge or inlining could lead to missing dependencies that cause run time errors
54-keepclassmembernames class android.**.Flags, com.android.**.Flags { public *; }
Jared Duke0504e562022-02-02 15:25:22 -080055
56# Referenced via CarServiceHelperService in car-frameworks-service (avoid removing)
57-keep public class com.android.server.utils.Slogf { *; }
58
Xin Guanee58f492022-08-02 02:56:54 +000059# Referenced in wear-service
Xin Guanee58f492022-08-02 02:56:54 +000060-keep public class com.android.server.wm.WindowManagerInternal { *; }
61
Jared Duke0504e562022-02-02 15:25:22 -080062# JNI keep rules
Jared Duke3027b4d2022-12-14 12:30:14 -080063# The global keep rule for native methods allows stripping of such methods if they're unreferenced
64# in Java. However, because system_server explicitly registers these methods from native code,
65# stripping them in Java can cause runtime issues. As such, conservatively keep all such methods in
66# system_server subpackages as long as the containing class is also kept or referenced.
67-keepclassmembers class com.android.server.** {
68 native <methods>;
69}
Jared Duke0504e562022-02-02 15:25:22 -080070# TODO(b/210510433): Revisit and fix with @Keep, or consider auto-generating from
71# frameworks/base/services/core/jni/onload.cpp.
72-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.BroadcastRadioService { *; }
73-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.Convert { *; }
74-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.Tuner { *; }
75-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.TunerCallback { *; }
76-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.GnssConfiguration$HalInterfaceVersion { *; }
77-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.GnssPowerStats { *; }
78-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.hal.GnssNative { *; }
Jared Dukedc50c852022-02-25 13:50:58 -080079-keep,allowoptimization,allowaccessmodification class com.android.server.pm.PackageManagerShellCommandDataLoader { *; }
Vladimir Komsiyski9d5084d2023-02-10 09:54:19 +010080-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$RuntimeSensorCallback { *; }
Jared Duke0504e562022-02-02 15:25:22 -080081-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$ProximityActiveListener { *; }
82-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorService { *; }
83-keep,allowoptimization,allowaccessmodification class com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl$AudioSessionProvider$AudioSession { *; }
84-keep,allowoptimization,allowaccessmodification class com.android.server.soundtrigger_middleware.ExternalCaptureStateTracker { *; }
85-keep,allowoptimization,allowaccessmodification class com.android.server.storage.AppFuseBridge { *; }
86-keep,allowoptimization,allowaccessmodification class com.android.server.tv.TvInputHal { *; }
87-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaJackDetector { *; }
Robert Wu8e7bf0f2023-01-26 01:44:07 +000088-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaMidiDevice { *; }
Jared Duke0504e562022-02-02 15:25:22 -080089-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorController$OnVibrationCompleteListener { *; }
90-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorManagerService$OnSyncedVibrationCompleteListener { *; }
91-keepclasseswithmembers,allowoptimization,allowaccessmodification class com.android.server.** {
92 *** *FromNative(...);
93}
94-keep,allowoptimization,allowaccessmodification class com.android.server.input.InputManagerService {
95 <methods>;
96}
97-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbHostManager {
98 *** usbDeviceRemoved(...);
99 *** usbDeviceAdded(...);
100}
101-keep,allowoptimization,allowaccessmodification class **.*NativeWrapper* { *; }
102
103# Miscellaneous reflection keep rules
104# TODO(b/210510433): Revisit and fix with @Keep.
Jared Duke0504e562022-02-02 15:25:22 -0800105-keep,allowoptimization,allowaccessmodification class android.hardware.usb.gadget.** { *; }
106
107# Needed when optimizations enabled
108# TODO(b/210510433): Revisit and fix with @Keep.
109-keep,allowoptimization,allowaccessmodification class com.android.server.SystemService { *; }
110-keep,allowoptimization,allowaccessmodification class com.android.server.SystemService$TargetUser { *; }
111-keep,allowoptimization,allowaccessmodification class com.android.server.usage.StorageStatsManagerLocal { *; }
Jared Dukee236dd72024-08-13 21:14:57 +0000112
113# Prevent optimizations of any statically linked code that may shadow code in
114# the bootclasspath. See also StrictJavaPackagesTest for details on exceptions.
115# TODO(b/222468116): Resolve such collisions in the build system.
116-keep public class android.gsi.** { *; }
117-keep public class android.hidl.base.** { *; }
118-keep public class android.hidl.manager.** { *; }
119-keep public class android.os.** { *; }
120-keep public class com.android.internal.util.** { *; }
121-keep public class com.android.modules.utils.build.** { *; }
Jared Dukeb0242b32024-08-14 20:57:44 +0000122# Also suppress related duplicate type warnings for the above kept classes.
123-dontwarn android.gsi.**
124-dontwarn android.hidl.base.**
125-dontwarn android.hidl.manager.**
126-dontwarn android.os.**
127-dontwarn com.android.internal.util.**
128-dontwarn com.android.modules.utils.build.**
Jared Duke06689ad2022-09-07 12:24:36 -0700129
130# CoverageService guards optional jacoco class references with a runtime guard, so we can safely
131# suppress build-time warnings.
132-dontwarn org.jacoco.agent.rt.*