Merge "[Bouncer] Set message for dismiss api." into tm-qpr-dev
This commit is contained in:
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
|
|||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
|
|
||||||
@@ -152,7 +153,9 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startAppearAnimation() {
|
public void startAppearAnimation() {
|
||||||
|
if (TextUtils.isEmpty(mMessageAreaController.getMessage())) {
|
||||||
mMessageAreaController.setMessage(getInitialMessageResId());
|
mMessageAreaController.setMessage(getInitialMessageResId());
|
||||||
|
}
|
||||||
mView.startAppearAnimation();
|
mView.startAppearAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ public class KeyguardMessageAreaController<T extends KeyguardMessageArea>
|
|||||||
mView.setNextMessageColor(colorState);
|
mView.setNextMessageColor(colorState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns the message of the underlying TextView. */
|
||||||
|
public CharSequence getMessage() {
|
||||||
|
return mView.getText();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload colors from resources.
|
* Reload colors from resources.
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -16,9 +16,7 @@
|
|||||||
|
|
||||||
package com.android.systemui.keyguard.data.repository
|
package com.android.systemui.keyguard.data.repository
|
||||||
|
|
||||||
import android.hardware.biometrics.BiometricSourceType
|
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor
|
import com.android.keyguard.KeyguardUpdateMonitor
|
||||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
|
||||||
import com.android.keyguard.ViewMediatorCallback
|
import com.android.keyguard.ViewMediatorCallback
|
||||||
import com.android.systemui.dagger.SysUISingleton
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
|
import com.android.systemui.keyguard.shared.model.BouncerShowMessageModel
|
||||||
@@ -70,33 +68,15 @@ constructor(
|
|||||||
private val _keyguardAuthenticated = MutableStateFlow<Boolean?>(null)
|
private val _keyguardAuthenticated = MutableStateFlow<Boolean?>(null)
|
||||||
/** Determines if user is already unlocked */
|
/** Determines if user is already unlocked */
|
||||||
val keyguardAuthenticated = _keyguardAuthenticated.asStateFlow()
|
val keyguardAuthenticated = _keyguardAuthenticated.asStateFlow()
|
||||||
|
|
||||||
var bouncerPromptReason: Int? = null
|
|
||||||
private val _showMessage = MutableStateFlow<BouncerShowMessageModel?>(null)
|
private val _showMessage = MutableStateFlow<BouncerShowMessageModel?>(null)
|
||||||
val showMessage = _showMessage.asStateFlow()
|
val showMessage = _showMessage.asStateFlow()
|
||||||
private val _resourceUpdateRequests = MutableStateFlow(false)
|
private val _resourceUpdateRequests = MutableStateFlow(false)
|
||||||
val resourceUpdateRequests = _resourceUpdateRequests.asStateFlow()
|
val resourceUpdateRequests = _resourceUpdateRequests.asStateFlow()
|
||||||
|
val bouncerPromptReason: Int
|
||||||
|
get() = viewMediatorCallback.bouncerPromptReason
|
||||||
val bouncerErrorMessage: CharSequence?
|
val bouncerErrorMessage: CharSequence?
|
||||||
get() = viewMediatorCallback.consumeCustomMessage()
|
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) {
|
fun setPrimaryScrimmed(isScrimmed: Boolean) {
|
||||||
_primaryBouncerScrimmed.value = isScrimmed
|
_primaryBouncerScrimmed.value = isScrimmed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,10 @@ object KeyguardBouncerViewBinder {
|
|||||||
viewModel.setBouncerViewDelegate(delegate)
|
viewModel.setBouncerViewDelegate(delegate)
|
||||||
launch {
|
launch {
|
||||||
viewModel.show.collect {
|
viewModel.show.collect {
|
||||||
|
hostViewController.showPromptReason(it.promptReason)
|
||||||
|
it.errorMessage?.let { errorMessage ->
|
||||||
|
hostViewController.showErrorMessage(errorMessage)
|
||||||
|
}
|
||||||
hostViewController.showPrimarySecurityScreen()
|
hostViewController.showPrimarySecurityScreen()
|
||||||
hostViewController.appear(
|
hostViewController.appear(
|
||||||
SystemBarUtils.getStatusBarHeight(view.context)
|
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 {
|
launch {
|
||||||
viewModel.showWithFullExpansion.collect { model ->
|
viewModel.showWithFullExpansion.collect { model ->
|
||||||
hostViewController.resetSecurityContainer()
|
hostViewController.resetSecurityContainer()
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import com.android.systemui.statusbar.phone.KeyguardBouncer.EXPANSION_VISIBLE
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.filterNotNull
|
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
|
|
||||||
/** Models UI state for the lock screen bouncer; handles user input. */
|
/** Models UI state for the lock screen bouncer; handles user input. */
|
||||||
@@ -45,13 +44,6 @@ constructor(
|
|||||||
/** Observe whether bouncer is showing. */
|
/** Observe whether bouncer is showing. */
|
||||||
val show: Flow<KeyguardBouncerModel> = interactor.show
|
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. */
|
/** Observe visible expansion when bouncer is showing. */
|
||||||
val showWithFullExpansion: Flow<KeyguardBouncerModel> =
|
val showWithFullExpansion: Flow<KeyguardBouncerModel> =
|
||||||
interactor.show.filter { it.expansionAmount == EXPANSION_VISIBLE }
|
interactor.show.filter { it.expansionAmount == EXPANSION_VISIBLE }
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.test.suitebuilder.annotation.SmallTest;
|
import android.test.suitebuilder.annotation.SmallTest;
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
@@ -90,4 +93,11 @@ public class KeyguardMessageAreaControllerTest extends SysuiTestCase {
|
|||||||
mMessageAreaController.setIsVisible(true);
|
mMessageAreaController.setIsVisible(true);
|
||||||
verify(mKeyguardMessageArea).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.junit.runner.RunWith
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.Mockito.never
|
import org.mockito.Mockito.never
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
@@ -118,4 +119,14 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
|
|||||||
keyguardPasswordViewController.startAppearAnimation()
|
keyguardPasswordViewController.startAppearAnimation()
|
||||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_password)
|
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.Mock
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
|
import org.mockito.Mockito.never
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@@ -112,4 +113,14 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
|||||||
mKeyguardPatternViewController.startAppearAnimation()
|
mKeyguardPatternViewController.startAppearAnimation()
|
||||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
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()
|
pinViewController.startAppearAnimation()
|
||||||
verify(keyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pin)
|
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