Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 1 | # TODO(b/210510433): Refine and optimize this configuration. Note that this |
Jared Duke | 4514bdf | 2021-11-18 13:18:21 -0800 | [diff] [blame] | 2 | # configuration is only used when `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA=true`. |
Jared Duke | 4514bdf | 2021-11-18 13:18:21 -0800 | [diff] [blame] | 3 | |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 4 | # Preserve line number information for debugging stack traces. |
| 5 | -keepattributes SourceFile,LineNumberTable |
Jared Duke | edb1339 | 2021-12-14 11:10:20 -0800 | [diff] [blame] | 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 | |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 11 | # Process entrypoint |
| 12 | -keep class com.android.server.SystemServer { |
| 13 | public static void main(java.lang.String[]); |
Jared Duke | edb1339 | 2021-12-14 11:10:20 -0800 | [diff] [blame] | 14 | } |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 15 | |
| 16 | # APIs referenced by dependent JAR files and modules |
Jared Duke | d7769ef | 2023-11-03 02:02:49 +0000 | [diff] [blame] | 17 | # TODO(b/300514883): Pull @SystemApi keep rules from system-api.pro. |
| 18 | -keep interface android.annotation.SystemApi |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 19 | -keep @android.annotation.SystemApi class * { |
| 20 | public protected *; |
| 21 | } |
| 22 | -keepclasseswithmembers class * { |
| 23 | @android.annotation.SystemApi *; |
| 24 | } |
Jared Duke | d7769ef | 2023-11-03 02:02:49 +0000 | [diff] [blame] | 25 | # 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 Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 31 | |
Alan Stokes | 8c9302c | 2022-05-06 18:35:12 +0100 | [diff] [blame] | 32 | # Accessed from com.android.compos APEX |
| 33 | -keep,allowoptimization,allowaccessmodification class com.android.internal.art.ArtStatsLog { |
| 34 | public static void write(...); |
| 35 | } |
| 36 | |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 37 | # 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 { *; } |
tyiu | d5dd07c | 2023-10-27 00:08:37 +0000 | [diff] [blame] | 42 | -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 Yiu | 1149dbb | 2024-03-19 02:56:06 +0000 | [diff] [blame] | 46 | |
Sandeep Bandaru | 46f44ce | 2024-11-26 18:44:20 +0000 | [diff] [blame] | 47 | # 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 Yiu | 1149dbb | 2024-03-19 02:56:06 +0000 | [diff] [blame] | 50 | # 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 Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 53 | |
| 54 | # Referenced via CarServiceHelperService in car-frameworks-service (avoid removing) |
| 55 | -keep public class com.android.server.utils.Slogf { *; } |
| 56 | |
Xin Guan | ee58f49 | 2022-08-02 02:56:54 +0000 | [diff] [blame] | 57 | # Referenced in wear-service |
Xin Guan | ee58f49 | 2022-08-02 02:56:54 +0000 | [diff] [blame] | 58 | -keep public class com.android.server.wm.WindowManagerInternal { *; } |
| 59 | |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 60 | # JNI keep rules |
Jared Duke | 3027b4d | 2022-12-14 12:30:14 -0800 | [diff] [blame] | 61 | # 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 Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 68 | # 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 Duke | dc50c85 | 2022-02-25 13:50:58 -0800 | [diff] [blame] | 77 | -keep,allowoptimization,allowaccessmodification class com.android.server.pm.PackageManagerShellCommandDataLoader { *; } |
Vladimir Komsiyski | 9d5084d | 2023-02-10 09:54:19 +0100 | [diff] [blame] | 78 | -keep,allowoptimization,allowaccessmodification class com.android.server.sensors.SensorManagerInternal$RuntimeSensorCallback { *; } |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 79 | -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 Wu | 8e7bf0f | 2023-01-26 01:44:07 +0000 | [diff] [blame] | 86 | -keep,allowoptimization,allowaccessmodification class com.android.server.usb.UsbAlsaMidiDevice { *; } |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 87 | -keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorController$OnVibrationCompleteListener { *; } |
Lais Andrade | 8c98628 | 2024-10-24 16:03:34 +0100 | [diff] [blame] | 88 | -keep,allowoptimization,allowaccessmodification class com.android.server.vibrator.VibratorManagerService$VibratorManagerNativeCallbacks { *; } |
Jared Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 89 | -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 Duke | 0504e56 | 2022-02-02 15:25:22 -0800 | [diff] [blame] | 103 | -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 Duke | e236dd7 | 2024-08-13 21:14:57 +0000 | [diff] [blame] | 110 | |
| 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 Duke | b0242b3 | 2024-08-14 20:57:44 +0000 | [diff] [blame] | 120 | # 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 Duke | 06689ad | 2022-09-07 12:24:36 -0700 | [diff] [blame] | 127 | |
| 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 Begovic | 14e307c1 | 2015-07-06 20:06:36 -0700 | [diff] [blame] | 131 | |
| 132 | # SDK |
| 133 | -keep,allowoptimization,allowaccessmodification class omnirom.** { *; } |
| 134 | -keep,allowoptimization,allowaccessmodification class org.omnirom.** { *; } |
Michael Bestas | 33a324bb8 | 2023-05-21 20:16:09 +0300 | [diff] [blame] | 135 | -keep,allowoptimization,allowaccessmodification class vendor.lineage.** { *; } |