blob: 53aa5d20c18df564a82cbbeee25b9a3a42d104bd [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.
Christoffer Adamsen6dcde632025-01-06 19:05:18 +010018# TODO(b/373579455): Evaluate if <init> needs to be kept.
19-keep interface android.annotation.SystemApi {
20 void <init>();
21}
Jared Duke0504e562022-02-02 15:25:22 -080022-keep @android.annotation.SystemApi class * {
23 public protected *;
24}
25-keepclasseswithmembers class * {
26 @android.annotation.SystemApi *;
27}
Jared Duked7769ef2023-11-03 02:02:49 +000028# Also ensure nested classes are kept. This is overly conservative, but handles
29# cases where such classes aren't explicitly marked @SystemApi.
30-if @android.annotation.SystemApi class *
31-keep public class <1>$** {
32 public protected *;
33}
Jared Duke0504e562022-02-02 15:25:22 -080034
Alan Stokes8c9302c2022-05-06 18:35:12 +010035# Accessed from com.android.compos APEX
36-keep,allowoptimization,allowaccessmodification class com.android.internal.art.ArtStatsLog {
37 public static void write(...);
38}
39
Jared Duke0504e562022-02-02 15:25:22 -080040# Various classes subclassed in or referenced via JNI in ethernet-service
41-keep public class android.net.** { *; }
42-keep,allowoptimization,allowaccessmodification class com.android.net.module.util.* { *; }
43-keep,allowoptimization,allowaccessmodification public class com.android.server.net.IpConfigStore { *; }
44-keep,allowoptimization,allowaccessmodification public class com.android.server.net.BaseNetworkObserver { *; }
tyiud5dd07c2023-10-27 00:08:37 +000045-keep,allowoptimization,allowaccessmodification class com.android.server.display.feature.DisplayManagerFlags { *; }
46-keep,allowoptimization,allowaccessmodification class android.app.admin.flags.FeatureFlagsImpl { *; }
47-keep,allowoptimization,allowaccessmodification class com.android.server.input.NativeInputManagerService$NativeImpl { *; }
48-keep,allowoptimization,allowaccessmodification class com.android.server.ThreadPriorityBooster { *; }
Timothy Yiu1149dbb2024-03-19 02:56:06 +000049
Sandeep Bandaru46f44ce2024-11-26 18:44:20 +000050# allow invoking start-service using class name in both apex and services jar.
51-keep,allowoptimization,allowaccessmodification class com.android.server.ondeviceintelligence.OnDeviceIntelligenceManagerService { *; }
52
Timothy Yiu1149dbb2024-03-19 02:56:06 +000053# Keep all aconfig Flag class as they might be statically referenced by other packages
54# An merge or inlining could lead to missing dependencies that cause run time errors
55-keepclassmembernames class android.**.Flags, com.android.**.Flags { public *; }
Jared Duke0504e562022-02-02 15:25:22 -080056
57# Referenced via CarServiceHelperService in car-frameworks-service (avoid removing)
58-keep public class com.android.server.utils.Slogf { *; }
59
Xin Guanee58f492022-08-02 02:56:54 +000060# Referenced in wear-service
Xin Guanee58f492022-08-02 02:56:54 +000061-keep public class com.android.server.wm.WindowManagerInternal { *; }
Yeabkal Wubshit63444192025-02-19 23:09:43 -080062-keep public class com.android.server.wm.WindowManagerInternal$WindowFocusChangeListener { *; }
Chen Baia210f3d2025-03-06 01:01:54 -080063-keep public class com.android.server.wm.ActivityAssistInfo { *; }
Xin Guanee58f492022-08-02 02:56:54 +000064
Jared Duke0504e562022-02-02 15:25:22 -080065# JNI keep rules
Jared Duke3027b4d2022-12-14 12:30:14 -080066# The global keep rule for native methods allows stripping of such methods if they're unreferenced
67# in Java. However, because system_server explicitly registers these methods from native code,
68# stripping them in Java can cause runtime issues. As such, conservatively keep all such methods in
69# system_server subpackages as long as the containing class is also kept or referenced.
70-keepclassmembers class com.android.server.** {
71 native <methods>;
72}
Jared Duke0504e562022-02-02 15:25:22 -080073# TODO(b/210510433): Revisit and fix with @Keep, or consider auto-generating from
74# frameworks/base/services/core/jni/onload.cpp.
75-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.BroadcastRadioService { *; }
76-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.Convert { *; }
77-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.Tuner { *; }
78-keep,allowoptimization,allowaccessmodification class com.android.server.broadcastradio.hal1.TunerCallback { *; }
79-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.GnssConfiguration$HalInterfaceVersion { *; }
80-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.GnssPowerStats { *; }
81-keep,allowoptimization,allowaccessmodification class com.android.server.location.gnss.hal.GnssNative { *; }
Jared Dukedc50c852022-02-25 13:50:58 -080082-keep,allowoptimization,allowaccessmodification class com.android.server.pm.PackageManagerShellCommandDataLoader { *; }
Vladimir Komsiyski9d5084d2023-02-10 09:54:19 +010083-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$RuntimeSensorCallback { *; }
Jared Duke0504e562022-02-02 15:25:22 -080084-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$ProximityActiveListener { *; }
85-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorService { *; }
86-keep,allowoptimization,allowaccessmodification class com.android.server.soundtrigger_middleware.SoundTriggerMiddlewareImpl$AudioSessionProvider$AudioSession { *; }
87-keep,allowoptimization,allowaccessmodification class com.android.server.soundtrigger_middleware.ExternalCaptureStateTracker { *; }
88-keep,allowoptimization,allowaccessmodification class com.android.server.storage.AppFuseBridge { *; }
89-keep,allowoptimization,allowaccessmodification class com.android.server.tv.TvInputHal { *; }
90-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaJackDetector { *; }
Robert Wu8e7bf0f2023-01-26 01:44:07 +000091-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaMidiDevice { *; }
Jared Duke0504e562022-02-02 15:25:22 -080092-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorController$OnVibrationCompleteListener { *; }
Lais Andrade8c986282024-10-24 16:03:34 +010093-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorManagerService$VibratorManagerNativeCallbacks { *; }
Jared Duke0504e562022-02-02 15:25:22 -080094-keepclasseswithmembers,allowoptimization,allowaccessmodification class com.android.server.** {
95 *** *FromNative(...);
96}
97-keep,allowoptimization,allowaccessmodification class com.android.server.input.InputManagerService {
98 <methods>;
99}
100-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbHostManager {
101 *** usbDeviceRemoved(...);
102 *** usbDeviceAdded(...);
103}
104-keep,allowoptimization,allowaccessmodification class **.*NativeWrapper* { *; }
105
106# Miscellaneous reflection keep rules
107# TODO(b/210510433): Revisit and fix with @Keep.
Jared Duke0504e562022-02-02 15:25:22 -0800108-keep,allowoptimization,allowaccessmodification class android.hardware.usb.gadget.** { *; }
109
110# Needed when optimizations enabled
111# TODO(b/210510433): Revisit and fix with @Keep.
112-keep,allowoptimization,allowaccessmodification class com.android.server.SystemService { *; }
113-keep,allowoptimization,allowaccessmodification class com.android.server.SystemService$TargetUser { *; }
114-keep,allowoptimization,allowaccessmodification class com.android.server.usage.StorageStatsManagerLocal { *; }
Jared Dukee236dd72024-08-13 21:14:57 +0000115
116# Prevent optimizations of any statically linked code that may shadow code in
117# the bootclasspath. See also StrictJavaPackagesTest for details on exceptions.
118# TODO(b/222468116): Resolve such collisions in the build system.
119-keep public class android.gsi.** { *; }
120-keep public class android.hidl.base.** { *; }
121-keep public class android.hidl.manager.** { *; }
122-keep public class android.os.** { *; }
123-keep public class com.android.internal.util.** { *; }
124-keep public class com.android.modules.utils.build.** { *; }
Jared Dukeb0242b32024-08-14 20:57:44 +0000125# Also suppress related duplicate type warnings for the above kept classes.
126-dontwarn android.gsi.**
127-dontwarn android.hidl.base.**
128-dontwarn android.hidl.manager.**
129-dontwarn android.os.**
130-dontwarn com.android.internal.util.**
131-dontwarn com.android.modules.utils.build.**
Jared Duke06689ad2022-09-07 12:24:36 -0700132
133# CoverageService guards optional jacoco class references with a runtime guard, so we can safely
134# suppress build-time warnings.
135-dontwarn org.jacoco.agent.rt.*
Adnan Begovic14e307c12015-07-06 20:06:36 -0700136
137# SDK
138-keep,allowoptimization,allowaccessmodification class omnirom.** { *; }
139-keep,allowoptimization,allowaccessmodification class org.omnirom.** { *; }
Michael Bestas33a324bb82023-05-21 20:16:09 +0300140-keep,allowoptimization,allowaccessmodification class vendor.lineage.** { *; }