From e0bfada528d361ebb4cdad929681d946a1ff5143 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Wed, 7 Jun 2023 22:15:19 +0000 Subject: [PATCH] Add keep rules for SysUI plugin annotations These rules are necessary to ensure correct runtime plugin annotation preservation for downstream targets built with R8 full mode. This was previously addressed in downstream target keep rules, but with aosp/2363992, such targets will now inherit the keep rules bundled with the plugin library. Bug: 215530220 Test: m + inspect downstream proguard_configuration output Change-Id: I3793947827902617eaa5af681e99c889869cdca6 --- packages/SystemUI/plugin_core/Android.bp | 3 +++ packages/SystemUI/plugin_core/proguard.flags | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 packages/SystemUI/plugin_core/proguard.flags diff --git a/packages/SystemUI/plugin_core/Android.bp b/packages/SystemUI/plugin_core/Android.bp index 34d31d9955fc1..4e39f1ac95450 100644 --- a/packages/SystemUI/plugin_core/Android.bp +++ b/packages/SystemUI/plugin_core/Android.bp @@ -25,6 +25,9 @@ java_library { sdk_version: "current", name: "PluginCoreLib", srcs: ["src/**/*.java"], + optimize: { + proguard_flags_files: ["proguard.flags"], + }, // Enforce that the library is built against java 8 so that there are // no compatibility issues with launcher diff --git a/packages/SystemUI/plugin_core/proguard.flags b/packages/SystemUI/plugin_core/proguard.flags new file mode 100644 index 0000000000000..6240898b3b93f --- /dev/null +++ b/packages/SystemUI/plugin_core/proguard.flags @@ -0,0 +1,11 @@ +# R8's full mode is a bit more aggressive in stripping annotations, but the +# SystemUI plugin architecture requires these annotations at runtime. The +# following rules are the minimal set necessary to ensure compatibility. +# For more details, see: +# https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode +-keepattributes RuntimeVisible*Annotation*,AnnotationDefault + +-keep interface com.android.systemui.plugins.annotations.** { + *; +} +-keep,allowshrinking,allowoptimization,allowobfuscation,allowaccessmodification @com.android.systemui.plugins.annotations.** class *