Loading packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt +0 −5 Original line number Diff line number Diff line Loading @@ -17,14 +17,12 @@ package com.android.systemui.keyguard.data.quickaffordance import android.content.Context import com.android.systemui.R import com.android.systemui.animation.ActivityLaunchAnimator import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.containeddrawable.ContainedDrawable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.qrcodescanner.controller.QRCodeScannerController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose Loading @@ -35,12 +33,9 @@ import kotlinx.coroutines.flow.Flow class QrCodeScannerKeyguardQuickAffordanceConfig @Inject constructor( @Application context: Context, private val controller: QRCodeScannerController, ) : KeyguardQuickAffordanceConfig { private val appContext = context.applicationContext override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow { val callback = object : QRCodeScannerController.Callback { Loading packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +37 −57 Original line number Diff line number Diff line Loading @@ -29,51 +29,21 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall import com.android.systemui.containeddrawable.ContainedDrawable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.KeyguardStateControllerExt.isKeyguardShowing import com.android.systemui.wallet.controller.QuickAccessWalletController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf /** Quick access wallet quick affordance data source. */ @SysUISingleton class QuickAccessWalletKeyguardQuickAffordanceConfig @Inject constructor( private val keyguardStateController: KeyguardStateController, private val walletController: QuickAccessWalletController, private val activityStarter: ActivityStarter, ) : KeyguardQuickAffordanceConfig { override val state: Flow<KeyguardQuickAffordanceConfig.State> = keyguardStateController .isKeyguardShowing(TAG) .flatMapLatest { isKeyguardShowing -> stateInternal(isKeyguardShowing) } override fun onQuickAffordanceClicked( animationController: ActivityLaunchAnimator.Controller?, ): KeyguardQuickAffordanceConfig.OnClickedResult { walletController.startQuickAccessUiIntent( activityStarter, animationController, /* hasCard= */ true, ) return KeyguardQuickAffordanceConfig.OnClickedResult.Handled } private fun stateInternal( isKeyguardShowing: Boolean ): Flow<KeyguardQuickAffordanceConfig.State> { if (!isKeyguardShowing) { return flowOf(KeyguardQuickAffordanceConfig.State.Hidden) } return conflatedCallbackFlow { override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow { val callback = object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback { override fun onWalletCardsRetrieved(response: GetWalletCardsResponse?) { Loading Loading @@ -111,6 +81,16 @@ constructor( ) } } override fun onQuickAffordanceClicked( animationController: ActivityLaunchAnimator.Controller?, ): KeyguardQuickAffordanceConfig.OnClickedResult { walletController.startQuickAccessUiIntent( activityStarter, animationController, /* hasCard= */ true, ) return KeyguardQuickAffordanceConfig.OnClickedResult.Handled } private fun state( Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +34 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall import com.android.systemui.common.data.model.Position import com.android.systemui.dagger.SysUISingleton import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.policy.KeyguardStateController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow Loading Loading @@ -49,6 +50,15 @@ interface KeyguardRepository { */ val clockPosition: StateFlow<Position> /** * Observable for whether the keyguard is showing. * * Note: this is also `true` when the lock-screen is occluded with an `Activity` "above" it in * the z-order (which is not really above the system UI window, but rather - the lock-screen * becomes invisible to reveal the "occluding activity"). */ val isKeyguardShowing: Flow<Boolean> /** * Observable for whether we are in doze state. * Loading Loading @@ -91,6 +101,7 @@ class KeyguardRepositoryImpl @Inject constructor( statusBarStateController: StatusBarStateController, keyguardStateController: KeyguardStateController, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading @@ -102,6 +113,29 @@ constructor( private val _clockPosition = MutableStateFlow(Position(0, 0)) override val clockPosition = _clockPosition.asStateFlow() override val isKeyguardShowing: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { trySendWithFailureLogging( keyguardStateController.isShowing, TAG, "updated isKeyguardShowing" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isShowing, TAG, "initial isKeyguardShowing" ) awaitClose { keyguardStateController.removeCallback(callback) } } override val isDozing: Flow<Boolean> = conflatedCallbackFlow { val callback = object : StatusBarStateController.StateListener { Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt +2 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,8 @@ interface KeyguardRepositoryModule { impl: KeyguardQuickAffordanceRepositoryImpl ): KeyguardQuickAffordanceRepository @Binds fun keyguardQuickAffordanceConfigs( @Binds fun keyguardQuickAffordanceConfigs( impl: KeyguardQuickAffordanceConfigsImpl ): KeyguardQuickAffordanceConfigs } packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerExt.kt→packages/SystemUI/src/com/android/systemui/keyguard/domain/usecase/ObserveIsKeyguardShowingUseCase.kt +39 −0 Original line number Diff line number Diff line Loading @@ -15,32 +15,25 @@ * */ package com.android.systemui.statusbar.policy package com.android.systemui.keyguard.domain.usecase import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.common.coroutine.ConflatedCallbackFlow import kotlinx.coroutines.channels.awaitClose import com.android.systemui.keyguard.data.repository.KeyguardRepository import javax.inject.Inject import kotlinx.coroutines.flow.Flow object KeyguardStateControllerExt { /** * Returns an observable for whether the keyguard is currently shown or not. * Use-case for observing whether the keyguard is currently being shown. * * Note: this is also `true` when the lock-screen is occluded with an `Activity` "above" it in the * z-order (which is not really above the system UI window, but rather - the lock-screen becomes * invisible to reveal the "occluding activity"). */ fun KeyguardStateController.isKeyguardShowing(loggingTag: String): Flow<Boolean> { return ConflatedCallbackFlow.conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { trySendWithFailureLogging( isShowing, loggingTag, "updated isKeyguardShowing") } } addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging(isShowing, loggingTag, "initial isKeyguardShowing") awaitClose { removeCallback(callback) } } class ObserveIsKeyguardShowingUseCase @Inject constructor( private val repository: KeyguardRepository, ) { operator fun invoke(): Flow<Boolean> { return repository.isKeyguardShowing } } Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QrCodeScannerKeyguardQuickAffordanceConfig.kt +0 −5 Original line number Diff line number Diff line Loading @@ -17,14 +17,12 @@ package com.android.systemui.keyguard.data.quickaffordance import android.content.Context import com.android.systemui.R import com.android.systemui.animation.ActivityLaunchAnimator import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.containeddrawable.ContainedDrawable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.qrcodescanner.controller.QRCodeScannerController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose Loading @@ -35,12 +33,9 @@ import kotlinx.coroutines.flow.Flow class QrCodeScannerKeyguardQuickAffordanceConfig @Inject constructor( @Application context: Context, private val controller: QRCodeScannerController, ) : KeyguardQuickAffordanceConfig { private val appContext = context.applicationContext override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow { val callback = object : QRCodeScannerController.Callback { Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +37 −57 Original line number Diff line number Diff line Loading @@ -29,51 +29,21 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall import com.android.systemui.containeddrawable.ContainedDrawable import com.android.systemui.dagger.SysUISingleton import com.android.systemui.plugins.ActivityStarter import com.android.systemui.statusbar.policy.KeyguardStateController import com.android.systemui.statusbar.policy.KeyguardStateControllerExt.isKeyguardShowing import com.android.systemui.wallet.controller.QuickAccessWalletController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOf /** Quick access wallet quick affordance data source. */ @SysUISingleton class QuickAccessWalletKeyguardQuickAffordanceConfig @Inject constructor( private val keyguardStateController: KeyguardStateController, private val walletController: QuickAccessWalletController, private val activityStarter: ActivityStarter, ) : KeyguardQuickAffordanceConfig { override val state: Flow<KeyguardQuickAffordanceConfig.State> = keyguardStateController .isKeyguardShowing(TAG) .flatMapLatest { isKeyguardShowing -> stateInternal(isKeyguardShowing) } override fun onQuickAffordanceClicked( animationController: ActivityLaunchAnimator.Controller?, ): KeyguardQuickAffordanceConfig.OnClickedResult { walletController.startQuickAccessUiIntent( activityStarter, animationController, /* hasCard= */ true, ) return KeyguardQuickAffordanceConfig.OnClickedResult.Handled } private fun stateInternal( isKeyguardShowing: Boolean ): Flow<KeyguardQuickAffordanceConfig.State> { if (!isKeyguardShowing) { return flowOf(KeyguardQuickAffordanceConfig.State.Hidden) } return conflatedCallbackFlow { override val state: Flow<KeyguardQuickAffordanceConfig.State> = conflatedCallbackFlow { val callback = object : QuickAccessWalletClient.OnWalletCardsRetrievedCallback { override fun onWalletCardsRetrieved(response: GetWalletCardsResponse?) { Loading Loading @@ -111,6 +81,16 @@ constructor( ) } } override fun onQuickAffordanceClicked( animationController: ActivityLaunchAnimator.Controller?, ): KeyguardQuickAffordanceConfig.OnClickedResult { walletController.startQuickAccessUiIntent( activityStarter, animationController, /* hasCard= */ true, ) return KeyguardQuickAffordanceConfig.OnClickedResult.Handled } private fun state( Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +34 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCall import com.android.systemui.common.data.model.Position import com.android.systemui.dagger.SysUISingleton import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.policy.KeyguardStateController import javax.inject.Inject import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow Loading Loading @@ -49,6 +50,15 @@ interface KeyguardRepository { */ val clockPosition: StateFlow<Position> /** * Observable for whether the keyguard is showing. * * Note: this is also `true` when the lock-screen is occluded with an `Activity` "above" it in * the z-order (which is not really above the system UI window, but rather - the lock-screen * becomes invisible to reveal the "occluding activity"). */ val isKeyguardShowing: Flow<Boolean> /** * Observable for whether we are in doze state. * Loading Loading @@ -91,6 +101,7 @@ class KeyguardRepositoryImpl @Inject constructor( statusBarStateController: StatusBarStateController, keyguardStateController: KeyguardStateController, ) : KeyguardRepository { private val _animateBottomAreaDozingTransitions = MutableStateFlow(false) override val animateBottomAreaDozingTransitions = Loading @@ -102,6 +113,29 @@ constructor( private val _clockPosition = MutableStateFlow(Position(0, 0)) override val clockPosition = _clockPosition.asStateFlow() override val isKeyguardShowing: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { trySendWithFailureLogging( keyguardStateController.isShowing, TAG, "updated isKeyguardShowing" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isShowing, TAG, "initial isKeyguardShowing" ) awaitClose { keyguardStateController.removeCallback(callback) } } override val isDozing: Flow<Boolean> = conflatedCallbackFlow { val callback = object : StatusBarStateController.StateListener { Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepositoryModule.kt +2 −1 Original line number Diff line number Diff line Loading @@ -30,7 +30,8 @@ interface KeyguardRepositoryModule { impl: KeyguardQuickAffordanceRepositoryImpl ): KeyguardQuickAffordanceRepository @Binds fun keyguardQuickAffordanceConfigs( @Binds fun keyguardQuickAffordanceConfigs( impl: KeyguardQuickAffordanceConfigsImpl ): KeyguardQuickAffordanceConfigs }
packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardStateControllerExt.kt→packages/SystemUI/src/com/android/systemui/keyguard/domain/usecase/ObserveIsKeyguardShowingUseCase.kt +39 −0 Original line number Diff line number Diff line Loading @@ -15,32 +15,25 @@ * */ package com.android.systemui.statusbar.policy package com.android.systemui.keyguard.domain.usecase import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging import com.android.systemui.common.coroutine.ConflatedCallbackFlow import kotlinx.coroutines.channels.awaitClose import com.android.systemui.keyguard.data.repository.KeyguardRepository import javax.inject.Inject import kotlinx.coroutines.flow.Flow object KeyguardStateControllerExt { /** * Returns an observable for whether the keyguard is currently shown or not. * Use-case for observing whether the keyguard is currently being shown. * * Note: this is also `true` when the lock-screen is occluded with an `Activity` "above" it in the * z-order (which is not really above the system UI window, but rather - the lock-screen becomes * invisible to reveal the "occluding activity"). */ fun KeyguardStateController.isKeyguardShowing(loggingTag: String): Flow<Boolean> { return ConflatedCallbackFlow.conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { trySendWithFailureLogging( isShowing, loggingTag, "updated isKeyguardShowing") } } addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging(isShowing, loggingTag, "initial isKeyguardShowing") awaitClose { removeCallback(callback) } } class ObserveIsKeyguardShowingUseCase @Inject constructor( private val repository: KeyguardRepository, ) { operator fun invoke(): Flow<Boolean> { return repository.isKeyguardShowing } }