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

Commit 0dbe21a0 authored by Josh Tsuji's avatar Josh Tsuji Committed by Android (Google) Code Review
Browse files

Merge "Support KeyguardService#showDismissibleKeyguard in keyguard_wm_state_refactor." into main

parents f2d7da4f d48bae09
Loading
Loading
Loading
Loading
+16 −19
Original line number Diff line number Diff line
@@ -39,42 +39,39 @@ import org.mockito.kotlin.whenever

@SmallTest
@RunWith(AndroidJUnit4::class)
class KeyguardLockWhileAwakeInteractorTest : SysuiTestCase() {
@kotlinx.coroutines.ExperimentalCoroutinesApi
class KeyguardShowWhileAwakeInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private lateinit var underTest: KeyguardLockWhileAwakeInteractor
    private lateinit var underTest: KeyguardShowWhileAwakeInteractor

    @Before
    fun setup() {
        underTest = kosmos.keyguardLockWhileAwakeInteractor
        underTest = kosmos.keyguardShowWhileAwakeInteractor
    }

    @Test
    fun emitsMultipleTimeoutEvents() =
        testScope.runTest {
            val values by collectValues(underTest.lockWhileAwakeEvents)
            val values by collectValues(underTest.showWhileAwakeEvents)

            kosmos.keyguardEnabledInteractor.notifyKeyguardEnabled(true)
            runCurrent()

            kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(
                options = null
            )
            kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
            runCurrent()

            assertThat(values)
                .containsExactly(LockWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON)
                .containsExactly(ShowWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON)

            advanceTimeBy(1000)
            kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(
                options = null
            )
            kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
            runCurrent()

            assertThat(values)
                .containsExactly(
                    LockWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON,
                    LockWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON,
                    ShowWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON,
                    ShowWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON,
                )
        }

@@ -88,7 +85,7 @@ class KeyguardLockWhileAwakeInteractorTest : SysuiTestCase() {
    @Test
    fun emitsWhenKeyguardReenabled_onlyIfShowingWhenDisabled() =
        testScope.runTest {
            val values by collectValues(underTest.lockWhileAwakeEvents)
            val values by collectValues(underTest.showWhileAwakeEvents)

            kosmos.biometricSettingsRepository.setIsUserInLockdown(false)
            runCurrent()
@@ -101,7 +98,7 @@ class KeyguardLockWhileAwakeInteractorTest : SysuiTestCase() {
            kosmos.keyguardEnabledInteractor.notifyKeyguardEnabled(true)
            runCurrent()

            assertThat(values).containsExactly(LockWhileAwakeReason.KEYGUARD_REENABLED)
            assertThat(values).containsExactly(ShowWhileAwakeReason.KEYGUARD_REENABLED)

            kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
@@ -112,7 +109,7 @@ class KeyguardLockWhileAwakeInteractorTest : SysuiTestCase() {
            kosmos.keyguardEnabledInteractor.notifyKeyguardEnabled(true)
            runCurrent()

            assertThat(values).containsExactly(LockWhileAwakeReason.KEYGUARD_REENABLED)
            assertThat(values).containsExactly(ShowWhileAwakeReason.KEYGUARD_REENABLED)
        }

    /**
@@ -122,7 +119,7 @@ class KeyguardLockWhileAwakeInteractorTest : SysuiTestCase() {
    @Test
    fun doesNotEmit_keyguardNoLongerSuppressed() =
        testScope.runTest {
            val values by collectValues(underTest.lockWhileAwakeEvents)
            val values by collectValues(underTest.showWhileAwakeEvents)

            // Enable keyguard and then suppress it.
            kosmos.keyguardEnabledInteractor.notifyKeyguardEnabled(true)
@@ -144,14 +141,14 @@ class KeyguardLockWhileAwakeInteractorTest : SysuiTestCase() {
    @Test
    fun doesNotEmit_fromLockdown_orFromLockNow_ifEnabledButSuppressed() =
        testScope.runTest {
            val values by collectValues(underTest.lockWhileAwakeEvents)
            val values by collectValues(underTest.showWhileAwakeEvents)

            // Set keyguard enabled, but then disable lockscreen (suppress it).
            kosmos.keyguardEnabledInteractor.notifyKeyguardEnabled(true)
            whenever(kosmos.lockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(true)
            runCurrent()

            kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(null)
            kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
            runCurrent()

            kosmos.biometricSettingsRepository.setIsUserInLockdown(true)
+2 −2
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ class KeyguardWakeDirectlyToGoneInteractorTest : SysuiTestCase() {
                canWake,
            )

            kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(null)
            kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
            runCurrent()

            assertEquals(
@@ -209,7 +209,7 @@ class KeyguardWakeDirectlyToGoneInteractorTest : SysuiTestCase() {
                canWake,
            )

            kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(null)
            kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
            runCurrent()

            assertEquals(
+20 −1
Original line number Diff line number Diff line
@@ -146,6 +146,9 @@ import com.android.systemui.deviceentry.shared.model.HelpFaceAuthenticationStatu
import com.android.systemui.deviceentry.shared.model.SuccessFaceAuthenticationStatus;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.dump.DumpsysTableLogger;
import com.android.systemui.keyguard.KeyguardWmStateRefactor;
import com.android.systemui.keyguard.domain.interactor.KeyguardServiceShowLockscreenInteractor;
import com.android.systemui.keyguard.domain.interactor.ShowWhileAwakeReason;
import com.android.systemui.keyguard.shared.constants.TrustAgentUiEvent;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.clocks.WeatherData;
@@ -298,6 +301,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private final Provider<SceneInteractor> mSceneInteractor;
    private final Provider<AlternateBouncerInteractor> mAlternateBouncerInteractor;
    private final Provider<CommunalSceneInteractor> mCommunalSceneInteractor;
    private final KeyguardServiceShowLockscreenInteractor mKeyguardServiceShowLockscreenInteractor;
    private final AuthController mAuthController;
    private final UiEventLogger mUiEventLogger;
    private final Set<String> mAllowFingerprintOnOccludingActivitiesFromPackage;
@@ -2214,7 +2218,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            Provider<AlternateBouncerInteractor> alternateBouncerInteractor,
            Provider<JavaAdapter> javaAdapter,
            Provider<SceneInteractor> sceneInteractor,
            Provider<CommunalSceneInteractor> communalSceneInteractor) {
            Provider<CommunalSceneInteractor> communalSceneInteractor,
            KeyguardServiceShowLockscreenInteractor keyguardServiceShowLockscreenInteractor) {
        mContext = context;
        mSubscriptionManager = subscriptionManager;
        mUserTracker = userTracker;
@@ -2264,6 +2269,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mJavaAdapter = javaAdapter;
        mSceneInteractor = sceneInteractor;
        mCommunalSceneInteractor = communalSceneInteractor;
        mKeyguardServiceShowLockscreenInteractor = keyguardServiceShowLockscreenInteractor;

        mHandler = new Handler(mainLooper) {
            @Override
@@ -2545,6 +2551,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            );
        }

        if (KeyguardWmStateRefactor.isEnabled()) {
            mJavaAdapter.get().alwaysCollectFlow(
                    mKeyguardServiceShowLockscreenInteractor.getShowNowEvents(),
                    this::onKeyguardServiceShowLockscreenNowEvents
            );
        }

        if (glanceableHubV2()) {
            mJavaAdapter.get().alwaysCollectFlow(
                    mCommunalSceneInteractor.get().isCommunalVisible(),
@@ -2578,6 +2591,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        handlePrimaryBouncerChanged(primaryBouncerIsOrWillBeShowing, primaryBouncerFullyShown);
    }

    void onKeyguardServiceShowLockscreenNowEvents(ShowWhileAwakeReason reason) {
        if (reason == ShowWhileAwakeReason.FOLDED_WITH_SWIPE_UP_TO_CONTINUE) {
            mMainExecutor.execute(this::tryForceIsDismissibleKeyguard);
        }
    }

    private void initializeSimState() {
        // Set initial sim states values.
        for (int slot = 0; slot < mTelephonyManager.getActiveModemCount(); slot++) {
+11 −6
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardEnabledInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardServiceLockNowInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardServiceShowLockscreenInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardStateCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardWakeDirectlyToGoneInteractor;
import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier;
@@ -331,7 +331,7 @@ public class KeyguardService extends Service {
            return new FoldGracePeriodProvider();
        }
    };
    private final KeyguardServiceLockNowInteractor mKeyguardServiceLockNowInteractor;
    private final KeyguardServiceShowLockscreenInteractor mKeyguardServiceShowLockscreenInteractor;
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;

    @Inject
@@ -358,7 +358,7 @@ public class KeyguardService extends Service {
            KeyguardDismissInteractor keyguardDismissInteractor,
            Lazy<DeviceEntryInteractor> deviceEntryInteractorLazy,
            KeyguardStateCallbackInteractor keyguardStateCallbackInteractor,
            KeyguardServiceLockNowInteractor keyguardServiceLockNowInteractor,
            KeyguardServiceShowLockscreenInteractor keyguardServiceShowLockscreenInteractor,
            KeyguardUpdateMonitor keyguardUpdateMonitor) {
        super();
        mKeyguardViewMediator = keyguardViewMediator;
@@ -391,7 +391,7 @@ public class KeyguardService extends Service {
        mKeyguardEnabledInteractor = keyguardEnabledInteractor;
        mKeyguardWakeDirectlyToGoneInteractor = keyguardWakeDirectlyToGoneInteractor;
        mKeyguardDismissInteractor = keyguardDismissInteractor;
        mKeyguardServiceLockNowInteractor = keyguardServiceLockNowInteractor;
        mKeyguardServiceShowLockscreenInteractor = keyguardServiceShowLockscreenInteractor;
        mKeyguardUpdateMonitor = keyguardUpdateMonitor;
    }

@@ -673,7 +673,7 @@ public class KeyguardService extends Service {
            if (SceneContainerFlag.isEnabled()) {
                mDeviceEntryInteractorLazy.get().lockNow("doKeyguardTimeout");
            } else if (KeyguardWmStateRefactor.isEnabled()) {
                mKeyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(options);
                mKeyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout();
            }

            mKeyguardViewMediator.doKeyguardTimeout(options);
@@ -686,7 +686,12 @@ public class KeyguardService extends Service {
            if (mFoldGracePeriodProvider.get().isEnabled()) {
                mKeyguardInteractor.showDismissibleKeyguard();
            }

            if (KeyguardWmStateRefactor.isEnabled()) {
                mKeyguardServiceShowLockscreenInteractor.onKeyguardServiceShowDismissibleKeyguard();
            } else {
                mKeyguardViewMediator.showDismissibleKeyguard();
            }

            if (SceneContainerFlag.isEnabled() && mFoldGracePeriodProvider.get().isEnabled()) {
                mMainExecutor.execute(() -> mSceneInteractorLazy.get().changeScene(
+2 −5
Original line number Diff line number Diff line
@@ -34,9 +34,6 @@ import javax.inject.Inject
import kotlin.time.Duration.Companion.milliseconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import com.android.app.tracing.coroutines.launchTraced as launch

@SysUISingleton
class FromGoneTransitionInteractor
@@ -52,7 +49,7 @@ constructor(
    powerInteractor: PowerInteractor,
    private val communalSceneInteractor: CommunalSceneInteractor,
    keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
    private val keyguardLockWhileAwakeInteractor: KeyguardLockWhileAwakeInteractor,
    private val keyguardShowWhileAwakeInteractor: KeyguardShowWhileAwakeInteractor,
) :
    TransitionInteractor(
        fromState = KeyguardState.GONE,
@@ -101,7 +98,7 @@ constructor(
    private fun listenForGoneToLockscreenOrHubOrOccluded() {
        if (KeyguardWmStateRefactor.isEnabled) {
            scope.launch {
                keyguardLockWhileAwakeInteractor.lockWhileAwakeEvents
                keyguardShowWhileAwakeInteractor.showWhileAwakeEvents
                    .filterRelevantKeyguardState()
                    .sample(communalSceneInteractor.isIdleOnCommunalNotEditMode, ::Pair)
                    .collect { (lockReason, idleOnCommunal) ->
Loading