diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java index b6357b8dbd8d4..045a1976d5024 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShadeWindowController.java @@ -36,6 +36,12 @@ public interface NotificationShadeWindowController extends RemoteInputController */ default void registerCallback(StatusBarWindowCallback callback) {} + /** + * Unregisters a {@link StatusBarWindowCallback previous registered with + * {@link #registerCallback(StatusBarWindowCallback)}} + */ + default void unregisterCallback(StatusBarWindowCallback callback) {} + /** Notifies the registered {@link StatusBarWindowCallback} instances. */ default void notifyStateChangedCallbacks() {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java index ae018ba4fe766..52f9aca827838 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationShadeWindowControllerImpl.java @@ -152,6 +152,16 @@ public class NotificationShadeWindowControllerImpl implements NotificationShadeW mCallbacks.add(new WeakReference(callback)); } + @Override + public void unregisterCallback(StatusBarWindowCallback callback) { + for (int i = 0; i < mCallbacks.size(); i++) { + if (mCallbacks.get(i).get() == callback) { + mCallbacks.remove(i); + return; + } + } + } + /** * Register a listener to monitor scrims visibility * @param listener A listener to monitor scrims visibility