Loading packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractorTest.kt +9 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.StatusBarState.KEYGUARD import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat as assertThatRepository import com.android.systemui.kosmos.testScope import com.android.systemui.shade.data.repository.FlingInfo import com.android.systemui.shade.data.repository.fakeShadeRepository Loading @@ -47,7 +48,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.reset import org.mockito.Mockito.spy import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat as assertThatRepository @OptIn(ExperimentalCoroutinesApi::class) @SmallTest Loading @@ -55,9 +55,8 @@ import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject class FromLockscreenTransitionInteractorTest : SysuiTestCase() { private val kosmos = testKosmos().apply { this.fakeKeyguardTransitionRepository = spy(FakeKeyguardTransitionRepository( testScope = testScope, )) this.fakeKeyguardTransitionRepository = spy(FakeKeyguardTransitionRepository(testScope = testScope)) } private val testScope = kosmos.testScope Loading Loading @@ -181,6 +180,12 @@ class FromLockscreenTransitionInteractorTest : SysuiTestCase() { underTest.start() assertThatRepository(transitionRepository).noTransitionsStarted() transitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN, testScope = testScope, ) keyguardRepository.setKeyguardDismissible(true) runCurrent() shadeRepository.setCurrentFling( Loading packages/SystemUI/multivalentTests/src/com/android/systemui/shade/data/repository/ShadeRepositoryImplTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class ShadeRepositoryImplTest : SysuiTestCase() { @Before fun setUp() { underTest = ShadeRepositoryImpl() underTest = ShadeRepositoryImpl(testScope) } @Test Loading packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt +18 −5 Original line number Diff line number Diff line Loading @@ -15,11 +15,18 @@ */ package com.android.systemui.shade.data.repository import android.annotation.SuppressLint import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch /** Data for the shade, mostly related to expansion of the shade and quick settings. */ interface ShadeRepository { Loading @@ -36,7 +43,7 @@ interface ShadeRepository { * Information about the currently running fling animation, or null if no fling animation is * running. */ val currentFling: StateFlow<FlingInfo?> val currentFling: SharedFlow<FlingInfo?> /** * The amount the lockscreen shade has dragged down by the user, [0-1]. 0 means fully collapsed, Loading Loading @@ -180,7 +187,8 @@ interface ShadeRepository { /** Business logic for shade interactions */ @SysUISingleton class ShadeRepositoryImpl @Inject constructor() : ShadeRepository { class ShadeRepositoryImpl @Inject constructor(@Background val backgroundScope: CoroutineScope) : ShadeRepository { private val _qsExpansion = MutableStateFlow(0f) @Deprecated("Use ShadeInteractor.qsExpansion instead") override val qsExpansion: StateFlow<Float> = _qsExpansion.asStateFlow() Loading @@ -193,8 +201,13 @@ class ShadeRepositoryImpl @Inject constructor() : ShadeRepository { override val udfpsTransitionToFullShadeProgress: StateFlow<Float> = _udfpsTransitionToFullShadeProgress.asStateFlow() private val _currentFling: MutableStateFlow<FlingInfo?> = MutableStateFlow(null) override val currentFling: StateFlow<FlingInfo?> = _currentFling.asStateFlow() /** * Must be a SharedFlow, since the fling is by definition an event and dropping it has extreme * consequences in some cases (for example, keyguard uses this to decide when to unlock). */ @SuppressLint("SharedFlowCreation") override val currentFling: MutableSharedFlow<FlingInfo?> = MutableSharedFlow(replay = 2, onBufferOverflow = BufferOverflow.DROP_OLDEST) private val _legacyShadeExpansion = MutableStateFlow(0f) @Deprecated("Use ShadeInteractor.shadeExpansion instead") Loading Loading @@ -294,7 +307,7 @@ class ShadeRepositoryImpl @Inject constructor() : ShadeRepository { } override fun setCurrentFling(info: FlingInfo?) { _currentFling.value = info backgroundScope.launch { currentFling.emit(info) } } @Deprecated("Should only be called by NPVC and tests") Loading packages/SystemUI/tests/utils/src/com/android/systemui/shade/data/repository/FakeShadeRepository.kt +5 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import com.android.systemui.dagger.SysUISingleton import dagger.Binds import dagger.Module import javax.inject.Inject import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow Loading @@ -37,8 +39,8 @@ class FakeShadeRepository @Inject constructor() : ShadeRepository { override val udfpsTransitionToFullShadeProgress = _udfpsTransitionToFullShadeProgress.asStateFlow() private val _currentFling: MutableStateFlow<FlingInfo?> = MutableStateFlow(null) override val currentFling: StateFlow<FlingInfo?> = _currentFling.asStateFlow() override val currentFling: MutableSharedFlow<FlingInfo?> = MutableSharedFlow(replay = 2, onBufferOverflow = BufferOverflow.DROP_OLDEST) private val _lockscreenShadeExpansion = MutableStateFlow(0f) override val lockscreenShadeExpansion = _lockscreenShadeExpansion.asStateFlow() Loading Loading @@ -139,7 +141,7 @@ class FakeShadeRepository @Inject constructor() : ShadeRepository { } override fun setCurrentFling(info: FlingInfo?) { _currentFling.value = info currentFling.tryEmit(info) } override fun setLockscreenShadeExpansion(lockscreenShadeExpansion: Float) { Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/FromLockscreenTransitionInteractorTest.kt +9 −4 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import com.android.systemui.keyguard.shared.model.StatusBarState import com.android.systemui.keyguard.shared.model.StatusBarState.KEYGUARD import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat as assertThatRepository import com.android.systemui.kosmos.testScope import com.android.systemui.shade.data.repository.FlingInfo import com.android.systemui.shade.data.repository.fakeShadeRepository Loading @@ -47,7 +48,6 @@ import org.junit.Test import org.junit.runner.RunWith import org.mockito.Mockito.reset import org.mockito.Mockito.spy import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject.Companion.assertThat as assertThatRepository @OptIn(ExperimentalCoroutinesApi::class) @SmallTest Loading @@ -55,9 +55,8 @@ import com.android.systemui.keyguard.util.KeyguardTransitionRepositorySpySubject class FromLockscreenTransitionInteractorTest : SysuiTestCase() { private val kosmos = testKosmos().apply { this.fakeKeyguardTransitionRepository = spy(FakeKeyguardTransitionRepository( testScope = testScope, )) this.fakeKeyguardTransitionRepository = spy(FakeKeyguardTransitionRepository(testScope = testScope)) } private val testScope = kosmos.testScope Loading Loading @@ -181,6 +180,12 @@ class FromLockscreenTransitionInteractorTest : SysuiTestCase() { underTest.start() assertThatRepository(transitionRepository).noTransitionsStarted() transitionRepository.sendTransitionSteps( from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN, testScope = testScope, ) keyguardRepository.setKeyguardDismissible(true) runCurrent() shadeRepository.setCurrentFling( Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/shade/data/repository/ShadeRepositoryImplTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ class ShadeRepositoryImplTest : SysuiTestCase() { @Before fun setUp() { underTest = ShadeRepositoryImpl() underTest = ShadeRepositoryImpl(testScope) } @Test Loading
packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt +18 −5 Original line number Diff line number Diff line Loading @@ -15,11 +15,18 @@ */ package com.android.systemui.shade.data.repository import android.annotation.SuppressLint import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch /** Data for the shade, mostly related to expansion of the shade and quick settings. */ interface ShadeRepository { Loading @@ -36,7 +43,7 @@ interface ShadeRepository { * Information about the currently running fling animation, or null if no fling animation is * running. */ val currentFling: StateFlow<FlingInfo?> val currentFling: SharedFlow<FlingInfo?> /** * The amount the lockscreen shade has dragged down by the user, [0-1]. 0 means fully collapsed, Loading Loading @@ -180,7 +187,8 @@ interface ShadeRepository { /** Business logic for shade interactions */ @SysUISingleton class ShadeRepositoryImpl @Inject constructor() : ShadeRepository { class ShadeRepositoryImpl @Inject constructor(@Background val backgroundScope: CoroutineScope) : ShadeRepository { private val _qsExpansion = MutableStateFlow(0f) @Deprecated("Use ShadeInteractor.qsExpansion instead") override val qsExpansion: StateFlow<Float> = _qsExpansion.asStateFlow() Loading @@ -193,8 +201,13 @@ class ShadeRepositoryImpl @Inject constructor() : ShadeRepository { override val udfpsTransitionToFullShadeProgress: StateFlow<Float> = _udfpsTransitionToFullShadeProgress.asStateFlow() private val _currentFling: MutableStateFlow<FlingInfo?> = MutableStateFlow(null) override val currentFling: StateFlow<FlingInfo?> = _currentFling.asStateFlow() /** * Must be a SharedFlow, since the fling is by definition an event and dropping it has extreme * consequences in some cases (for example, keyguard uses this to decide when to unlock). */ @SuppressLint("SharedFlowCreation") override val currentFling: MutableSharedFlow<FlingInfo?> = MutableSharedFlow(replay = 2, onBufferOverflow = BufferOverflow.DROP_OLDEST) private val _legacyShadeExpansion = MutableStateFlow(0f) @Deprecated("Use ShadeInteractor.shadeExpansion instead") Loading Loading @@ -294,7 +307,7 @@ class ShadeRepositoryImpl @Inject constructor() : ShadeRepository { } override fun setCurrentFling(info: FlingInfo?) { _currentFling.value = info backgroundScope.launch { currentFling.emit(info) } } @Deprecated("Should only be called by NPVC and tests") Loading
packages/SystemUI/tests/utils/src/com/android/systemui/shade/data/repository/FakeShadeRepository.kt +5 −3 Original line number Diff line number Diff line Loading @@ -21,6 +21,8 @@ import com.android.systemui.dagger.SysUISingleton import dagger.Binds import dagger.Module import javax.inject.Inject import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow Loading @@ -37,8 +39,8 @@ class FakeShadeRepository @Inject constructor() : ShadeRepository { override val udfpsTransitionToFullShadeProgress = _udfpsTransitionToFullShadeProgress.asStateFlow() private val _currentFling: MutableStateFlow<FlingInfo?> = MutableStateFlow(null) override val currentFling: StateFlow<FlingInfo?> = _currentFling.asStateFlow() override val currentFling: MutableSharedFlow<FlingInfo?> = MutableSharedFlow(replay = 2, onBufferOverflow = BufferOverflow.DROP_OLDEST) private val _lockscreenShadeExpansion = MutableStateFlow(0f) override val lockscreenShadeExpansion = _lockscreenShadeExpansion.asStateFlow() Loading Loading @@ -139,7 +141,7 @@ class FakeShadeRepository @Inject constructor() : ShadeRepository { } override fun setCurrentFling(info: FlingInfo?) { _currentFling.value = info currentFling.tryEmit(info) } override fun setLockscreenShadeExpansion(lockscreenShadeExpansion: Float) { Loading