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

Commit f92345fd authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Update keyguard flow to always be on main thread." into main

parents 8b01fb12 50cfcf9c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -574,7 +574,7 @@ class KeyguardRepositoryImplTest : SysuiTestCase() {

    @Test
    fun isEncryptedOrLockdown() =
        testScope.runTest {
        TestScope(mainDispatcher).runTest {
            whenever(userTracker.userId).thenReturn(0)
            whenever(keyguardUpdateMonitor.isEncryptedOrLockdown(0)).thenReturn(true)

+3 −3
Original line number Diff line number Diff line
@@ -567,17 +567,17 @@ constructor(
                val callback =
                    object : KeyguardUpdateMonitorCallback() {
                        override fun onStrongAuthStateChanged(userId: Int) {
                            trySend(userId)
                            trySendWithFailureLogging(userId, TAG, "strong auth state change")
                        }
                    }

                keyguardUpdateMonitor.registerCallback(callback)

                awaitClose { keyguardUpdateMonitor.removeCallback(callback) }
            }
            .filter { userId -> userId == userTracker.userId }
            .onStart { emit(userTracker.userId) }
            .mapLatest { userId -> keyguardUpdateMonitor.isEncryptedOrLockdown(userId) }
            // KeyguardUpdateMonitor#registerCallback needs to be called on the main thread.
            .flowOn(mainDispatcher)

    override fun isKeyguardShowing(): Boolean {
        return keyguardStateController.isShowing