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

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

Merge "Directly set isKeyguardGoingAway in repo" into main

parents 9d0b420b 2f97d532
Loading
Loading
Loading
Loading
+6 −18
Original line number Diff line number Diff line
@@ -326,26 +326,14 @@ class KeyguardRepositoryImplTest : SysuiTestCase() {
    @Test
    fun isKeyguardGoingAway() =
        testScope.runTest {
            whenever(keyguardStateController.isKeyguardGoingAway).thenReturn(false)
            var latest: Boolean? = null
            val job = underTest.isKeyguardGoingAway.onEach { latest = it }.launchIn(this)
            runCurrent()
            assertThat(latest).isFalse()

            val captor = argumentCaptor<KeyguardStateController.Callback>()
            verify(keyguardStateController, atLeastOnce()).addCallback(captor.capture())
            val isGoingAway by collectLastValue(underTest.isKeyguardGoingAway)
            assertThat(isGoingAway).isFalse()

            whenever(keyguardStateController.isKeyguardGoingAway).thenReturn(true)
            captor.value.onKeyguardGoingAwayChanged()
            runCurrent()
            assertThat(latest).isTrue()

            whenever(keyguardStateController.isKeyguardGoingAway).thenReturn(false)
            captor.value.onKeyguardGoingAwayChanged()
            runCurrent()
            assertThat(latest).isFalse()
            underTest.isKeyguardGoingAway.value = true
            assertThat(isGoingAway).isTrue()

            job.cancel()
            underTest.isKeyguardGoingAway.value = false
            assertThat(isGoingAway).isFalse()
        }

    @Test
+16 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT

    private lateinit var powerInteractor: PowerInteractor
    private lateinit var transitionRepository: FakeKeyguardTransitionRepository
    private lateinit var keyguardInteractor: KeyguardInteractor

    companion object {
        @JvmStatic
@@ -106,6 +107,7 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
    @Before
    fun setup() {
        powerInteractor = kosmos.powerInteractor
        keyguardInteractor = kosmos.keyguardInteractor
        transitionRepository = kosmos.fakeKeyguardTransitionRepositorySpy
        underTest = kosmos.fromDozingTransitionInteractor

@@ -136,6 +138,20 @@ class FromDozingTransitionInteractorTest(flags: FlagsParameterization?) : SysuiT
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.LOCKSCREEN)
        }

    @Test
    @DisableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR)
    fun testTransitionToGone_onWakeup_whenGoingAway() =
        testScope.runTest {
            keyguardInteractor.setIsKeyguardGoingAway(true)
            runCurrent()

            powerInteractor.setAwakeForTest()
            advanceTimeBy(60L)

            assertThat(transitionRepository)
                .startedTransition(from = KeyguardState.DOZING, to = KeyguardState.GONE)
        }

    @Test
    @EnableFlags(FLAG_KEYGUARD_WM_STATE_REFACTOR)
    @DisableFlags(FLAG_COMMUNAL_SCENE_KTF_REFACTOR)
+4 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import androidx.test.filters.SmallTest;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.keyguard.logging.KeyguardUpdateMonitorLogger;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dump.DumpManager;
@@ -67,6 +68,8 @@ public class KeyguardStateControllerTest extends SysuiTestCase {
    @Mock
    private Lazy<KeyguardUnlockAnimationController> mKeyguardUnlockAnimationControllerLazy;
    @Mock
    private Lazy<KeyguardInteractor> mKeyguardInteractorLazy;
    @Mock
    private SelectedUserInteractor mSelectedUserInteractor;
    @Mock
    private KeyguardUpdateMonitorLogger mLogger;
@@ -86,6 +89,7 @@ public class KeyguardStateControllerTest extends SysuiTestCase {
                mKeyguardUnlockAnimationControllerLazy,
                mLogger,
                mDumpManager,
                mKeyguardInteractorLazy,
                mFeatureFlags,
                mSelectedUserInteractor);
    }
+1 −1
Original line number Diff line number Diff line
@@ -2975,7 +2975,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        @Override
        public void run() {
            Trace.beginSection("KeyguardViewMediator.mKeyGuardGoingAwayRunnable");
            if (DEBUG) Log.d(TAG, "keyguardGoingAway");
            Log.d(TAG, "keyguardGoingAwayRunnable");
            mKeyguardViewControllerLazy.get().keyguardGoingAway();

            int flags = 0;
+1 −5
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ interface KeyguardRepository {
            "away' is isInTransitionToState(GONE), but consider using more specific flows " +
            "whenever possible."
    )
    val isKeyguardGoingAway: Flow<Boolean>
    val isKeyguardGoingAway: MutableStateFlow<Boolean>

    /**
     * Whether the keyguard is enabled, per [KeyguardService]. If the keyguard is not enabled, the
@@ -647,10 +647,6 @@ constructor(
                override fun onUnlockedChanged() {
                    isKeyguardDismissible.value = keyguardStateController.isUnlocked
                }

                override fun onKeyguardGoingAwayChanged() {
                    isKeyguardGoingAway.value = keyguardStateController.isKeyguardGoingAway
                }
            }

        keyguardStateController.addCallback(callback)
Loading