From fb416ecf31bdd18d49de9ba03a35ba0d56a45000 Mon Sep 17 00:00:00 2001 From: Justin Weir Date: Thu, 4 May 2023 14:00:45 -0400 Subject: [PATCH] Add method for adding expansion listener without firing event The current method immediately sends a change event to the listener, which causes the AuthDialogPanelInteractionDetector dialog to immediately cancel itself upon adding the listener. Adding a new method that doesn't fire the event and calling that instead fixes the problem. Test: manually verified Test: atest SystemUITests SystemUIGoogleTests Fixes: 278455611 Change-Id: Id94bba0ab10890fd3c380d69cf6409c614c7e84c --- .../biometrics/AuthDialogPanelInteractionDetector.kt | 2 +- .../systemui/shade/ShadeExpansionStateManager.kt | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthDialogPanelInteractionDetector.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthDialogPanelInteractionDetector.kt index b72801d3b5fe4..8edccf166efea 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthDialogPanelInteractionDetector.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthDialogPanelInteractionDetector.kt @@ -21,7 +21,7 @@ constructor( fun enable(onPanelInteraction: Runnable) { if (action == null) { action = Action(onPanelInteraction) - shadeExpansionStateManager.addExpansionListener(this::onPanelExpansionChanged) + shadeExpansionStateManager.addShadeExpansionListener(this::onPanelExpansionChanged) } else { Log.e(TAG, "Already enabled") } diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt index 20313c3df465f..a048f543d476e 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeExpansionStateManager.kt @@ -54,12 +54,20 @@ class ShadeExpansionStateManager @Inject constructor() : ShadeStateEvents { * Listener will also be immediately notified with the current values. */ fun addExpansionListener(listener: ShadeExpansionListener) { - expansionListeners.add(listener) + addShadeExpansionListener(listener) listener.onPanelExpansionChanged( ShadeExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount) ) } + /** + * Adds a listener that will be notified when the panel expansion fraction has changed. + * @see #addExpansionListener + */ + fun addShadeExpansionListener(listener: ShadeExpansionListener) { + expansionListeners.add(listener) + } + /** Removes an expansion listener. */ fun removeExpansionListener(listener: ShadeExpansionListener) { expansionListeners.remove(listener)