Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +81 −6 Original line number Diff line number Diff line Loading @@ -22,10 +22,13 @@ import static com.android.systemui.flags.SceneContainerFlagParameterizationKt.pa import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.RUBBER_BAND_FACTOR_NORMAL; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -101,6 +104,8 @@ import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController; import kotlin.Unit; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; Loading @@ -111,14 +116,13 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import kotlin.Unit; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; /** * Tests for {@link NotificationStackScrollLayout}. */ Loading Loading @@ -248,6 +252,78 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { assertThat(mAmbientState.getStackY()).isEqualTo(expected); } @Test @EnableSceneContainer public void updateInterpolatedStackHeight_qsExpanded_shouldSkipUpdateStackEndHeight() { // Before: QS is fully expanded final float expansionFraction = 0.2f; final float endHeight = 200f; mStackScroller.setQsExpandFraction(1f); mStackScroller.suppressHeightUpdates(true); mAmbientState.setExpansionFraction(expansionFraction); mAmbientState.setStackEndHeight(endHeight); // When: update StackEndHeightAndStackHeight mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); // Then: stackEndHeight is not updated float expected = mStackScroller .calculateInterpolatedStackHeight(endHeight, expansionFraction); assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @EnableSceneContainer public void updateInterpolatedStackHeight_onLockScreenStack_shouldUpdateStackEndHeight() { // Before: QS is fully collapsed, on lockscreen final float expansionFraction = 0.2f; final float endHeight = 200f; mStackScroller.setQsExpandFraction(0f); mStackScroller.suppressHeightUpdates(false); mStackScroller.setMaxDisplayedNotifications(2); mAmbientState.setExpansionFraction(expansionFraction); mAmbientState.setStackEndHeight(endHeight); // When: update StackEndHeightAndStackHeight mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); // Then: updatedEndHeight should be mStackScroller.getIntrinsicStackHeight() float updatedEndHeight = mStackScroller.getIntrinsicStackHeight(); float expected = mStackScroller.calculateInterpolatedStackHeight( updatedEndHeight, expansionFraction); assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @EnableSceneContainer public void updateInterpolatedStackHeight_onExpandedShade_shouldUpdateStackEndHeight() { // Before: QS is fully collapsed, on expanded Shade final float expansionFraction = 0.2f; final float endHeight = 200f; mStackScroller.setQsExpandFraction(0f); mStackScroller.suppressHeightUpdates(false); mStackScroller.setMaxDisplayedNotifications(-1); mAmbientState.setExpansionFraction(expansionFraction); mAmbientState.setStackEndHeight(endHeight); // When: update StackEndHeightAndStackHeight mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); // Then: updatedEndHeight should be determined by the stack cutoffs float updatedEndHeight = Math.max( 0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop()); float expected = mStackScroller.calculateInterpolatedStackHeight( updatedEndHeight, expansionFraction); assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @EnableSceneContainer public void testIntrinsicStackHeight() { Loading Loading @@ -281,8 +357,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { public void testUpdateStackHeight_withExpansionAmount_whenDozeNotChanging() { final float endHeight = 8f; final float expansionFraction = 0.5f; final float expected = MathUtils.lerp( endHeight * StackScrollAlgorithm.START_FRACTION, final float expected = mStackScroller.calculateInterpolatedStackHeight( endHeight, expansionFraction); mStackScroller.updateInterpolatedStackHeight(endHeight, expansionFraction); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +10 −2 Original line number Diff line number Diff line Loading @@ -615,6 +615,8 @@ public class NotificationStackScrollLayout private boolean mShouldSkipTopPaddingAnimationAfterFold = false; @Nullable private SplitShadeStateController mSplitShadeStateController = null; private boolean mIsSmallLandscapeLockscreenEnabled = false; /** Suppress the stackEndHeight updates. */ private boolean mSuppressHeightUpdates; private boolean mIsOnLockscreen; Loading Loading @@ -1775,6 +1777,7 @@ public class NotificationStackScrollLayout * True when * 1) Unlock hint is running * 2) Swiping up on lockscreen or flinging down after swipe up * 3) When transiting between the expanded QS and the single Shade. */ private boolean shouldSkipHeightUpdate() { if (SceneContainerFlag.isEnabled()) { Loading Loading @@ -1877,8 +1880,13 @@ public class NotificationStackScrollLayout @VisibleForTesting public void updateInterpolatedStackHeight(float endHeight, float fraction) { mAmbientState.setInterpolatedStackHeight( MathUtils.lerp(endHeight * StackScrollAlgorithm.START_FRACTION, endHeight, fraction)); calculateInterpolatedStackHeight(endHeight, fraction)); } @VisibleForTesting float calculateInterpolatedStackHeight(float endHeight, float fraction) { return MathUtils.lerp(endHeight * StackScrollAlgorithm.START_FRACTION, endHeight, fraction); } /** Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt +18 −8 Original line number Diff line number Diff line Loading @@ -152,13 +152,26 @@ constructor( } } val qsExpandFraction: Flow<Float> = shadeInteractor.qsExpansion.dumpWhileCollecting("qsExpandFraction") /** Are notification stack height updates suppressed? */ val suppressHeightUpdates: Flow<Boolean> = sceneInteractor.transitionState.map { transition: ObservableTransitionState -> transition is Transition && transition.fromContent == Scenes.Lockscreen && (transition.toContent == Overlays.Bouncer || transition.toContent == Scenes.Gone) sceneInteractor.transitionState .map { state: ObservableTransitionState -> when (state) { is Idle -> { state.currentScene == Scenes.QuickSettings } is Transition -> { state.isTransitioningBetween(Scenes.Shade, Scenes.QuickSettings) || state.fromContent == Scenes.Lockscreen && (state.toContent == Overlays.Bouncer || state.toContent == Scenes.Gone) } } } .dumpWhileCollecting("suppressHeightUpdates") /** * The expansion fraction of the notification stack. It should go from 0 to 1 when transitioning Loading Loading @@ -208,9 +221,6 @@ constructor( .distinctUntilChanged() .dumpWhileCollecting("expandFraction") val qsExpandFraction: Flow<Float> = shadeInteractor.qsExpansion.dumpWhileCollecting("qsExpandFraction") val isOccluded: Flow<Boolean> = bouncerInteractor.bouncerExpansion .map { it == 1f } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +81 −6 Original line number Diff line number Diff line Loading @@ -22,10 +22,13 @@ import static com.android.systemui.flags.SceneContainerFlagParameterizationKt.pa import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_GENTLE; import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.RUBBER_BAND_FACTOR_NORMAL; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -101,6 +104,8 @@ import com.android.systemui.statusbar.phone.ScreenOffAnimationController; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController; import kotlin.Unit; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; Loading @@ -111,14 +116,13 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; import kotlin.Unit; import platform.test.runner.parameterized.ParameterizedAndroidJunit4; import platform.test.runner.parameterized.Parameters; /** * Tests for {@link NotificationStackScrollLayout}. */ Loading Loading @@ -248,6 +252,78 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { assertThat(mAmbientState.getStackY()).isEqualTo(expected); } @Test @EnableSceneContainer public void updateInterpolatedStackHeight_qsExpanded_shouldSkipUpdateStackEndHeight() { // Before: QS is fully expanded final float expansionFraction = 0.2f; final float endHeight = 200f; mStackScroller.setQsExpandFraction(1f); mStackScroller.suppressHeightUpdates(true); mAmbientState.setExpansionFraction(expansionFraction); mAmbientState.setStackEndHeight(endHeight); // When: update StackEndHeightAndStackHeight mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); // Then: stackEndHeight is not updated float expected = mStackScroller .calculateInterpolatedStackHeight(endHeight, expansionFraction); assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @EnableSceneContainer public void updateInterpolatedStackHeight_onLockScreenStack_shouldUpdateStackEndHeight() { // Before: QS is fully collapsed, on lockscreen final float expansionFraction = 0.2f; final float endHeight = 200f; mStackScroller.setQsExpandFraction(0f); mStackScroller.suppressHeightUpdates(false); mStackScroller.setMaxDisplayedNotifications(2); mAmbientState.setExpansionFraction(expansionFraction); mAmbientState.setStackEndHeight(endHeight); // When: update StackEndHeightAndStackHeight mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); // Then: updatedEndHeight should be mStackScroller.getIntrinsicStackHeight() float updatedEndHeight = mStackScroller.getIntrinsicStackHeight(); float expected = mStackScroller.calculateInterpolatedStackHeight( updatedEndHeight, expansionFraction); assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @EnableSceneContainer public void updateInterpolatedStackHeight_onExpandedShade_shouldUpdateStackEndHeight() { // Before: QS is fully collapsed, on expanded Shade final float expansionFraction = 0.2f; final float endHeight = 200f; mStackScroller.setQsExpandFraction(0f); mStackScroller.suppressHeightUpdates(false); mStackScroller.setMaxDisplayedNotifications(-1); mAmbientState.setExpansionFraction(expansionFraction); mAmbientState.setStackEndHeight(endHeight); // When: update StackEndHeightAndStackHeight mStackScroller.updateStackEndHeightAndStackHeight(expansionFraction); // Then: updatedEndHeight should be determined by the stack cutoffs float updatedEndHeight = Math.max( 0f, mAmbientState.getStackCutoff() - mAmbientState.getStackTop()); float expected = mStackScroller.calculateInterpolatedStackHeight( updatedEndHeight, expansionFraction); assertThat(mAmbientState.getInterpolatedStackHeight()).isEqualTo(expected); } @Test @EnableSceneContainer public void testIntrinsicStackHeight() { Loading Loading @@ -281,8 +357,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { public void testUpdateStackHeight_withExpansionAmount_whenDozeNotChanging() { final float endHeight = 8f; final float expansionFraction = 0.5f; final float expected = MathUtils.lerp( endHeight * StackScrollAlgorithm.START_FRACTION, final float expected = mStackScroller.calculateInterpolatedStackHeight( endHeight, expansionFraction); mStackScroller.updateInterpolatedStackHeight(endHeight, expansionFraction); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +10 −2 Original line number Diff line number Diff line Loading @@ -615,6 +615,8 @@ public class NotificationStackScrollLayout private boolean mShouldSkipTopPaddingAnimationAfterFold = false; @Nullable private SplitShadeStateController mSplitShadeStateController = null; private boolean mIsSmallLandscapeLockscreenEnabled = false; /** Suppress the stackEndHeight updates. */ private boolean mSuppressHeightUpdates; private boolean mIsOnLockscreen; Loading Loading @@ -1775,6 +1777,7 @@ public class NotificationStackScrollLayout * True when * 1) Unlock hint is running * 2) Swiping up on lockscreen or flinging down after swipe up * 3) When transiting between the expanded QS and the single Shade. */ private boolean shouldSkipHeightUpdate() { if (SceneContainerFlag.isEnabled()) { Loading Loading @@ -1877,8 +1880,13 @@ public class NotificationStackScrollLayout @VisibleForTesting public void updateInterpolatedStackHeight(float endHeight, float fraction) { mAmbientState.setInterpolatedStackHeight( MathUtils.lerp(endHeight * StackScrollAlgorithm.START_FRACTION, endHeight, fraction)); calculateInterpolatedStackHeight(endHeight, fraction)); } @VisibleForTesting float calculateInterpolatedStackHeight(float endHeight, float fraction) { return MathUtils.lerp(endHeight * StackScrollAlgorithm.START_FRACTION, endHeight, fraction); } /** Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/NotificationScrollViewModel.kt +18 −8 Original line number Diff line number Diff line Loading @@ -152,13 +152,26 @@ constructor( } } val qsExpandFraction: Flow<Float> = shadeInteractor.qsExpansion.dumpWhileCollecting("qsExpandFraction") /** Are notification stack height updates suppressed? */ val suppressHeightUpdates: Flow<Boolean> = sceneInteractor.transitionState.map { transition: ObservableTransitionState -> transition is Transition && transition.fromContent == Scenes.Lockscreen && (transition.toContent == Overlays.Bouncer || transition.toContent == Scenes.Gone) sceneInteractor.transitionState .map { state: ObservableTransitionState -> when (state) { is Idle -> { state.currentScene == Scenes.QuickSettings } is Transition -> { state.isTransitioningBetween(Scenes.Shade, Scenes.QuickSettings) || state.fromContent == Scenes.Lockscreen && (state.toContent == Overlays.Bouncer || state.toContent == Scenes.Gone) } } } .dumpWhileCollecting("suppressHeightUpdates") /** * The expansion fraction of the notification stack. It should go from 0 to 1 when transitioning Loading Loading @@ -208,9 +221,6 @@ constructor( .distinctUntilChanged() .dumpWhileCollecting("expandFraction") val qsExpandFraction: Flow<Float> = shadeInteractor.qsExpansion.dumpWhileCollecting("qsExpandFraction") val isOccluded: Flow<Boolean> = bouncerInteractor.bouncerExpansion .map { it == 1f } Loading