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

Commit 093f2cb9 authored by Justin Weir's avatar Justin Weir
Browse files

Switch AuthDialogPanelInteractionDetector to isUserInteracting

Also deletes ShadeInteractor.isAnyExpanding, which was only used by
AuthDialogPanelInteractionDetector.

Fixes: 285111529
Test: Updated and ran existing tests
Test: Manual
Change-Id: Id3fc0bee4f08bf26545c3766743de0344ae98d69
parent 58e72130
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.biometrics

import android.annotation.MainThread
@@ -25,7 +41,7 @@ constructor(
            shadeExpansionCollectorJob =
                scope.launch {
                    // wait for it to emit true once
                    shadeInteractorLazy.get().isAnyExpanding.first { it }
                    shadeInteractorLazy.get().isUserInteracting.first { it }
                    onShadeInteraction.run()
                }
            shadeExpansionCollectorJob?.invokeOnCompletion { shadeExpansionCollectorJob = null }
+0 −8
Original line number Diff line number Diff line
@@ -35,7 +35,6 @@ import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.pipeline.mobile.data.repository.UserSetupRepository
import com.android.systemui.statusbar.policy.data.repository.DeviceProvisioningRepository
import com.android.systemui.user.domain.interactor.UserSwitcherInteractor
import com.android.systemui.util.kotlin.pairwise
import javax.inject.Inject
import javax.inject.Provider
import kotlinx.coroutines.CoroutineScope
@@ -140,13 +139,6 @@ constructor(
    /** Whether either the shade or QS is fully expanded. */
    val isAnyFullyExpanded: Flow<Boolean> = anyExpansion.map { it >= 1f }.distinctUntilChanged()

    /** Whether either the shade or QS is expanding from a fully collapsed state. */
    val isAnyExpanding: Flow<Boolean> =
        anyExpansion
            .pairwise(1f)
            .map { (prev, curr) -> curr > 0f && curr < 1f && prev < 1f }
            .distinctUntilChanged()

    /**
     * Whether either the shade or QS is partially or fully expanded, i.e. not fully collapsed. At
     * this time, this is not simply a matter of checking if either value in shadeExpansion and
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ class AuthDialogPanelInteractionDetectorTest : SysuiTestCase() {
            runCurrent()

            // WHEN shade expands
            shadeRepository.setLegacyShadeTracking(true)
            shadeRepository.setLegacyShadeExpansion(.5f)
            runCurrent()

@@ -108,6 +109,7 @@ class AuthDialogPanelInteractionDetectorTest : SysuiTestCase() {

            // WHEN detector is disabled and shade opens
            detector.disable()
            shadeRepository.setLegacyShadeTracking(true)
            shadeRepository.setLegacyShadeExpansion(.5f)
            runCurrent()

+0 −99
Original line number Diff line number Diff line
@@ -444,105 +444,6 @@ class ShadeInteractorTest : SysuiTestCase() {
            assertThat(underTest.anyExpansion.value).isEqualTo(.5f)
        }

    @Test
    fun expanding_shadeDraggedDown_expandingTrue() =
        testScope.runTest() {
            val actual by collectLastValue(underTest.isAnyExpanding)

            // GIVEN shade and QS collapsed
            shadeRepository.setLegacyShadeExpansion(0f)
            shadeRepository.setQsExpansion(0f)
            runCurrent()

            // WHEN shade partially expanded
            shadeRepository.setLegacyShadeExpansion(.5f)
            runCurrent()

            // THEN anyExpanding is true
            assertThat(actual).isTrue()
        }

    @Test
    fun expanding_qsDraggedDown_expandingTrue() =
        testScope.runTest() {
            val actual by collectLastValue(underTest.isAnyExpanding)

            // GIVEN shade and QS collapsed
            shadeRepository.setLegacyShadeExpansion(0f)
            shadeRepository.setQsExpansion(0f)
            runCurrent()

            // WHEN shade partially expanded
            shadeRepository.setQsExpansion(.5f)
            runCurrent()

            // THEN anyExpanding is true
            assertThat(actual).isTrue()
        }

    @Test
    fun expanding_shadeDraggedUpAndDown() =
        testScope.runTest() {
            val actual by collectLastValue(underTest.isAnyExpanding)

            // WHEN shade starts collapsed then partially expanded
            shadeRepository.setLegacyShadeExpansion(0f)
            shadeRepository.setLegacyShadeExpansion(.5f)
            shadeRepository.setQsExpansion(0f)
            runCurrent()

            // THEN anyExpanding is true
            assertThat(actual).isTrue()

            // WHEN shade dragged up a bit
            shadeRepository.setLegacyShadeExpansion(.2f)
            runCurrent()

            // THEN anyExpanding is still true
            assertThat(actual).isTrue()

            // WHEN shade dragged down a bit
            shadeRepository.setLegacyShadeExpansion(.7f)
            runCurrent()

            // THEN anyExpanding is still true
            assertThat(actual).isTrue()

            // WHEN shade fully expanded
            shadeRepository.setLegacyShadeExpansion(1f)
            runCurrent()

            // THEN anyExpanding is now false
            assertThat(actual).isFalse()

            // WHEN shade dragged up a bit
            shadeRepository.setLegacyShadeExpansion(.7f)
            runCurrent()

            // THEN anyExpanding is still false
            assertThat(actual).isFalse()
        }

    @Test
    fun expanding_shadeDraggedDownThenUp_expandingFalse() =
        testScope.runTest() {
            val actual by collectLastValue(underTest.isAnyExpanding)

            // GIVEN shade starts collapsed
            shadeRepository.setLegacyShadeExpansion(0f)
            shadeRepository.setQsExpansion(0f)
            runCurrent()

            // WHEN shade expands but doesn't complete
            shadeRepository.setLegacyShadeExpansion(.5f)
            runCurrent()
            shadeRepository.setLegacyShadeExpansion(0f)
            runCurrent()

            // THEN anyExpanding is false
            assertThat(actual).isFalse()
        }

    @Test
    fun lockscreenShadeExpansion_idle_onScene() =
        testScope.runTest() {