Merge "PanelExpansionStateManager: add new parameter for raw drag amount" into tm-dev

This commit is contained in:
TreeHugger Robot
2022-04-25 17:44:26 +00:00
committed by Android (Google) Code Review
17 changed files with 240 additions and 229 deletions

View File

@@ -54,12 +54,11 @@ abstract class UdfpsAnimationViewController<T : UdfpsAnimationView>(
private var dialogAlphaAnimator: ValueAnimator? = null private var dialogAlphaAnimator: ValueAnimator? = null
private val dialogListener = SystemUIDialogManager.Listener { runDialogAlphaAnimator() } private val dialogListener = SystemUIDialogManager.Listener { runDialogAlphaAnimator() }
private val panelExpansionListener = private val panelExpansionListener = PanelExpansionListener { event ->
PanelExpansionListener { fraction, expanded, tracking ->
// Notification shade can be expanded but not visible (fraction: 0.0), for example // Notification shade can be expanded but not visible (fraction: 0.0), for example
// when a heads-up notification (HUN) is showing. // when a heads-up notification (HUN) is showing.
notificationShadeVisible = expanded && fraction > 0f notificationShadeVisible = event.expanded && event.fraction > 0f
view.onExpansionChanged(fraction) view.onExpansionChanged(event.fraction)
updatePauseAuth() updatePauseAuth()
} }

View File

@@ -38,6 +38,7 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.phone.SystemUIDialogManager;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -491,8 +492,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
private final PanelExpansionListener mPanelExpansionListener = new PanelExpansionListener() { private final PanelExpansionListener mPanelExpansionListener = new PanelExpansionListener() {
@Override @Override
public void onPanelExpansionChanged( public void onPanelExpansionChanged(PanelExpansionChangeEvent event) {
float fraction, boolean expanded, boolean tracking) { float fraction = event.getFraction();
mPanelExpansionFraction = mPanelExpansionFraction =
mKeyguardViewManager.isBouncerInTransit() ? BouncerPanelExpansionCalculator mKeyguardViewManager.isBouncerInTransit() ? BouncerPanelExpansionCalculator
.aboutToShowBouncerProgress(fraction) : fraction; .aboutToShowBouncerProgress(fraction) : fraction;

View File

@@ -40,6 +40,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.wm.shell.animation.FlingAnimationUtils; import com.android.wm.shell.animation.FlingAnimationUtils;
import java.util.Optional; import java.util.Optional;
@@ -141,19 +142,27 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
// bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer // bouncer. As that view's expansion shrinks, the bouncer appears. The bouncer
// is fully hidden at full expansion (1) and fully visible when fully collapsed // is fully hidden at full expansion (1) and fully visible when fully collapsed
// (0). // (0).
final float dragDownAmount = e2.getY() - e1.getY();
final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY()) final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY())
/ mCentralSurfaces.get().getDisplayHeight(); / mCentralSurfaces.get().getDisplayHeight();
setPanelExpansion(mBouncerInitiallyShowing setPanelExpansion(mBouncerInitiallyShowing
? screenTravelPercentage : 1 - screenTravelPercentage); ? screenTravelPercentage : 1 - screenTravelPercentage, dragDownAmount);
return true; return true;
} }
}; };
private void setPanelExpansion(float expansion) { private void setPanelExpansion(float expansion, float dragDownAmount) {
mCurrentExpansion = expansion; mCurrentExpansion = expansion;
mStatusBarKeyguardViewManager.onPanelExpansionChanged(mCurrentExpansion, false, true); PanelExpansionChangeEvent event =
new PanelExpansionChangeEvent(
/* fraction= */ mCurrentExpansion,
/* expanded= */ false,
/* tracking= */ true,
/* dragDownPxAmount= */ dragDownAmount);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(event);
} }
@VisibleForTesting @VisibleForTesting
public enum DreamEvent implements UiEventLogger.UiEventEnum { public enum DreamEvent implements UiEventLogger.UiEventEnum {
@UiEvent(doc = "The screensaver has been swiped up.") @UiEvent(doc = "The screensaver has been swiped up.")
@@ -283,12 +292,14 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
} }
} }
private ValueAnimator createExpansionAnimator(float targetExpansion) { private ValueAnimator createExpansionAnimator(float targetExpansion, float expansionHeight) {
final ValueAnimator animator = final ValueAnimator animator =
mValueAnimatorCreator.create(mCurrentExpansion, targetExpansion); mValueAnimatorCreator.create(mCurrentExpansion, targetExpansion);
animator.addUpdateListener( animator.addUpdateListener(
animation -> { animation -> {
setPanelExpansion((float) animation.getAnimatedValue()); float expansionFraction = (float) animation.getAnimatedValue();
float dragDownAmount = expansionFraction * expansionHeight;
setPanelExpansion(expansionFraction, dragDownAmount);
}); });
if (!mBouncerInitiallyShowing && targetExpansion == KeyguardBouncer.EXPANSION_VISIBLE) { if (!mBouncerInitiallyShowing && targetExpansion == KeyguardBouncer.EXPANSION_VISIBLE) {
animator.addListener( animator.addListener(
@@ -321,8 +332,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
final float viewHeight = mCentralSurfaces.get().getDisplayHeight(); final float viewHeight = mCentralSurfaces.get().getDisplayHeight();
final float currentHeight = viewHeight * mCurrentExpansion; final float currentHeight = viewHeight * mCurrentExpansion;
final float targetHeight = viewHeight * expansion; final float targetHeight = viewHeight * expansion;
final float expansionHeight = targetHeight - currentHeight;
final ValueAnimator animator = createExpansionAnimator(expansion); final ValueAnimator animator = createExpansionAnimator(expansion, expansionHeight);
if (expansion == KeyguardBouncer.EXPANSION_HIDDEN) { if (expansion == KeyguardBouncer.EXPANSION_HIDDEN) {
// Hides the bouncer, i.e., fully expands the space above the bouncer. // Hides the bouncer, i.e., fully expands the space above the bouncer.
mFlingAnimationUtilsClosing.apply(animator, currentHeight, targetHeight, velocity, mFlingAnimationUtilsClosing.apply(animator, currentHeight, targetHeight, velocity,

View File

@@ -42,6 +42,7 @@ import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK
import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.ScrimController import com.android.systemui.statusbar.phone.ScrimController
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener
import com.android.systemui.statusbar.policy.ConfigurationController import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.KeyguardStateController
@@ -340,7 +341,9 @@ class NotificationShadeDepthController @Inject constructor(
/** /**
* Update blurs when pulling down the shade * Update blurs when pulling down the shade
*/ */
override fun onPanelExpansionChanged(rawFraction: Float, expanded: Boolean, tracking: Boolean) { override fun onPanelExpansionChanged(event: PanelExpansionChangeEvent) {
val rawFraction = event.fraction
val tracking = event.tracking
val timestamp = SystemClock.elapsedRealtimeNanos() val timestamp = SystemClock.elapsedRealtimeNanos()
val expansion = MathUtils.saturate( val expansion = MathUtils.saturate(
(rawFraction - panelPullDownMinFraction) / (1f - panelPullDownMinFraction)) (rawFraction - panelPullDownMinFraction) / (1f - panelPullDownMinFraction))

View File

@@ -28,6 +28,7 @@ import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.KeyguardBypassController import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.statusbar.phone.ScreenOffAnimationController import com.android.systemui.statusbar.phone.ScreenOffAnimationController
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener
import com.android.systemui.statusbar.policy.HeadsUpManager import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener
@@ -292,8 +293,8 @@ class NotificationWakeUpCoordinator @Inject constructor(
this.state = newState this.state = newState
} }
override fun onPanelExpansionChanged(fraction: Float, expanded: Boolean, tracking: Boolean) { override fun onPanelExpansionChanged(event: PanelExpansionChangeEvent) {
val collapsedEnough = fraction <= 0.9f val collapsedEnough = event.fraction <= 0.9f
if (collapsedEnough != this.collapsedEnoughToHide) { if (collapsedEnough != this.collapsedEnoughToHide) {
val couldShowPulsingHuns = canShowPulsingHuns val couldShowPulsingHuns = canShowPulsingHuns
this.collapsedEnoughToHide = collapsedEnough this.collapsedEnoughToHide = collapsedEnough

View File

@@ -225,6 +225,7 @@ import com.android.systemui.statusbar.notification.stack.NotificationStackScroll
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent; import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent;
import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule; import com.android.systemui.statusbar.phone.dagger.StatusBarPhoneModule;
import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController; import com.android.systemui.statusbar.phone.ongoingcall.OngoingCallController;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.BatteryController; import com.android.systemui.statusbar.policy.BatteryController;
import com.android.systemui.statusbar.policy.BrightnessMirrorController; import com.android.systemui.statusbar.policy.BrightnessMirrorController;
@@ -1417,7 +1418,9 @@ public class CentralSurfaces extends CoreStartable implements
} }
} }
private void onPanelExpansionChanged(float fraction, boolean expanded, boolean tracking) { private void onPanelExpansionChanged(PanelExpansionChangeEvent event) {
float fraction = event.getFraction();
boolean tracking = event.getTracking();
dispatchPanelExpansionForKeyguardDismiss(fraction, tracking); dispatchPanelExpansionForKeyguardDismiss(fraction, tracking);
if (fraction == 0 || fraction == 1) { if (fraction == 0 || fraction == 1) {

View File

@@ -120,6 +120,7 @@ public abstract class PanelViewController {
private float mInitialOffsetOnTouch; private float mInitialOffsetOnTouch;
private boolean mCollapsedAndHeadsUpOnDown; private boolean mCollapsedAndHeadsUpOnDown;
private float mExpandedFraction = 0; private float mExpandedFraction = 0;
private float mExpansionDragDownAmountPx = 0;
protected float mExpandedHeight = 0; protected float mExpandedHeight = 0;
private boolean mPanelClosedOnDown; private boolean mPanelClosedOnDown;
private boolean mHasLayoutedSinceDown; private boolean mHasLayoutedSinceDown;
@@ -793,6 +794,7 @@ public abstract class PanelViewController {
mHeightAnimator.end(); mHeightAnimator.end();
} }
} }
mExpansionDragDownAmountPx = h;
mExpandedFraction = Math.min(1f, mExpandedFraction = Math.min(1f,
maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight); maxPanelHeight == 0 ? 0 : mExpandedHeight / maxPanelHeight);
mAmbientState.setExpansionFraction(mExpandedFraction); mAmbientState.setExpansionFraction(mExpandedFraction);
@@ -1109,7 +1111,7 @@ public abstract class PanelViewController {
*/ */
public void updatePanelExpansionAndVisibility() { public void updatePanelExpansionAndVisibility() {
mPanelExpansionStateManager.onPanelExpansionChanged( mPanelExpansionStateManager.onPanelExpansionChanged(
mExpandedFraction, isExpanded(), mTracking); mExpandedFraction, isExpanded(), mTracking, mExpansionDragDownAmountPx);
updateVisibility(); updateVisibility();
} }

View File

@@ -306,7 +306,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
} }
}); });
panelExpansionStateManager.addExpansionListener( panelExpansionStateManager.addExpansionListener(
(fraction, expanded, tracking) -> setRawPanelExpansionFraction(fraction) event -> setRawPanelExpansionFraction(event.getFraction())
); );
mColors = new GradientColors(); mColors = new GradientColors();

View File

@@ -65,6 +65,7 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.notification.ViewGroupFadeHelper; import com.android.systemui.statusbar.notification.ViewGroupFadeHelper;
import com.android.systemui.statusbar.phone.KeyguardBouncer.BouncerExpansionCallback; import com.android.systemui.statusbar.phone.KeyguardBouncer.BouncerExpansionCallback;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -353,7 +354,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
@Override @Override
public void onPanelExpansionChanged(float fraction, boolean expanded, boolean tracking) { public void onPanelExpansionChanged(PanelExpansionChangeEvent event) {
float fraction = event.getFraction();
boolean tracking = event.getTracking();
// Avoid having the shade and the bouncer open at the same time over a dream. // Avoid having the shade and the bouncer open at the same time over a dream.
final boolean hideBouncerOverDream = final boolean hideBouncerOverDream =
mDreamOverlayStateController.isOverlayActive() mDreamOverlayStateController.isOverlayActive()

View File

@@ -0,0 +1,14 @@
package com.android.systemui.statusbar.phone.panelstate
import android.annotation.FloatRange
data class PanelExpansionChangeEvent(
/** 0 when collapsed, 1 when fully expanded. */
@FloatRange(from = 0.0, to = 1.0) val fraction: Float,
/** Whether the panel should be considered expanded */
val expanded: Boolean,
/** Whether the user is actively dragging the panel. */
val tracking: Boolean,
/** The amount of pixels that the user has dragged during the expansion. */
val dragDownPxAmount: Float
)

View File

@@ -13,19 +13,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.android.systemui.statusbar.phone.panelstate
package com.android.systemui.statusbar.phone.panelstate;
/** A listener interface to be notified of expansion events for the notification panel. */ /** A listener interface to be notified of expansion events for the notification panel. */
public interface PanelExpansionListener { fun interface PanelExpansionListener {
/** /**
* Invoked whenever the notification panel expansion changes, at every animation frame. * Invoked whenever the notification panel expansion changes, at every animation frame. This is
* This is the main expansion that happens when the user is swiping up to dismiss the * the main expansion that happens when the user is swiping up to dismiss the lock screen and
* lock screen and swiping to pull down the notification shade. * swiping to pull down the notification shade.
*
* @param fraction 0 when collapsed, 1 when fully expanded.
* @param expanded true if the panel should be considered expanded.
* @param tracking {@code true} when the user is actively dragging the panel.
*/ */
void onPanelExpansionChanged(float fraction, boolean expanded, boolean tracking); fun onPanelExpansionChanged(event: PanelExpansionChangeEvent)
} }

View File

@@ -37,6 +37,7 @@ class PanelExpansionStateManager @Inject constructor() {
@FloatRange(from = 0.0, to = 1.0) private var fraction: Float = 0f @FloatRange(from = 0.0, to = 1.0) private var fraction: Float = 0f
private var expanded: Boolean = false private var expanded: Boolean = false
private var tracking: Boolean = false private var tracking: Boolean = false
private var dragDownPxAmount: Float = 0f
/** /**
* Adds a listener that will be notified when the panel expansion fraction has changed. * Adds a listener that will be notified when the panel expansion fraction has changed.
@@ -45,7 +46,8 @@ class PanelExpansionStateManager @Inject constructor() {
*/ */
fun addExpansionListener(listener: PanelExpansionListener) { fun addExpansionListener(listener: PanelExpansionListener) {
expansionListeners.add(listener) expansionListeners.add(listener)
listener.onPanelExpansionChanged(fraction, expanded, tracking) listener.onPanelExpansionChanged(
PanelExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount))
} }
/** Removes an expansion listener. */ /** Removes an expansion listener. */
@@ -77,7 +79,8 @@ class PanelExpansionStateManager @Inject constructor() {
fun onPanelExpansionChanged( fun onPanelExpansionChanged(
@FloatRange(from = 0.0, to = 1.0) fraction: Float, @FloatRange(from = 0.0, to = 1.0) fraction: Float,
expanded: Boolean, expanded: Boolean,
tracking: Boolean tracking: Boolean,
dragDownPxAmount: Float
) { ) {
require(!fraction.isNaN()) { "fraction cannot be NaN" } require(!fraction.isNaN()) { "fraction cannot be NaN" }
val oldState = state val oldState = state
@@ -85,6 +88,7 @@ class PanelExpansionStateManager @Inject constructor() {
this.fraction = fraction this.fraction = fraction
this.expanded = expanded this.expanded = expanded
this.tracking = tracking this.tracking = tracking
this.dragDownPxAmount = dragDownPxAmount
var fullyClosed = true var fullyClosed = true
var fullyOpened = false var fullyOpened = false
@@ -110,11 +114,14 @@ class PanelExpansionStateManager @Inject constructor() {
"f=$fraction " + "f=$fraction " +
"expanded=$expanded " + "expanded=$expanded " +
"tracking=$tracking" + "tracking=$tracking" +
"drawDownPxAmount=$dragDownPxAmount " +
"${if (fullyOpened) " fullyOpened" else ""} " + "${if (fullyOpened) " fullyOpened" else ""} " +
if (fullyClosed) " fullyClosed" else "" if (fullyClosed) " fullyClosed" else ""
) )
expansionListeners.forEach { it.onPanelExpansionChanged(fraction, expanded, tracking) } val expansionChangeEvent =
PanelExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount)
expansionListeners.forEach { it.onPanelExpansionChanged(expansionChangeEvent) }
} }
/** Updates the panel state if necessary. */ /** Updates the panel state if necessary. */

View File

@@ -45,6 +45,7 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.phone.SystemUIDialogManager;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -483,8 +484,11 @@ public class UdfpsKeyguardViewControllerTest extends SysuiTestCase {
} }
private void updateStatusBarExpansion(float fraction, boolean expanded) { private void updateStatusBarExpansion(float fraction, boolean expanded) {
PanelExpansionChangeEvent event =
new PanelExpansionChangeEvent(
fraction, expanded, /* tracking= */ false, /* dragDownPxAmount= */ 0f);
for (PanelExpansionListener listener : mExpansionListeners) { for (PanelExpansionListener listener : mExpansionListeners) {
listener.onPanelExpansionChanged(fraction, expanded, /* tracking= */ false); listener.onPanelExpansionChanged(event);
} }
} }

View File

@@ -19,7 +19,6 @@ package com.android.systemui.dreams.touch;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.never; import static org.mockito.Mockito.never;
@@ -47,6 +46,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.CentralSurfaces; import com.android.systemui.statusbar.phone.CentralSurfaces;
import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.wm.shell.animation.FlingAnimationUtils; import com.android.wm.shell.animation.FlingAnimationUtils;
import org.junit.Before; import org.junit.Before;
@@ -193,8 +193,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
.isTrue(); .isTrue();
verify(mStatusBarKeyguardViewManager, never()) verify(mStatusBarKeyguardViewManager, never()).onPanelExpansionChanged(any());
.onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
} }
/** /**
@@ -221,8 +220,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
assertThat(gestureListener.onScroll(event1, event2, 0, distanceY)) assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
.isTrue(); .isTrue();
verify(mStatusBarKeyguardViewManager, never()) verify(mStatusBarKeyguardViewManager, never()).onPanelExpansionChanged(any());
.onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
} }
/** /**
@@ -281,14 +279,16 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
.isTrue(); .isTrue();
// Ensure only called once // Ensure only called once
verify(mStatusBarKeyguardViewManager) verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(any());
.onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
final float expansion = isBouncerInitiallyShowing ? percent : 1 - percent; final float expansion = isBouncerInitiallyShowing ? percent : 1 - percent;
final float dragDownAmount = event2.getY() - event1.getY();
// Ensure correct expansion passed in. // Ensure correct expansion passed in.
verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(eq(expansion), eq(false), PanelExpansionChangeEvent event =
eq(true)); new PanelExpansionChangeEvent(
expansion, /* expanded= */ false, /* tracking= */ true, dragDownAmount);
verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(event);
} }
/** /**

View File

@@ -31,6 +31,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController
import com.android.systemui.statusbar.phone.BiometricUnlockController import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.DozeParameters import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.ScrimController import com.android.systemui.statusbar.phone.ScrimController
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent
import com.android.systemui.statusbar.policy.FakeConfigurationController import com.android.systemui.statusbar.policy.FakeConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.WallpaperController import com.android.systemui.util.WallpaperController
@@ -136,16 +137,16 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test @Test
fun onPanelExpansionChanged_apliesBlur_ifShade() { fun onPanelExpansionChanged_apliesBlur_ifShade() {
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
verify(shadeAnimation).animateTo(eq(maxBlur), any()) verify(shadeAnimation).animateTo(eq(maxBlur), any())
} }
@Test @Test
fun onPanelExpansionChanged_animatesBlurIn_ifShade() { fun onPanelExpansionChanged_animatesBlurIn_ifShade() {
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.01f, expanded = false, tracking = false PanelExpansionChangeEvent(
) fraction = 0.01f, expanded = false, tracking = false, dragDownPxAmount = 0f))
verify(shadeAnimation).animateTo(eq(maxBlur), any()) verify(shadeAnimation).animateTo(eq(maxBlur), any())
} }
@@ -154,28 +155,27 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
onPanelExpansionChanged_animatesBlurIn_ifShade() onPanelExpansionChanged_animatesBlurIn_ifShade()
clearInvocations(shadeAnimation) clearInvocations(shadeAnimation)
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0f, expanded = false, tracking = false PanelExpansionChangeEvent(
) fraction = 0f, expanded = false, tracking = false, dragDownPxAmount = 0f))
verify(shadeAnimation).animateTo(eq(0), any()) verify(shadeAnimation).animateTo(eq(0), any())
} }
@Test @Test
fun onPanelExpansionChanged_animatesBlurOut_ifFlick() { fun onPanelExpansionChanged_animatesBlurOut_ifFlick() {
val event =
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)
onPanelExpansionChanged_apliesBlur_ifShade() onPanelExpansionChanged_apliesBlur_ifShade()
clearInvocations(shadeAnimation) clearInvocations(shadeAnimation)
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(event)
rawFraction = 1f, expanded = true, tracking = true
)
verify(shadeAnimation, never()).animateTo(anyInt(), any()) verify(shadeAnimation, never()).animateTo(anyInt(), any())
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.9f, expanded = true, tracking = true event.copy(fraction = 0.9f, tracking = true))
)
verify(shadeAnimation, never()).animateTo(anyInt(), any()) verify(shadeAnimation, never()).animateTo(anyInt(), any())
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.8f, expanded = true, tracking = false event.copy(fraction = 0.8f, tracking = false))
)
verify(shadeAnimation).animateTo(eq(0), any()) verify(shadeAnimation).animateTo(eq(0), any())
} }
@@ -184,27 +184,24 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
onPanelExpansionChanged_animatesBlurOut_ifFlick() onPanelExpansionChanged_animatesBlurOut_ifFlick()
clearInvocations(shadeAnimation) clearInvocations(shadeAnimation)
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.6f, expanded = true, tracking = true PanelExpansionChangeEvent(
) fraction = 0.6f, expanded = true, tracking = true, dragDownPxAmount = 0f))
verify(shadeAnimation).animateTo(eq(maxBlur), any()) verify(shadeAnimation).animateTo(eq(maxBlur), any())
} }
@Test @Test
fun onPanelExpansionChanged_respectsMinPanelPullDownFraction() { fun onPanelExpansionChanged_respectsMinPanelPullDownFraction() {
val event =
PanelExpansionChangeEvent(
fraction = 0.5f, expanded = true, tracking = true, dragDownPxAmount = 0f)
notificationShadeDepthController.panelPullDownMinFraction = 0.5f notificationShadeDepthController.panelPullDownMinFraction = 0.5f
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(event)
rawFraction = 0.5f, expanded = true, tracking = true
)
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0f) assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0f)
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(event.copy(fraction = 0.75f))
rawFraction = 0.75f, expanded = true, tracking = true
)
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0.5f) assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0.5f)
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(event.copy(fraction = 1f))
rawFraction = 1f, expanded = true, tracking = true
)
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(1f) assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(1f)
} }
@@ -223,8 +220,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
statusBarState = StatusBarState.KEYGUARD statusBarState = StatusBarState.KEYGUARD
notificationShadeDepthController.qsPanelExpansion = 1f notificationShadeDepthController.qsPanelExpansion = 1f
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
} }
@@ -234,11 +231,11 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
statusBarState = StatusBarState.KEYGUARD statusBarState = StatusBarState.KEYGUARD
notificationShadeDepthController.qsPanelExpansion = 0.25f notificationShadeDepthController.qsPanelExpansion = 0.25f
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom( verify(wallpaperController)
eq(ShadeInterpolation.getNotificationScrimAlpha(0.25f))) .setNotificationShadeZoom(eq(ShadeInterpolation.getNotificationScrimAlpha(0.25f)))
} }
@Test @Test
@@ -246,7 +243,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
enableSplitShade() enableSplitShade()
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false) PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom(0f) verify(wallpaperController).setNotificationShadeZoom(0f)
@@ -257,7 +255,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
disableSplitShade() disableSplitShade()
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false) PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 }) verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 })
@@ -269,14 +268,16 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
val rawFraction = 1f val rawFraction = 1f
val expanded = true val expanded = true
val tracking = false val tracking = false
val dragDownPxAmount = 0f
val event = PanelExpansionChangeEvent(rawFraction, expanded, tracking, dragDownPxAmount)
val inOrder = Mockito.inOrder(wallpaperController) val inOrder = Mockito.inOrder(wallpaperController)
notificationShadeDepthController.onPanelExpansionChanged(rawFraction, expanded, tracking) notificationShadeDepthController.onPanelExpansionChanged(event)
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
inOrder.verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 }) inOrder.verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 })
enableSplitShade() enableSplitShade()
notificationShadeDepthController.onPanelExpansionChanged(rawFraction, expanded, tracking) notificationShadeDepthController.onPanelExpansionChanged(event)
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
inOrder.verify(wallpaperController).setNotificationShadeZoom(0f) inOrder.verify(wallpaperController).setNotificationShadeZoom(0f)
} }
@@ -332,8 +333,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test @Test
fun updateBlurCallback_setsBlur_whenExpanded() { fun updateBlurCallback_setsBlur_whenExpanded() {
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false)) verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
@@ -342,8 +343,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test @Test
fun updateBlurCallback_ignoreShadeBlurUntilHidden_overridesZoom() { fun updateBlurCallback_ignoreShadeBlurUntilHidden_overridesZoom() {
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.blursDisabledForAppLaunch = true notificationShadeDepthController.blursDisabledForAppLaunch = true
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)
@@ -353,15 +354,15 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test @Test
fun ignoreShadeBlurUntilHidden_schedulesFrame() { fun ignoreShadeBlurUntilHidden_schedulesFrame() {
notificationShadeDepthController.blursDisabledForAppLaunch = true notificationShadeDepthController.blursDisabledForAppLaunch = true
verify(choreographer).postFrameCallback( verify(choreographer)
eq(notificationShadeDepthController.updateBlurCallback)) .postFrameCallback(eq(notificationShadeDepthController.updateBlurCallback))
} }
@Test @Test
fun ignoreBlurForUnlock_ignores() { fun ignoreBlurForUnlock_ignores() {
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.blursDisabledForAppLaunch = false notificationShadeDepthController.blursDisabledForAppLaunch = false
@@ -377,8 +378,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test @Test
fun ignoreBlurForUnlock_doesNotIgnore() { fun ignoreBlurForUnlock_doesNotIgnore() {
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.blursDisabledForAppLaunch = false notificationShadeDepthController.blursDisabledForAppLaunch = false
@@ -409,8 +410,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
`when`(brightnessSpring.ratio).thenReturn(1f) `when`(brightnessSpring.ratio).thenReturn(1f)
// And shade is blurred // And shade is blurred
notificationShadeDepthController.onPanelExpansionChanged( notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false PanelExpansionChangeEvent(
) fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat()) `when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.updateBlurCallback.doFrame(0) notificationShadeDepthController.updateBlurCallback.doFrame(0)

View File

@@ -50,6 +50,7 @@ import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.SysuiStatusBarStateController; import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager; import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController; import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -70,48 +71,30 @@ import java.util.Optional;
@TestableLooper.RunWithLooper @TestableLooper.RunWithLooper
public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
@Mock private static final PanelExpansionChangeEvent EXPANSION_EVENT =
private ViewMediatorCallback mViewMediatorCallback; expansionEvent(/* fraction= */ 0.5f, /* expanded= */ false, /* tracking= */ true);
@Mock
private LockPatternUtils mLockPatternUtils; @Mock private ViewMediatorCallback mViewMediatorCallback;
@Mock @Mock private LockPatternUtils mLockPatternUtils;
private KeyguardStateController mKeyguardStateController; @Mock private KeyguardStateController mKeyguardStateController;
@Mock @Mock private CentralSurfaces mCentralSurfaces;
private CentralSurfaces mCentralSurfaces; @Mock private ViewGroup mContainer;
@Mock @Mock private NotificationPanelViewController mNotificationPanelView;
private ViewGroup mContainer; @Mock private BiometricUnlockController mBiometricUnlockController;
@Mock @Mock private SysuiStatusBarStateController mStatusBarStateController;
private NotificationPanelViewController mNotificationPanelView; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock @Mock private View mNotificationContainer;
private BiometricUnlockController mBiometricUnlockController; @Mock private KeyguardBypassController mBypassController;
@Mock @Mock private KeyguardBouncer.Factory mKeyguardBouncerFactory;
private SysuiStatusBarStateController mStatusBarStateController; @Mock private KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory;
@Mock @Mock private KeyguardMessageAreaController mKeyguardMessageAreaController;
private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock private KeyguardBouncer mBouncer;
@Mock @Mock private StatusBarKeyguardViewManager.AlternateAuthInterceptor mAlternateAuthInterceptor;
private View mNotificationContainer; @Mock private KeyguardMessageArea mKeyguardMessageArea;
@Mock @Mock private ShadeController mShadeController;
private KeyguardBypassController mBypassController; @Mock private SysUIUnfoldComponent mSysUiUnfoldComponent;
@Mock @Mock private DreamOverlayStateController mDreamOverlayStateController;
private KeyguardBouncer.Factory mKeyguardBouncerFactory; @Mock private LatencyTracker mLatencyTracker;
@Mock
private KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory;
@Mock
private KeyguardMessageAreaController mKeyguardMessageAreaController;
@Mock
private KeyguardBouncer mBouncer;
@Mock
private StatusBarKeyguardViewManager.AlternateAuthInterceptor mAlternateAuthInterceptor;
@Mock
private KeyguardMessageArea mKeyguardMessageArea;
@Mock
private ShadeController mShadeController;
@Mock
private SysUIUnfoldComponent mSysUiUnfoldComponent;
@Mock
private DreamOverlayStateController mDreamOverlayStateController;
@Mock
private LatencyTracker mLatencyTracker;
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@@ -119,14 +102,14 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
when(mKeyguardBouncerFactory.create( when(mKeyguardBouncerFactory.create(
any(ViewGroup.class), any(ViewGroup.class), any(KeyguardBouncer.BouncerExpansionCallback.class)))
any(KeyguardBouncer.BouncerExpansionCallback.class)))
.thenReturn(mBouncer); .thenReturn(mBouncer);
when(mCentralSurfaces.getBouncerContainer()).thenReturn(mContainer); when(mCentralSurfaces.getBouncerContainer()).thenReturn(mContainer);
when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea); when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea);
when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class))) when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class)))
.thenReturn(mKeyguardMessageAreaController); .thenReturn(mKeyguardMessageAreaController);
mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager( mStatusBarKeyguardViewManager =
new StatusBarKeyguardViewManager(
getContext(), getContext(),
mViewMediatorCallback, mViewMediatorCallback,
mLockPatternUtils, mLockPatternUtils,
@@ -159,8 +142,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void dismissWithAction_AfterKeyguardGoneSetToFalse() { public void dismissWithAction_AfterKeyguardGoneSetToFalse() {
OnDismissAction action = () -> false; OnDismissAction action = () -> false;
Runnable cancelAction = () -> {}; Runnable cancelAction = () -> {};
mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, mStatusBarKeyguardViewManager.dismissWithAction(
false /* afterKeyguardGone */); action, cancelAction, false /* afterKeyguardGone */);
verify(mBouncer).showWithDismissAction(eq(action), eq(cancelAction)); verify(mBouncer).showWithDismissAction(eq(action), eq(cancelAction));
} }
@@ -191,67 +174,46 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void onPanelExpansionChanged_neverHidesScrimmedBouncer() { public void onPanelExpansionChanged_neverHidesScrimmedBouncer() {
when(mBouncer.isShowing()).thenReturn(true); when(mBouncer.isShowing()).thenReturn(true);
when(mBouncer.isScrimmed()).thenReturn(true); when(mBouncer.isScrimmed()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_VISIBLE)); verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_VISIBLE));
} }
@Test @Test
public void onPanelExpansionChanged_neverShowsDuringHintAnimation() { public void onPanelExpansionChanged_neverShowsDuringHintAnimation() {
when(mNotificationPanelView.isUnlockHintRunning()).thenReturn(true); when(mNotificationPanelView.isUnlockHintRunning()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_HIDDEN)); verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_HIDDEN));
} }
@Test @Test
public void onPanelExpansionChanged_propagatesToBouncer() { public void onPanelExpansionChanged_propagatesToBouncer() {
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer).setExpansion(eq(0.5f)); verify(mBouncer).setExpansion(eq(0.5f));
} }
@Test @Test
public void onPanelExpansionChanged_showsBouncerWhenSwiping() { public void onPanelExpansionChanged_showsBouncerWhenSwiping() {
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false); when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer).show(eq(false), eq(false)); verify(mBouncer).show(eq(false), eq(false));
// But not when it's already visible // But not when it's already visible
reset(mBouncer); reset(mBouncer);
when(mBouncer.isShowing()).thenReturn(true); when(mBouncer.isShowing()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer, never()).show(eq(false), eq(false)); verify(mBouncer, never()).show(eq(false), eq(false));
// Or animating away // Or animating away
reset(mBouncer); reset(mBouncer);
when(mBouncer.isAnimatingAway()).thenReturn(true); when(mBouncer.isAnimatingAway()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer, never()).show(eq(false), eq(false)); verify(mBouncer, never()).show(eq(false), eq(false));
} }
@Test @Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenOccluded() { public void onPanelExpansionChanged_neverTranslatesBouncerWhenOccluded() {
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animate */); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animate */);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
verify(mBouncer, never()).setExpansion(eq(0.5f)); verify(mBouncer, never()).setExpansion(eq(0.5f));
} }
@@ -260,9 +222,10 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
when(mBiometricUnlockController.getMode()) when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK); .thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE, /* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true, /* expanded= */ true,
/* tracking= */ false); /* tracking= */ false));
verify(mBouncer, never()).setExpansion(anyFloat()); verify(mBouncer, never()).setExpansion(anyFloat());
} }
@@ -270,9 +233,10 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() { public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() {
when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true); when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged( mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE, /* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true, /* expanded= */ true,
/* tracking= */ false); /* tracking= */ false));
verify(mBouncer, never()).setExpansion(anyFloat()); verify(mBouncer, never()).setExpansion(anyFloat());
} }
@@ -336,8 +300,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void testHiding_cancelsGoneRunnable() { public void testHiding_cancelsGoneRunnable() {
OnDismissAction action = mock(OnDismissAction.class); OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class); Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, mStatusBarKeyguardViewManager.dismissWithAction(
true /* afterKeyguardGone */); action, cancelAction, true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.hideBouncer(true); mStatusBarKeyguardViewManager.hideBouncer(true);
mStatusBarKeyguardViewManager.hide(0, 30); mStatusBarKeyguardViewManager.hide(0, 30);
@@ -349,8 +313,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void testHiding_doesntCancelWhenShowing() { public void testHiding_doesntCancelWhenShowing() {
OnDismissAction action = mock(OnDismissAction.class); OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class); Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, mStatusBarKeyguardViewManager.dismissWithAction(
true /* afterKeyguardGone */); action, cancelAction, true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.hide(0, 30); mStatusBarKeyguardViewManager.hide(0, 30);
verify(action).onDismiss(); verify(action).onDismiss();
@@ -362,7 +326,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor); mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
when(mBouncer.isShowing()).thenReturn(false); when(mBouncer.isShowing()).thenReturn(false);
when(mAlternateAuthInterceptor.isShowingAlternateAuthBouncer()).thenReturn(true); when(mAlternateAuthInterceptor.isShowingAlternateAuthBouncer()).thenReturn(true);
assertTrue("Is showing not accurate when alternative auth showing", assertTrue(
"Is showing not accurate when alternative auth showing",
mStatusBarKeyguardViewManager.isShowing()); mStatusBarKeyguardViewManager.isShowing());
} }
@@ -371,7 +336,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor); mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
when(mBouncer.isShowing()).thenReturn(false); when(mBouncer.isShowing()).thenReturn(false);
when(mAlternateAuthInterceptor.isShowingAlternateAuthBouncer()).thenReturn(true); when(mAlternateAuthInterceptor.isShowingAlternateAuthBouncer()).thenReturn(true);
assertTrue("Is or will be showing not accurate when alternative auth showing", assertTrue(
"Is or will be showing not accurate when alternative auth showing",
mStatusBarKeyguardViewManager.bouncerIsOrWillBeShowing()); mStatusBarKeyguardViewManager.bouncerIsOrWillBeShowing());
} }
@@ -412,8 +378,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
// GIVEN alt auth exists, unlocking with biometric is allowed // GIVEN alt auth exists, unlocking with biometric is allowed
mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor); mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
when(mBouncer.isShowing()).thenReturn(false); when(mBouncer.isShowing()).thenReturn(false);
when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())) when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
.thenReturn(true);
// WHEN showGenericBouncer is called // WHEN showGenericBouncer is called
mStatusBarKeyguardViewManager.showGenericBouncer(true); mStatusBarKeyguardViewManager.showGenericBouncer(true);
@@ -446,4 +411,10 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mBouncer = null; mBouncer = null;
Truth.assertThat(mStatusBarKeyguardViewManager.isBouncerInTransit()).isFalse(); Truth.assertThat(mStatusBarKeyguardViewManager.isBouncerInTransit()).isFalse();
} }
private static PanelExpansionChangeEvent expansionEvent(
float fraction, boolean expanded, boolean tracking) {
return new PanelExpansionChangeEvent(
fraction, expanded, tracking, /* dragDownPxAmount= */ 0f);
}
} }

View File

@@ -39,12 +39,15 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
val fraction = 0.6f val fraction = 0.6f
val expanded = true val expanded = true
val tracking = true val tracking = true
val dragDownAmount = 1234f
panelExpansionStateManager.onPanelExpansionChanged(fraction, expanded, tracking) panelExpansionStateManager.onPanelExpansionChanged(
fraction, expanded, tracking, dragDownAmount)
assertThat(listener.fraction).isEqualTo(fraction) assertThat(listener.fraction).isEqualTo(fraction)
assertThat(listener.expanded).isEqualTo(expanded) assertThat(listener.expanded).isEqualTo(expanded)
assertThat(listener.tracking).isEqualTo(tracking) assertThat(listener.tracking).isEqualTo(tracking)
assertThat(listener.dragDownAmountPx).isEqualTo(dragDownAmount)
} }
@Test @Test
@@ -52,7 +55,9 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
val fraction = 0.6f val fraction = 0.6f
val expanded = true val expanded = true
val tracking = true val tracking = true
panelExpansionStateManager.onPanelExpansionChanged(fraction, expanded, tracking) val dragDownAmount = 1234f
panelExpansionStateManager.onPanelExpansionChanged(
fraction, expanded, tracking, dragDownAmount)
val listener = TestPanelExpansionListener() val listener = TestPanelExpansionListener()
panelExpansionStateManager.addExpansionListener(listener) panelExpansionStateManager.addExpansionListener(listener)
@@ -60,6 +65,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
assertThat(listener.fraction).isEqualTo(fraction) assertThat(listener.fraction).isEqualTo(fraction)
assertThat(listener.expanded).isEqualTo(expanded) assertThat(listener.expanded).isEqualTo(expanded)
assertThat(listener.tracking).isEqualTo(tracking) assertThat(listener.tracking).isEqualTo(tracking)
assertThat(listener.dragDownAmountPx).isEqualTo(dragDownAmount)
} }
@Test @Test
@@ -82,8 +88,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener) panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = true, tracking = false fraction = 0.5f, expanded = true, tracking = false, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_OPENING) assertThat(listener.state).isEqualTo(STATE_OPENING)
} }
@@ -94,8 +99,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener) panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = true, tracking = true fraction = 0.5f, expanded = true, tracking = true, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_OPENING) assertThat(listener.state).isEqualTo(STATE_OPENING)
} }
@@ -108,8 +112,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN) panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = false, tracking = false fraction = 0.5f, expanded = false, tracking = false, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_CLOSED) assertThat(listener.state).isEqualTo(STATE_CLOSED)
} }
@@ -122,8 +125,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN) panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = false, tracking = true fraction = 0.5f, expanded = false, tracking = true, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_OPEN) assertThat(listener.state).isEqualTo(STATE_OPEN)
} }
@@ -136,8 +138,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener) panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = true, tracking = false fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)
)
assertThat(listener.previousState).isEqualTo(STATE_OPENING) assertThat(listener.previousState).isEqualTo(STATE_OPENING)
assertThat(listener.state).isEqualTo(STATE_OPEN) assertThat(listener.state).isEqualTo(STATE_OPEN)
@@ -149,8 +150,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener) panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = true, tracking = true fraction = 1f, expanded = true, tracking = true, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_OPENING) assertThat(listener.state).isEqualTo(STATE_OPENING)
} }
@@ -163,8 +163,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN) panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = false, tracking = false fraction = 1f, expanded = false, tracking = false, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_CLOSED) assertThat(listener.state).isEqualTo(STATE_CLOSED)
} }
@@ -177,8 +176,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN) panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged( panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = false, tracking = true fraction = 1f, expanded = false, tracking = true, dragDownPxAmount = 0f)
)
assertThat(listener.state).isEqualTo(STATE_OPEN) assertThat(listener.state).isEqualTo(STATE_OPEN)
} }
@@ -189,15 +187,13 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
var fraction: Float = 0f var fraction: Float = 0f
var expanded: Boolean = false var expanded: Boolean = false
var tracking: Boolean = false var tracking: Boolean = false
var dragDownAmountPx: Float = 0f
override fun onPanelExpansionChanged( override fun onPanelExpansionChanged(event: PanelExpansionChangeEvent) {
fraction: Float, this.fraction = event.fraction
expanded: Boolean, this.expanded = event.expanded
tracking: Boolean this.tracking = event.tracking
) { this.dragDownAmountPx = event.dragDownPxAmount
this.fraction = fraction
this.expanded = expanded
this.tracking = tracking
} }
} }