Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f2fdac5 authored by Jared Duke's avatar Jared Duke Committed by Android (Google) Code Review
Browse files

Merge "Refactor weakly referenced callback keep rules" into main

parents 2fab20a3 8e741230
Loading
Loading
Loading
Loading
+9 −37
Original line number Diff line number Diff line
@@ -2,45 +2,17 @@

# Needed to ensure callback field references are kept in their respective
# owning classes when the downstream callback registrars only store weak refs.
# 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.** {
# Note that we restrict this to SysUISingleton classes, as other registering
# classes should either *always* unregister or *never* register from their
# constructor. We also keep callback class names for easier debugging.
-keepnames @com.android.systemui.util.annotations.WeaklyReferencedCallback class *
-keepnames class * extends @com.android.systemui.util.annotations.WeaklyReferencedCallback **
-if @com.android.systemui.util.annotations.WeaklyReferencedCallback class *
-keepclassmembers,allowaccessmodification @com.android.systemui.dagger.SysUISingleton class * {
  <1> *;
}
-if class * extends com.android.systemui.util.service.ObservableServiceConnection$Callback
-keepclassmembers,allowaccessmodification class com.android.systemui.**, com.android.keyguard.** {
-if class * extends @com.android.systemui.util.annotations.WeaklyReferencedCallback **
-keepclassmembers,allowaccessmodification @com.android.systemui.dagger.SysUISingleton class * {
  <1> *;
}

+2 −0
Original line number Diff line number Diff line
@@ -25,12 +25,14 @@ import androidx.annotation.Nullable;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.plugins.WeatherData;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.util.annotations.WeaklyReferencedCallback;

import java.util.TimeZone;

/**
 * Callback for general information relevant to lock screen.
 */
@WeaklyReferencedCallback
public class KeyguardUpdateMonitorCallback {

    /**
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.media.controls.pipeline
import android.content.Context
import android.os.SystemProperties
import android.util.Log
import com.android.internal.annotations.KeepForWeakReference
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.broadcast.BroadcastSender
import com.android.systemui.dagger.qualifiers.Main
@@ -82,6 +83,8 @@ constructor(
    private var smartspaceMediaData: SmartspaceMediaData = EMPTY_SMARTSPACE_MEDIA_DATA
    private var reactivatedKey: String? = null

    // Ensure the field (and associated reference) isn't removed during optimization.
    @KeepForWeakReference
    private val userTrackerCallback =
        object : UserTracker.Callback {
            override fun onUserChanged(newUser: Int, userContext: Context) {
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.util.DeviceConfigProxy
import com.android.systemui.util.asIndenting
import com.android.systemui.util.annotations.WeaklyReferencedCallback
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.util.withIncreasedIndent
import java.io.PrintWriter
@@ -144,6 +145,7 @@ class PrivacyConfig @Inject constructor(
        ipw.flush()
    }

    @WeaklyReferencedCallback
    interface Callback {
        fun onFlagMicCameraChanged(flag: Boolean) {}

+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.settings

import com.android.systemui.util.annotations.WeaklyReferencedCallback

import android.content.Context
import android.content.pm.UserInfo
import android.os.UserHandle
@@ -64,6 +66,7 @@ interface UserTracker : UserContentResolverProvider, UserContextProvider {
    /**
     * Callback for notifying of changes.
     */
    @WeaklyReferencedCallback
    interface Callback {

        /**
Loading