Merge "Merge "[Bouncer] Set message for dismiss api." into tm-qpr-dev am: d4286fa1a8" into tm-qpr-dev-plus-aosp am: efa222dc06
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20427569 Change-Id: I5d395e3f354e1b8cdf97302034f64fcd978fb4aa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
@@ -152,7 +153,9 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
}
|
||||
|
||||
public void startAppearAnimation() {
|
||||
mMessageAreaController.setMessage(getInitialMessageResId());
|
||||
if (TextUtils.isEmpty(mMessageAreaController.getMessage())) {
|
||||
mMessageAreaController.setMessage(getInitialMessageResId());
|
||||
}
|
||||
mView.startAppearAnimation();
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,11 @@ public class KeyguardMessageAreaController<T extends KeyguardMessageArea>
|
||||
mView.setNextMessageColor(colorState);
|
||||
}
|
||||
|
||||
/** Returns the message of the underlying TextView. */
|
||||
public CharSequence getMessage() {
|
||||
return mView.getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload colors from resources.
|
||||
**/
|
||||
|
||||
@@ -16,9 +16,7 @@
|
||||
|
||||
package com.android.systemui.keyguard.data.repository
|
||||
|
||||
import android.hardware.biometrics.BiometricSourceType
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||
import com.android.keyguard.ViewMediatorCallback
|
||||
import com.android.systemui.dagger.SysUISingleton
|
||||
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
|
||||
@@ -70,33 +68,15 @@ constructor(
|
||||
private val _keyguardAuthenticated = MutableStateFlow<Boolean?>(null)
|
||||
/** Determines if user is already unlocked */
|
||||
val keyguardAuthenticated = _keyguardAuthenticated.asStateFlow()
|
||||
|
||||
var bouncerPromptReason: Int? = null
|
||||
private val _showMessage = MutableStateFlow<BouncerShowMessageModel?>(null)
|
||||
val showMessage = _showMessage.asStateFlow()
|
||||
private val _resourceUpdateRequests = MutableStateFlow(false)
|
||||
val resourceUpdateRequests = _resourceUpdateRequests.asStateFlow()
|
||||
|
||||
val bouncerPromptReason: Int
|
||||
get() = viewMediatorCallback.bouncerPromptReason
|
||||
val bouncerErrorMessage: CharSequence?
|
||||
get() = viewMediatorCallback.consumeCustomMessage()
|
||||
|
||||
init {
|
||||
val callback =
|
||||
object : KeyguardUpdateMonitorCallback() {
|
||||
override fun onStrongAuthStateChanged(userId: Int) {
|
||||
bouncerPromptReason = viewMediatorCallback.bouncerPromptReason
|
||||
}
|
||||
|
||||
override fun onLockedOutStateChanged(type: BiometricSourceType) {
|
||||
if (type == BiometricSourceType.FINGERPRINT) {
|
||||
bouncerPromptReason = viewMediatorCallback.bouncerPromptReason
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keyguardUpdateMonitor.registerCallback(callback)
|
||||
}
|
||||
|
||||
fun setPrimaryScrimmed(isScrimmed: Boolean) {
|
||||
_primaryBouncerScrimmed.value = isScrimmed
|
||||
}
|
||||
|
||||
@@ -94,6 +94,10 @@ object KeyguardBouncerViewBinder {
|
||||
viewModel.setBouncerViewDelegate(delegate)
|
||||
launch {
|
||||
viewModel.show.collect {
|
||||
hostViewController.showPromptReason(it.promptReason)
|
||||
it.errorMessage?.let { errorMessage ->
|
||||
hostViewController.showErrorMessage(errorMessage)
|
||||
}
|
||||
hostViewController.showPrimarySecurityScreen()
|
||||
hostViewController.appear(
|
||||
SystemBarUtils.getStatusBarHeight(view.context)
|
||||
@@ -101,18 +105,6 @@ object KeyguardBouncerViewBinder {
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
viewModel.showPromptReason.collect { prompt ->
|
||||
hostViewController.showPromptReason(prompt)
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
viewModel.showBouncerErrorMessage.collect { errorMessage ->
|
||||
hostViewController.showErrorMessage(errorMessage)
|
||||
}
|
||||
}
|
||||
|
||||
launch {
|
||||
viewModel.showWithFullExpansion.collect { model ->
|
||||
hostViewController.resetSecurityContainer()
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer.EXPANSION_VISIBLE
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
/** Models UI state for the lock screen bouncer; handles user input. */
|
||||
@@ -45,13 +44,6 @@ constructor(
|
||||
/** Observe whether bouncer is showing. */
|
||||
val show: Flow<KeyguardBouncerModel> = interactor.show
|
||||
|
||||
/** Observe bouncer prompt when bouncer is showing. */
|
||||
val showPromptReason: Flow<Int> = interactor.show.map { it.promptReason }
|
||||
|
||||
/** Observe bouncer error message when bouncer is showing. */
|
||||
val showBouncerErrorMessage: Flow<CharSequence> =
|
||||
interactor.show.map { it.errorMessage }.filterNotNull()
|
||||
|
||||
/** Observe visible expansion when bouncer is showing. */
|
||||
val showWithFullExpansion: Flow<KeyguardBouncerModel> =
|
||||
interactor.show.filter { it.expansionAmount == EXPANSION_VISIBLE }
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
@@ -90,4 +93,11 @@ public class KeyguardMessageAreaControllerTest extends SysuiTestCase {
|
||||
mMessageAreaController.setIsVisible(true);
|
||||
verify(mKeyguardMessageArea).setIsVisible(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessage() {
|
||||
String msg = "abc";
|
||||
when(mKeyguardMessageArea.getText()).thenReturn(msg);
|
||||
assertThat(mMessageAreaController.getMessage()).isEqualTo(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.MockitoAnnotations
|
||||
@@ -118,4 +119,14 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
|
||||
keyguardPasswordViewController.startAppearAnimation()
|
||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_password)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withExistingMessage() {
|
||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
keyguardPasswordViewController.startAppearAnimation()
|
||||
verify(
|
||||
mKeyguardMessageAreaController,
|
||||
never()
|
||||
).setMessage(R.string.keyguard_enter_your_password)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
@SmallTest
|
||||
@@ -112,4 +113,14 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
mKeyguardPatternViewController.startAppearAnimation()
|
||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withExistingMessage() {
|
||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
mKeyguardPatternViewController.startAppearAnimation()
|
||||
verify(
|
||||
mKeyguardMessageAreaController,
|
||||
never()
|
||||
).setMessage(R.string.keyguard_enter_your_password)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,4 +100,12 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
|
||||
pinViewController.startAppearAnimation()
|
||||
verify(keyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pin)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withExistingMessage() {
|
||||
Mockito.`when`(keyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
pinViewController.startAppearAnimation()
|
||||
verify(keyguardMessageAreaController, Mockito.never())
|
||||
.setMessage(R.string.keyguard_enter_your_password)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user