• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TODO(b/210510433): Refine and optimize this configuration. Note that this
2# configuration is only used when `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA=true`.
3
4# Preserve line number information for debugging stack traces.
5-keepattributes SourceFile,LineNumberTable
6
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
11# Process entrypoint
12-keep class com.android.server.SystemServer {
13  public static void main(java.lang.String[]);
14}
15
16# APIs referenced by dependent JAR files and modules
17# TODO(b/300514883): Pull @SystemApi keep rules from system-api.pro.
18# TODO(b/373579455): Evaluate if <init> needs to be kept.
19-keep interface android.annotation.SystemApi {
20  void <init>();
21}
22-keep @android.annotation.SystemApi class * {
23  public protected *;
24}
25-keepclasseswithmembers class * {
26  @android.annotation.SystemApi *;
27}
28# 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}
34
35# Accessed from com.android.compos APEX
36-keep,allowoptimization,allowaccessmodification class com.android.internal.art.ArtStatsLog {
37   public static void write(...);
38}
39
40# 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 { *; }
45-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 { *; }
49
50# allow invoking start-service using class name in both apex and services jar.
51-keep,allowoptimization,allowaccessmodification class com.android.server.ondeviceintelligence.OnDeviceIntelligenceManagerService { *; }
52
53# 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 *; }
56
57# Referenced via CarServiceHelperService in car-frameworks-service (avoid removing)
58-keep public class com.android.server.utils.Slogf { *; }
59
60# Referenced in wear-service
61-keep public class com.android.server.wm.WindowManagerInternal { *; }
62-keep public class com.android.server.wm.WindowManagerInternal$WindowFocusChangeListener { *; }
63-keep public class com.android.server.wm.ActivityAssistInfo { *; }
64
65# JNI keep rules
66# 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}
73# 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 { *; }
82-keep,allowoptimization,allowaccessmodification class com.android.server.pm.PackageManagerShellCommandDataLoader { *; }
83-keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$RuntimeSensorCallback { *; }
84-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 { *; }
91-keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaMidiDevice { *; }
92-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorController$OnVibrationCompleteListener { *; }
93-keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorManagerService$VibratorManagerNativeCallbacks { *; }
94-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.
108-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 { *; }
115
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.** { *; }
125# 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.**
132
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.*
136