diff options
| author | 2023-12-12 20:13:17 +0000 | |
|---|---|---|
| committer | 2023-12-12 20:13:17 +0000 | |
| commit | 35b770f3a14b64fc0579d027feb10d6a33351638 (patch) | |
| tree | d554af27ab621abcb927cd2614b5034418365f91 | |
| parent | 192cf8a604ab686178dfa58e9081fb36db18b122 (diff) | |
| parent | 506164fdaa26fc9054c2c00fdefbfc23683e939f (diff) | |
Merge changes from topic "mpietal_shelf" into main
* changes:
Keyguard translation - Emit value on start
Allow shelf to overlap UDFPS/lock icon
16 files changed, 185 insertions, 61 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt index b51edab6dfe8..0df7f9b809fd 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt @@ -160,6 +160,9 @@ interface KeyguardRepository { /** Last point that [KeyguardRootView] was tapped */ val lastRootViewTapPosition: MutableStateFlow<Point?> + /** Is the ambient indication area visible? */ + val ambientIndicationVisible: MutableStateFlow<Boolean> + /** Observable for the [StatusBarState] */ val statusBarState: StateFlow<StatusBarState> @@ -423,6 +426,8 @@ constructor( override val lastRootViewTapPosition: MutableStateFlow<Point?> = MutableStateFlow(null) + override val ambientIndicationVisible: MutableStateFlow<Boolean> = MutableStateFlow(false) + override val isDreamingWithOverlay: Flow<Boolean> = conflatedCallbackFlow { val callback = diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt index c12efe875b0b..defca18b64b8 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardInteractor.kt @@ -174,6 +174,9 @@ constructor( /** Last point that [KeyguardRootView] view was tapped */ val lastRootViewTapPosition: Flow<Point?> = repository.lastRootViewTapPosition.asStateFlow() + /** Is the ambient indication area visible? */ + val ambientIndicationVisible: Flow<Boolean> = repository.ambientIndicationVisible.asStateFlow() + /** Whether the primary bouncer is showing or not. */ val primaryBouncerShowing: Flow<Boolean> = bouncerRepository.primaryBouncerShow @@ -311,6 +314,10 @@ constructor( repository.lastRootViewTapPosition.value = point } + fun setAmbientIndicationVisible(isVisible: Boolean) { + repository.ambientIndicationVisible.value = isVisible + } + companion object { private const val TAG = "KeyguardInteractor" } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt index 1d4520ff8f03..26dace00ad76 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModel.kt @@ -180,7 +180,9 @@ constructor( goneToAodTransitionViewModel .enterFromTopTranslationY(enterFromTopAmount) .onStart { emit(0f) }, - occludedToLockscreenTransitionViewModel.lockscreenTranslationY, + occludedToLockscreenTransitionViewModel.lockscreenTranslationY.onStart { + emit(0f) + }, ) { keyguardTransitionY, burnInTranslationY, @@ -193,6 +195,7 @@ constructor( occludedToLockscreenTransitionTranslationY } } + .distinctUntilChanged() val translationX: Flow<Float> = burnIn().map { it.translationX.toFloat() } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt index adf6cca1ac65..625fdc1c12f8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractor.kt @@ -20,6 +20,8 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor import android.content.Context import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor +import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.res.R import com.android.systemui.statusbar.policy.SplitShadeStateController import javax.inject.Inject @@ -28,6 +30,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow +import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.onStart @@ -39,7 +42,9 @@ class SharedNotificationContainerInteractor constructor( configurationRepository: ConfigurationRepository, private val context: Context, - private val splitShadeStateController: SplitShadeStateController + private val splitShadeStateController: SplitShadeStateController, + keyguardInteractor: KeyguardInteractor, + deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor, ) { private val _topPosition = MutableStateFlow(0f) @@ -75,6 +80,19 @@ constructor( } .distinctUntilChanged() + /** + * The notification shelf can extend over the lock icon area if: + * * UDFPS supported. Ambient indication will always appear below + * * UDFPS not supported and ambient indication not visible, which will appear above lock icon + */ + val useExtraShelfSpace: Flow<Boolean> = + combine( + keyguardInteractor.ambientIndicationVisible, + deviceEntryUdfpsInteractor.isUdfpsSupported, + ) { ambientIndicationVisible, isUdfpsSupported -> + isUdfpsSupported || !ambientIndicationVisible + } + val isSplitShadeEnabled: Flow<Boolean> = configurationBasedDimensions .map { dimens: ConfigurationBasedDimensions -> dimens.useSplitShade } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt index af56a3f51281..12927b87630e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewbinder/SharedNotificationContainerBinder.kt @@ -101,12 +101,13 @@ object SharedNotificationContainerBinder { launch { viewModel - .getMaxNotifications { space -> + .getMaxNotifications { space, extraShelfSpace -> + val shelfHeight = controller.getShelfHeight().toFloat() notificationStackSizeCalculator.computeMaxKeyguardNotifications( controller.getView(), space, - 0f, // Vertical space for shelf is already accounted for - controller.getShelfHeight().toFloat(), + if (extraShelfSpace) shelfHeight else 0f, + shelfHeight, ) } .collect { controller.setMaxDisplayedNotifications(it) } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt index 9594bc3bfd86..eff91e55d9a8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModel.kt @@ -229,7 +229,7 @@ constructor( * When expanding or when the user is interacting with the shade, keep the count stable; do not * emit a value. */ - fun getMaxNotifications(calculateSpace: (Float) -> Int): Flow<Int> { + fun getMaxNotifications(calculateSpace: (Float, Boolean) -> Int): Flow<Int> { val showLimitedNotifications = isOnLockscreenWithoutShade val showUnlimitedNotifications = combine( @@ -245,11 +245,17 @@ constructor( shadeInteractor.isUserInteracting, bounds, interactor.notificationStackChanged.onStart { emit(Unit) }, - ) { showLimitedNotifications, showUnlimitedNotifications, isUserInteracting, bounds, _ - -> + interactor.useExtraShelfSpace, + ) { flows -> + val showLimitedNotifications = flows[0] as Boolean + val showUnlimitedNotifications = flows[1] as Boolean + val isUserInteracting = flows[2] as Boolean + val bounds = flows[3] as NotificationContainerBounds + val useExtraShelfSpace = flows[5] as Boolean + if (!isUserInteracting) { if (showLimitedNotifications) { - emit(calculateSpace(bounds.bottom - bounds.top)) + emit(calculateSpace(bounds.bottom - bounds.top, useExtraShelfSpace)) } else if (showUnlimitedNotifications) { emit(-1) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt index 687800714e05..459a74c82da4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardRootViewModelTest.kt @@ -184,6 +184,13 @@ class KeyguardRootViewModelTest : SysuiTestCase() { } @Test + fun translationYInitialValueIsZero() = + testScope.runTest { + val translationY by collectLastValue(underTest.translationY) + assertThat(translationY).isEqualTo(0) + } + + @Test fun translationAndScaleFromBurnInNotDozing() = testScope.runTest { val translationX by collectLastValue(underTest.translationX) diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java index 657f9127dc7e..e572dcca5a34 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java @@ -23,6 +23,8 @@ import static com.android.systemui.dump.LogBufferHelperKt.logcatLogBuffer; import static com.google.common.truth.Truth.assertThat; +import static kotlinx.coroutines.flow.FlowKt.emptyFlow; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; @@ -37,8 +39,6 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static kotlinx.coroutines.flow.FlowKt.emptyFlow; - import android.annotation.IdRes; import android.content.ContentResolver; import android.content.res.Configuration; @@ -86,6 +86,7 @@ import com.android.systemui.classifier.FalsingCollectorFake; import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository; import com.android.systemui.common.ui.view.LongPressHandlingView; +import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor; import com.android.systemui.doze.DozeLog; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FakeFeatureFlagsClassic; @@ -402,6 +403,10 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { mPowerInteractor = keyguardInteractorDeps.getPowerInteractor(); when(mKeyguardTransitionInteractor.isInTransitionToStateWhere(any())).thenReturn( StateFlowKt.MutableStateFlow(false)); + DeviceEntryUdfpsInteractor deviceEntryUdfpsInteractor = + mock(DeviceEntryUdfpsInteractor.class); + when(deviceEntryUdfpsInteractor.isUdfpsSupported()).thenReturn(emptyFlow()); + mShadeInteractor = new ShadeInteractorImpl( mTestScope.getBackgroundScope(), new FakeDeviceProvisioningRepository(), @@ -418,7 +423,9 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase { new SharedNotificationContainerInteractor( new FakeConfigurationRepository(), mContext, - new ResourcesSplitShadeStateController() + new ResourcesSplitShadeStateController(), + mKeyguardInteractor, + deviceEntryUdfpsInteractor ), mShadeRepository ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java index 5ffbe65d2c50..9d8b21464585 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowControllerImplTest.java @@ -23,6 +23,8 @@ import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static com.google.common.truth.Truth.assertThat; +import static kotlinx.coroutines.flow.FlowKt.emptyFlow; + import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; @@ -54,6 +56,7 @@ import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepositor import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository; import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor; +import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FakeFeatureFlagsClassic; import com.android.systemui.keyguard.KeyguardViewMediator; @@ -235,6 +238,11 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { mKeyguardSecurityModel, mSelectedUserInteractor, powerInteractor); + + DeviceEntryUdfpsInteractor deviceEntryUdfpsInteractor = + mock(DeviceEntryUdfpsInteractor.class); + when(deviceEntryUdfpsInteractor.isUdfpsSupported()).thenReturn(emptyFlow()); + mShadeInteractor = new ShadeInteractorImpl( mTestScope.getBackgroundScope(), new FakeDeviceProvisioningRepository(), @@ -251,7 +259,9 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase { new SharedNotificationContainerInteractor( configurationRepository, mContext, - new ResourcesSplitShadeStateController()), + new ResourcesSplitShadeStateController(), + keyguardInteractor, + deviceEntryUdfpsInteractor), shadeRepository ) ); diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerBaseTest.java index e723d7d0367b..eb5633b70f61 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerBaseTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerBaseTest.java @@ -22,6 +22,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static kotlinx.coroutines.flow.FlowKt.emptyFlow; import static kotlinx.coroutines.test.TestCoroutineDispatchersKt.StandardTestDispatcher; import android.content.res.Resources; @@ -41,6 +42,7 @@ import com.android.systemui.SysuiTestCase; import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository; import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository; import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor; +import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FakeFeatureFlagsClassic; import com.android.systemui.flags.FeatureFlags; @@ -275,6 +277,10 @@ public class QuickSettingsControllerBaseTest extends SysuiTestCase { ResourcesSplitShadeStateController splitShadeStateController = new ResourcesSplitShadeStateController(); + DeviceEntryUdfpsInteractor deviceEntryUdfpsInteractor = + mock(DeviceEntryUdfpsInteractor.class); + when(deviceEntryUdfpsInteractor.isUdfpsSupported()).thenReturn(emptyFlow()); + mShadeInteractor = new ShadeInteractorImpl( mTestScope.getBackgroundScope(), deviceProvisioningRepository, @@ -291,7 +297,9 @@ public class QuickSettingsControllerBaseTest extends SysuiTestCase { new SharedNotificationContainerInteractor( configurationRepository, mContext, - splitShadeStateController), + splitShadeStateController, + keyguardInteractor, + deviceEntryUdfpsInteractor), mShadeRepository ) ); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt index dff91ddf559f..f25ce0aa5278 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarStateControllerImplTest.kt @@ -27,6 +27,7 @@ import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepositor import com.android.systemui.classifier.FalsingCollectorFake import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor +import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor; import com.android.systemui.flags.FakeFeatureFlagsClassic import com.android.systemui.keyguard.data.repository.FakeCommandQueue import com.android.systemui.keyguard.data.repository.FakeKeyguardRepository @@ -53,6 +54,7 @@ import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeUserSe import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController import com.android.systemui.statusbar.policy.data.repository.FakeDeviceProvisioningRepository import com.android.systemui.util.mockito.mock +import kotlinx.coroutines.flow.emptyFlow import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -83,6 +85,7 @@ class StatusBarStateControllerImplTest : SysuiTestCase() { FromPrimaryBouncerTransitionInteractor @Mock lateinit var interactionJankMonitor: InteractionJankMonitor @Mock lateinit var mockDarkAnimator: ObjectAnimator + @Mock lateinit var deviceEntryUdfpsInteractor: DeviceEntryUdfpsInteractor private lateinit var controller: StatusBarStateControllerImpl private lateinit var uiEventLogger: UiEventLoggerFake @@ -164,6 +167,8 @@ class StatusBarStateControllerImplTest : SysuiTestCase() { mock(), powerInteractor ) + + whenever(deviceEntryUdfpsInteractor.isUdfpsSupported).thenReturn(emptyFlow()) shadeInteractor = ShadeInteractorImpl( testScope.backgroundScope, @@ -181,7 +186,9 @@ class StatusBarStateControllerImplTest : SysuiTestCase() { SharedNotificationContainerInteractor( configurationRepository, mContext, - ResourcesSplitShadeStateController() + ResourcesSplitShadeStateController(), + keyguardInteractor, + deviceEntryUdfpsInteractor, ), shadeRepository, ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorTest.kt index a07b5705d171..327a07d6179f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorTest.kt @@ -20,57 +20,86 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase -import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository +import com.android.systemui.biometrics.data.repository.fingerprintPropertyRepository +import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.coroutines.collectLastValue +import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository +import com.android.systemui.kosmos.testScope import com.android.systemui.res.R -import com.android.systemui.statusbar.policy.ResourcesSplitShadeStateController +import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @SmallTest @RunWith(AndroidJUnit4::class) class SharedNotificationContainerInteractorTest : SysuiTestCase() { - private lateinit var configurationRepository: FakeConfigurationRepository - private lateinit var underTest: SharedNotificationContainerInteractor - - @Before - fun setUp() { - configurationRepository = FakeConfigurationRepository() - underTest = - SharedNotificationContainerInteractor( - configurationRepository, - mContext, - ResourcesSplitShadeStateController() - ) - } + private val kosmos = testKosmos() + private val testScope = kosmos.testScope + private val keyguardRepository = kosmos.fakeKeyguardRepository + private val configurationRepository = kosmos.fakeConfigurationRepository + private val fingerprintPropertyRepository = kosmos.fingerprintPropertyRepository + private val underTest = kosmos.sharedNotificationContainerInteractor @Test - fun validateConfigValues() = runTest { - overrideResource(R.bool.config_use_split_notification_shade, true) - overrideResource(R.bool.config_use_large_screen_shade_header, false) - overrideResource(R.dimen.notification_panel_margin_horizontal, 0) - overrideResource(R.dimen.notification_panel_margin_bottom, 10) - overrideResource(R.dimen.notification_panel_margin_top, 10) - overrideResource(R.dimen.large_screen_shade_header_height, 0) - overrideResource(R.dimen.keyguard_split_shade_top_margin, 55) - - val dimens = collectLastValue(underTest.configurationBasedDimensions) - - configurationRepository.onAnyConfigurationChange() - runCurrent() - - val lastDimens = dimens()!! - - assertThat(lastDimens.useSplitShade).isTrue() - assertThat(lastDimens.useLargeScreenHeader).isFalse() - assertThat(lastDimens.marginHorizontal).isEqualTo(0) - assertThat(lastDimens.marginBottom).isGreaterThan(0) - assertThat(lastDimens.marginTop).isGreaterThan(0) - assertThat(lastDimens.marginTopLargeScreen).isEqualTo(0) - assertThat(lastDimens.keyguardSplitShadeTopMargin).isEqualTo(55) - } + fun validateConfigValues() = + testScope.runTest { + overrideResource(R.bool.config_use_split_notification_shade, true) + overrideResource(R.bool.config_use_large_screen_shade_header, false) + overrideResource(R.dimen.notification_panel_margin_horizontal, 0) + overrideResource(R.dimen.notification_panel_margin_bottom, 10) + overrideResource(R.dimen.notification_panel_margin_top, 10) + overrideResource(R.dimen.large_screen_shade_header_height, 0) + overrideResource(R.dimen.keyguard_split_shade_top_margin, 55) + + val dimens = collectLastValue(underTest.configurationBasedDimensions) + + configurationRepository.onAnyConfigurationChange() + runCurrent() + + val lastDimens = dimens()!! + + assertThat(lastDimens.useSplitShade).isTrue() + assertThat(lastDimens.useLargeScreenHeader).isFalse() + assertThat(lastDimens.marginHorizontal).isEqualTo(0) + assertThat(lastDimens.marginBottom).isGreaterThan(0) + assertThat(lastDimens.marginTop).isGreaterThan(0) + assertThat(lastDimens.marginTopLargeScreen).isEqualTo(0) + assertThat(lastDimens.keyguardSplitShadeTopMargin).isEqualTo(55) + } + + @Test + fun useExtraShelfSpaceIsTrueWithUdfps() = + testScope.runTest { + val useExtraShelfSpace by collectLastValue(underTest.useExtraShelfSpace) + + keyguardRepository.ambientIndicationVisible.value = true + fingerprintPropertyRepository.supportsUdfps() + + assertThat(useExtraShelfSpace).isEqualTo(true) + } + + @Test + fun useExtraShelfSpaceIsTrueWithRearFpsAndNoAmbientIndicationArea() = + testScope.runTest { + val useExtraShelfSpace by collectLastValue(underTest.useExtraShelfSpace) + + keyguardRepository.ambientIndicationVisible.value = false + fingerprintPropertyRepository.supportsRearFps() + + assertThat(useExtraShelfSpace).isEqualTo(true) + } + + @Test + fun useExtraShelfSpaceIsFalseWithRearFpsAndAmbientIndicationArea() = + testScope.runTest { + val useExtraShelfSpace by collectLastValue(underTest.useExtraShelfSpace) + + keyguardRepository.ambientIndicationVisible.value = true + fingerprintPropertyRepository.supportsRearFps() + + assertThat(useExtraShelfSpace).isEqualTo(false) + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt index f0205b3f5974..36a471238c8a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/ui/viewmodel/SharedNotificationContainerViewModelTest.kt @@ -332,8 +332,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { fun maxNotificationsOnLockscreen() = testScope.runTest { var notificationCount = 10 - val maxNotifications by - collectLastValue(underTest.getMaxNotifications { notificationCount }) + val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount } + val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) showLockscreen() @@ -355,8 +355,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { fun maxNotificationsOnLockscreen_DoesNotUpdateWhenUserInteracting() = testScope.runTest { var notificationCount = 10 - val maxNotifications by - collectLastValue(underTest.getMaxNotifications { notificationCount }) + val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> notificationCount } + val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) showLockscreen() @@ -390,7 +390,8 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() { @Test fun maxNotificationsOnShade() = testScope.runTest { - val maxNotifications by collectLastValue(underTest.getMaxNotifications { 10 }) + val calculateSpace = { space: Float, useExtraShelfSpace: Boolean -> 10 } + val maxNotifications by collectLastValue(underTest.getMaxNotifications(calculateSpace)) // Show lockscreen with shade expanded showLockscreenWithShadeExpanded() diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 5b9b390eea2d..b217195000b4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -29,6 +29,8 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.google.common.truth.Truth.assertThat; +import static kotlinx.coroutines.flow.FlowKt.emptyFlow; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -97,6 +99,7 @@ import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepositor import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository; import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor; +import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor; import com.android.systemui.dump.DumpManager; import com.android.systemui.flags.FakeFeatureFlags; import com.android.systemui.flags.FakeFeatureFlagsClassic; @@ -465,6 +468,10 @@ public class BubblesTest extends SysuiTestCase { ResourcesSplitShadeStateController splitShadeStateController = new ResourcesSplitShadeStateController(); + DeviceEntryUdfpsInteractor deviceEntryUdfpsInteractor = + mock(DeviceEntryUdfpsInteractor.class); + when(deviceEntryUdfpsInteractor.isUdfpsSupported()).thenReturn(emptyFlow()); + mShadeInteractor = new ShadeInteractorImpl( mTestScope.getBackgroundScope(), @@ -481,7 +488,9 @@ public class BubblesTest extends SysuiTestCase { new SharedNotificationContainerInteractor( configurationRepository, mContext, - splitShadeStateController), + splitShadeStateController, + keyguardInteractor, + deviceEntryUdfpsInteractor), shadeRepository ) ); diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt index 0e7c6625264c..c5d745a65e96 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardRepository.kt @@ -121,6 +121,8 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository { override val lastRootViewTapPosition: MutableStateFlow<Point?> = MutableStateFlow(null) + override val ambientIndicationVisible: MutableStateFlow<Boolean> = MutableStateFlow(false) + override fun setQuickSettingsVisible(isVisible: Boolean) { _isQuickSettingsVisible.value = isVisible } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt index 3403227f6d27..13d577bde711 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/notification/stack/domain/interactor/SharedNotificationContainerInteractorKosmos.kt @@ -18,6 +18,8 @@ package com.android.systemui.statusbar.notification.stack.domain.interactor import android.content.applicationContext import com.android.systemui.common.ui.data.repository.configurationRepository +import com.android.systemui.deviceentry.domain.interactor.deviceEntryUdfpsInteractor +import com.android.systemui.keyguard.domain.interactor.keyguardInteractor import com.android.systemui.kosmos.Kosmos import com.android.systemui.statusbar.policy.splitShadeStateController @@ -27,5 +29,7 @@ val Kosmos.sharedNotificationContainerInteractor by configurationRepository = configurationRepository, context = applicationContext, splitShadeStateController = splitShadeStateController, + keyguardInteractor = keyguardInteractor, + deviceEntryUdfpsInteractor = deviceEntryUdfpsInteractor, ) } |