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

Commit 34ac82ff authored by Chandru S's avatar Chandru S
Browse files

Remove flexiglass dependency from repository that is used by existing code

This reduces the flexibility we have in changing flexiglass code.
We will be changing the implementation of DeviceEntryInteractor#isUnlocked to not depend on keyguard going away state from the legacy system.

Bug: 295366149
Test: everything builds and runs.
Flag: NA (this is reverting unflagged code that was added before)

Change-Id: I5c6bbcd8acc61e3c7a8f47c622f0f77883c51aec
parent 8bf88f23
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -92,6 +92,12 @@ interface KeyguardRepository {
    /** Is an activity showing over the keyguard? */
    val isKeyguardOccluded: Flow<Boolean>

    /**
     * Whether the device is locked or unlocked right now. This is true when keyguard has been
     * dismissed or can be dismissed by a swipe
     */
    val isKeyguardUnlocked: StateFlow<Boolean>

    /**
     * Observable for the signal that keyguard is about to go away.
     *
@@ -332,6 +338,44 @@ constructor(
            }
            .distinctUntilChanged()

    override val isKeyguardUnlocked: StateFlow<Boolean> =
        conflatedCallbackFlow {
                val callback =
                    object : KeyguardStateController.Callback {
                        override fun onUnlockedChanged() {
                            trySendWithFailureLogging(
                                keyguardStateController.isUnlocked,
                                TAG,
                                "updated isKeyguardUnlocked due to onUnlockedChanged"
                            )
                        }

                        override fun onKeyguardShowingChanged() {
                            trySendWithFailureLogging(
                                keyguardStateController.isUnlocked,
                                TAG,
                                "updated isKeyguardUnlocked due to onKeyguardShowingChanged"
                            )
                        }
                    }

                keyguardStateController.addCallback(callback)
                // Adding the callback does not send an initial update.
                trySendWithFailureLogging(
                    keyguardStateController.isUnlocked,
                    TAG,
                    "initial isKeyguardUnlocked"
                )

                awaitClose { keyguardStateController.removeCallback(callback) }
            }
            .distinctUntilChanged()
            .stateIn(
                scope,
                SharingStarted.Eagerly,
                initialValue = false,
            )

    override val isKeyguardGoingAway: Flow<Boolean> = conflatedCallbackFlow {
        val callback =
            object : KeyguardStateController.Callback {
+1 −3
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.systemui.common.shared.model.Position
import com.android.systemui.common.shared.model.SharedNotificationContainerPosition
import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.deviceentry.data.repository.DeviceEntryRepository
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.repository.KeyguardRepository
@@ -78,7 +77,6 @@ constructor(
    private val powerInteractor: PowerInteractor,
    featureFlags: FeatureFlags,
    sceneContainerFlags: SceneContainerFlags,
    deviceEntryRepository: DeviceEntryRepository,
    bouncerRepository: KeyguardBouncerRepository,
    configurationRepository: ConfigurationRepository,
    shadeRepository: ShadeRepository,
@@ -160,7 +158,7 @@ constructor(
    val isKeyguardShowing: Flow<Boolean> = repository.isKeyguardShowing

    /** Whether the keyguard is unlocked or not. */
    val isKeyguardUnlocked: Flow<Boolean> = deviceEntryRepository.isUnlocked
    val isKeyguardUnlocked: Flow<Boolean> = repository.isKeyguardUnlocked

    /** Whether the keyguard is occluded (covered by an activity). */
    val isKeyguardOccluded: Flow<Boolean> = repository.isKeyguardOccluded
+23 −0
Original line number Diff line number Diff line
@@ -215,6 +215,29 @@ class KeyguardRepositoryImplTest : SysuiTestCase() {
            job.cancel()
        }

    @Test
    fun isKeyguardUnlocked() =
        testScope.runTest {
            whenever(keyguardStateController.isUnlocked).thenReturn(false)
            val isKeyguardUnlocked by collectLastValue(underTest.isKeyguardUnlocked)

            runCurrent()
            assertThat(isKeyguardUnlocked).isFalse()

            val captor = argumentCaptor<KeyguardStateController.Callback>()
            verify(keyguardStateController, atLeastOnce()).addCallback(captor.capture())

            whenever(keyguardStateController.isUnlocked).thenReturn(true)
            captor.value.onUnlockedChanged()
            runCurrent()
            assertThat(isKeyguardUnlocked).isTrue()

            whenever(keyguardStateController.isUnlocked).thenReturn(false)
            captor.value.onKeyguardShowingChanged()
            runCurrent()
            assertThat(isKeyguardUnlocked).isFalse()
        }

    @Test
    fun isDozing() =
        testScope.runTest {
+0 −1
Original line number Diff line number Diff line
@@ -68,7 +68,6 @@ class KeyguardInteractorTest : SysuiTestCase() {
            powerInteractor = PowerInteractorFactory.create().powerInteractor,
            featureFlags = featureFlags,
            sceneContainerFlags = testUtils.sceneContainerFlags,
            deviceEntryRepository = testUtils.deviceEntryRepository,
            bouncerRepository = bouncerRepository,
            configurationRepository = configurationRepository,
            shadeRepository = shadeRepository,
+0 −2
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ import com.android.systemui.bouncer.data.repository.FakeKeyguardBouncerRepositor
import com.android.systemui.classifier.FalsingCollectorFake;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.common.ui.data.repository.FakeConfigurationRepository;
import com.android.systemui.deviceentry.data.repository.FakeDeviceEntryRepository;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FakeFeatureFlagsClassic;
import com.android.systemui.keyguard.KeyguardViewMediator;
@@ -185,7 +184,6 @@ public class NotificationShadeWindowControllerImplTest extends SysuiTestCase {
                powerInteractor,
                featureFlags,
                sceneContainerFlags,
                new FakeDeviceEntryRepository(),
                new FakeKeyguardBouncerRepository(),
                configurationRepository,
                shadeRepository,
Loading