Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0007eb49 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Reduce continuations for bottom area" into main

parents a5e34152 17d40048
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
        }

    @Test
    fun quickAffordance_updateOncePerShadeExpansion() =
    fun quickAffordance_doNotSendUpdatesWhileShadeExpandingAndStillHidden() =
        testScope.runTest {
            val shadeExpansion = MutableStateFlow(0f)
            whenever(shadeInteractor.anyExpansion).thenReturn(shadeExpansion)
@@ -365,7 +365,9 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() {
                shadeExpansion.value = i / 10f
            }

            assertThat(collectedValue.size).isEqualTo(initialSize + 1)
            assertThat(collectedValue[0])
                .isInstanceOf(KeyguardQuickAffordanceModel.Hidden::class.java)
            assertThat(collectedValue.size).isEqualTo(initialSize)
        }

    @Test
+9 −7
Original line number Diff line number Diff line
@@ -19,10 +19,11 @@ package com.android.systemui.dock
import com.android.systemui.common.coroutine.ConflatedCallbackFlow
import kotlinx.coroutines.channels.awaitClose
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 isDocked.
 * Retrieves whether or not the device is docked according to DockManager. Emits a starting value of
 * isDocked.
 */
fun DockManager.retrieveIsDocked(): Flow<Boolean> =
    ConflatedCallbackFlow.conflatedCallbackFlow {
@@ -32,3 +33,4 @@ fun DockManager.retrieveIsDocked(): Flow<Boolean> =

            awaitClose { removeListener(callback) }
        }
        .distinctUntilChanged()
+27 −25
Original line number Diff line number Diff line
@@ -116,7 +116,8 @@ constructor(
                                is ObservableTransitionState.Idle ->
                                    it.currentScene == Scenes.Lockscreen
                                is ObservableTransitionState.Transition ->
                                it.fromScene == Scenes.Lockscreen || it.toScene == Scenes.Lockscreen
                                    it.fromScene == Scenes.Lockscreen ||
                                        it.toScene == Scenes.Lockscreen
                            }
                        }
                        .distinctUntilChanged()
@@ -132,6 +133,7 @@ constructor(
                    KeyguardQuickAffordanceModel.Hidden
                }
            }
            .distinctUntilChanged()
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ object KeyguardIndicationAreaBinder {
        val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
        val disposableHandle =
            view.repeatWhenAttached {
                repeatOnLifecycle(Lifecycle.State.STARTED) {
                repeatOnLifecycle(Lifecycle.State.CREATED) {
                    launch("$TAG#viewModel.alpha") {
                        // Do not independently apply alpha, as [KeyguardRootViewModel] should work
                        // for this and all its children
+7 −4
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.app.tracing.coroutines.launch
import com.android.settingslib.Utils
import com.android.systemui.animation.Expandable
import com.android.systemui.animation.view.LaunchableImageView
@@ -80,8 +81,8 @@ object KeyguardQuickAffordanceViewBinder {
        val configurationBasedDimensions = MutableStateFlow(loadFromResources(view))
        val disposableHandle =
            view.repeatWhenAttached {
                repeatOnLifecycle(Lifecycle.State.STARTED) {
                    launch {
                repeatOnLifecycle(Lifecycle.State.CREATED) {
                    launch("$TAG#viewModel.collect") {
                        viewModel.collect { buttonModel ->
                            updateButton(
                                view = button,
@@ -93,7 +94,7 @@ object KeyguardQuickAffordanceViewBinder {
                        }
                    }

                    launch {
                    launch("$TAG#updateButtonAlpha") {
                        updateButtonAlpha(
                            view = button,
                            viewModel = viewModel,
@@ -101,7 +102,7 @@ object KeyguardQuickAffordanceViewBinder {
                        )
                    }

                    launch {
                    launch("$TAG#configurationBasedDimensions") {
                        configurationBasedDimensions.collect { dimensions ->
                            button.updateLayoutParams<ViewGroup.LayoutParams> {
                                width = dimensions.buttonSizePx.width
@@ -323,4 +324,6 @@ object KeyguardQuickAffordanceViewBinder {
    private data class ConfigurationBasedDimensions(
        val buttonSizePx: Size,
    )

    private const val TAG = "KeyguardQuickAffordanceViewBinder"
}
Loading