Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt +30 −15 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -12,20 +12,19 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.android.systemui.keyguard.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.common.ui.domain.interactor.configurationInteractor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.doze.util.BurnInHelperWrapper import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.FakeCommandQueue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState Loading @@ -33,7 +32,10 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.PowerInteractorFactory import com.android.systemui.shade.data.repository.FakeShadeRepository import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.shade.domain.interactor.shadeLockscreenInteractor import com.android.systemui.shade.shadeTestUtil import com.android.systemui.statusbar.phone.SystemUIDialogManager import com.android.systemui.testKosmos import com.android.systemui.util.mockito.argumentCaptor Loading @@ -50,15 +52,18 @@ import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest @RunWith(AndroidJUnit4::class) class UdfpsKeyguardInteractorTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class UdfpsKeyguardInteractorTest(flags: FlagsParameterization?) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val configRepository = kosmos.fakeConfigurationRepository val keyguardRepository = kosmos.fakeKeyguardRepository val shadeRepository = kosmos.fakeShadeRepository val shadeTestUtil by lazy { kosmos.shadeTestUtil } private val burnInProgress = 1f private val burnInYOffset = 20 Loading @@ -67,7 +72,6 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { private lateinit var bouncerRepository: KeyguardBouncerRepository private lateinit var fakeCommandQueue: FakeCommandQueue private lateinit var burnInInteractor: BurnInInteractor private lateinit var shadeRepository: FakeShadeRepository private lateinit var powerInteractor: PowerInteractor @Mock private lateinit var burnInHelper: BurnInHelperWrapper Loading @@ -75,11 +79,22 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { private lateinit var underTest: UdfpsKeyguardInteractor companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf().andSceneContainer() } } init { mSetFlagsRule.setFlagsParameterization(flags!!) } @Before fun setUp() { MockitoAnnotations.initMocks(this) bouncerRepository = FakeKeyguardBouncerRepository() shadeRepository = FakeShadeRepository() fakeCommandQueue = FakeCommandQueue() burnInInteractor = BurnInInteractor( Loading @@ -93,10 +108,10 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { underTest = UdfpsKeyguardInteractor( configRepository, burnInInteractor, kosmos.keyguardInteractor, shadeRepository, kosmos.shadeInteractor, kosmos.shadeLockscreenInteractor, dialogManager, ) } Loading Loading @@ -183,13 +198,13 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { val qsProgress by collectLastValue(underTest.qsProgress) assertThat(qsProgress).isEqualTo(0f) shadeRepository.setQsExpansion(.22f) shadeTestUtil.setQsExpansion(.22f) assertThat(qsProgress).isEqualTo(.44f) shadeRepository.setQsExpansion(.5f) shadeTestUtil.setQsExpansion(.5f) assertThat(qsProgress).isEqualTo(1f) shadeRepository.setQsExpansion(.7f) shadeTestUtil.setQsExpansion(.7f) assertThat(qsProgress).isEqualTo(1f) } Loading packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractor.kt +7 −7 Original line number Diff line number Diff line Loading @@ -19,10 +19,10 @@ package com.android.systemui.keyguard.domain.interactor import android.animation.FloatEvaluator import android.animation.IntEvaluator import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.shade.data.repository.ShadeRepository import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor import com.android.systemui.statusbar.phone.SystemUIDialogManager import com.android.systemui.statusbar.phone.hideAffordancesRequest import javax.inject.Inject Loading @@ -38,17 +38,16 @@ import kotlinx.coroutines.flow.onStart class UdfpsKeyguardInteractor @Inject constructor( configRepo: ConfigurationRepository, burnInInteractor: BurnInInteractor, keyguardInteractor: KeyguardInteractor, shadeRepository: ShadeRepository, shadeInteractor: ShadeInteractor, shadeLockscreenInteractor: ShadeLockscreenInteractor, dialogManager: SystemUIDialogManager, ) { private val intEvaluator = IntEvaluator() private val floatEvaluator = FloatEvaluator() val dozeAmount = keyguardInteractor.dozeAmount val scaleForResolution = configRepo.scaleForResolution /** Burn-in offsets for the UDFPS view to mitigate burn-in on AOD. */ val burnInOffsets: Flow<Offsets> = Loading @@ -68,13 +67,14 @@ constructor( val dialogHideAffordancesRequest: Flow<Boolean> = dialogManager.hideAffordancesRequest val qsProgress: Flow<Float> = shadeRepository.qsExpansion // swipe from top of LS shadeInteractor.qsExpansion // swipe from top of LS .map { (it * 2).coerceIn(0f, 1f) } .onStart { emit(0f) } val shadeExpansion: Flow<Float> = combine( shadeRepository.udfpsTransitionToFullShadeProgress, // swipe from middle of LS shadeLockscreenInteractor .udfpsTransitionToFullShadeProgress, // swipe from middle of LS keyguardInteractor.statusBarState, // quick swipe from middle of LS ) { shadeProgress, statusBarState -> if (statusBarState == StatusBarState.SHADE_LOCKED) { Loading packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +6 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,7 @@ import kotlin.Unit; import kotlinx.coroutines.CoroutineDispatcher; import kotlinx.coroutines.flow.Flow; import kotlinx.coroutines.flow.StateFlow; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -4054,6 +4055,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mExpandedFraction; } @Override public StateFlow<Float> getUdfpsTransitionToFullShadeProgress() { return mShadeRepository.getUdfpsTransitionToFullShadeProgress(); } @Override public Flow<Float> getLegacyPanelExpansion() { return mShadeRepository.getLegacyShadeExpansion(); Loading packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.phone.HeadsUpAppearanceController import java.util.function.Consumer import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf /** Empty implementation of ShadeViewController for variants with no shade. */ Loading Loading @@ -92,6 +93,7 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : override val shadeFoldAnimator = ShadeFoldAnimatorEmptyImpl() @Deprecated("Use SceneInteractor.currentScene instead.") override val legacyPanelExpansion = flowOf(0f) override val udfpsTransitionToFullShadeProgress = MutableStateFlow(0f) } class ShadeHeadsUpTrackerEmptyImpl : ShadeHeadsUpTracker { Loading packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ interface ShadeRepository { * Amount qs has expanded, [0-1]. 0 means fully collapsed, 1 means fully expanded. Quick * Settings can be expanded without the full shade expansion. */ val qsExpansion: StateFlow<Float> @Deprecated("Use ShadeInteractor.qsExpansion instead") val qsExpansion: StateFlow<Float> /** Amount shade has expanded with regard to the UDFPS location */ val udfpsTransitionToFullShadeProgress: StateFlow<Float> Loading Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt→packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractorTest.kt +30 −15 Original line number Diff line number Diff line /* * Copyright (C) 2023 The Android Open Source Project * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading @@ -12,20 +12,19 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.android.systemui.keyguard.domain.interactor import androidx.test.ext.junit.runners.AndroidJUnit4 import android.platform.test.flag.junit.FlagsParameterization import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepository import com.android.systemui.bouncer.data.repository.KeyguardBouncerRepository import com.android.systemui.common.ui.data.repository.fakeConfigurationRepository import com.android.systemui.common.ui.domain.interactor.configurationInteractor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.doze.util.BurnInHelperWrapper import com.android.systemui.flags.andSceneContainer import com.android.systemui.keyguard.data.repository.FakeCommandQueue import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository import com.android.systemui.keyguard.shared.model.StatusBarState Loading @@ -33,7 +32,10 @@ import com.android.systemui.kosmos.testScope import com.android.systemui.power.domain.interactor.PowerInteractor import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest import com.android.systemui.power.domain.interactor.PowerInteractorFactory import com.android.systemui.shade.data.repository.FakeShadeRepository import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.shade.domain.interactor.shadeLockscreenInteractor import com.android.systemui.shade.shadeTestUtil import com.android.systemui.statusbar.phone.SystemUIDialogManager import com.android.systemui.testKosmos import com.android.systemui.util.mockito.argumentCaptor Loading @@ -50,15 +52,18 @@ import org.mockito.ArgumentMatchers.anyInt import org.mockito.Mock import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations import platform.test.runner.parameterized.ParameterizedAndroidJunit4 import platform.test.runner.parameterized.Parameters @ExperimentalCoroutinesApi @SmallTest @RunWith(AndroidJUnit4::class) class UdfpsKeyguardInteractorTest : SysuiTestCase() { @RunWith(ParameterizedAndroidJunit4::class) class UdfpsKeyguardInteractorTest(flags: FlagsParameterization?) : SysuiTestCase() { val kosmos = testKosmos() val testScope = kosmos.testScope val configRepository = kosmos.fakeConfigurationRepository val keyguardRepository = kosmos.fakeKeyguardRepository val shadeRepository = kosmos.fakeShadeRepository val shadeTestUtil by lazy { kosmos.shadeTestUtil } private val burnInProgress = 1f private val burnInYOffset = 20 Loading @@ -67,7 +72,6 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { private lateinit var bouncerRepository: KeyguardBouncerRepository private lateinit var fakeCommandQueue: FakeCommandQueue private lateinit var burnInInteractor: BurnInInteractor private lateinit var shadeRepository: FakeShadeRepository private lateinit var powerInteractor: PowerInteractor @Mock private lateinit var burnInHelper: BurnInHelperWrapper Loading @@ -75,11 +79,22 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { private lateinit var underTest: UdfpsKeyguardInteractor companion object { @JvmStatic @Parameters(name = "{0}") fun getParams(): List<FlagsParameterization> { return FlagsParameterization.allCombinationsOf().andSceneContainer() } } init { mSetFlagsRule.setFlagsParameterization(flags!!) } @Before fun setUp() { MockitoAnnotations.initMocks(this) bouncerRepository = FakeKeyguardBouncerRepository() shadeRepository = FakeShadeRepository() fakeCommandQueue = FakeCommandQueue() burnInInteractor = BurnInInteractor( Loading @@ -93,10 +108,10 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { underTest = UdfpsKeyguardInteractor( configRepository, burnInInteractor, kosmos.keyguardInteractor, shadeRepository, kosmos.shadeInteractor, kosmos.shadeLockscreenInteractor, dialogManager, ) } Loading Loading @@ -183,13 +198,13 @@ class UdfpsKeyguardInteractorTest : SysuiTestCase() { val qsProgress by collectLastValue(underTest.qsProgress) assertThat(qsProgress).isEqualTo(0f) shadeRepository.setQsExpansion(.22f) shadeTestUtil.setQsExpansion(.22f) assertThat(qsProgress).isEqualTo(.44f) shadeRepository.setQsExpansion(.5f) shadeTestUtil.setQsExpansion(.5f) assertThat(qsProgress).isEqualTo(1f) shadeRepository.setQsExpansion(.7f) shadeTestUtil.setQsExpansion(.7f) assertThat(qsProgress).isEqualTo(1f) } Loading
packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/UdfpsKeyguardInteractor.kt +7 −7 Original line number Diff line number Diff line Loading @@ -19,10 +19,10 @@ package com.android.systemui.keyguard.domain.interactor import android.animation.FloatEvaluator import android.animation.IntEvaluator import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.shade.data.repository.ShadeRepository import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor import com.android.systemui.statusbar.phone.SystemUIDialogManager import com.android.systemui.statusbar.phone.hideAffordancesRequest import javax.inject.Inject Loading @@ -38,17 +38,16 @@ import kotlinx.coroutines.flow.onStart class UdfpsKeyguardInteractor @Inject constructor( configRepo: ConfigurationRepository, burnInInteractor: BurnInInteractor, keyguardInteractor: KeyguardInteractor, shadeRepository: ShadeRepository, shadeInteractor: ShadeInteractor, shadeLockscreenInteractor: ShadeLockscreenInteractor, dialogManager: SystemUIDialogManager, ) { private val intEvaluator = IntEvaluator() private val floatEvaluator = FloatEvaluator() val dozeAmount = keyguardInteractor.dozeAmount val scaleForResolution = configRepo.scaleForResolution /** Burn-in offsets for the UDFPS view to mitigate burn-in on AOD. */ val burnInOffsets: Flow<Offsets> = Loading @@ -68,13 +67,14 @@ constructor( val dialogHideAffordancesRequest: Flow<Boolean> = dialogManager.hideAffordancesRequest val qsProgress: Flow<Float> = shadeRepository.qsExpansion // swipe from top of LS shadeInteractor.qsExpansion // swipe from top of LS .map { (it * 2).coerceIn(0f, 1f) } .onStart { emit(0f) } val shadeExpansion: Flow<Float> = combine( shadeRepository.udfpsTransitionToFullShadeProgress, // swipe from middle of LS shadeLockscreenInteractor .udfpsTransitionToFullShadeProgress, // swipe from middle of LS keyguardInteractor.statusBarState, // quick swipe from middle of LS ) { shadeProgress, statusBarState -> if (statusBarState == StatusBarState.SHADE_LOCKED) { Loading
packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +6 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,7 @@ import kotlin.Unit; import kotlinx.coroutines.CoroutineDispatcher; import kotlinx.coroutines.flow.Flow; import kotlinx.coroutines.flow.StateFlow; import java.io.PrintWriter; import java.util.ArrayList; Loading Loading @@ -4054,6 +4055,11 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump return mExpandedFraction; } @Override public StateFlow<Float> getUdfpsTransitionToFullShadeProgress() { return mShadeRepository.getUdfpsTransitionToFullShadeProgress(); } @Override public Flow<Float> getLegacyPanelExpansion() { return mShadeRepository.getLegacyShadeExpansion(); Loading
packages/SystemUI/src/com/android/systemui/shade/ShadeViewControllerEmptyImpl.kt +2 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow import com.android.systemui.statusbar.phone.HeadsUpAppearanceController import java.util.function.Consumer import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.flowOf /** Empty implementation of ShadeViewController for variants with no shade. */ Loading Loading @@ -92,6 +93,7 @@ open class ShadeViewControllerEmptyImpl @Inject constructor() : override val shadeFoldAnimator = ShadeFoldAnimatorEmptyImpl() @Deprecated("Use SceneInteractor.currentScene instead.") override val legacyPanelExpansion = flowOf(0f) override val udfpsTransitionToFullShadeProgress = MutableStateFlow(0f) } class ShadeHeadsUpTrackerEmptyImpl : ShadeHeadsUpTracker { Loading
packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ interface ShadeRepository { * Amount qs has expanded, [0-1]. 0 means fully collapsed, 1 means fully expanded. Quick * Settings can be expanded without the full shade expansion. */ val qsExpansion: StateFlow<Float> @Deprecated("Use ShadeInteractor.qsExpansion instead") val qsExpansion: StateFlow<Float> /** Amount shade has expanded with regard to the UDFPS location */ val udfpsTransitionToFullShadeProgress: StateFlow<Float> Loading