From 1935a2f2c1704fc1958783c0ceb74095e4052ca6 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Thu, 12 Jan 2023 13:56:51 -0800 Subject: [PATCH] Ensure weakly referenced Kotlin callback fields are kept This is an extension of earlier work for keeping callback fields that are weakly referenced in the registrar. Private Kotlin fields for anonymous objects default to using the anonymous type. This breaks the existing keep pattern matching for such callbacks. Extend the rules to handle this case, also keeping any fields that extend the callback type. A better solution will be to annotate the Callback types directly, and define a single rule that keeps any fields of a correspondingly annotated type, but that requires more invasive changes. This should fix any issues now while we work on that solution. Bug: 264686688 Test: m + `dexdump SystemUI.apk | grep MediaDataFilter$userTracker` Change-Id: Ib4d75c4cc3b121b818250e7191747b01413bd71a --- packages/SystemUI/proguard.flags | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags index 030eaa660c9f1..5fc919330e928 100644 --- a/packages/SystemUI/proguard.flags +++ b/packages/SystemUI/proguard.flags @@ -21,12 +21,44 @@ # TODO(b/264686688): Handle these cases with more targeted annotations. -keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { private com.android.keyguard.KeyguardUpdateMonitorCallback *; + private com.android.systemui.privacy.PrivacyConfig$Callback *; private com.android.systemui.privacy.PrivacyItemController$Callback *; private com.android.systemui.settings.UserTracker$Callback *; private com.android.systemui.statusbar.phone.StatusBarWindowCallback *; private com.android.systemui.util.service.Observer$Callback *; private com.android.systemui.util.service.ObservableServiceConnection$Callback *; } +# Note that these rules are temporary companions to the above rules, required +# for cases like Kotlin where fields with anonymous types use the anonymous type +# rather than the supertype. +-if class * extends com.android.keyguard.KeyguardUpdateMonitorCallback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} +-if class * extends com.android.systemui.privacy.PrivacyConfig$Callback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} +-if class * extends com.android.systemui.privacy.PrivacyItemController$Callback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} +-if class * extends com.android.systemui.settings.UserTracker$Callback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} +-if class * extends com.android.systemui.statusbar.phone.StatusBarWindowCallback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} +-if class * extends com.android.systemui.util.service.Observer$Callback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} +-if class * extends com.android.systemui.util.service.ObservableServiceConnection$Callback +-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** { + <1> *; +} -keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet);