Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +69 −0 Original line number Diff line number Diff line Loading @@ -1229,6 +1229,75 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S assertThat(alpha).isEqualTo(1f) } @Test @DisableSceneContainer fun notificationAbsoluteBottom() = testScope.runTest { var notificationCount = 2 val calculateSpace = { _: Float, _: Boolean -> notificationCount } val shelfHeight = 10F val heightForNotification = 20F val calculateHeight = { count: Int -> count * heightForNotification + shelfHeight } val stackAbsoluteBottom by collectLastValue( underTest.getNotificationStackAbsoluteBottom( calculateSpace, calculateHeight, shelfHeight, ) ) advanceTimeBy(50L) showLockscreen() shadeTestUtil.setSplitShade(false) keyguardInteractor.setNotificationContainerBounds( NotificationContainerBounds(top = 100F, bottom = 300F) ) configurationRepository.onAnyConfigurationChange() assertThat(stackAbsoluteBottom).isEqualTo(150F) // Also updates when directly requested (as it would from NotificationStackScrollLayout) notificationCount = 3 sharedNotificationContainerInteractor.notificationStackChanged() advanceTimeBy(50L) assertThat(stackAbsoluteBottom).isEqualTo(170F) } @Test @DisableSceneContainer fun notificationAbsoluteBottom_maxNotificationIsZero_noShelfHeight() = testScope.runTest { var notificationCount = 2 val calculateSpace = { _: Float, _: Boolean -> notificationCount } val shelfHeight = 10F val heightForNotification = 20F val calculateHeight = { count: Int -> count * heightForNotification + shelfHeight } val stackAbsoluteBottom by collectLastValue( underTest.getNotificationStackAbsoluteBottom( calculateSpace, calculateHeight, shelfHeight, ) ) advanceTimeBy(50L) showLockscreen() shadeTestUtil.setSplitShade(false) keyguardInteractor.setNotificationContainerBounds( NotificationContainerBounds(top = 100F, bottom = 300F) ) configurationRepository.onAnyConfigurationChange() assertThat(stackAbsoluteBottom).isEqualTo(150F) notificationCount = 0 sharedNotificationContainerInteractor.notificationStackChanged() advanceTimeBy(50L) assertThat(stackAbsoluteBottom).isEqualTo(100F) } private suspend fun TestScope.showLockscreen() { shadeTestUtil.setQsExpansion(0f) shadeTestUtil.setLockscreenShadeExpansion(0f) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/FakeWallpaperRepository.kt +0 −5 Original line number Diff line number Diff line Loading @@ -25,9 +25,4 @@ class FakeWallpaperRepository : WallpaperRepository { override val wallpaperInfo = MutableStateFlow<WallpaperInfo?>(null) override val wallpaperSupportsAmbientMode = MutableStateFlow(false) override var rootView: View? = null private val _notificationStackAbsoluteBottom = MutableStateFlow(0F) override fun setNotificationStackAbsoluteBottom(bottom: Float) { _notificationStackAbsoluteBottom.value = bottom } } packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +15 −0 Original line number Diff line number Diff line Loading @@ -269,6 +269,8 @@ interface KeyguardRepository { /** The top of shortcut in screen, used by wallpaper to find remaining space in lockscreen */ val shortcutAbsoluteTop: StateFlow<Float> val notificationStackAbsoluteBottom: StateFlow<Float> /** * Returns `true` if the keyguard is showing; `false` otherwise. * Loading Loading @@ -339,6 +341,12 @@ interface KeyguardRepository { fun isShowKeyguardWhenReenabled(): Boolean fun setShortcutAbsoluteTop(top: Float) /** * Set bottom of notifications from notification stack, and Magic Portrait will layout base on * this value */ fun setNotificationStackAbsoluteBottom(bottom: Float) } /** Encapsulates application state for the keyguard. */ Loading Loading @@ -635,6 +643,9 @@ constructor( private val _shortcutAbsoluteTop = MutableStateFlow(0F) override val shortcutAbsoluteTop = _shortcutAbsoluteTop.asStateFlow() private val _notificationStackAbsoluteBottom = MutableStateFlow(0F) override val notificationStackAbsoluteBottom = _notificationStackAbsoluteBottom.asStateFlow() init { val callback = object : KeyguardStateController.Callback { Loading Loading @@ -717,6 +728,10 @@ constructor( _shortcutAbsoluteTop.value = top } override fun setNotificationStackAbsoluteBottom(bottom: Float) { _notificationStackAbsoluteBottom.value = bottom } private fun dozeMachineStateToModel(state: DozeMachine.State): DozeStateModel { return when (state) { DozeMachine.State.UNINITIALIZED -> DozeStateModel.UNINITIALIZED Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -545,6 +545,10 @@ constructor( repository.isKeyguardGoingAway.value = isGoingAway } fun setNotificationStackAbsoluteBottom(bottom: Float) { repository.setNotificationStackAbsoluteBottom(bottom) } companion object { private const val TAG = "KeyguardInteractor" } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +1 −2 Original line number Diff line number Diff line Loading @@ -1200,7 +1200,6 @@ public class NotificationStackScrollLayout if (!SceneContainerFlag.isEnabled()) { setMaxLayoutHeight(getHeight()); updateContentHeight(); mWallpaperInteractor.setNotificationStackAbsoluteBottom(mContentHeight); } clampScrollPosition(); requestChildrenUpdate(); Loading Loading @@ -1278,7 +1277,6 @@ public class NotificationStackScrollLayout if (mAmbientState.getStackTop() != stackTop) { mAmbientState.setStackTop(stackTop); onTopPaddingChanged(/* animate = */ isAddOrRemoveAnimationPending()); mWallpaperInteractor.setNotificationStackAbsoluteBottom((int) stackTop); } } Loading Loading @@ -2648,6 +2646,7 @@ public class NotificationStackScrollLayout // The topPadding can be bigger than the regular padding when qs is expanded, in that // state the maxPanelHeight and the contentHeight should be bigger mContentHeight = (int) (height + Math.max(getIntrinsicPadding(), getTopPadding()) + mBottomPadding); updateScrollability(); Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +69 −0 Original line number Diff line number Diff line Loading @@ -1229,6 +1229,75 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S assertThat(alpha).isEqualTo(1f) } @Test @DisableSceneContainer fun notificationAbsoluteBottom() = testScope.runTest { var notificationCount = 2 val calculateSpace = { _: Float, _: Boolean -> notificationCount } val shelfHeight = 10F val heightForNotification = 20F val calculateHeight = { count: Int -> count * heightForNotification + shelfHeight } val stackAbsoluteBottom by collectLastValue( underTest.getNotificationStackAbsoluteBottom( calculateSpace, calculateHeight, shelfHeight, ) ) advanceTimeBy(50L) showLockscreen() shadeTestUtil.setSplitShade(false) keyguardInteractor.setNotificationContainerBounds( NotificationContainerBounds(top = 100F, bottom = 300F) ) configurationRepository.onAnyConfigurationChange() assertThat(stackAbsoluteBottom).isEqualTo(150F) // Also updates when directly requested (as it would from NotificationStackScrollLayout) notificationCount = 3 sharedNotificationContainerInteractor.notificationStackChanged() advanceTimeBy(50L) assertThat(stackAbsoluteBottom).isEqualTo(170F) } @Test @DisableSceneContainer fun notificationAbsoluteBottom_maxNotificationIsZero_noShelfHeight() = testScope.runTest { var notificationCount = 2 val calculateSpace = { _: Float, _: Boolean -> notificationCount } val shelfHeight = 10F val heightForNotification = 20F val calculateHeight = { count: Int -> count * heightForNotification + shelfHeight } val stackAbsoluteBottom by collectLastValue( underTest.getNotificationStackAbsoluteBottom( calculateSpace, calculateHeight, shelfHeight, ) ) advanceTimeBy(50L) showLockscreen() shadeTestUtil.setSplitShade(false) keyguardInteractor.setNotificationContainerBounds( NotificationContainerBounds(top = 100F, bottom = 300F) ) configurationRepository.onAnyConfigurationChange() assertThat(stackAbsoluteBottom).isEqualTo(150F) notificationCount = 0 sharedNotificationContainerInteractor.notificationStackChanged() advanceTimeBy(50L) assertThat(stackAbsoluteBottom).isEqualTo(100F) } private suspend fun TestScope.showLockscreen() { shadeTestUtil.setQsExpansion(0f) shadeTestUtil.setLockscreenShadeExpansion(0f) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/wallpapers/data/repository/FakeWallpaperRepository.kt +0 −5 Original line number Diff line number Diff line Loading @@ -25,9 +25,4 @@ class FakeWallpaperRepository : WallpaperRepository { override val wallpaperInfo = MutableStateFlow<WallpaperInfo?>(null) override val wallpaperSupportsAmbientMode = MutableStateFlow(false) override var rootView: View? = null private val _notificationStackAbsoluteBottom = MutableStateFlow(0F) override fun setNotificationStackAbsoluteBottom(bottom: Float) { _notificationStackAbsoluteBottom.value = bottom } }
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +15 −0 Original line number Diff line number Diff line Loading @@ -269,6 +269,8 @@ interface KeyguardRepository { /** The top of shortcut in screen, used by wallpaper to find remaining space in lockscreen */ val shortcutAbsoluteTop: StateFlow<Float> val notificationStackAbsoluteBottom: StateFlow<Float> /** * Returns `true` if the keyguard is showing; `false` otherwise. * Loading Loading @@ -339,6 +341,12 @@ interface KeyguardRepository { fun isShowKeyguardWhenReenabled(): Boolean fun setShortcutAbsoluteTop(top: Float) /** * Set bottom of notifications from notification stack, and Magic Portrait will layout base on * this value */ fun setNotificationStackAbsoluteBottom(bottom: Float) } /** Encapsulates application state for the keyguard. */ Loading Loading @@ -635,6 +643,9 @@ constructor( private val _shortcutAbsoluteTop = MutableStateFlow(0F) override val shortcutAbsoluteTop = _shortcutAbsoluteTop.asStateFlow() private val _notificationStackAbsoluteBottom = MutableStateFlow(0F) override val notificationStackAbsoluteBottom = _notificationStackAbsoluteBottom.asStateFlow() init { val callback = object : KeyguardStateController.Callback { Loading Loading @@ -717,6 +728,10 @@ constructor( _shortcutAbsoluteTop.value = top } override fun setNotificationStackAbsoluteBottom(bottom: Float) { _notificationStackAbsoluteBottom.value = bottom } private fun dozeMachineStateToModel(state: DozeMachine.State): DozeStateModel { return when (state) { DozeMachine.State.UNINITIALIZED -> DozeStateModel.UNINITIALIZED Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +4 −0 Original line number Diff line number Diff line Loading @@ -545,6 +545,10 @@ constructor( repository.isKeyguardGoingAway.value = isGoingAway } fun setNotificationStackAbsoluteBottom(bottom: Float) { repository.setNotificationStackAbsoluteBottom(bottom) } companion object { private const val TAG = "KeyguardInteractor" } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +1 −2 Original line number Diff line number Diff line Loading @@ -1200,7 +1200,6 @@ public class NotificationStackScrollLayout if (!SceneContainerFlag.isEnabled()) { setMaxLayoutHeight(getHeight()); updateContentHeight(); mWallpaperInteractor.setNotificationStackAbsoluteBottom(mContentHeight); } clampScrollPosition(); requestChildrenUpdate(); Loading Loading @@ -1278,7 +1277,6 @@ public class NotificationStackScrollLayout if (mAmbientState.getStackTop() != stackTop) { mAmbientState.setStackTop(stackTop); onTopPaddingChanged(/* animate = */ isAddOrRemoveAnimationPending()); mWallpaperInteractor.setNotificationStackAbsoluteBottom((int) stackTop); } } Loading Loading @@ -2648,6 +2646,7 @@ public class NotificationStackScrollLayout // The topPadding can be bigger than the regular padding when qs is expanded, in that // state the maxPanelHeight and the contentHeight should be bigger mContentHeight = (int) (height + Math.max(getIntrinsicPadding(), getTopPadding()) + mBottomPadding); updateScrollability(); Loading