Allow flag-guarded Java optimizations for SystemUI
Introduce a set of optional Java optimization settings for
SystemUI, based on the Soong variable added in aosp/1896612.
Opting in to optimizations can be achieved with either:
* Env:
export SYSTEM_OPTIMIZE_JAVA=true
* Make:
$(call add_soong_config_var_value,ANDROID,SYSTEM_OPTIMIZE_JAVA,true)
As these optimizations can change the resulting stack traces, a parallel
effort is working to simplify retracing of stack traces for more
accurate debugging and diagnostics. Additional stabilization and testing
will occur before any effort to enable these optimizations by default
for specific targets. Also note that there are no plans to enable
obfuscation.
Preliminary results (w/ `SYSTEM_OPTIMIZE_JAVA=true`):
* SystemUI.apk (31MB -> 26MB)
Bug: 203472868
Test: SYSTEM_OPTIMIZE_JAVA=true m (validate SystemUI.apk)
Change-Id: Idd8d5ef32c06e992ad35846eb5fab67ecb58830a
diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags
index 3517eba..ce63b44 100644
--- a/packages/SystemUI/proguard.flags
+++ b/packages/SystemUI/proguard.flags
@@ -33,10 +33,14 @@
*;
}
--keep class com.android.systemui.dagger.GlobalRootComponent { *; }
--keep class com.android.systemui.dagger.GlobalRootComponent$SysUIComponentImpl { *; }
--keep class com.android.systemui.dagger.Dagger** { *; }
--keep class com.android.systemui.tv.Dagger** { *; }
+-keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.GlobalRootComponent { !synthetic *; }
+-keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.GlobalRootComponent$SysUIComponentImpl { !synthetic *; }
+-keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.Dagger** { !synthetic *; }
+-keep,allowoptimization,allowaccessmodification class com.android.systemui.tv.Dagger** { !synthetic *; }
+
+# Allows proguard to make private and protected methods and fields public as
+# part of optimization. This lets proguard inline trivial getter/setter methods.
+-allowaccessmodification
# Removes runtime checks added through Kotlin to JVM code genereration to
# avoid linear growth as more Kotlin code is converted / added to the codebase.