Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +13 −12 Original line number Diff line number Diff line Loading @@ -843,26 +843,27 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S kosmos.runTest { var notificationCount = 10 val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount } val config by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) showLockscreen() shadeTestUtil.setSplitShade(false) fakeConfigurationRepository.onAnyConfigurationChange() assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) // Also updates when directly requested (as it would from NotificationStackScrollLayout) notificationCount = 25 sharedNotificationContainerInteractor.notificationStackChanged() testScope.advanceTimeBy(50L) assertThat(config?.maxNotifications).isEqualTo(25) assertThat(maxNotifications).isEqualTo(25) // Also ensure another collection starts with the same value. As an example, folding // then unfolding will restart the coroutine and it must get the last value immediately. val newConfig by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val newMaxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) assertThat(newConfig?.maxNotifications).isEqualTo(25) assertThat(newMaxNotifications).isEqualTo(25) } @Test Loading @@ -871,17 +872,17 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S enableSingleShade() var notificationCount = 10 val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount } val config by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) showLockscreen() fakeConfigurationRepository.onAnyConfigurationChange() assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) // Shade expanding... still 10 shadeTestUtil.setLockscreenShadeExpansion(0.5f) assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) notificationCount = 25 Loading @@ -889,20 +890,20 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S shadeTestUtil.setLockscreenShadeTracking(true) // Should still be 10, since the user is interacting assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) shadeTestUtil.setLockscreenShadeTracking(false) shadeTestUtil.setLockscreenShadeExpansion(0f) // Stopped tracking, show 25 assertThat(config?.maxNotifications).isEqualTo(25) assertThat(maxNotifications).isEqualTo(25) } @Test fun maxNotificationsOnShade() = kosmos.runTest { val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> 10 } val config by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) // Show lockscreen with shade expanded Loading @@ -912,7 +913,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S fakeConfigurationRepository.onAnyConfigurationChange() // -1 means No Limit assertThat(config?.maxNotifications).isEqualTo(-1) assertThat(maxNotifications).isEqualTo(-1) } @Test Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationListContainer.java +0 −3 Original line number Diff line number Diff line Loading @@ -100,9 +100,6 @@ public interface NotificationListContainer extends */ void addContainerViewAt(View v, int index); /** Sets whether the notificatios are displayed on the unoccluded lockscreen. */ void setOnLockscreen(boolean isOnKeyguard); /** * Sets the maximum number of notifications to display. * Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +0 −11 Original line number Diff line number Diff line Loading @@ -1613,12 +1613,6 @@ public class NotificationStackScrollLayoutController implements Dumpable { mView.setPulsing(pulsing, animatePulse); } /** Sets whether the NSSL is displayed over the unoccluded Lockscreen. */ public void setOnLockscreen(boolean isOnLockscreen) { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; mNotificationListContainer.setOnLockscreen(isOnLockscreen); } /** * Set the maximum number of notifications that can currently be displayed */ Loading Loading @@ -2031,11 +2025,6 @@ public class NotificationStackScrollLayoutController implements Dumpable { mView.addContainerViewAt(v, index); } @Override public void setOnLockscreen(boolean isOnLockscreen) { mView.setOnLockscreen(isOnLockscreen); } @Override public void setMaxDisplayedNotifications(int maxNotifications) { mView.setMaxDisplayedNotifications(maxNotifications); Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt +3 −8 Original line number Diff line number Diff line Loading @@ -119,13 +119,8 @@ constructor( if (!SceneContainerFlag.isEnabled) { launch { viewModel .getLockscreenDisplayConfig(calculateMaxNotifications) .collect { (isOnLockscreen, maxNotifications) -> if (SceneContainerFlag.isEnabled) { controller.setOnLockscreen(isOnLockscreen) } controller.setMaxDisplayedNotifications(maxNotifications) viewModel.getMaxNotifications(calculateMaxNotifications).collect { controller.setMaxDisplayedNotifications(it) } } } Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +10 −36 Original line number Diff line number Diff line Loading @@ -850,11 +850,9 @@ constructor( * When expanding or when the user is interacting with the shade, keep the count stable; do not * emit a value. */ fun getLockscreenDisplayConfig( calculateSpace: (Float, Boolean) -> Int ): Flow<LockscreenDisplayConfig> { fun getMaxNotifications(calculateSpace: (Float, Boolean) -> Int): Flow<Int> { val showLimitedNotifications = isOnLockscreenWithoutShade val showUnlimitedNotificationsAndIsOnLockScreen = val showUnlimitedNotifications = combine( isOnLockscreen, keyguardInteractor.statusBarState, Loading @@ -864,43 +862,31 @@ constructor( ) .onStart { emit(false) }, ) { isOnLockscreen, statusBarState, showAllNotifications -> (statusBarState == SHADE_LOCKED || !isOnLockscreen || showAllNotifications) to isOnLockscreen statusBarState == SHADE_LOCKED || !isOnLockscreen || showAllNotifications } .dumpWhileCollecting("showUnlimitedNotificationsAndIsOnLockScreen") .dumpWhileCollecting("showUnlimitedNotifications") @Suppress("UNCHECKED_CAST") return combineTransform( showLimitedNotifications, showUnlimitedNotificationsAndIsOnLockScreen, showUnlimitedNotifications, shadeInteractor.isUserInteracting.dumpWhileCollecting("isUserInteracting"), availableHeight, interactor.useExtraShelfSpace, interactor.notificationStackChanged, ) { flows -> val showLimitedNotifications = flows[0] as Boolean val (showUnlimitedNotifications, isOnLockscreen) = flows[1] as Pair<Boolean, Boolean> val showUnlimitedNotifications = flows[1] as Boolean val isUserInteracting = flows[2] as Boolean val availableHeight = flows[3] as Float val useExtraShelfSpace = flows[4] as Boolean if (!isUserInteracting) { if (showLimitedNotifications) { emit( LockscreenDisplayConfig( isOnLockscreen = isOnLockscreen, maxNotifications = calculateSpace(availableHeight, useExtraShelfSpace), ) ) emit(calculateSpace(availableHeight, useExtraShelfSpace)) } else if (showUnlimitedNotifications) { emit( LockscreenDisplayConfig( isOnLockscreen = isOnLockscreen, maxNotifications = -1, ) ) // -1 means no limit emit(-1) } } } Loading Loading @@ -931,10 +917,7 @@ constructor( .flatMapLatest { (hasNotifications, isOnLockscreen, hasActiveMedia) -> if ((hasNotifications || hasActiveMedia) && isOnLockscreen) { combine( getLockscreenDisplayConfig(calculateMaxNotifications).map { (_, maxNotifications) -> maxNotifications }, getMaxNotifications(calculateMaxNotifications), bounds.map { it.top }, isOnLockscreenWithoutShade, interactor.notificationStackChanged, Loading Loading @@ -983,13 +966,4 @@ constructor( /** The container is laid out from the given [ratio] of the screen width to the end edge. */ data class MiddleToEdge(val ratio: Float = 0.5f) : HorizontalPosition } /** * Data class representing a configuration for displaying Notifications on the Lockscreen. * * @param isOnLockscreen is the user on the lockscreen * @param maxNotifications Limit for the max number of top-level Notifications to be displayed. * A value of -1 indicates no limit. */ data class LockscreenDisplayConfig(val isOnLockscreen: Boolean, val maxNotifications: Int) } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +13 −12 Original line number Diff line number Diff line Loading @@ -843,26 +843,27 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S kosmos.runTest { var notificationCount = 10 val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount } val config by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) showLockscreen() shadeTestUtil.setSplitShade(false) fakeConfigurationRepository.onAnyConfigurationChange() assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) // Also updates when directly requested (as it would from NotificationStackScrollLayout) notificationCount = 25 sharedNotificationContainerInteractor.notificationStackChanged() testScope.advanceTimeBy(50L) assertThat(config?.maxNotifications).isEqualTo(25) assertThat(maxNotifications).isEqualTo(25) // Also ensure another collection starts with the same value. As an example, folding // then unfolding will restart the coroutine and it must get the last value immediately. val newConfig by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val newMaxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) assertThat(newConfig?.maxNotifications).isEqualTo(25) assertThat(newMaxNotifications).isEqualTo(25) } @Test Loading @@ -871,17 +872,17 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S enableSingleShade() var notificationCount = 10 val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount } val config by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) showLockscreen() fakeConfigurationRepository.onAnyConfigurationChange() assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) // Shade expanding... still 10 shadeTestUtil.setLockscreenShadeExpansion(0.5f) assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) notificationCount = 25 Loading @@ -889,20 +890,20 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S shadeTestUtil.setLockscreenShadeTracking(true) // Should still be 10, since the user is interacting assertThat(config?.maxNotifications).isEqualTo(10) assertThat(maxNotifications).isEqualTo(10) shadeTestUtil.setLockscreenShadeTracking(false) shadeTestUtil.setLockscreenShadeExpansion(0f) // Stopped tracking, show 25 assertThat(config?.maxNotifications).isEqualTo(25) assertThat(maxNotifications).isEqualTo(25) } @Test fun maxNotificationsOnShade() = kosmos.runTest { val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> 10 } val config by collectLastValue(underTest.getLockscreenDisplayConfig(calculateSpace)) val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) testScope.advanceTimeBy(50L) // Show lockscreen with shade expanded Loading @@ -912,7 +913,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S fakeConfigurationRepository.onAnyConfigurationChange() // -1 means No Limit assertThat(config?.maxNotifications).isEqualTo(-1) assertThat(maxNotifications).isEqualTo(-1) } @Test Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationListContainer.java +0 −3 Original line number Diff line number Diff line Loading @@ -100,9 +100,6 @@ public interface NotificationListContainer extends */ void addContainerViewAt(View v, int index); /** Sets whether the notificatios are displayed on the unoccluded lockscreen. */ void setOnLockscreen(boolean isOnKeyguard); /** * Sets the maximum number of notifications to display. * Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +0 −11 Original line number Diff line number Diff line Loading @@ -1613,12 +1613,6 @@ public class NotificationStackScrollLayoutController implements Dumpable { mView.setPulsing(pulsing, animatePulse); } /** Sets whether the NSSL is displayed over the unoccluded Lockscreen. */ public void setOnLockscreen(boolean isOnLockscreen) { if (SceneContainerFlag.isUnexpectedlyInLegacyMode()) return; mNotificationListContainer.setOnLockscreen(isOnLockscreen); } /** * Set the maximum number of notifications that can currently be displayed */ Loading Loading @@ -2031,11 +2025,6 @@ public class NotificationStackScrollLayoutController implements Dumpable { mView.addContainerViewAt(v, index); } @Override public void setOnLockscreen(boolean isOnLockscreen) { mView.setOnLockscreen(isOnLockscreen); } @Override public void setMaxDisplayedNotifications(int maxNotifications) { mView.setMaxDisplayedNotifications(maxNotifications); Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt +3 −8 Original line number Diff line number Diff line Loading @@ -119,13 +119,8 @@ constructor( if (!SceneContainerFlag.isEnabled) { launch { viewModel .getLockscreenDisplayConfig(calculateMaxNotifications) .collect { (isOnLockscreen, maxNotifications) -> if (SceneContainerFlag.isEnabled) { controller.setOnLockscreen(isOnLockscreen) } controller.setMaxDisplayedNotifications(maxNotifications) viewModel.getMaxNotifications(calculateMaxNotifications).collect { controller.setMaxDisplayedNotifications(it) } } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +10 −36 Original line number Diff line number Diff line Loading @@ -850,11 +850,9 @@ constructor( * When expanding or when the user is interacting with the shade, keep the count stable; do not * emit a value. */ fun getLockscreenDisplayConfig( calculateSpace: (Float, Boolean) -> Int ): Flow<LockscreenDisplayConfig> { fun getMaxNotifications(calculateSpace: (Float, Boolean) -> Int): Flow<Int> { val showLimitedNotifications = isOnLockscreenWithoutShade val showUnlimitedNotificationsAndIsOnLockScreen = val showUnlimitedNotifications = combine( isOnLockscreen, keyguardInteractor.statusBarState, Loading @@ -864,43 +862,31 @@ constructor( ) .onStart { emit(false) }, ) { isOnLockscreen, statusBarState, showAllNotifications -> (statusBarState == SHADE_LOCKED || !isOnLockscreen || showAllNotifications) to isOnLockscreen statusBarState == SHADE_LOCKED || !isOnLockscreen || showAllNotifications } .dumpWhileCollecting("showUnlimitedNotificationsAndIsOnLockScreen") .dumpWhileCollecting("showUnlimitedNotifications") @Suppress("UNCHECKED_CAST") return combineTransform( showLimitedNotifications, showUnlimitedNotificationsAndIsOnLockScreen, showUnlimitedNotifications, shadeInteractor.isUserInteracting.dumpWhileCollecting("isUserInteracting"), availableHeight, interactor.useExtraShelfSpace, interactor.notificationStackChanged, ) { flows -> val showLimitedNotifications = flows[0] as Boolean val (showUnlimitedNotifications, isOnLockscreen) = flows[1] as Pair<Boolean, Boolean> val showUnlimitedNotifications = flows[1] as Boolean val isUserInteracting = flows[2] as Boolean val availableHeight = flows[3] as Float val useExtraShelfSpace = flows[4] as Boolean if (!isUserInteracting) { if (showLimitedNotifications) { emit( LockscreenDisplayConfig( isOnLockscreen = isOnLockscreen, maxNotifications = calculateSpace(availableHeight, useExtraShelfSpace), ) ) emit(calculateSpace(availableHeight, useExtraShelfSpace)) } else if (showUnlimitedNotifications) { emit( LockscreenDisplayConfig( isOnLockscreen = isOnLockscreen, maxNotifications = -1, ) ) // -1 means no limit emit(-1) } } } Loading Loading @@ -931,10 +917,7 @@ constructor( .flatMapLatest { (hasNotifications, isOnLockscreen, hasActiveMedia) -> if ((hasNotifications || hasActiveMedia) && isOnLockscreen) { combine( getLockscreenDisplayConfig(calculateMaxNotifications).map { (_, maxNotifications) -> maxNotifications }, getMaxNotifications(calculateMaxNotifications), bounds.map { it.top }, isOnLockscreenWithoutShade, interactor.notificationStackChanged, Loading Loading @@ -983,13 +966,4 @@ constructor( /** The container is laid out from the given [ratio] of the screen width to the end edge. */ data class MiddleToEdge(val ratio: Float = 0.5f) : HorizontalPosition } /** * Data class representing a configuration for displaying Notifications on the Lockscreen. * * @param isOnLockscreen is the user on the lockscreen * @param maxNotifications Limit for the max number of top-level Notifications to be displayed. * A value of -1 indicates no limit. */ data class LockscreenDisplayConfig(val isOnLockscreen: Boolean, val maxNotifications: Int) }