From b11b1d243769436450a5c72c55e843083e84e206 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Mon, 13 Jun 2022 09:32:49 -0700 Subject: [PATCH] Enable R8 code shrinking for system_server by default Flip the setting that controls R8 shrinking for system_server from opt-in to opt-out. This can be controlled by vendor makefiles and from the command-line using the `SYSTEM_OPTIMIZE_JAVA` boolean build flag. Note that this change only enables code shrinking for system_server, and should not impact stack traces except for certain stack frames involving synthetics. Additional (vendor) code that is loaded dynamically into system_server, that references system_server code, should use system_server APIs that are expicitly annotated with `@android.annotation.SystemApi`. Additional (vendor) code added directly to services.jar, which doesn't fall into existing keep patterns in the services proguard.flags configuration and would otherwise be stripped, should be annotated with `@com.android.internal.annotations.Keep`. Results: services.jar (20MB -> 17MB) Bug: 210510433 Test: atest CtsInstalledLoadingProgressHostTests CtsAutoFillServiceTestCases CtsAppSecurityHostTestCases CtsAppTestCases Change-Id: Icc77c9451d9a4a83e02cb591693354988f8d0ec4 --- core/android_soong_config_vars.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk index 6dfb61ed02..6e521950ee 100644 --- a/core/android_soong_config_vars.mk +++ b/core/android_soong_config_vars.mk @@ -97,6 +97,7 @@ endif # TODO(b/203088572): Remove when Java optimizations enabled by default for # SystemUI. $(call add_soong_config_var,ANDROID,SYSTEMUI_OPTIMIZE_JAVA) -# TODO(b/196084106): Remove when Java optimizations enabled by default for -# system packages. +# Enable by default unless explicitly set or overridden. +# See frameworks/base/services/Android.bp for additional notes on side effects. +SYSTEM_OPTIMIZE_JAVA ?= true $(call add_soong_config_var,ANDROID,SYSTEM_OPTIMIZE_JAVA)