Skip to content
Snippets Groups Projects
Commit bcb70d42 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Revert "Reduce continuations for bottom area"

This reverts commit 17d40048.

Reason for revert: b/343692887

Change-Id: Ie79fc9c9f0fa17ab1188dd19a9ae9b64f5bdade2
parent 17d40048
No related branches found
No related tags found
No related merge requests found
...@@ -350,7 +350,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { ...@@ -350,7 +350,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
} }
@Test @Test
fun quickAffordance_doNotSendUpdatesWhileShadeExpandingAndStillHidden() = fun quickAffordance_updateOncePerShadeExpansion() =
testScope.runTest { testScope.runTest {
val shadeExpansion = MutableStateFlow(0f) val shadeExpansion = MutableStateFlow(0f)
whenever(shadeInteractor.anyExpansion).thenReturn(shadeExpansion) whenever(shadeInteractor.anyExpansion).thenReturn(shadeExpansion)
...@@ -365,9 +365,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { ...@@ -365,9 +365,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
shadeExpansion.value = i / 10f shadeExpansion.value = i / 10f
} }
assertThat(collectedValue[0]) assertThat(collectedValue.size).isEqualTo(initialSize + 1)
.isInstanceOf(KeyguardQuickAffordanceModel.Hidden::class.java)
assertThat(collectedValue.size).isEqualTo(initialSize)
} }
@Test @Test
......
...@@ -19,18 +19,16 @@ package com.android.systemui.dock ...@@ -19,18 +19,16 @@ package com.android.systemui.dock
import com.android.systemui.common.coroutine.ConflatedCallbackFlow import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
/** /**
* Retrieves whether or not the device is docked according to DockManager. Emits a starting value of * Retrieves whether or not the device is docked according to DockManager. Emits a starting value
* isDocked. * of isDocked.
*/ */
fun DockManager.retrieveIsDocked(): Flow<Boolean> = fun DockManager.retrieveIsDocked(): Flow<Boolean> =
ConflatedCallbackFlow.conflatedCallbackFlow { ConflatedCallbackFlow.conflatedCallbackFlow {
val callback = DockManager.DockEventListener { trySend(isDocked) } val callback = DockManager.DockEventListener { trySend(isDocked) }
addListener(callback) addListener(callback)
trySend(isDocked) trySend(isDocked)
awaitClose { removeListener(callback) } awaitClose { removeListener(callback) }
} }
.distinctUntilChanged() \ No newline at end of file
...@@ -105,35 +105,33 @@ constructor( ...@@ -105,35 +105,33 @@ constructor(
} }
return combine( return combine(
quickAffordanceAlwaysVisible(position), quickAffordanceAlwaysVisible(position),
keyguardInteractor.isDozing, keyguardInteractor.isDozing,
if (SceneContainerFlag.isEnabled) { if (SceneContainerFlag.isEnabled) {
sceneInteractor sceneInteractor
.get() .get()
.transitionState .transitionState
.map { .map {
when (it) { when (it) {
is ObservableTransitionState.Idle -> is ObservableTransitionState.Idle ->
it.currentScene == Scenes.Lockscreen it.currentScene == Scenes.Lockscreen
is ObservableTransitionState.Transition -> is ObservableTransitionState.Transition ->
it.fromScene == Scenes.Lockscreen || it.fromScene == Scenes.Lockscreen || it.toScene == Scenes.Lockscreen
it.toScene == Scenes.Lockscreen
}
} }
.distinctUntilChanged() }
} else { .distinctUntilChanged()
keyguardInteractor.isKeyguardShowing } else {
}, keyguardInteractor.isKeyguardShowing
shadeInteractor.anyExpansion.map { it < 1.0f }.distinctUntilChanged(), },
biometricSettingsRepository.isCurrentUserInLockdown, shadeInteractor.anyExpansion.map { it < 1.0f }.distinctUntilChanged(),
) { affordance, isDozing, isKeyguardShowing, isQuickSettingsVisible, isUserInLockdown -> biometricSettingsRepository.isCurrentUserInLockdown,
if (!isDozing && isKeyguardShowing && isQuickSettingsVisible && !isUserInLockdown) { ) { affordance, isDozing, isKeyguardShowing, isQuickSettingsVisible, isUserInLockdown ->
affordance if (!isDozing && isKeyguardShowing && isQuickSettingsVisible && !isUserInLockdown) {
} else { affordance
KeyguardQuickAffordanceModel.Hidden } else {
} KeyguardQuickAffordanceModel.Hidden
} }
.distinctUntilChanged() }
} }
/** /**
......
...@@ -65,7 +65,7 @@ object KeyguardIndicationAreaBinder { ...@@ -65,7 +65,7 @@ object KeyguardIndicationAreaBinder {
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view)) val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
val disposableHandle = val disposableHandle =
view.repeatWhenAttached { view.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) { repeatOnLifecycle(Lifecycle.State.STARTED) {
launch("$TAG#viewModel.alpha") { launch("$TAG#viewModel.alpha") {
// Do not independently apply alpha, as [KeyguardRootViewModel] should work // Do not independently apply alpha, as [KeyguardRootViewModel] should work
// for this and all its children // for this and all its children
......
...@@ -30,7 +30,6 @@ import androidx.core.view.isVisible ...@@ -30,7 +30,6 @@ import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launch
import com.android.settingslib.Utils import com.android.settingslib.Utils
import com.android.systemui.animation.Expandable import com.android.systemui.animation.Expandable
import com.android.systemui.animation.view.LaunchableImageView import com.android.systemui.animation.view.LaunchableImageView
...@@ -81,8 +80,8 @@ object KeyguardQuickAffordanceViewBinder { ...@@ -81,8 +80,8 @@ object KeyguardQuickAffordanceViewBinder {
val configurationBasedDimensions = MutableStateFlow(loadFromResources(view)) val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
val disposableHandle = val disposableHandle =
view.repeatWhenAttached { view.repeatWhenAttached {
repeatOnLifecycle(Lifecycle.State.CREATED) { repeatOnLifecycle(Lifecycle.State.STARTED) {
launch("$TAG#viewModel.collect") { launch {
viewModel.collect { buttonModel -> viewModel.collect { buttonModel ->
updateButton( updateButton(
view = button, view = button,
...@@ -94,7 +93,7 @@ object KeyguardQuickAffordanceViewBinder { ...@@ -94,7 +93,7 @@ object KeyguardQuickAffordanceViewBinder {
} }
} }
launch("$TAG#updateButtonAlpha") { launch {
updateButtonAlpha( updateButtonAlpha(
view = button, view = button,
viewModel = viewModel, viewModel = viewModel,
...@@ -102,7 +101,7 @@ object KeyguardQuickAffordanceViewBinder { ...@@ -102,7 +101,7 @@ object KeyguardQuickAffordanceViewBinder {
) )
} }
launch("$TAG#configurationBasedDimensions") { launch {
configurationBasedDimensions.collect { dimensions -> configurationBasedDimensions.collect { dimensions ->
button.updateLayoutParams<ViewGroup.LayoutParams> { button.updateLayoutParams<ViewGroup.LayoutParams> {
width = dimensions.buttonSizePx.width width = dimensions.buttonSizePx.width
...@@ -324,6 +323,4 @@ object KeyguardQuickAffordanceViewBinder { ...@@ -324,6 +323,4 @@ object KeyguardQuickAffordanceViewBinder {
private data class ConfigurationBasedDimensions( private data class ConfigurationBasedDimensions(
val buttonSizePx: Size, val buttonSizePx: Size,
) )
private const val TAG = "KeyguardQuickAffordanceViewBinder"
} }
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
package com.android.systemui.keyguard.ui.viewmodel package com.android.systemui.keyguard.ui.viewmodel
import androidx.annotation.VisibleForTesting import androidx.annotation.VisibleForTesting
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardQuickAffordanceInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
...@@ -29,23 +28,19 @@ import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAfforda ...@@ -29,23 +28,19 @@ import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAfforda
import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots import com.android.systemui.shared.keyguard.shared.model.KeyguardQuickAffordanceSlots
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.stateIn
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
class KeyguardQuickAffordancesCombinedViewModel class KeyguardQuickAffordancesCombinedViewModel
@Inject @Inject
constructor( constructor(
@Application applicationScope: CoroutineScope,
private val quickAffordanceInteractor: KeyguardQuickAffordanceInteractor, private val quickAffordanceInteractor: KeyguardQuickAffordanceInteractor,
private val keyguardInteractor: KeyguardInteractor, private val keyguardInteractor: KeyguardInteractor,
shadeInteractor: ShadeInteractor, shadeInteractor: ShadeInteractor,
...@@ -89,20 +84,15 @@ constructor( ...@@ -89,20 +84,15 @@ constructor(
/** The only time the expansion is important is while lockscreen is actively displayed */ /** The only time the expansion is important is while lockscreen is actively displayed */
private val shadeExpansionAlpha = private val shadeExpansionAlpha =
combine( combine(
showingLockscreen, showingLockscreen,
shadeInteractor.anyExpansion, shadeInteractor.anyExpansion,
) { showingLockscreen, expansion -> ) { showingLockscreen, expansion ->
if (showingLockscreen) { if (showingLockscreen) {
1 - expansion 1 - expansion
} else { } else {
0f 0f
}
} }
.stateIn( }
scope = applicationScope,
started = SharingStarted.Lazily,
initialValue = 0f,
)
/** /**
* ID of the slot that's currently selected in the preview that renders exclusively in the * ID of the slot that's currently selected in the preview that renders exclusively in the
......
...@@ -49,7 +49,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardState ...@@ -49,7 +49,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.quickaffordance.ActivationState import com.android.systemui.keyguard.shared.quickaffordance.ActivationState
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancePosition
import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancesMetricsLogger import com.android.systemui.keyguard.shared.quickaffordance.KeyguardQuickAffordancesMetricsLogger
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.testDispatcher import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope
import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.ActivityStarter
...@@ -290,7 +289,6 @@ class KeyguardQuickAffordancesCombinedViewModelTest : SysuiTestCase() { ...@@ -290,7 +289,6 @@ class KeyguardQuickAffordancesCombinedViewModelTest : SysuiTestCase() {
underTest = underTest =
KeyguardQuickAffordancesCombinedViewModel( KeyguardQuickAffordancesCombinedViewModel(
applicationScope = kosmos.applicationCoroutineScope,
quickAffordanceInteractor = quickAffordanceInteractor =
KeyguardQuickAffordanceInteractor( KeyguardQuickAffordanceInteractor(
keyguardInteractor = keyguardInteractor, keyguardInteractor = keyguardInteractor,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment