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

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17733164

Change-Id: I75be00a21a09d2a04239c8ad5f6340a372b213b3
Ignore-AOSP-First: this is an automerge
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-04-25 17:50:41 +00:00
committed by Automerger Merge Worker
17 changed files with 240 additions and 229 deletions

View File

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

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.SystemUIDialogManager;
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.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -491,8 +492,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController<Ud
private final PanelExpansionListener mPanelExpansionListener = new PanelExpansionListener() {
@Override
public void onPanelExpansionChanged(
float fraction, boolean expanded, boolean tracking) {
public void onPanelExpansionChanged(PanelExpansionChangeEvent event) {
float fraction = event.getFraction();
mPanelExpansionFraction =
mKeyguardViewManager.isBouncerInTransit() ? BouncerPanelExpansionCalculator
.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.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.wm.shell.animation.FlingAnimationUtils;
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
// is fully hidden at full expansion (1) and fully visible when fully collapsed
// (0).
final float dragDownAmount = e2.getY() - e1.getY();
final float screenTravelPercentage = Math.abs(e1.getY() - e2.getY())
/ mCentralSurfaces.get().getDisplayHeight();
setPanelExpansion(mBouncerInitiallyShowing
? screenTravelPercentage : 1 - screenTravelPercentage);
? screenTravelPercentage : 1 - screenTravelPercentage, dragDownAmount);
return true;
}
};
private void setPanelExpansion(float expansion) {
private void setPanelExpansion(float expansion, float dragDownAmount) {
mCurrentExpansion = expansion;
mStatusBarKeyguardViewManager.onPanelExpansionChanged(mCurrentExpansion, false, true);
PanelExpansionChangeEvent event =
new PanelExpansionChangeEvent(
/* fraction= */ mCurrentExpansion,
/* expanded= */ false,
/* tracking= */ true,
/* dragDownPxAmount= */ dragDownAmount);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(event);
}
@VisibleForTesting
public enum DreamEvent implements UiEventLogger.UiEventEnum {
@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 =
mValueAnimatorCreator.create(mCurrentExpansion, targetExpansion);
animator.addUpdateListener(
animation -> {
setPanelExpansion((float) animation.getAnimatedValue());
float expansionFraction = (float) animation.getAnimatedValue();
float dragDownAmount = expansionFraction * expansionHeight;
setPanelExpansion(expansionFraction, dragDownAmount);
});
if (!mBouncerInitiallyShowing && targetExpansion == KeyguardBouncer.EXPANSION_VISIBLE) {
animator.addListener(
@@ -321,8 +332,8 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler {
final float viewHeight = mCentralSurfaces.get().getDisplayHeight();
final float currentHeight = viewHeight * mCurrentExpansion;
final float targetHeight = viewHeight * expansion;
final ValueAnimator animator = createExpansionAnimator(expansion);
final float expansionHeight = targetHeight - currentHeight;
final ValueAnimator animator = createExpansionAnimator(expansion, expansionHeight);
if (expansion == KeyguardBouncer.EXPANSION_HIDDEN) {
// Hides the bouncer, i.e., fully expands the space above the bouncer.
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.DozeParameters
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.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
@@ -340,7 +341,9 @@ class NotificationShadeDepthController @Inject constructor(
/**
* 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 expansion = MathUtils.saturate(
(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.KeyguardBypassController
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.policy.HeadsUpManager
import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener
@@ -292,8 +293,8 @@ class NotificationWakeUpCoordinator @Inject constructor(
this.state = newState
}
override fun onPanelExpansionChanged(fraction: Float, expanded: Boolean, tracking: Boolean) {
val collapsedEnough = fraction <= 0.9f
override fun onPanelExpansionChanged(event: PanelExpansionChangeEvent) {
val collapsedEnough = event.fraction <= 0.9f
if (collapsedEnough != this.collapsedEnoughToHide) {
val couldShowPulsingHuns = canShowPulsingHuns
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.StatusBarPhoneModule;
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.policy.BatteryController;
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);
if (fraction == 0 || fraction == 1) {

View File

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

View File

@@ -306,7 +306,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
}
});
panelExpansionStateManager.addExpansionListener(
(fraction, expanded, tracking) -> setRawPanelExpansionFraction(fraction)
event -> setRawPanelExpansionFraction(event.getFraction())
);
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.notification.ViewGroupFadeHelper;
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.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -353,7 +354,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
}
@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.
final boolean hideBouncerOverDream =
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
* 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. */
public interface PanelExpansionListener {
fun interface PanelExpansionListener {
/**
* Invoked whenever the notification panel expansion changes, at every animation frame.
* This is the main expansion that happens when the user is swiping up to dismiss the
* lock screen and 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.
* Invoked whenever the notification panel expansion changes, at every animation frame. This is
* the main expansion that happens when the user is swiping up to dismiss the lock screen and
* swiping to pull down the notification shade.
*/
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
private var expanded: 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.
@@ -45,7 +46,8 @@ class PanelExpansionStateManager @Inject constructor() {
*/
fun addExpansionListener(listener: PanelExpansionListener) {
expansionListeners.add(listener)
listener.onPanelExpansionChanged(fraction, expanded, tracking)
listener.onPanelExpansionChanged(
PanelExpansionChangeEvent(fraction, expanded, tracking, dragDownPxAmount))
}
/** Removes an expansion listener. */
@@ -77,7 +79,8 @@ class PanelExpansionStateManager @Inject constructor() {
fun onPanelExpansionChanged(
@FloatRange(from = 0.0, to = 1.0) fraction: Float,
expanded: Boolean,
tracking: Boolean
tracking: Boolean,
dragDownPxAmount: Float
) {
require(!fraction.isNaN()) { "fraction cannot be NaN" }
val oldState = state
@@ -85,6 +88,7 @@ class PanelExpansionStateManager @Inject constructor() {
this.fraction = fraction
this.expanded = expanded
this.tracking = tracking
this.dragDownPxAmount = dragDownPxAmount
var fullyClosed = true
var fullyOpened = false
@@ -110,14 +114,17 @@ class PanelExpansionStateManager @Inject constructor() {
"f=$fraction " +
"expanded=$expanded " +
"tracking=$tracking" +
"drawDownPxAmount=$dragDownPxAmount " +
"${if (fullyOpened) " fullyOpened" 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. */
fun updateState(@PanelState state: Int) {
debugLog("update state: ${this.state.stateToString()} -> ${state.stateToString()}")
if (this.state != state) {
@@ -137,7 +144,7 @@ class PanelExpansionStateManager @Inject constructor() {
}
}
/** Enum for the current state of the panel. */
/** Enum for the current state of the panel. */
@Retention(AnnotationRetention.SOURCE)
@IntDef(value = [STATE_CLOSED, STATE_OPENING, STATE_OPEN])
internal annotation class PanelState

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.SystemUIDialogManager;
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.PanelExpansionStateManager;
import com.android.systemui.statusbar.policy.ConfigurationController;
@@ -483,8 +484,11 @@ public class UdfpsKeyguardViewControllerTest extends SysuiTestCase {
}
private void updateStatusBarExpansion(float fraction, boolean expanded) {
PanelExpansionChangeEvent event =
new PanelExpansionChangeEvent(
fraction, expanded, /* tracking= */ false, /* dragDownPxAmount= */ 0f);
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 org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.eq;
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.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionChangeEvent;
import com.android.wm.shell.animation.FlingAnimationUtils;
import org.junit.Before;
@@ -193,8 +193,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
.isTrue();
verify(mStatusBarKeyguardViewManager, never())
.onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
verify(mStatusBarKeyguardViewManager, never()).onPanelExpansionChanged(any());
}
/**
@@ -221,8 +220,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
assertThat(gestureListener.onScroll(event1, event2, 0, distanceY))
.isTrue();
verify(mStatusBarKeyguardViewManager, never())
.onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
verify(mStatusBarKeyguardViewManager, never()).onPanelExpansionChanged(any());
}
/**
@@ -281,14 +279,16 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase {
.isTrue();
// Ensure only called once
verify(mStatusBarKeyguardViewManager)
.onPanelExpansionChanged(anyFloat(), anyBoolean(), anyBoolean());
verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(any());
final float expansion = isBouncerInitiallyShowing ? percent : 1 - percent;
final float dragDownAmount = event2.getY() - event1.getY();
// Ensure correct expansion passed in.
verify(mStatusBarKeyguardViewManager).onPanelExpansionChanged(eq(expansion), eq(false),
eq(true));
PanelExpansionChangeEvent event =
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.DozeParameters
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.KeyguardStateController
import com.android.systemui.util.WallpaperController
@@ -123,7 +124,7 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
verify(statusBarStateController).addCallback(captor.capture())
statusBarStateListener = captor.value
verify(notificationShadeWindowController)
.setScrimsVisibilityListener(scrimVisibilityCaptor.capture())
.setScrimsVisibilityListener(scrimVisibilityCaptor.capture())
disableSplitShade()
}
@@ -136,16 +137,16 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test
fun onPanelExpansionChanged_apliesBlur_ifShade() {
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
verify(shadeAnimation).animateTo(eq(maxBlur), any())
}
@Test
fun onPanelExpansionChanged_animatesBlurIn_ifShade() {
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())
}
@@ -154,28 +155,27 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
onPanelExpansionChanged_animatesBlurIn_ifShade()
clearInvocations(shadeAnimation)
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0f, expanded = false, tracking = false
)
PanelExpansionChangeEvent(
fraction = 0f, expanded = false, tracking = false, dragDownPxAmount = 0f))
verify(shadeAnimation).animateTo(eq(0), any())
}
@Test
fun onPanelExpansionChanged_animatesBlurOut_ifFlick() {
val event =
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)
onPanelExpansionChanged_apliesBlur_ifShade()
clearInvocations(shadeAnimation)
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = true
)
notificationShadeDepthController.onPanelExpansionChanged(event)
verify(shadeAnimation, never()).animateTo(anyInt(), any())
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.9f, expanded = true, tracking = true
)
event.copy(fraction = 0.9f, tracking = true))
verify(shadeAnimation, never()).animateTo(anyInt(), any())
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.8f, expanded = true, tracking = false
)
event.copy(fraction = 0.8f, tracking = false))
verify(shadeAnimation).animateTo(eq(0), any())
}
@@ -184,27 +184,24 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
onPanelExpansionChanged_animatesBlurOut_ifFlick()
clearInvocations(shadeAnimation)
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())
}
@Test
fun onPanelExpansionChanged_respectsMinPanelPullDownFraction() {
val event =
PanelExpansionChangeEvent(
fraction = 0.5f, expanded = true, tracking = true, dragDownPxAmount = 0f)
notificationShadeDepthController.panelPullDownMinFraction = 0.5f
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.5f, expanded = true, tracking = true
)
notificationShadeDepthController.onPanelExpansionChanged(event)
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0f)
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 0.75f, expanded = true, tracking = true
)
notificationShadeDepthController.onPanelExpansionChanged(event.copy(fraction = 0.75f))
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(0.5f)
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = true
)
notificationShadeDepthController.onPanelExpansionChanged(event.copy(fraction = 1f))
assertThat(notificationShadeDepthController.shadeExpansion).isEqualTo(1f)
}
@@ -223,8 +220,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
statusBarState = StatusBarState.KEYGUARD
notificationShadeDepthController.qsPanelExpansion = 1f
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
}
@@ -234,11 +231,11 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
statusBarState = StatusBarState.KEYGUARD
notificationShadeDepthController.qsPanelExpansion = 0.25f
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom(
eq(ShadeInterpolation.getNotificationScrimAlpha(0.25f)))
verify(wallpaperController)
.setNotificationShadeZoom(eq(ShadeInterpolation.getNotificationScrimAlpha(0.25f)))
}
@Test
@@ -246,7 +243,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
enableSplitShade()
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom(0f)
@@ -257,7 +255,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
disableSplitShade()
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 })
@@ -269,14 +268,16 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
val rawFraction = 1f
val expanded = true
val tracking = false
val dragDownPxAmount = 0f
val event = PanelExpansionChangeEvent(rawFraction, expanded, tracking, dragDownPxAmount)
val inOrder = Mockito.inOrder(wallpaperController)
notificationShadeDepthController.onPanelExpansionChanged(rawFraction, expanded, tracking)
notificationShadeDepthController.onPanelExpansionChanged(event)
notificationShadeDepthController.updateBlurCallback.doFrame(0)
inOrder.verify(wallpaperController).setNotificationShadeZoom(floatThat { it > 0 })
enableSplitShade()
notificationShadeDepthController.onPanelExpansionChanged(rawFraction, expanded, tracking)
notificationShadeDepthController.onPanelExpansionChanged(event)
notificationShadeDepthController.updateBlurCallback.doFrame(0)
inOrder.verify(wallpaperController).setNotificationShadeZoom(0f)
}
@@ -332,8 +333,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test
fun updateBlurCallback_setsBlur_whenExpanded() {
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.updateBlurCallback.doFrame(0)
verify(blurUtils).applyBlur(any(), eq(maxBlur), eq(false))
@@ -342,8 +343,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test
fun updateBlurCallback_ignoreShadeBlurUntilHidden_overridesZoom() {
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.blursDisabledForAppLaunch = true
notificationShadeDepthController.updateBlurCallback.doFrame(0)
@@ -353,15 +354,15 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test
fun ignoreShadeBlurUntilHidden_schedulesFrame() {
notificationShadeDepthController.blursDisabledForAppLaunch = true
verify(choreographer).postFrameCallback(
eq(notificationShadeDepthController.updateBlurCallback))
verify(choreographer)
.postFrameCallback(eq(notificationShadeDepthController.updateBlurCallback))
}
@Test
fun ignoreBlurForUnlock_ignores() {
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.blursDisabledForAppLaunch = false
@@ -377,8 +378,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
@Test
fun ignoreBlurForUnlock_doesNotIgnore() {
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
notificationShadeDepthController.blursDisabledForAppLaunch = false
@@ -409,8 +410,8 @@ class NotificationShadeDepthControllerTest : SysuiTestCase() {
`when`(brightnessSpring.ratio).thenReturn(1f)
// And shade is blurred
notificationShadeDepthController.onPanelExpansionChanged(
rawFraction = 1f, expanded = true, tracking = false
)
PanelExpansionChangeEvent(
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f))
`when`(shadeAnimation.radius).thenReturn(maxBlur.toFloat())
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.NotificationShadeWindowController;
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.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -70,48 +71,30 @@ import java.util.Optional;
@TestableLooper.RunWithLooper
public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
@Mock
private ViewMediatorCallback mViewMediatorCallback;
@Mock
private LockPatternUtils mLockPatternUtils;
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private CentralSurfaces mCentralSurfaces;
@Mock
private ViewGroup mContainer;
@Mock
private NotificationPanelViewController mNotificationPanelView;
@Mock
private BiometricUnlockController mBiometricUnlockController;
@Mock
private SysuiStatusBarStateController mStatusBarStateController;
@Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
private View mNotificationContainer;
@Mock
private KeyguardBypassController mBypassController;
@Mock
private KeyguardBouncer.Factory mKeyguardBouncerFactory;
@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 static final PanelExpansionChangeEvent EXPANSION_EVENT =
expansionEvent(/* fraction= */ 0.5f, /* expanded= */ false, /* tracking= */ true);
@Mock private ViewMediatorCallback mViewMediatorCallback;
@Mock private LockPatternUtils mLockPatternUtils;
@Mock private KeyguardStateController mKeyguardStateController;
@Mock private CentralSurfaces mCentralSurfaces;
@Mock private ViewGroup mContainer;
@Mock private NotificationPanelViewController mNotificationPanelView;
@Mock private BiometricUnlockController mBiometricUnlockController;
@Mock private SysuiStatusBarStateController mStatusBarStateController;
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock private View mNotificationContainer;
@Mock private KeyguardBypassController mBypassController;
@Mock private KeyguardBouncer.Factory mKeyguardBouncerFactory;
@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;
@@ -119,31 +102,31 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mKeyguardBouncerFactory.create(
any(ViewGroup.class),
any(KeyguardBouncer.BouncerExpansionCallback.class)))
any(ViewGroup.class), any(KeyguardBouncer.BouncerExpansionCallback.class)))
.thenReturn(mBouncer);
when(mCentralSurfaces.getBouncerContainer()).thenReturn(mContainer);
when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea);
when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class)))
.thenReturn(mKeyguardMessageAreaController);
mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager(
getContext(),
mViewMediatorCallback,
mLockPatternUtils,
mStatusBarStateController,
mock(ConfigurationController.class),
mKeyguardUpdateMonitor,
mDreamOverlayStateController,
mock(NavigationModeController.class),
mock(DockManager.class),
mock(NotificationShadeWindowController.class),
mKeyguardStateController,
mock(NotificationMediaManager.class),
mKeyguardBouncerFactory,
mKeyguardMessageAreaFactory,
Optional.of(mSysUiUnfoldComponent),
() -> mShadeController,
mLatencyTracker);
mStatusBarKeyguardViewManager =
new StatusBarKeyguardViewManager(
getContext(),
mViewMediatorCallback,
mLockPatternUtils,
mStatusBarStateController,
mock(ConfigurationController.class),
mKeyguardUpdateMonitor,
mDreamOverlayStateController,
mock(NavigationModeController.class),
mock(DockManager.class),
mock(NotificationShadeWindowController.class),
mKeyguardStateController,
mock(NotificationMediaManager.class),
mKeyguardBouncerFactory,
mKeyguardMessageAreaFactory,
Optional.of(mSysUiUnfoldComponent),
() -> mShadeController,
mLatencyTracker);
mStatusBarKeyguardViewManager.registerCentralSurfaces(
mCentralSurfaces,
mNotificationPanelView,
@@ -159,8 +142,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void dismissWithAction_AfterKeyguardGoneSetToFalse() {
OnDismissAction action = () -> false;
Runnable cancelAction = () -> {};
mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction,
false /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, false /* afterKeyguardGone */);
verify(mBouncer).showWithDismissAction(eq(action), eq(cancelAction));
}
@@ -191,67 +174,46 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void onPanelExpansionChanged_neverHidesScrimmedBouncer() {
when(mBouncer.isShowing()).thenReturn(true);
when(mBouncer.isScrimmed()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_VISIBLE));
}
@Test
public void onPanelExpansionChanged_neverShowsDuringHintAnimation() {
when(mNotificationPanelView.isUnlockHintRunning()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_HIDDEN));
}
@Test
public void onPanelExpansionChanged_propagatesToBouncer() {
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer).setExpansion(eq(0.5f));
}
@Test
public void onPanelExpansionChanged_showsBouncerWhenSwiping() {
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer).show(eq(false), eq(false));
// But not when it's already visible
reset(mBouncer);
when(mBouncer.isShowing()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer, never()).show(eq(false), eq(false));
// Or animating away
reset(mBouncer);
when(mBouncer.isAnimatingAway()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer, never()).show(eq(false), eq(false));
}
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenOccluded() {
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animate */);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ 0.5f,
/* expanded= */ false,
/* tracking= */ true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer, never()).setExpansion(eq(0.5f));
}
@@ -260,9 +222,10 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false);
expansionEvent(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mBouncer, never()).setExpansion(anyFloat());
}
@@ -270,9 +233,10 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() {
when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false);
expansionEvent(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mBouncer, never()).setExpansion(anyFloat());
}
@@ -336,8 +300,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void testHiding_cancelsGoneRunnable() {
OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction,
true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.hideBouncer(true);
mStatusBarKeyguardViewManager.hide(0, 30);
@@ -349,8 +313,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void testHiding_doesntCancelWhenShowing() {
OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction,
true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.hide(0, 30);
verify(action).onDismiss();
@@ -362,7 +326,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
when(mBouncer.isShowing()).thenReturn(false);
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());
}
@@ -371,7 +336,8 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
when(mBouncer.isShowing()).thenReturn(false);
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());
}
@@ -412,8 +378,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
// GIVEN alt auth exists, unlocking with biometric is allowed
mStatusBarKeyguardViewManager.setAlternateAuthInterceptor(mAlternateAuthInterceptor);
when(mBouncer.isShowing()).thenReturn(false);
when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean()))
.thenReturn(true);
when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(true);
// WHEN showGenericBouncer is called
mStatusBarKeyguardViewManager.showGenericBouncer(true);
@@ -446,4 +411,10 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mBouncer = null;
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 expanded = 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.expanded).isEqualTo(expanded)
assertThat(listener.tracking).isEqualTo(tracking)
assertThat(listener.dragDownAmountPx).isEqualTo(dragDownAmount)
}
@Test
@@ -52,7 +55,9 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
val fraction = 0.6f
val expanded = true
val tracking = true
panelExpansionStateManager.onPanelExpansionChanged(fraction, expanded, tracking)
val dragDownAmount = 1234f
panelExpansionStateManager.onPanelExpansionChanged(
fraction, expanded, tracking, dragDownAmount)
val listener = TestPanelExpansionListener()
panelExpansionStateManager.addExpansionListener(listener)
@@ -60,6 +65,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
assertThat(listener.fraction).isEqualTo(fraction)
assertThat(listener.expanded).isEqualTo(expanded)
assertThat(listener.tracking).isEqualTo(tracking)
assertThat(listener.dragDownAmountPx).isEqualTo(dragDownAmount)
}
@Test
@@ -82,8 +88,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = true, tracking = false
)
fraction = 0.5f, expanded = true, tracking = false, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_OPENING)
}
@@ -94,8 +99,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = true, tracking = true
)
fraction = 0.5f, expanded = true, tracking = true, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_OPENING)
}
@@ -108,8 +112,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = false, tracking = false
)
fraction = 0.5f, expanded = false, tracking = false, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_CLOSED)
}
@@ -122,8 +125,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 0.5f, expanded = false, tracking = true
)
fraction = 0.5f, expanded = false, tracking = true, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_OPEN)
}
@@ -136,8 +138,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = true, tracking = false
)
fraction = 1f, expanded = true, tracking = false, dragDownPxAmount = 0f)
assertThat(listener.previousState).isEqualTo(STATE_OPENING)
assertThat(listener.state).isEqualTo(STATE_OPEN)
@@ -149,8 +150,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.addStateListener(listener)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = true, tracking = true
)
fraction = 1f, expanded = true, tracking = true, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_OPENING)
}
@@ -163,8 +163,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = false, tracking = false
)
fraction = 1f, expanded = false, tracking = false, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_CLOSED)
}
@@ -177,8 +176,7 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
panelExpansionStateManager.updateState(STATE_OPEN)
panelExpansionStateManager.onPanelExpansionChanged(
fraction = 1f, expanded = false, tracking = true
)
fraction = 1f, expanded = false, tracking = true, dragDownPxAmount = 0f)
assertThat(listener.state).isEqualTo(STATE_OPEN)
}
@@ -189,15 +187,13 @@ class PanelExpansionStateManagerTest : SysuiTestCase() {
var fraction: Float = 0f
var expanded: Boolean = false
var tracking: Boolean = false
var dragDownAmountPx: Float = 0f
override fun onPanelExpansionChanged(
fraction: Float,
expanded: Boolean,
tracking: Boolean
) {
this.fraction = fraction
this.expanded = expanded
this.tracking = tracking
override fun onPanelExpansionChanged(event: PanelExpansionChangeEvent) {
this.fraction = event.fraction
this.expanded = event.expanded
this.tracking = event.tracking
this.dragDownAmountPx = event.dragDownPxAmount
}
}