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

Commit dbbbedb3 authored by Chris Göllner's avatar Chris Göllner
Browse files

Fix bouncer always being on the left side

The keyguard position value was being set to 0 as the initial/default
value, which would be passed on to the view/ui layer on start, which
would then move the bouncer to the left.

At the moment there is code in the view layer that stores the last used
position (left vs right), and by having the 0 value always coming from
the data layer, it would override this setting.
A better refactor in the future, would probably be to have this logic
of storing/retrieving the setting, in the data layer itself, but would
like to leave that fix/improvement for a later stage.
This stage is just to fix the bug.

Test: Unit tests in this CL
Test: Manually - By moving the bouncer and then restarting the device
Fixes: 296845861
Change-Id: Ib5c508ef0c589c173b3e10280b0fe5156274e7e0
parent 2d505f32
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -58,7 +58,7 @@ interface KeyguardBouncerRepository {
     * ```
     * ```
     */
     */
    val panelExpansionAmount: StateFlow<Float>
    val panelExpansionAmount: StateFlow<Float>
    val keyguardPosition: StateFlow<Float>
    val keyguardPosition: StateFlow<Float?>
    val isBackButtonEnabled: StateFlow<Boolean?>
    val isBackButtonEnabled: StateFlow<Boolean?>
    /** Determines if user is already unlocked */
    /** Determines if user is already unlocked */
    val keyguardAuthenticated: StateFlow<Boolean?>
    val keyguardAuthenticated: StateFlow<Boolean?>
@@ -130,7 +130,7 @@ constructor(
     */
     */
    private val _panelExpansionAmount = MutableStateFlow(EXPANSION_HIDDEN)
    private val _panelExpansionAmount = MutableStateFlow(EXPANSION_HIDDEN)
    override val panelExpansionAmount = _panelExpansionAmount.asStateFlow()
    override val panelExpansionAmount = _panelExpansionAmount.asStateFlow()
    private val _keyguardPosition = MutableStateFlow(0f)
    private val _keyguardPosition = MutableStateFlow<Float?>(null)
    override val keyguardPosition = _keyguardPosition.asStateFlow()
    override val keyguardPosition = _keyguardPosition.asStateFlow()
    private val _isBackButtonEnabled = MutableStateFlow<Boolean?>(null)
    private val _isBackButtonEnabled = MutableStateFlow<Boolean?>(null)
    override val isBackButtonEnabled = _isBackButtonEnabled.asStateFlow()
    override val isBackButtonEnabled = _isBackButtonEnabled.asStateFlow()
@@ -244,6 +244,7 @@ constructor(
            .logDiffsForTable(buffer, "", "PanelExpansionAmountMillis", -1)
            .logDiffsForTable(buffer, "", "PanelExpansionAmountMillis", -1)
            .launchIn(applicationScope)
            .launchIn(applicationScope)
        keyguardPosition
        keyguardPosition
            .filterNotNull()
            .map { it.toInt() }
            .map { it.toInt() }
            .logDiffsForTable(buffer, "", "KeyguardPosition", -1)
            .logDiffsForTable(buffer, "", "KeyguardPosition", -1)
            .launchIn(applicationScope)
            .launchIn(applicationScope)
+1 −1
Original line number Original line Diff line number Diff line
@@ -94,7 +94,7 @@ constructor(
    val startingDisappearAnimation: Flow<Runnable> =
    val startingDisappearAnimation: Flow<Runnable> =
        repository.primaryBouncerStartingDisappearAnimation.filterNotNull()
        repository.primaryBouncerStartingDisappearAnimation.filterNotNull()
    val resourceUpdateRequests: Flow<Boolean> = repository.resourceUpdateRequests.filter { it }
    val resourceUpdateRequests: Flow<Boolean> = repository.resourceUpdateRequests.filter { it }
    val keyguardPosition: Flow<Float> = repository.keyguardPosition
    val keyguardPosition: Flow<Float> = repository.keyguardPosition.filterNotNull()
    val panelExpansionAmount: Flow<Float> = repository.panelExpansionAmount
    val panelExpansionAmount: Flow<Float> = repository.panelExpansionAmount
    /** 0f = bouncer fully hidden. 1f = bouncer fully visible. */
    /** 0f = bouncer fully hidden. 1f = bouncer fully visible. */
    val bouncerExpansion: Flow<Float> =
    val bouncerExpansion: Flow<Float> =
+22 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,8 @@ import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.bouncer.shared.model.BouncerShowMessageModel
import com.android.systemui.bouncer.shared.model.BouncerShowMessageModel
import com.android.systemui.bouncer.ui.BouncerView
import com.android.systemui.bouncer.ui.BouncerView
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.classifier.FalsingCollector
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.flags.FakeFeatureFlags
import com.android.systemui.flags.FakeFeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.DismissCallbackRegistry
import com.android.systemui.keyguard.DismissCallbackRegistry
@@ -156,4 +158,24 @@ class KeyguardBouncerViewModelTest : SysuiTestCase() {
        assertThat(isShowing).isEqualTo(false)
        assertThat(isShowing).isEqualTo(false)
        job.cancel()
        job.cancel()
    }
    }

    @Test
    fun keyguardPosition_noValueSet_emptyByDefault() = runTest {
        val positionValues by collectValues(underTest.keyguardPosition)

        runCurrent()

        assertThat(positionValues).isEmpty()
    }

    @Test
    fun keyguardPosition_valueSet_returnsValue() = runTest {
        val position by collectLastValue(underTest.keyguardPosition)
        runCurrent()

        repository.setKeyguardPosition(123f)
        runCurrent()

        assertThat(position).isEqualTo(123f)
    }
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ class FakeKeyguardBouncerRepository : KeyguardBouncerRepository {
    override val primaryBouncerScrimmed = _primaryBouncerScrimmed.asStateFlow()
    override val primaryBouncerScrimmed = _primaryBouncerScrimmed.asStateFlow()
    private val _panelExpansionAmount = MutableStateFlow(KeyguardBouncerConstants.EXPANSION_HIDDEN)
    private val _panelExpansionAmount = MutableStateFlow(KeyguardBouncerConstants.EXPANSION_HIDDEN)
    override val panelExpansionAmount = _panelExpansionAmount.asStateFlow()
    override val panelExpansionAmount = _panelExpansionAmount.asStateFlow()
    private val _keyguardPosition = MutableStateFlow(0f)
    private val _keyguardPosition = MutableStateFlow<Float?>(null)
    override val keyguardPosition = _keyguardPosition.asStateFlow()
    override val keyguardPosition = _keyguardPosition.asStateFlow()
    private val _isBackButtonEnabled = MutableStateFlow<Boolean?>(null)
    private val _isBackButtonEnabled = MutableStateFlow<Boolean?>(null)
    override val isBackButtonEnabled = _isBackButtonEnabled.asStateFlow()
    override val isBackButtonEnabled = _isBackButtonEnabled.asStateFlow()