blob: 30c4525a51e11722ed579e06c5cd251fbb5d6747 [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
Alan Stokes8c9302c2022-05-06 18:35:12 +010032# Accessed from com.android.compos APEX
33-keep,allowoptimization,allowaccessmodification class com.android.internal.art.ArtStatsLog {
34 public static void write(...);
35}
36
Jared Duke0504e562022-02-02 15:25:22 -080037# Various classes subclassed in or referenced via JNI in ethernet-service
38-keep public class android.net.** { *; }
39-keep,allowoptimization,allowaccessmodification class com.android.net.module.util.* { *; }
40-keep,allowoptimization,allowaccessmodification public class com.android.server.net.IpConfigStore { *; }
41-keep,allowoptimization,allowaccessmodification public class com.android.server.net.BaseNetworkObserver { *; }
tyiud5dd07c2023-10-27 00:08:37 +000042-keep,allowoptimization,allowaccessmodification class com.android.server.display.feature.DisplayManagerFlags { *; }
43-keep,allowoptimization,allowaccessmodification class android.app.admin.flags.FeatureFlagsImpl { *; }
44-keep,allowoptimization,allowaccessmodification class com.android.server.input.NativeInputManagerService$NativeImpl { *; }
45-keep,allowoptimization,allowaccessmodification class com.android.server.ThreadPriorityBooster { *; }
Timothy Yiu1149dbb2024-03-19 02:56:06 +000046
Sandeep Bandaru46f44ce2024-11-26 18:44:20 +000047# allow invoking start-service using class name in both apex and services jar.
48-keep,allowoptimization,allowaccessmodification class com.android.server.ondeviceintelligence.OnDeviceIntelligenceManagerService { *; }
49
Timothy Yiu1149dbb2024-03-19 02:56:06 +000050# Keep all aconfig Flag class as they might be statically referenced by other packages
51# An merge or inlining could lead to missing dependencies that cause run time errors
52-keepclassmembernames class android.**.Flags, com.android.**.Flags { public *; }
Jared Duke0504e562022-02-02 15:25:22 -080053
54# Referenced via CarServiceHelperService in car-frameworks-service (avoid removing)
55-keep public class com.android.server.utils.Slogf { *; }
56
Xin Guanee58f492022-08-02 02:56:54 +000057# Referenced in wear-service
Xin Guanee58f492022-08-02 02:56:54 +000058-keep public class com.android.server.wm.WindowManagerInternal { *; }
59
Jared Duke0504e562022-02-02 15:25:22 -080060# JNI keep rules
Jared Duke3027b4d2022-12-14 12:30:14 -080061# The global keep rule for native methods allows stripping of such methods if they're unreferenced
62# in Java. However, because system_server explicitly registers these methods from native code,
63# stripping them in Java can cause runtime issues. As such, conservatively keep all such methods in
64# system_server subpackages as long as the containing class is also kept or referenced.
65-keepclassmembers class com.android.server.** {
66 native <methods>;
67}
Jared Duke0504e562022-02-02 15:25:22 -080068# TODO(b/210510433): Revisit and fix with @Keep, or consider auto-generating from
69# frameworks/base/services/core/jni/onload.cpp.
70-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.BroadcastRadioService { *; }
71-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.Convert { *; }
72-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.Tuner { *; }
73-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.TunerCallback { *; }
74-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.GnssConfiguration$HalInterfaceVersion { *; }
75-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.GnssPowerStats { *; }
76-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.hal.GnssNative { *; }
Jared Dukedc50c852022-02-25 13:50:58 -080077-keep,allowoptimization,allowaccessmodification class com.android.server.pm.PackageManagerShellCommandDataLoader { *; }
Vladimir Komsiyski9d5084d2023-02-10 09:54:19 +010078-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$RuntimeSensorCallback { *; }
Jared Duke0504e562022-02-02 15:25:22 -080079-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$ProximityActiveListener { *; }
80-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorService { *; }
81-keep,allowoptimization,allowaccessmodification class com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl$AudioSessionProvider$AudioSession { *; }
82-keep,allowoptimization,allowaccessmodification class com.android.server.soundtrigger_middleware.ExternalCaptureStateTracker { *; }
83-keep,allowoptimization,allowaccessmodification class com.android.server.storage.AppFuseBridge { *; }
84-keep,allowoptimization,allowaccessmodification class com.android.server.tv.TvInputHal { *; }
85-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaJackDetector { *; }
Robert Wu8e7bf0f2023-01-26 01:44:07 +000086-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaMidiDevice { *; }
Jared Duke0504e562022-02-02 15:25:22 -080087-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorController$OnVibrationCompleteListener { *; }
Lais Andrade8c986282024-10-24 16:03:34 +010088-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorManagerService$VibratorManagerNativeCallbacks { *; }
Jared Duke0504e562022-02-02 15:25:22 -080089-keepclasseswithmembers,allowoptimization,allowaccessmodification class com.android.server.** {
90 *** *FromNative(...);
91}
92-keep,allowoptimization,allowaccessmodification class com.android.server.input.InputManagerService {
93 <methods>;
94}
95-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbHostManager {
96 *** usbDeviceRemoved(...);
97 *** usbDeviceAdded(...);
98}
99-keep,allowoptimization,allowaccessmodification class **.*NativeWrapper* { *; }
100
101# Miscellaneous reflection keep rules
102# TODO(b/210510433): Revisit and fix with @Keep.
Jared Duke0504e562022-02-02 15:25:22 -0800103-keep,allowoptimization,allowaccessmodification class android.hardware.usb.gadget.** { *; }
104
105# Needed when optimizations enabled
106# TODO(b/210510433): Revisit and fix with @Keep.
107-keep,allowoptimization,allowaccessmodification class com.android.server.SystemService { *; }
108-keep,allowoptimization,allowaccessmodification class com.android.server.SystemService$TargetUser { *; }
109-keep,allowoptimization,allowaccessmodification class com.android.server.usage.StorageStatsManagerLocal { *; }
Jared Dukee236dd72024-08-13 21:14:57 +0000110
111# Prevent optimizations of any statically linked code that may shadow code in
112# the bootclasspath. See also StrictJavaPackagesTest for details on exceptions.
113# TODO(b/222468116): Resolve such collisions in the build system.
114-keep public class android.gsi.** { *; }
115-keep public class android.hidl.base.** { *; }
116-keep public class android.hidl.manager.** { *; }
117-keep public class android.os.** { *; }
118-keep public class com.android.internal.util.** { *; }
119-keep public class com.android.modules.utils.build.** { *; }
Jared Dukeb0242b32024-08-14 20:57:44 +0000120# Also suppress related duplicate type warnings for the above kept classes.
121-dontwarn android.gsi.**
122-dontwarn android.hidl.base.**
123-dontwarn android.hidl.manager.**
124-dontwarn android.os.**
125-dontwarn com.android.internal.util.**
126-dontwarn com.android.modules.utils.build.**
Jared Duke06689ad2022-09-07 12:24:36 -0700127
128# CoverageService guards optional jacoco class references with a runtime guard, so we can safely
129# suppress build-time warnings.
130-dontwarn org.jacoco.agent.rt.*
Adnan Begovic14e307c12015-07-06 20:06:36 -0700131
132# SDK
133-keep,allowoptimization,allowaccessmodification class omnirom.** { *; }
134-keep,allowoptimization,allowaccessmodification class org.omnirom.** { *; }
Michael Bestas33a324bb82023-05-21 20:16:09 +0300135-keep,allowoptimization,allowaccessmodification class vendor.lineage.** { *; }