Loading packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +38 −107 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch /** Defines interface for classes that encapsulate application state for the keyguard. */ interface KeyguardRepository { Loading Loading @@ -362,30 +363,8 @@ constructor( override val topClippingBounds = MutableStateFlow<Int?>(null) 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) } } .distinctUntilChanged() override val isKeyguardShowing: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isShowing) private val _isAodAvailable = MutableStateFlow(false) override val isAodAvailable: StateFlow<Boolean> = _isAodAvailable.asStateFlow() Loading @@ -394,91 +373,14 @@ constructor( _isAodAvailable.value = value } override val isKeyguardOccluded: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { trySendWithFailureLogging( keyguardStateController.isOccluded, TAG, "updated isKeyguardOccluded" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isOccluded, TAG, "initial isKeyguardOccluded" ) awaitClose { keyguardStateController.removeCallback(callback) } } .distinctUntilChanged() override val isKeyguardDismissible: StateFlow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onUnlockedChanged() { trySendWithFailureLogging( keyguardStateController.isUnlocked, TAG, "updated isKeyguardDismissible due to onUnlockedChanged" ) } override fun onKeyguardShowingChanged() { trySendWithFailureLogging( keyguardStateController.isUnlocked, TAG, "updated isKeyguardDismissible due to onKeyguardShowingChanged" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isUnlocked, TAG, "initial isKeyguardUnlocked" ) override val isKeyguardOccluded: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isOccluded) awaitClose { keyguardStateController.removeCallback(callback) } } .distinctUntilChanged() .stateIn( scope, SharingStarted.Eagerly, initialValue = false, ) override val isKeyguardDismissible: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isUnlocked) override val isKeyguardGoingAway: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardGoingAwayChanged() { trySendWithFailureLogging( keyguardStateController.isKeyguardGoingAway, TAG, "updated isKeyguardGoingAway" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isKeyguardGoingAway, TAG, "initial isKeyguardGoingAway" ) awaitClose { keyguardStateController.removeCallback(callback) } } override val isKeyguardGoingAway: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isKeyguardGoingAway) private val _isKeyguardEnabled = MutableStateFlow(!lockPatternUtils.isLockScreenDisabled(userTracker.userId)) Loading Loading @@ -669,6 +571,35 @@ constructor( private val _isActiveDreamLockscreenHosted = MutableStateFlow(false) override val isActiveDreamLockscreenHosted = _isActiveDreamLockscreenHosted.asStateFlow() init { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { isKeyguardShowing.value = keyguardStateController.isShowing isKeyguardOccluded.value = keyguardStateController.isOccluded isKeyguardDismissible.value = keyguardStateController.isUnlocked } override fun onUnlockedChanged() { isKeyguardDismissible.value = keyguardStateController.isUnlocked } override fun onKeyguardGoingAwayChanged() { isKeyguardGoingAway.value = keyguardStateController.isKeyguardGoingAway } } keyguardStateController.addCallback(callback) scope .launch { isKeyguardShowing.collect { // no-op to allow for callback removal } } .invokeOnCompletion { keyguardStateController.removeCallback(callback) } } override fun setAnimateDozingTransitions(animate: Boolean) { _animateBottomAreaDozingTransitions.value = animate } Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt +101 −91 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.FalsingManager import com.android.systemui.res.R import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.util.kotlin.DisposableHandles import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch Loading @@ -64,8 +66,9 @@ object DeviceEntryIconViewBinder { falsingManager: FalsingManager, vibratorHelper: VibratorHelper, overrideColor: Color? = null, ) { ): DisposableHandle { DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode() val disposables = DisposableHandles() val longPressHandlingView = view.longPressHandlingView val fgIconView = view.iconView val bgView = view.bgView Loading @@ -83,6 +86,7 @@ object DeviceEntryIconViewBinder { } } disposables += view.repeatWhenAttached { // Repeat on CREATED so that the view will always observe the entire // GONE => AOD transition (even though the view may not be visible until the middle Loading @@ -104,7 +108,9 @@ object DeviceEntryIconViewBinder { if (udfpsSupported) { { view.resources .getInteger(R.integer.config_udfpsDeviceEntryIconLongPress) .getInteger( R.integer.config_udfpsDeviceEntryIconLongPress ) .toLong() } } else { Loading Loading @@ -155,6 +161,7 @@ object DeviceEntryIconViewBinder { } } disposables += fgIconView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { // Start with an empty state Loading Loading @@ -184,6 +191,7 @@ object DeviceEntryIconViewBinder { } } disposables += bgView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { launch("$TAG#bgViewModel.alpha") { Loading @@ -196,5 +204,7 @@ object DeviceEntryIconViewBinder { } } } return disposables } } packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +72 −61 Original line number Diff line number Diff line Loading @@ -37,7 +37,9 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.clocks.AodClockBurnInModel import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.util.kotlin.DisposableHandles import com.android.systemui.util.ui.value import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map Loading @@ -56,13 +58,16 @@ object KeyguardClockViewBinder { keyguardClockInteractor: KeyguardClockInteractor, blueprintInteractor: KeyguardBlueprintInteractor, rootViewModel: KeyguardRootViewModel, ) { ): DisposableHandle { val disposables = DisposableHandles() disposables += keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { keyguardClockInteractor.clockEventController.registerListeners(keyguardRootView) } } disposables += keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { launch { Loading @@ -70,7 +75,11 @@ object KeyguardClockViewBinder { viewModel.currentClock.collect { currentClock -> cleanupClockViews(currentClock, keyguardRootView, viewModel.burnInLayer) addClockViews(currentClock, keyguardRootView) updateBurnInLayer(keyguardRootView, viewModel, viewModel.clockSize.value) updateBurnInLayer( keyguardRootView, viewModel, viewModel.clockSize.value ) applyConstraints(clockSection, keyguardRootView, true) } } Loading Loading @@ -135,6 +144,8 @@ object KeyguardClockViewBinder { } } } return disposables } @VisibleForTesting Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import kotlinx.coroutines.DisposableHandle object KeyguardSmartspaceViewBinder { @JvmStatic Loading @@ -39,8 +40,8 @@ object KeyguardSmartspaceViewBinder { clockViewModel: KeyguardClockViewModel, smartspaceViewModel: KeyguardSmartspaceViewModel, blueprintInteractor: KeyguardBlueprintInteractor, ) { keyguardRootView.repeatWhenAttached { ): DisposableHandle { return keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { launch("$TAG#clockViewModel.hasCustomWeatherDataDisplay") { if (!MigrateClocksToBlueprint.isEnabled) return@launch Loading packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt +20 −10 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import com.android.systemui.shared.R as sharedR import com.android.systemui.util.ui.value import dagger.Lazy import javax.inject.Inject import kotlinx.coroutines.DisposableHandle internal fun ConstraintSet.setVisibility( views: Iterable<View>, Loading @@ -70,13 +71,16 @@ constructor( val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, private val rootViewModel: KeyguardRootViewModel, ) : KeyguardSection() { private var disposableHandle: DisposableHandle? = null override fun addViews(constraintLayout: ConstraintLayout) {} override fun bindData(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) { return } disposableHandle?.dispose() disposableHandle = KeyguardClockViewBinder.bind( this, constraintLayout, Loading @@ -97,7 +101,13 @@ constructor( } } override fun removeViews(constraintLayout: ConstraintLayout) {} override fun removeViews(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) { return } disposableHandle?.dispose() } private fun buildConstraints( clock: ClockController, Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/repository/KeyguardRepository.kt +38 −107 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.mapLatest import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch /** Defines interface for classes that encapsulate application state for the keyguard. */ interface KeyguardRepository { Loading Loading @@ -362,30 +363,8 @@ constructor( override val topClippingBounds = MutableStateFlow<Int?>(null) 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) } } .distinctUntilChanged() override val isKeyguardShowing: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isShowing) private val _isAodAvailable = MutableStateFlow(false) override val isAodAvailable: StateFlow<Boolean> = _isAodAvailable.asStateFlow() Loading @@ -394,91 +373,14 @@ constructor( _isAodAvailable.value = value } override val isKeyguardOccluded: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { trySendWithFailureLogging( keyguardStateController.isOccluded, TAG, "updated isKeyguardOccluded" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isOccluded, TAG, "initial isKeyguardOccluded" ) awaitClose { keyguardStateController.removeCallback(callback) } } .distinctUntilChanged() override val isKeyguardDismissible: StateFlow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onUnlockedChanged() { trySendWithFailureLogging( keyguardStateController.isUnlocked, TAG, "updated isKeyguardDismissible due to onUnlockedChanged" ) } override fun onKeyguardShowingChanged() { trySendWithFailureLogging( keyguardStateController.isUnlocked, TAG, "updated isKeyguardDismissible due to onKeyguardShowingChanged" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isUnlocked, TAG, "initial isKeyguardUnlocked" ) override val isKeyguardOccluded: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isOccluded) awaitClose { keyguardStateController.removeCallback(callback) } } .distinctUntilChanged() .stateIn( scope, SharingStarted.Eagerly, initialValue = false, ) override val isKeyguardDismissible: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isUnlocked) override val isKeyguardGoingAway: Flow<Boolean> = conflatedCallbackFlow { val callback = object : KeyguardStateController.Callback { override fun onKeyguardGoingAwayChanged() { trySendWithFailureLogging( keyguardStateController.isKeyguardGoingAway, TAG, "updated isKeyguardGoingAway" ) } } keyguardStateController.addCallback(callback) // Adding the callback does not send an initial update. trySendWithFailureLogging( keyguardStateController.isKeyguardGoingAway, TAG, "initial isKeyguardGoingAway" ) awaitClose { keyguardStateController.removeCallback(callback) } } override val isKeyguardGoingAway: MutableStateFlow<Boolean> = MutableStateFlow(keyguardStateController.isKeyguardGoingAway) private val _isKeyguardEnabled = MutableStateFlow(!lockPatternUtils.isLockScreenDisabled(userTracker.userId)) Loading Loading @@ -669,6 +571,35 @@ constructor( private val _isActiveDreamLockscreenHosted = MutableStateFlow(false) override val isActiveDreamLockscreenHosted = _isActiveDreamLockscreenHosted.asStateFlow() init { val callback = object : KeyguardStateController.Callback { override fun onKeyguardShowingChanged() { isKeyguardShowing.value = keyguardStateController.isShowing isKeyguardOccluded.value = keyguardStateController.isOccluded isKeyguardDismissible.value = keyguardStateController.isUnlocked } override fun onUnlockedChanged() { isKeyguardDismissible.value = keyguardStateController.isUnlocked } override fun onKeyguardGoingAwayChanged() { isKeyguardGoingAway.value = keyguardStateController.isKeyguardGoingAway } } keyguardStateController.addCallback(callback) scope .launch { isKeyguardShowing.collect { // no-op to allow for callback removal } } .invokeOnCompletion { keyguardStateController.removeCallback(callback) } } override fun setAnimateDozingTransitions(animate: Boolean) { _animateBottomAreaDozingTransitions.value = animate } Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/DeviceEntryIconViewBinder.kt +101 −91 Original line number Diff line number Diff line Loading @@ -38,7 +38,9 @@ import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.FalsingManager import com.android.systemui.res.R import com.android.systemui.statusbar.VibratorHelper import com.android.systemui.util.kotlin.DisposableHandles import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.launch Loading @@ -64,8 +66,9 @@ object DeviceEntryIconViewBinder { falsingManager: FalsingManager, vibratorHelper: VibratorHelper, overrideColor: Color? = null, ) { ): DisposableHandle { DeviceEntryUdfpsRefactor.isUnexpectedlyInLegacyMode() val disposables = DisposableHandles() val longPressHandlingView = view.longPressHandlingView val fgIconView = view.iconView val bgView = view.bgView Loading @@ -83,6 +86,7 @@ object DeviceEntryIconViewBinder { } } disposables += view.repeatWhenAttached { // Repeat on CREATED so that the view will always observe the entire // GONE => AOD transition (even though the view may not be visible until the middle Loading @@ -104,7 +108,9 @@ object DeviceEntryIconViewBinder { if (udfpsSupported) { { view.resources .getInteger(R.integer.config_udfpsDeviceEntryIconLongPress) .getInteger( R.integer.config_udfpsDeviceEntryIconLongPress ) .toLong() } } else { Loading Loading @@ -155,6 +161,7 @@ object DeviceEntryIconViewBinder { } } disposables += fgIconView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.STARTED) { // Start with an empty state Loading Loading @@ -184,6 +191,7 @@ object DeviceEntryIconViewBinder { } } disposables += bgView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { launch("$TAG#bgViewModel.alpha") { Loading @@ -196,5 +204,7 @@ object DeviceEntryIconViewBinder { } } } return disposables } }
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardClockViewBinder.kt +72 −61 Original line number Diff line number Diff line Loading @@ -37,7 +37,9 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.plugins.clocks.AodClockBurnInModel import com.android.systemui.plugins.clocks.ClockController import com.android.systemui.util.kotlin.DisposableHandles import com.android.systemui.util.ui.value import kotlinx.coroutines.DisposableHandle import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map Loading @@ -56,13 +58,16 @@ object KeyguardClockViewBinder { keyguardClockInteractor: KeyguardClockInteractor, blueprintInteractor: KeyguardBlueprintInteractor, rootViewModel: KeyguardRootViewModel, ) { ): DisposableHandle { val disposables = DisposableHandles() disposables += keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { keyguardClockInteractor.clockEventController.registerListeners(keyguardRootView) } } disposables += keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { launch { Loading @@ -70,7 +75,11 @@ object KeyguardClockViewBinder { viewModel.currentClock.collect { currentClock -> cleanupClockViews(currentClock, keyguardRootView, viewModel.burnInLayer) addClockViews(currentClock, keyguardRootView) updateBurnInLayer(keyguardRootView, viewModel, viewModel.clockSize.value) updateBurnInLayer( keyguardRootView, viewModel, viewModel.clockSize.value ) applyConstraints(clockSection, keyguardRootView, true) } } Loading Loading @@ -135,6 +144,8 @@ object KeyguardClockViewBinder { } } } return disposables } @VisibleForTesting Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardSmartspaceViewBinder.kt +3 −2 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.keyguard.ui.viewmodel.KeyguardSmartspaceViewModel import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.res.R import com.android.systemui.shared.R as sharedR import kotlinx.coroutines.DisposableHandle object KeyguardSmartspaceViewBinder { @JvmStatic Loading @@ -39,8 +40,8 @@ object KeyguardSmartspaceViewBinder { clockViewModel: KeyguardClockViewModel, smartspaceViewModel: KeyguardSmartspaceViewModel, blueprintInteractor: KeyguardBlueprintInteractor, ) { keyguardRootView.repeatWhenAttached { ): DisposableHandle { return keyguardRootView.repeatWhenAttached { repeatOnLifecycle(Lifecycle.State.CREATED) { launch("$TAG#clockViewModel.hasCustomWeatherDataDisplay") { if (!MigrateClocksToBlueprint.isEnabled) return@launch Loading
packages/SystemUI/src/com/android/systemui/keyguard/ui/view/layout/sections/ClockSection.kt +20 −10 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ import com.android.systemui.shared.R as sharedR import com.android.systemui.util.ui.value import dagger.Lazy import javax.inject.Inject import kotlinx.coroutines.DisposableHandle internal fun ConstraintSet.setVisibility( views: Iterable<View>, Loading @@ -70,13 +71,16 @@ constructor( val blueprintInteractor: Lazy<KeyguardBlueprintInteractor>, private val rootViewModel: KeyguardRootViewModel, ) : KeyguardSection() { private var disposableHandle: DisposableHandle? = null override fun addViews(constraintLayout: ConstraintLayout) {} override fun bindData(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) { return } disposableHandle?.dispose() disposableHandle = KeyguardClockViewBinder.bind( this, constraintLayout, Loading @@ -97,7 +101,13 @@ constructor( } } override fun removeViews(constraintLayout: ConstraintLayout) {} override fun removeViews(constraintLayout: ConstraintLayout) { if (!MigrateClocksToBlueprint.isEnabled) { return } disposableHandle?.dispose() } private fun buildConstraints( clock: ClockController, Loading