[flexiglass] Adds logging for scene and visibility changes.
This should prove useful in debugging. Fix: 294228910 Test: manually ran, changed scenes, and verified scene and visibility logging works as intended. Change-Id: I9efc88fddc30544d7629a76aa73aa3ee1c91caae
This commit is contained in:
@@ -127,10 +127,12 @@ constructor(
|
||||
repository.setMessage(message ?: promptMessage(getAuthenticationMethod()))
|
||||
sceneInteractor.setCurrentScene(
|
||||
scene = SceneModel(SceneKey.Bouncer),
|
||||
loggingReason = "request to unlock device while authentication required",
|
||||
)
|
||||
} else {
|
||||
sceneInteractor.setCurrentScene(
|
||||
scene = SceneModel(SceneKey.Gone),
|
||||
loggingReason = "request to unlock device while authentication isn't required",
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -176,6 +178,7 @@ constructor(
|
||||
if (isAuthenticated) {
|
||||
sceneInteractor.setCurrentScene(
|
||||
scene = SceneModel(SceneKey.Gone),
|
||||
loggingReason = "successful authentication",
|
||||
)
|
||||
} else {
|
||||
repository.setMessage(errorMessage(getAuthenticationMethod()))
|
||||
|
||||
@@ -496,4 +496,12 @@ public class LogModule {
|
||||
public static LogBuffer provideDisplayMetricsRepoLogBuffer(LogBufferFactory factory) {
|
||||
return factory.create("DisplayMetricsRepo", 50);
|
||||
}
|
||||
|
||||
/** Provides a {@link LogBuffer} for the scene framework. */
|
||||
@Provides
|
||||
@SysUISingleton
|
||||
@SceneFrameworkLog
|
||||
public static LogBuffer provideSceneFrameworkLogBuffer(LogBufferFactory factory) {
|
||||
return factory.create("SceneFramework", 50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.log.dagger
|
||||
|
||||
import javax.inject.Qualifier
|
||||
|
||||
/** A [com.android.systemui.log.LogBuffer] for the Scene Framework. */
|
||||
@Qualifier
|
||||
@MustBeDocumented
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class SceneFrameworkLog
|
||||
@@ -220,7 +220,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
|
||||
// If scene framework is enabled, set the scene container window to
|
||||
// visible and let the touch "slip" into that window.
|
||||
if (mFeatureFlags.isEnabled(Flags.SCENE_CONTAINER)) {
|
||||
mSceneInteractor.get().setVisible(true);
|
||||
mSceneInteractor.get().setVisible(true, "swipe down on launcher");
|
||||
} else {
|
||||
centralSurfaces.onInputFocusTransfer(
|
||||
mInputFocusTransferStarted, false /* cancel */,
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.systemui.scene.domain.interactor
|
||||
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.scene.data.repository.SceneContainerRepository
|
||||
import com.android.systemui.scene.shared.logger.SceneLogger
|
||||
import com.android.systemui.scene.shared.model.ObservableTransitionState
|
||||
import com.android.systemui.scene.shared.model.RemoteUserInput
|
||||
import com.android.systemui.scene.shared.model.SceneKey
|
||||
@@ -41,6 +42,7 @@ class SceneInteractor
|
||||
@Inject
|
||||
constructor(
|
||||
private val repository: SceneContainerRepository,
|
||||
private val logger: SceneLogger,
|
||||
) {
|
||||
|
||||
/**
|
||||
@@ -54,8 +56,17 @@ constructor(
|
||||
}
|
||||
|
||||
/** Sets the scene in the container with the given name. */
|
||||
fun setCurrentScene(scene: SceneModel) {
|
||||
fun setCurrentScene(scene: SceneModel, loggingReason: String) {
|
||||
val currentSceneKey = repository.currentScene.value.key
|
||||
if (currentSceneKey == scene.key) {
|
||||
return
|
||||
}
|
||||
|
||||
logger.logSceneChange(
|
||||
from = currentSceneKey,
|
||||
to = scene.key,
|
||||
reason = loggingReason,
|
||||
)
|
||||
repository.setCurrentScene(scene)
|
||||
repository.setSceneTransition(from = currentSceneKey, to = scene.key)
|
||||
}
|
||||
@@ -64,7 +75,17 @@ constructor(
|
||||
val currentScene: StateFlow<SceneModel> = repository.currentScene
|
||||
|
||||
/** Sets the visibility of the container with the given name. */
|
||||
fun setVisible(isVisible: Boolean) {
|
||||
fun setVisible(isVisible: Boolean, loggingReason: String) {
|
||||
val wasVisible = repository.isVisible.value
|
||||
if (wasVisible == isVisible) {
|
||||
return
|
||||
}
|
||||
|
||||
logger.logVisibilityChange(
|
||||
from = wasVisible,
|
||||
to = isVisible,
|
||||
reason = loggingReason,
|
||||
)
|
||||
return repository.setVisible(isVisible)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.android.systemui.keyguard.shared.model.WakefulnessState
|
||||
import com.android.systemui.model.SysUiState
|
||||
import com.android.systemui.model.updateFlags
|
||||
import com.android.systemui.scene.domain.interactor.SceneInteractor
|
||||
import com.android.systemui.scene.shared.logger.SceneLogger
|
||||
import com.android.systemui.scene.shared.model.SceneKey
|
||||
import com.android.systemui.scene.shared.model.SceneModel
|
||||
import com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_BOUNCER_SHOWING
|
||||
@@ -57,13 +58,17 @@ constructor(
|
||||
private val featureFlags: FeatureFlags,
|
||||
private val sysUiState: SysUiState,
|
||||
@DisplayId private val displayId: Int,
|
||||
private val sceneLogger: SceneLogger,
|
||||
) : CoreStartable {
|
||||
|
||||
override fun start() {
|
||||
if (featureFlags.isEnabled(Flags.SCENE_CONTAINER)) {
|
||||
sceneLogger.logFrameworkEnabled(isEnabled = true)
|
||||
hydrateVisibility()
|
||||
automaticallySwitchScenes()
|
||||
hydrateSystemUiState()
|
||||
} else {
|
||||
sceneLogger.logFrameworkEnabled(isEnabled = false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +78,9 @@ constructor(
|
||||
sceneInteractor.currentScene
|
||||
.map { it.key }
|
||||
.distinctUntilChanged()
|
||||
.collect { sceneKey -> sceneInteractor.setVisible(sceneKey != SceneKey.Gone) }
|
||||
.collect { sceneKey ->
|
||||
sceneInteractor.setVisible(sceneKey != SceneKey.Gone, "scene is $sceneKey")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +95,17 @@ constructor(
|
||||
isUnlocked ->
|
||||
when (currentSceneKey) {
|
||||
// When the device becomes unlocked in Bouncer, go to Gone.
|
||||
is SceneKey.Bouncer -> SceneKey.Gone
|
||||
is SceneKey.Bouncer ->
|
||||
SceneKey.Gone to "device unlocked in Bouncer scene"
|
||||
// When the device becomes unlocked in Lockscreen, go to Gone if
|
||||
// bypass is enabled.
|
||||
is SceneKey.Lockscreen -> SceneKey.Gone.takeIf { isBypassEnabled }
|
||||
is SceneKey.Lockscreen ->
|
||||
if (isBypassEnabled) {
|
||||
SceneKey.Gone to
|
||||
"device unlocked in Lockscreen scene with bypass"
|
||||
} else {
|
||||
null
|
||||
}
|
||||
// We got unlocked while on a scene that's not Lockscreen or
|
||||
// Bouncer, no need to change scenes.
|
||||
else -> null
|
||||
@@ -104,13 +118,19 @@ constructor(
|
||||
is SceneKey.Bouncer -> null
|
||||
// We got locked while on a scene that's not Lockscreen or Bouncer,
|
||||
// go to Lockscreen.
|
||||
else -> SceneKey.Lockscreen
|
||||
else ->
|
||||
SceneKey.Lockscreen to "device locked in $currentSceneKey scene"
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
.filterNotNull()
|
||||
.collect { targetSceneKey -> switchToScene(targetSceneKey) }
|
||||
.collect { (targetSceneKey, loggingReason) ->
|
||||
switchToScene(
|
||||
targetSceneKey = targetSceneKey,
|
||||
loggingReason = loggingReason,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
applicationScope.launch {
|
||||
@@ -121,7 +141,16 @@ constructor(
|
||||
if (isAsleep) {
|
||||
// When the device goes to sleep, reset the current scene.
|
||||
val isUnlocked = authenticationInteractor.isUnlocked.value
|
||||
switchToScene(if (isUnlocked) SceneKey.Gone else SceneKey.Lockscreen)
|
||||
val (targetSceneKey, loggingReason) =
|
||||
if (isUnlocked) {
|
||||
SceneKey.Gone to "device is asleep while unlocked"
|
||||
} else {
|
||||
SceneKey.Lockscreen to "device is asleep while locked"
|
||||
}
|
||||
switchToScene(
|
||||
targetSceneKey = targetSceneKey,
|
||||
loggingReason = loggingReason,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,9 +176,10 @@ constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchToScene(targetSceneKey: SceneKey) {
|
||||
private fun switchToScene(targetSceneKey: SceneKey, loggingReason: String) {
|
||||
sceneInteractor.setCurrentScene(
|
||||
scene = SceneModel(targetSceneKey),
|
||||
loggingReason = loggingReason,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2023 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.scene.shared.logger
|
||||
|
||||
import com.android.systemui.log.LogBuffer
|
||||
import com.android.systemui.log.core.LogLevel
|
||||
import com.android.systemui.log.dagger.SceneFrameworkLog
|
||||
import com.android.systemui.scene.shared.model.SceneKey
|
||||
import javax.inject.Inject
|
||||
|
||||
class SceneLogger @Inject constructor(@SceneFrameworkLog private val logBuffer: LogBuffer) {
|
||||
|
||||
fun logFrameworkEnabled(isEnabled: Boolean) {
|
||||
fun asWord(isEnabled: Boolean): String {
|
||||
return if (isEnabled) "enabled" else "disabled"
|
||||
}
|
||||
|
||||
logBuffer.log(
|
||||
tag = TAG,
|
||||
level = LogLevel.INFO,
|
||||
messageInitializer = { bool1 = isEnabled },
|
||||
messagePrinter = { "Scene framework is ${asWord(bool1)}" }
|
||||
)
|
||||
}
|
||||
|
||||
fun logSceneChange(
|
||||
from: SceneKey,
|
||||
to: SceneKey,
|
||||
reason: String,
|
||||
) {
|
||||
logBuffer.log(
|
||||
tag = TAG,
|
||||
level = LogLevel.INFO,
|
||||
messageInitializer = {
|
||||
str1 = from.toString()
|
||||
str2 = to.toString()
|
||||
str3 = reason
|
||||
},
|
||||
messagePrinter = { "$str1 → $str2, reason: $str3" },
|
||||
)
|
||||
}
|
||||
|
||||
fun logVisibilityChange(
|
||||
from: Boolean,
|
||||
to: Boolean,
|
||||
reason: String,
|
||||
) {
|
||||
fun asWord(isVisible: Boolean): String {
|
||||
return if (isVisible) "visible" else "invisible"
|
||||
}
|
||||
|
||||
logBuffer.log(
|
||||
tag = TAG,
|
||||
level = LogLevel.INFO,
|
||||
messageInitializer = {
|
||||
str1 = asWord(from)
|
||||
str2 = asWord(to)
|
||||
str3 = reason
|
||||
},
|
||||
messagePrinter = { "$str1 → $str2, reason: $str3" },
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "SceneFramework"
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,10 @@ constructor(
|
||||
|
||||
/** Requests a transition to the scene with the given key. */
|
||||
fun setCurrentScene(scene: SceneModel) {
|
||||
interactor.setCurrentScene(scene)
|
||||
interactor.setCurrentScene(
|
||||
scene = scene,
|
||||
loggingReason = SCENE_TRANSITION_LOGGING_REASON,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,4 +72,8 @@ constructor(
|
||||
fun onRemoteUserInput(event: MotionEvent) {
|
||||
interactor.onRemoteUserInput(RemoteUserInput.translateMotionEvent(event))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val SCENE_TRANSITION_LOGGING_REASON = "user input"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,10 +150,10 @@ class PhoneStatusBarViewController private constructor(
|
||||
fun onTouch(event: MotionEvent) {
|
||||
if (centralSurfaces.statusBarWindowState == WINDOW_STATE_SHOWING) {
|
||||
val upOrCancel =
|
||||
event.action == MotionEvent.ACTION_UP ||
|
||||
event.action == MotionEvent.ACTION_UP ||
|
||||
event.action == MotionEvent.ACTION_CANCEL
|
||||
centralSurfaces.setInteracting(WINDOW_STATUS_BAR,
|
||||
!upOrCancel || shadeController.isExpandedVisible)
|
||||
!upOrCancel || shadeController.isExpandedVisible)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ class PhoneStatusBarViewController private constructor(
|
||||
if (!centralSurfaces.commandQueuePanelsEnabled) {
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
Log.v(TAG, String.format("onTouchForwardedFromStatusBar: panel disabled, " +
|
||||
"ignoring touch at (${event.x.toInt()},${event.y.toInt()})"))
|
||||
"ignoring touch at (${event.x.toInt()},${event.y.toInt()})"))
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -182,7 +182,7 @@ class PhoneStatusBarViewController private constructor(
|
||||
sceneInteractor.get()
|
||||
.onRemoteUserInput(RemoteUserInput.translateMotionEvent(event))
|
||||
// TODO(b/291965119): remove once view is expanded to cover the status bar
|
||||
sceneInteractor.get().setVisible(true)
|
||||
sceneInteractor.get().setVisible(true, "swipe down from status bar")
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -191,11 +191,11 @@ class PhoneStatusBarViewController private constructor(
|
||||
// bar eat the gesture.
|
||||
if (!shadeViewController.isViewEnabled) {
|
||||
shadeLogger.logMotionEvent(event,
|
||||
"onTouchForwardedFromStatusBar: panel view disabled")
|
||||
"onTouchForwardedFromStatusBar: panel view disabled")
|
||||
return true
|
||||
}
|
||||
if (shadeViewController.isFullyCollapsed &&
|
||||
event.y < 1f) {
|
||||
event.y < 1f) {
|
||||
// b/235889526 Eat events on the top edge of the phone when collapsed
|
||||
shadeLogger.logMotionEvent(event, "top edge touch ignored")
|
||||
return true
|
||||
@@ -257,27 +257,27 @@ class PhoneStatusBarViewController private constructor(
|
||||
view: PhoneStatusBarView
|
||||
): PhoneStatusBarViewController {
|
||||
val statusBarMoveFromCenterAnimationController =
|
||||
if (featureFlags.isEnabled(Flags.ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS)) {
|
||||
unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
if (featureFlags.isEnabled(Flags.ENABLE_UNFOLD_STATUS_BAR_ANIMATIONS)) {
|
||||
unfoldComponent.getOrNull()?.getStatusBarMoveFromCenterAnimationController()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
return PhoneStatusBarViewController(
|
||||
view,
|
||||
progressProvider.getOrNull(),
|
||||
centralSurfaces,
|
||||
shadeController,
|
||||
shadeViewController,
|
||||
sceneInteractor,
|
||||
shadeLogger,
|
||||
statusBarMoveFromCenterAnimationController,
|
||||
userChipViewModel,
|
||||
viewUtil,
|
||||
featureFlags,
|
||||
configurationController,
|
||||
statusOverlayHoverListenerFactory,
|
||||
view,
|
||||
progressProvider.getOrNull(),
|
||||
centralSurfaces,
|
||||
shadeController,
|
||||
shadeViewController,
|
||||
sceneInteractor,
|
||||
shadeLogger,
|
||||
statusBarMoveFromCenterAnimationController,
|
||||
userChipViewModel,
|
||||
viewUtil,
|
||||
featureFlags,
|
||||
configurationController,
|
||||
statusOverlayHoverListenerFactory,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,20 +733,20 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
|
||||
// is
|
||||
// not enough to trigger a dismissal of the keyguard.
|
||||
underTest.onViewAttached()
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null), "reason")
|
||||
runCurrent()
|
||||
verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
|
||||
|
||||
// While listening, going from the bouncer scene to the gone scene, does dismiss the
|
||||
// keyguard.
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null), "reason")
|
||||
runCurrent()
|
||||
verify(viewMediatorCallback).keyguardDone(anyBoolean(), anyInt())
|
||||
|
||||
// While listening, moving back to the bouncer scene does not dismiss the keyguard
|
||||
// again.
|
||||
clearInvocations(viewMediatorCallback)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null), "reason")
|
||||
runCurrent()
|
||||
verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
|
||||
|
||||
@@ -754,12 +754,12 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
|
||||
// scene
|
||||
// does not dismiss the keyguard while we're not listening.
|
||||
underTest.onViewDetached()
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null), "reason")
|
||||
runCurrent()
|
||||
verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
|
||||
|
||||
// While not listening, moving back to the bouncer does not dismiss the keyguard.
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer, null), "reason")
|
||||
runCurrent()
|
||||
verify(viewMediatorCallback, never()).keyguardDone(anyBoolean(), anyInt())
|
||||
|
||||
@@ -767,7 +767,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
|
||||
// gone
|
||||
// scene now does dismiss the keyguard again.
|
||||
underTest.onViewAttached()
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone, null), "reason")
|
||||
runCurrent()
|
||||
verify(viewMediatorCallback).keyguardDone(anyBoolean(), anyInt())
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Password
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
|
||||
underTest.onShown()
|
||||
@@ -99,7 +99,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Password
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
runCurrent()
|
||||
@@ -119,7 +119,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Password
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onPasswordInputChanged("password")
|
||||
@@ -139,7 +139,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Password
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onPasswordInputChanged("wrong")
|
||||
@@ -161,7 +161,7 @@ class PasswordBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Password
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onPasswordInputChanged("wrong")
|
||||
|
||||
@@ -83,7 +83,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Pattern
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
|
||||
underTest.onShown()
|
||||
@@ -105,7 +105,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Pattern
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
runCurrent()
|
||||
@@ -128,7 +128,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Pattern
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onDragStart()
|
||||
@@ -176,7 +176,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Pattern
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onDragStart()
|
||||
@@ -208,7 +208,7 @@ class PatternBouncerViewModelTest : SysuiTestCase() {
|
||||
AuthenticationMethodModel.Pattern
|
||||
)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onDragStart()
|
||||
|
||||
@@ -79,7 +79,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val message by collectLastValue(bouncerViewModel.message)
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
|
||||
underTest.onShown()
|
||||
@@ -97,7 +97,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
runCurrent()
|
||||
@@ -117,7 +117,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
runCurrent()
|
||||
@@ -138,7 +138,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
|
||||
@@ -161,7 +161,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
runCurrent()
|
||||
@@ -183,7 +183,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val currentScene by collectLastValue(sceneInteractor.currentScene)
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
|
||||
@@ -203,7 +203,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onPinButtonClicked(1)
|
||||
@@ -227,7 +227,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
val pin by collectLastValue(underTest.pinInput.map { it.getPin() })
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
underTest.onPinButtonClicked(1)
|
||||
@@ -258,7 +258,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
utils.authenticationRepository.setAutoConfirmEnabled(true)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
FakeAuthenticationRepository.DEFAULT_PIN.forEach { digit ->
|
||||
@@ -277,7 +277,7 @@ class PinBouncerViewModelTest : SysuiTestCase() {
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
utils.authenticationRepository.setUnlocked(false)
|
||||
utils.authenticationRepository.setAutoConfirmEnabled(true)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Bouncer), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Bouncer))
|
||||
underTest.onShown()
|
||||
FakeAuthenticationRepository.DEFAULT_PIN.dropLast(1).forEach { digit ->
|
||||
|
||||
@@ -130,11 +130,11 @@ class LockscreenSceneInteractorTest : SysuiTestCase() {
|
||||
fun switchFromLockScreenToGone_authMethodNotSwipe_doesNotUnlockDevice() =
|
||||
testScope.runTest {
|
||||
val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked)
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Lockscreen))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Lockscreen), "reason")
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Pin)
|
||||
assertThat(isUnlocked).isFalse()
|
||||
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone), "reason")
|
||||
|
||||
assertThat(isUnlocked).isFalse()
|
||||
}
|
||||
@@ -144,13 +144,13 @@ class LockscreenSceneInteractorTest : SysuiTestCase() {
|
||||
testScope.runTest {
|
||||
val isUnlocked by collectLastValue(authenticationInteractor.isUnlocked)
|
||||
runCurrent()
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade), "reason")
|
||||
runCurrent()
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
|
||||
runCurrent()
|
||||
assertThat(isUnlocked).isFalse()
|
||||
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone), "reason")
|
||||
|
||||
assertThat(isUnlocked).isFalse()
|
||||
}
|
||||
@@ -161,7 +161,7 @@ class LockscreenSceneInteractorTest : SysuiTestCase() {
|
||||
val currentScene by collectLastValue(sceneInteractor.currentScene)
|
||||
utils.authenticationRepository.setAuthenticationMethod(AuthenticationMethodModel.Swipe)
|
||||
runCurrent()
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.QuickSettings))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.QuickSettings), "reason")
|
||||
runCurrent()
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.QuickSettings))
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class SceneInteractorTest : SysuiTestCase() {
|
||||
val currentScene by collectLastValue(underTest.currentScene)
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Lockscreen))
|
||||
|
||||
underTest.setCurrentScene(SceneModel(SceneKey.Shade))
|
||||
underTest.setCurrentScene(SceneModel(SceneKey.Shade), "reason")
|
||||
assertThat(currentScene).isEqualTo(SceneModel(SceneKey.Shade))
|
||||
}
|
||||
|
||||
@@ -79,10 +79,10 @@ class SceneInteractorTest : SysuiTestCase() {
|
||||
val isVisible by collectLastValue(underTest.isVisible)
|
||||
assertThat(isVisible).isTrue()
|
||||
|
||||
underTest.setVisible(false)
|
||||
underTest.setVisible(false, "reason")
|
||||
assertThat(isVisible).isFalse()
|
||||
|
||||
underTest.setVisible(true)
|
||||
underTest.setVisible(true, "reason")
|
||||
assertThat(isVisible).isTrue()
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class SceneInteractorTest : SysuiTestCase() {
|
||||
assertThat(transitions).isNull()
|
||||
|
||||
val initialSceneKey = underTest.currentScene.value.key
|
||||
underTest.setCurrentScene(SceneModel(SceneKey.Shade))
|
||||
underTest.setCurrentScene(SceneModel(SceneKey.Shade), "reason")
|
||||
assertThat(transitions)
|
||||
.isEqualTo(
|
||||
SceneTransitionModel(
|
||||
@@ -101,7 +101,7 @@ class SceneInteractorTest : SysuiTestCase() {
|
||||
)
|
||||
)
|
||||
|
||||
underTest.setCurrentScene(SceneModel(SceneKey.QuickSettings))
|
||||
underTest.setCurrentScene(SceneModel(SceneKey.QuickSettings), "reason")
|
||||
assertThat(transitions)
|
||||
.isEqualTo(
|
||||
SceneTransitionModel(
|
||||
|
||||
@@ -73,6 +73,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
|
||||
featureFlags = featureFlags,
|
||||
sysUiState = sysUiState,
|
||||
displayId = Display.DEFAULT_DISPLAY,
|
||||
sceneLogger = mock(),
|
||||
)
|
||||
|
||||
@Before
|
||||
@@ -97,7 +98,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
|
||||
|
||||
assertThat(isVisible).isFalse()
|
||||
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade), "reason")
|
||||
assertThat(isVisible).isTrue()
|
||||
}
|
||||
|
||||
@@ -117,10 +118,10 @@ class SceneContainerStartableTest : SysuiTestCase() {
|
||||
underTest.start()
|
||||
assertThat(isVisible).isTrue()
|
||||
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Gone), "reason")
|
||||
assertThat(isVisible).isTrue()
|
||||
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade))
|
||||
sceneInteractor.setCurrentScene(SceneModel(SceneKey.Shade), "reason")
|
||||
assertThat(isVisible).isTrue()
|
||||
}
|
||||
|
||||
@@ -326,7 +327,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
|
||||
SceneKey.QuickSettings,
|
||||
)
|
||||
.forEachIndexed { index, sceneKey ->
|
||||
sceneInteractor.setCurrentScene(SceneModel(sceneKey))
|
||||
sceneInteractor.setCurrentScene(SceneModel(sceneKey), "reason")
|
||||
runCurrent()
|
||||
|
||||
verify(sysUiState, times(index + 1)).commitUpdate(Display.DEFAULT_DISPLAY)
|
||||
@@ -342,7 +343,7 @@ class SceneContainerStartableTest : SysuiTestCase() {
|
||||
featureFlags.set(Flags.SCENE_CONTAINER, isFeatureEnabled)
|
||||
authenticationRepository.setUnlocked(isDeviceUnlocked)
|
||||
keyguardRepository.setBypassEnabled(isBypassEnabled)
|
||||
initialSceneKey?.let { sceneInteractor.setCurrentScene(SceneModel(it)) }
|
||||
initialSceneKey?.let { sceneInteractor.setCurrentScene(SceneModel(it), "reason") }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -52,10 +52,10 @@ class SceneContainerViewModelTest : SysuiTestCase() {
|
||||
val isVisible by collectLastValue(underTest.isVisible)
|
||||
assertThat(isVisible).isTrue()
|
||||
|
||||
interactor.setVisible(false)
|
||||
interactor.setVisible(false, "reason")
|
||||
assertThat(isVisible).isFalse()
|
||||
|
||||
interactor.setVisible(true)
|
||||
interactor.setVisible(true, "reason")
|
||||
assertThat(isVisible).isTrue()
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ class SceneTestUtils(
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val context = test.context
|
||||
|
||||
fun fakeSceneContainerRepository(
|
||||
@@ -124,6 +125,7 @@ class SceneTestUtils(
|
||||
): SceneInteractor {
|
||||
return SceneInteractor(
|
||||
repository = repository,
|
||||
logger = mock(),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user