Support KeyguardService#showDismissibleKeyguard in keyguard_wm_state_refactor.
This CL is mostly renaming KeyguardLockWhileAwake and KeyguardLockNow to KeyguardShowWhileAwake/KeyguardServiceShowLockscreen to reflect that we're not necessarily locking the device.
The only logical changes are:
- KeyguardService asks KeyguardUpdateMonitor to delay locking instead of having KeyguardViewMediator do it, then calls KeyguardServiceShowLockscreenInteractor#onKeyguardServiceShowDismissibleKeyguard.
- That interactor now emits a ShowWhileAwakeReason, and an unused bundle is removed (didn't end up finding that actually was used).
- One collector of that flow (WakeDirectlyToGoneInteractor) filters out the fold events, the other just emits it into the existing showWhileAwakeEvents flow.
Fixes: 341400177
Test: fold my foldable
Flag: com.android.systemui.keyguard_wm_state_refactor
Change-Id: Ifd68d32326a221c420d2c3c1ecb3169391816021
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractorTest.kt
similarity index 81%
rename from packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractorTest.kt
rename to packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractorTest.kt
index 3eacc28..cfe3826 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractorTest.kt
@@ -39,42 +39,39 @@
@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 @@
@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 @@
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 @@
kosmos.keyguardEnabledInteractor.notifyKeyguardEnabled(true)
runCurrent()
- assertThat(values).containsExactly(LockWhileAwakeReason.KEYGUARD_REENABLED)
+ assertThat(values).containsExactly(ShowWhileAwakeReason.KEYGUARD_REENABLED)
}
/**
@@ -122,7 +119,7 @@
@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 @@
@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)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorTest.kt
index a814953..561eee7 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorTest.kt
@@ -185,7 +185,7 @@
canWake,
)
- kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(null)
+ kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
runCurrent()
assertEquals(
@@ -209,7 +209,7 @@
canWake,
)
- kosmos.keyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(null)
+ kosmos.keyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout()
runCurrent()
assertEquals(
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 0b66a0f..87e6c34 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -145,6 +145,9 @@
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;
@@ -297,6 +300,7 @@
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;
@@ -2210,7 +2214,8 @@
Provider<AlternateBouncerInteractor> alternateBouncerInteractor,
Provider<JavaAdapter> javaAdapter,
Provider<SceneInteractor> sceneInteractor,
- Provider<CommunalSceneInteractor> communalSceneInteractor) {
+ Provider<CommunalSceneInteractor> communalSceneInteractor,
+ KeyguardServiceShowLockscreenInteractor keyguardServiceShowLockscreenInteractor) {
mContext = context;
mSubscriptionManager = subscriptionManager;
mUserTracker = userTracker;
@@ -2260,6 +2265,7 @@
mJavaAdapter = javaAdapter;
mSceneInteractor = sceneInteractor;
mCommunalSceneInteractor = communalSceneInteractor;
+ mKeyguardServiceShowLockscreenInteractor = keyguardServiceShowLockscreenInteractor;
mHandler = new Handler(mainLooper) {
@Override
@@ -2541,6 +2547,13 @@
);
}
+ if (KeyguardWmStateRefactor.isEnabled()) {
+ mJavaAdapter.get().alwaysCollectFlow(
+ mKeyguardServiceShowLockscreenInteractor.getShowNowEvents(),
+ this::onKeyguardServiceShowLockscreenNowEvents
+ );
+ }
+
if (glanceableHubV2()) {
mJavaAdapter.get().alwaysCollectFlow(
mCommunalSceneInteractor.get().isCommunalVisible(),
@@ -2574,6 +2587,12 @@
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++) {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index c1a59f1..7574649 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -82,7 +82,7 @@
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 @@
return new FoldGracePeriodProvider();
}
};
- private final KeyguardServiceLockNowInteractor mKeyguardServiceLockNowInteractor;
+ private final KeyguardServiceShowLockscreenInteractor mKeyguardServiceShowLockscreenInteractor;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Inject
@@ -358,7 +358,7 @@
KeyguardDismissInteractor keyguardDismissInteractor,
Lazy<DeviceEntryInteractor> deviceEntryInteractorLazy,
KeyguardStateCallbackInteractor keyguardStateCallbackInteractor,
- KeyguardServiceLockNowInteractor keyguardServiceLockNowInteractor,
+ KeyguardServiceShowLockscreenInteractor keyguardServiceShowLockscreenInteractor,
KeyguardUpdateMonitor keyguardUpdateMonitor) {
super();
mKeyguardViewMediator = keyguardViewMediator;
@@ -391,7 +391,7 @@
mKeyguardEnabledInteractor = keyguardEnabledInteractor;
mKeyguardWakeDirectlyToGoneInteractor = keyguardWakeDirectlyToGoneInteractor;
mKeyguardDismissInteractor = keyguardDismissInteractor;
- mKeyguardServiceLockNowInteractor = keyguardServiceLockNowInteractor;
+ mKeyguardServiceShowLockscreenInteractor = keyguardServiceShowLockscreenInteractor;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
}
@@ -673,7 +673,7 @@
if (SceneContainerFlag.isEnabled()) {
mDeviceEntryInteractorLazy.get().lockNow("doKeyguardTimeout");
} else if (KeyguardWmStateRefactor.isEnabled()) {
- mKeyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout(options);
+ mKeyguardServiceShowLockscreenInteractor.onKeyguardServiceDoKeyguardTimeout();
}
mKeyguardViewMediator.doKeyguardTimeout(options);
@@ -686,7 +686,12 @@
if (mFoldGracePeriodProvider.get().isEnabled()) {
mKeyguardInteractor.showDismissibleKeyguard();
}
- mKeyguardViewMediator.showDismissibleKeyguard();
+
+ if (KeyguardWmStateRefactor.isEnabled()) {
+ mKeyguardServiceShowLockscreenInteractor.onKeyguardServiceShowDismissibleKeyguard();
+ } else {
+ mKeyguardViewMediator.showDismissibleKeyguard();
+ }
if (SceneContainerFlag.isEnabled() && mFoldGracePeriodProvider.get().isEnabled()) {
mMainExecutor.execute(() -> mSceneInteractorLazy.get().changeScene(
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt
index bd9836f..ca6a790 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractor.kt
@@ -34,9 +34,6 @@
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 @@
powerInteractor: PowerInteractor,
private val communalSceneInteractor: CommunalSceneInteractor,
keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
- private val keyguardLockWhileAwakeInteractor: KeyguardLockWhileAwakeInteractor,
+ private val keyguardShowWhileAwakeInteractor: KeyguardShowWhileAwakeInteractor,
) :
TransitionInteractor(
fromState = KeyguardState.GONE,
@@ -101,7 +98,7 @@
private fun listenForGoneToLockscreenOrHubOrOccluded() {
if (KeyguardWmStateRefactor.isEnabled) {
scope.launch {
- keyguardLockWhileAwakeInteractor.lockWhileAwakeEvents
+ keyguardShowWhileAwakeInteractor.showWhileAwakeEvents
.filterRelevantKeyguardState()
.sample(communalSceneInteractor.isIdleOnCommunalNotEditMode, ::Pair)
.collect { (lockReason, idleOnCommunal) ->
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceLockNowInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceLockNowInteractor.kt
deleted file mode 100644
index 9ed53ea..0000000
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceLockNowInteractor.kt
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2024 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.keyguard.domain.interactor
-
-import android.annotation.SuppressLint
-import android.os.Bundle
-import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.dagger.qualifiers.Background
-import javax.inject.Inject
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.flow.MutableSharedFlow
-import kotlinx.coroutines.launch
-
-/**
- * Emitted when we receive a [KeyguardServiceLockNowInteractor.onKeyguardServiceDoKeyguardTimeout]
- * call.
- */
-data class KeyguardLockNowEvent(val options: Bundle?)
-
-/**
- * Logic around requests by [KeyguardService] to lock the device right now, even though the device
- * is awake and not going to sleep.
- *
- * This can happen if WM#lockNow() is called, or if the screen is forced to stay awake but the lock
- * timeout elapses.
- *
- * This is not the only way for the device to lock while the screen is on. The other cases, which do
- * not directly involve [KeyguardService], are handled in [KeyguardLockWhileAwakeInteractor].
- */
-@SysUISingleton
-class KeyguardServiceLockNowInteractor
-@Inject
-constructor(@Background val backgroundScope: CoroutineScope) {
-
- /**
- * Emits whenever [KeyguardService] receives a call that indicates we should lock the device
- * right now, even though the device is awake and not going to sleep.
- *
- * WARNING: This is only one of multiple reasons the device might need to lock while not going
- * to sleep. Unless you're dealing with keyguard internals that specifically need to know that
- * we're locking due to a call to doKeyguardTimeout, use
- * [KeyguardLockWhileAwakeInteractor.lockWhileAwakeEvents].
- *
- * This is fundamentally an event flow, hence the SharedFlow.
- */
- @SuppressLint("SharedFlowCreation")
- val lockNowEvents: MutableSharedFlow<KeyguardLockNowEvent> = MutableSharedFlow()
-
- /**
- * Called by [KeyguardService] when it receives a doKeyguardTimeout() call. This indicates that
- * the device locked while the screen was on.
- *
- * [options] appears to be no longer used, but we'll keep it in this interactor in case that
- * turns out not to be true.
- */
- fun onKeyguardServiceDoKeyguardTimeout(options: Bundle?) {
- backgroundScope.launch { lockNowEvents.emit(KeyguardLockNowEvent(options = options)) }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt
new file mode 100644
index 0000000..b55bb38
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2024 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.keyguard.domain.interactor
+
+import android.annotation.SuppressLint
+import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Background
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.launch
+
+/**
+ * Logic around requests by [KeyguardService] to show keyguard right now, even though the device is
+ * awake and not going to sleep.
+ *
+ * This can happen if WM#lockNow() is called, if KeyguardService#showDismissibleKeyguard is called
+ * because we're folding with "continue using apps on fold" set to "swipe up to continue", or if the
+ * screen is forced to stay awake but the lock timeout elapses.
+ *
+ * This is not the only way for the device to lock while the screen is on. The other cases, which do
+ * not directly involve [KeyguardService], are handled in [KeyguardShowWhileAwakeInteractor].
+ */
+@SysUISingleton
+class KeyguardServiceShowLockscreenInteractor
+@Inject
+constructor(@Background val backgroundScope: CoroutineScope) {
+
+ /**
+ * Emits whenever [KeyguardService] receives a call that indicates we should show the lockscreen
+ * right now, even though the device is awake and not going to sleep.
+ *
+ * WARNING: This is only one of multiple reasons the keyguard might need to show while not going
+ * to sleep. Unless you're dealing with keyguard internals that specifically need to know that
+ * we're locking due to a call to doKeyguardTimeout or showDismissibleKeyguard, use
+ * [KeyguardShowWhileAwakeInteractor.showWhileAwakeEvents].
+ *
+ * This is fundamentally an event flow, hence the SharedFlow.
+ */
+ @SuppressLint("SharedFlowCreation")
+ val showNowEvents: MutableSharedFlow<ShowWhileAwakeReason> = MutableSharedFlow()
+
+ /**
+ * Called by [KeyguardService] when it receives a doKeyguardTimeout() call. This indicates that
+ * the device locked while the screen was on.
+ */
+ fun onKeyguardServiceDoKeyguardTimeout() {
+ backgroundScope.launch {
+ showNowEvents.emit(ShowWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON)
+ }
+ }
+
+ /**
+ * Called by [KeyguardService] when it receives a showDismissibleKeyguard() call. This indicates
+ * that the device was folded with settings configured to show a dismissible keyguard on the
+ * outer display.
+ */
+ fun onKeyguardServiceShowDismissibleKeyguard() {
+ backgroundScope.launch {
+ showNowEvents.emit(ShowWhileAwakeReason.FOLDED_WITH_SWIPE_UP_TO_CONTINUE)
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractor.kt
similarity index 66%
rename from packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractor.kt
rename to packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractor.kt
index ce84e71..a8000a56 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractor.kt
@@ -26,8 +26,11 @@
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
-/** The reason we're locking while awake, used for logging. */
-enum class LockWhileAwakeReason(private val logReason: String) {
+/** The reason we're showing lockscreen while awake, used for logging. */
+enum class ShowWhileAwakeReason(private val logReason: String) {
+ FOLDED_WITH_SWIPE_UP_TO_CONTINUE(
+ "Folded with continue using apps on fold set to 'swipe up to continue'."
+ ),
LOCKDOWN("Lockdown initiated."),
KEYGUARD_REENABLED(
"Keyguard was re-enabled. We weren't unlocked when it was disabled, " +
@@ -43,60 +46,67 @@
}
/**
- * Logic around cases where the device locks while still awake (transitioning from GONE ->
+ * Logic around cases where the we show the lockscreen while still awake (transition from GONE ->
* LOCKSCREEN), vs. the more common cases of a power button press or screen timeout, which result in
* the device going to sleep.
*
+ * This does not necessarily mean we lock the device (which does not happen if showing the
+ * lockscreen is triggered by [KeyguardService.showDismissibleKeyguard]). We'll show keyguard here
+ * and authentication logic will decide if that keyguard is dismissible or not.
+ *
* This is possible in the following situations:
* - The user initiates lockdown from the power menu.
* - Theft detection, etc. has requested lockdown.
* - The keyguard was disabled while visible, and has now been re-enabled, so it's re-showing.
* - Someone called WM#lockNow().
* - The screen timed out, but an activity with FLAG_ALLOW_LOCK_WHILE_SCREEN_ON is on top.
+ * - A foldable is folded with "Continue using apps on fold" set to "Swipe up to continue" (if set
+ * to "never", then lockscreen will be shown when the device goes to sleep, which is not tnohe
+ * concern of this interactor).
*/
@SysUISingleton
-class KeyguardLockWhileAwakeInteractor
+class KeyguardShowWhileAwakeInteractor
@Inject
constructor(
biometricSettingsRepository: BiometricSettingsRepository,
keyguardEnabledInteractor: KeyguardEnabledInteractor,
- keyguardServiceLockNowInteractor: KeyguardServiceLockNowInteractor,
+ keyguardServiceShowLockscreenInteractor: KeyguardServiceShowLockscreenInteractor,
) {
/** Emits whenever the current user is in lockdown mode. */
- private val inLockdown: Flow<LockWhileAwakeReason> =
+ private val inLockdown: Flow<ShowWhileAwakeReason> =
biometricSettingsRepository.isCurrentUserInLockdown
.distinctUntilChanged()
.filter { inLockdown -> inLockdown }
- .map { LockWhileAwakeReason.LOCKDOWN }
+ .map { ShowWhileAwakeReason.LOCKDOWN }
/**
* Emits whenever the keyguard is re-enabled, and we need to return to lockscreen due to the
* device being locked when the keyguard was originally disabled.
*/
- private val keyguardReenabled: Flow<LockWhileAwakeReason> =
+ private val keyguardReenabled: Flow<ShowWhileAwakeReason> =
keyguardEnabledInteractor.isKeyguardEnabled
.filter { enabled -> enabled }
.sample(keyguardEnabledInteractor.showKeyguardWhenReenabled)
.filter { reshow -> reshow }
- .map { LockWhileAwakeReason.KEYGUARD_REENABLED }
+ .map { ShowWhileAwakeReason.KEYGUARD_REENABLED }
- /** Emits whenever we should lock while the screen is on, for any reason. */
- val lockWhileAwakeEvents: Flow<LockWhileAwakeReason> =
+ /** Emits whenever we should show lockscreen while the screen is on, for any reason. */
+ val showWhileAwakeEvents: Flow<ShowWhileAwakeReason> =
merge(
// We're in lockdown, and the keyguard is enabled. If the keyguard is disabled, the
// lockdown button is hidden in the UI, but it's still possible to trigger lockdown in
// tests.
inLockdown
.filter { keyguardEnabledInteractor.isKeyguardEnabledAndNotSuppressed() }
- .map { LockWhileAwakeReason.LOCKDOWN },
+ .map { ShowWhileAwakeReason.LOCKDOWN },
// The keyguard was re-enabled, and it was showing when it was originally disabled.
// Tests currently expect that if the keyguard is re-enabled, it will show even if it's
// suppressed, so we don't check for isKeyguardEnabledAndNotSuppressed() on this flow.
- keyguardReenabled.map { LockWhileAwakeReason.KEYGUARD_REENABLED },
- // KeyguardService says we need to lock now, and the lockscreen is enabled.
- keyguardServiceLockNowInteractor.lockNowEvents
- .filter { keyguardEnabledInteractor.isKeyguardEnabledAndNotSuppressed() }
- .map { LockWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON },
+ keyguardReenabled.map { ShowWhileAwakeReason.KEYGUARD_REENABLED },
+ // KeyguardService says we need to show now, and the lockscreen is enabled.
+ keyguardServiceShowLockscreenInteractor.showNowEvents.filter {
+ keyguardEnabledInteractor.isKeyguardEnabledAndNotSuppressed()
+ },
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractor.kt
index 3bdc32d..ef1fe49 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractor.kt
@@ -52,6 +52,7 @@
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.distinctUntilChangedBy
+import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart
@@ -89,7 +90,7 @@
private val systemSettings: SystemSettings,
private val selectedUserInteractor: SelectedUserInteractor,
keyguardEnabledInteractor: KeyguardEnabledInteractor,
- keyguardServiceLockNowInteractor: KeyguardServiceLockNowInteractor,
+ keyguardServiceShowLockscreenInteractor: KeyguardServiceShowLockscreenInteractor,
keyguardInteractor: KeyguardInteractor,
) {
@@ -100,7 +101,15 @@
* depend on that behavior, so for now, we'll replicate it here.
*/
private val shouldSuppressKeyguard =
- merge(powerInteractor.isAwake, keyguardServiceLockNowInteractor.lockNowEvents)
+ merge(
+ powerInteractor.isAwake,
+ // Update only when doKeyguardTimeout is called, not on fold or other events, to
+ // match
+ // pre-existing logic.
+ keyguardServiceShowLockscreenInteractor.showNowEvents.filter {
+ it == ShowWhileAwakeReason.KEYGUARD_TIMEOUT_WHILE_SCREEN_ON
+ },
+ )
.map { keyguardEnabledInteractor.isKeyguardSuppressed() }
// Default to false, so that flows that combine this one emit prior to the first
// wakefulness emission.
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
index 4110a05..9f825ef 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardUpdateMonitorTest.java
@@ -149,6 +149,7 @@
import com.android.systemui.deviceentry.shared.model.FailedFaceAuthenticationStatus;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.SceneContainerFlagParameterizationKt;
+import com.android.systemui.keyguard.domain.interactor.KeyguardServiceShowLockscreenInteractor;
import com.android.systemui.kosmos.KosmosJavaAdapter;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
@@ -307,6 +308,8 @@
private SceneInteractor mSceneInteractor;
@Mock
private CommunalSceneInteractor mCommunalSceneInteractor;
+ @Mock
+ private KeyguardServiceShowLockscreenInteractor mKeyguardServiceShowLockscreenInteractor;
@Captor
private ArgumentCaptor<FaceAuthenticationListener> mFaceAuthenticationListener;
@@ -2716,7 +2719,8 @@
() -> mAlternateBouncerInteractor,
() -> mJavaAdapter,
() -> mSceneInteractor,
- () -> mCommunalSceneInteractor);
+ () -> mCommunalSceneInteractor,
+ mKeyguardServiceShowLockscreenInteractor);
setAlternateBouncerVisibility(false);
setPrimaryBouncerVisibility(false);
setStrongAuthTracker(KeyguardUpdateMonitorTest.this.mStrongAuthTracker);
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt
index ff0f13e..1698a50 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/FromGoneTransitionInteractorKosmos.kt
@@ -37,6 +37,6 @@
powerInteractor = powerInteractor,
communalSceneInteractor = communalSceneInteractor,
keyguardOcclusionInteractor = keyguardOcclusionInteractor,
- keyguardLockWhileAwakeInteractor = keyguardLockWhileAwakeInteractor,
+ keyguardShowWhileAwakeInteractor = keyguardShowWhileAwakeInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceLockNowInteractor.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt
similarity index 83%
rename from packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceLockNowInteractor.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt
index 29335c5..3cec5a9 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceLockNowInteractor.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardServiceShowLockscreenInteractor.kt
@@ -19,5 +19,5 @@
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
-val Kosmos.keyguardServiceLockNowInteractor by
- Kosmos.Fixture { KeyguardServiceLockNowInteractor(backgroundScope = testScope) }
+val Kosmos.keyguardServiceShowLockscreenInteractor by
+ Kosmos.Fixture { KeyguardServiceShowLockscreenInteractor(backgroundScope = testScope) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractorKosmos.kt
similarity index 84%
rename from packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractorKosmos.kt
rename to packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractorKosmos.kt
index 2423949..f7caeb6 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardLockWhileAwakeInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardShowWhileAwakeInteractorKosmos.kt
@@ -19,11 +19,11 @@
import com.android.systemui.keyguard.data.repository.biometricSettingsRepository
import com.android.systemui.kosmos.Kosmos
-val Kosmos.keyguardLockWhileAwakeInteractor by
+val Kosmos.keyguardShowWhileAwakeInteractor by
Kosmos.Fixture {
- KeyguardLockWhileAwakeInteractor(
+ KeyguardShowWhileAwakeInteractor(
biometricSettingsRepository = biometricSettingsRepository,
keyguardEnabledInteractor = keyguardEnabledInteractor,
- keyguardServiceLockNowInteractor = keyguardServiceLockNowInteractor,
+ keyguardServiceShowLockscreenInteractor = keyguardServiceShowLockscreenInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorKosmos.kt
index 8c9163d..43fa718 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardWakeDirectlyToGoneInteractorKosmos.kt
@@ -42,7 +42,7 @@
fakeSettings,
selectedUserInteractor,
keyguardEnabledInteractor,
- keyguardServiceLockNowInteractor,
+ keyguardServiceShowLockscreenInteractor,
keyguardInteractor,
)
}