diff options
| author | 2023-10-31 11:21:32 -0700 | |
|---|---|---|
| committer | 2023-11-07 10:42:50 -0800 | |
| commit | cedd452cc7c04821715b77b41cfc4a84a351b15d (patch) | |
| tree | 089942b01e3fea15dc76e2f2301bb61648934397 | |
| parent | a16cb4676742fe6782228b7c2bbd77e8c5f6ddd7 (diff) | |
systemui: separate proguard files into multiple ones
- Keep proguard_common still containing all of them.
- To allow customization per form factor with only inclusion of
proguard_common_core.flags.
- Minor bp lint fix using bpfmt for SystemUIPluginLib
Flag: NONE
Test: build
Bug: 301283783
Change-Id: Idf352e7bfe542d263ad2ef4c1cda80d818ed54e6
| -rw-r--r-- | packages/SystemUI/plugin/Android.bp | 12 | ||||
| -rw-r--r-- | packages/SystemUI/plugin/proguard_plugins.flags | 9 | ||||
| -rw-r--r-- | packages/SystemUI/proguard.flags | 2 | ||||
| -rw-r--r-- | packages/SystemUI/proguard_common.flags | 48 | ||||
| -rw-r--r-- | packages/SystemUI/proguard_kotlin.flags | 37 |
5 files changed, 58 insertions, 50 deletions
diff --git a/packages/SystemUI/plugin/Android.bp b/packages/SystemUI/plugin/Android.bp index 1beb55bb6b31..0537f17b3594 100644 --- a/packages/SystemUI/plugin/Android.bp +++ b/packages/SystemUI/plugin/Android.bp @@ -26,12 +26,19 @@ java_library { name: "SystemUIPluginLib", srcs: [ - "src/**/*.java", - "src/**/*.kt", "bcsmartspace/src/**/*.java", "bcsmartspace/src/**/*.kt", + "src/**/*.java", + "src/**/*.kt", ], + optimize: { + proguard_flags_files: [ + "proguard_plugins.flags", + ], + export_proguard_flags_files: true, + }, + // If you add a static lib here, you may need to also add the package to the ClassLoaderFilter // in PluginInstance. That will ensure that loaded plugins have access to the related classes. // You should also add it to proguard_common.flags so that proguard does not remove the portions @@ -43,6 +50,7 @@ java_library { "SystemUIAnimationLib", "SystemUICommon", "SystemUILogLib", + "androidx.annotation_annotation", ], } diff --git a/packages/SystemUI/plugin/proguard_plugins.flags b/packages/SystemUI/plugin/proguard_plugins.flags new file mode 100644 index 000000000000..abac27f0cbe6 --- /dev/null +++ b/packages/SystemUI/plugin/proguard_plugins.flags @@ -0,0 +1,9 @@ +# The plugins and core log subpackages act as shared libraries that might be referenced in +# dynamically-loaded plugin APKs. +-keep class com.android.systemui.plugins.** { + *; +} + +-keep class com.android.systemui.log.core.** { + *; +} diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags index b534fcec2a85..42b592346e5f 100644 --- a/packages/SystemUI/proguard.flags +++ b/packages/SystemUI/proguard.flags @@ -4,4 +4,4 @@ *; } --keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.DaggerReferenceGlobalRootComponent** { !synthetic *; }
\ No newline at end of file +-keep,allowoptimization,allowaccessmodification class com.android.systemui.dagger.DaggerReferenceGlobalRootComponent** { !synthetic *; } diff --git a/packages/SystemUI/proguard_common.flags b/packages/SystemUI/proguard_common.flags index 73ae59abcadf..21b019eacdcc 100644 --- a/packages/SystemUI/proguard_common.flags +++ b/packages/SystemUI/proguard_common.flags @@ -1,3 +1,4 @@ +-include proguard_kotlin.flags -keep class com.android.systemui.VendorServices # Needed to ensure callback field references are kept in their respective @@ -20,14 +21,6 @@ public <init>(android.content.Context, android.util.AttributeSet); } -# The plugins and core log subpackages act as shared libraries that might be referenced in -# dynamically-loaded plugin APKs. --keep class com.android.systemui.plugins.** { - *; -} --keep class com.android.systemui.log.core.** { - *; -} -keep class androidx.core.app.CoreComponentFactory # Keep the wm shell lib @@ -49,45 +42,6 @@ # 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. -# These checks are generally applied to Java platform types (values returned -# from Java code that don't have nullness annotations), but we remove them to -# avoid code size increases. -# -# See also https://kotlinlang.org/docs/reference/java-interop.html -# -# TODO(b/199941987): Consider standardizing these rules in a central place as -# Kotlin gains adoption with other platform targets. --assumenosideeffects class kotlin.jvm.internal.Intrinsics { - # Remove check for method parameters being null - static void checkParameterIsNotNull(java.lang.Object, java.lang.String); - - # When a Java platform type is returned and passed to Kotlin NonNull method, - # remove the null check - static void checkExpressionValueIsNotNull(java.lang.Object, java.lang.String); - static void checkNotNullExpressionValue(java.lang.Object, java.lang.String); - - # Remove check that final value returned from method is null, if passing - # back Java platform type. - static void checkReturnedValueIsNotNull(java.lang.Object, java.lang.String, java.lang.String); - static void checkReturnedValueIsNotNull(java.lang.Object, java.lang.String); - - # Null check for accessing a field from a parent class written in Java. - static void checkFieldIsNotNull(java.lang.Object, java.lang.String, java.lang.String); - static void checkFieldIsNotNull(java.lang.Object, java.lang.String); - - # Removes code generated from !! operator which converts Nullable type to - # NonNull type. These would throw an NPE immediate after on access. - static void checkNotNull(java.lang.Object, java.lang.String); - static void checkNotNullParameter(java.lang.Object, java.lang.String); - - # Removes lateinit var check being used before being set. Check is applied - # on every field access without this. - static void throwUninitializedPropertyAccessException(java.lang.String); -} - - # Strip verbose logs. -assumenosideeffects class android.util.Log { static *** v(...); diff --git a/packages/SystemUI/proguard_kotlin.flags b/packages/SystemUI/proguard_kotlin.flags new file mode 100644 index 000000000000..ceea3c872200 --- /dev/null +++ b/packages/SystemUI/proguard_kotlin.flags @@ -0,0 +1,37 @@ +# Removes runtime checks added through Kotlin to JVM code genereration to +# avoid linear growth as more Kotlin code is converted / added to the codebase. +# These checks are generally applied to Java platform types (values returned +# from Java code that don't have nullness annotations), but we remove them to +# avoid code size increases. +# +# See also https://kotlinlang.org/docs/reference/java-interop.html +# +# TODO(b/199941987): Consider standardizing these rules in a central place as +# Kotlin gains adoption with other platform targets. +-assumenosideeffects class kotlin.jvm.internal.Intrinsics { + # Remove check for method parameters being null + static void checkParameterIsNotNull(java.lang.Object, java.lang.String); + + # When a Java platform type is returned and passed to Kotlin NonNull method, + # remove the null check + static void checkExpressionValueIsNotNull(java.lang.Object, java.lang.String); + static void checkNotNullExpressionValue(java.lang.Object, java.lang.String); + + # Remove check that final value returned from method is null, if passing + # back Java platform type. + static void checkReturnedValueIsNotNull(java.lang.Object, java.lang.String, java.lang.String); + static void checkReturnedValueIsNotNull(java.lang.Object, java.lang.String); + + # Null check for accessing a field from a parent class written in Java. + static void checkFieldIsNotNull(java.lang.Object, java.lang.String, java.lang.String); + static void checkFieldIsNotNull(java.lang.Object, java.lang.String); + + # Removes code generated from !! operator which converts Nullable type to + # NonNull type. These would throw an NPE immediate after on access. + static void checkNotNull(java.lang.Object, java.lang.String); + static void checkNotNullParameter(java.lang.Object, java.lang.String); + + # Removes lateinit var check being used before being set. Check is applied + # on every field access without this. + static void throwUninitializedPropertyAccessException(java.lang.String); +} |