Merge changes I838b4797,I9fce3bb8,Ia081a0ad into udc-dev
* changes: Set initial message after Set lockout in onResume. Revert "Set lockout in onResume."
This commit is contained in:
@@ -107,14 +107,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
// start fresh
|
||||
mDismissing = false;
|
||||
mView.resetPasswordText(false /* animate */, false /* announce */);
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (shouldLockout(deadline)) {
|
||||
handleAttemptLockout(deadline);
|
||||
} else {
|
||||
resetState();
|
||||
}
|
||||
resetState();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,7 +270,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
mResumed = true;
|
||||
reset();
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (shouldLockout(deadline)) {
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -260,20 +260,18 @@ public class KeyguardPatternViewController
|
||||
mLockPatternView.setEnabled(true);
|
||||
mLockPatternView.clearPattern();
|
||||
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (deadline != 0) {
|
||||
handleAttemptLockout(deadline);
|
||||
} else {
|
||||
displayDefaultSecurityMessage();
|
||||
}
|
||||
displayDefaultSecurityMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
super.onResume(reason);
|
||||
reset();
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (deadline != 0) {
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -300,34 +298,38 @@ public class KeyguardPatternViewController
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
/// TODO: move all this logic into the MessageAreaController?
|
||||
int resId = 0;
|
||||
switch (reason) {
|
||||
case PROMPT_REASON_RESTART:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_restart_pattern);
|
||||
resId = R.string.kg_prompt_reason_restart_pattern;
|
||||
break;
|
||||
case PROMPT_REASON_TIMEOUT:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
resId = R.string.kg_prompt_reason_timeout_pattern;
|
||||
break;
|
||||
case PROMPT_REASON_DEVICE_ADMIN:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_device_admin);
|
||||
resId = R.string.kg_prompt_reason_device_admin;
|
||||
break;
|
||||
case PROMPT_REASON_USER_REQUEST:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_user_request);
|
||||
resId = R.string.kg_prompt_reason_user_request;
|
||||
break;
|
||||
case PROMPT_REASON_PREPARE_FOR_UPDATE:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
resId = R.string.kg_prompt_reason_timeout_pattern;
|
||||
break;
|
||||
case PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
resId = R.string.kg_prompt_reason_timeout_pattern;
|
||||
break;
|
||||
case PROMPT_REASON_TRUSTAGENT_EXPIRED:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
resId = R.string.kg_prompt_reason_timeout_pattern;
|
||||
break;
|
||||
case PROMPT_REASON_NONE:
|
||||
break;
|
||||
default:
|
||||
mMessageAreaController.setMessage(R.string.kg_prompt_reason_timeout_pattern);
|
||||
resId = R.string.kg_prompt_reason_timeout_pattern;
|
||||
break;
|
||||
}
|
||||
if (resId != 0) {
|
||||
mMessageAreaController.setMessage(getResources().getText(resId), /* animate= */ false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,6 +40,7 @@ import android.metrics.LogMaker;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.MathUtils;
|
||||
import android.util.Slog;
|
||||
@@ -64,6 +65,7 @@ import com.android.keyguard.KeyguardSecurityContainer.BouncerUiEvent;
|
||||
import com.android.keyguard.KeyguardSecurityContainer.SwipeListener;
|
||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||
import com.android.keyguard.dagger.KeyguardBouncerScope;
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
import com.android.systemui.Gefingerpoken;
|
||||
import com.android.systemui.R;
|
||||
@@ -634,6 +636,16 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
mKeyguardStateController.isFaceAuthEnabled());
|
||||
}
|
||||
|
||||
/** Sets an initial message that would override the default message */
|
||||
public void setInitialMessage() {
|
||||
CharSequence customMessage = mViewMediatorCallback.consumeCustomMessage();
|
||||
if (!TextUtils.isEmpty(customMessage)) {
|
||||
showMessage(customMessage, Utils.getColorError(getContext()));
|
||||
return;
|
||||
}
|
||||
showPromptReason(mViewMediatorCallback.getBouncerPromptReason());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the bouncer and start appear animations.
|
||||
*
|
||||
|
||||
@@ -65,8 +65,6 @@ interface KeyguardBouncerRepository {
|
||||
val keyguardAuthenticated: StateFlow<Boolean?>
|
||||
val showMessage: StateFlow<BouncerShowMessageModel?>
|
||||
val resourceUpdateRequests: StateFlow<Boolean>
|
||||
val bouncerPromptReason: Int
|
||||
val bouncerErrorMessage: CharSequence?
|
||||
val alternateBouncerVisible: StateFlow<Boolean>
|
||||
val alternateBouncerUIAvailable: StateFlow<Boolean>
|
||||
val sideFpsShowing: StateFlow<Boolean>
|
||||
@@ -145,11 +143,6 @@ constructor(
|
||||
override val showMessage = _showMessage.asStateFlow()
|
||||
private val _resourceUpdateRequests = MutableStateFlow(false)
|
||||
override val resourceUpdateRequests = _resourceUpdateRequests.asStateFlow()
|
||||
override val bouncerPromptReason: Int
|
||||
get() = viewMediatorCallback.bouncerPromptReason
|
||||
override val bouncerErrorMessage: CharSequence?
|
||||
get() = viewMediatorCallback.consumeCustomMessage()
|
||||
|
||||
/** Values associated with the AlternateBouncer */
|
||||
private val _alternateBouncerVisible = MutableStateFlow(false)
|
||||
override val alternateBouncerVisible = _alternateBouncerVisible.asStateFlow()
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.android.keyguard.KeyguardConstants
|
||||
import com.android.keyguard.KeyguardSecurityModel
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||
import com.android.settingslib.Utils
|
||||
import com.android.systemui.DejankUtils
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.classifier.FalsingCollector
|
||||
@@ -42,12 +41,12 @@ import com.android.systemui.plugins.ActivityStarter
|
||||
import com.android.systemui.shared.system.SysUiStatsLog
|
||||
import com.android.systemui.statusbar.phone.KeyguardBypassController
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController
|
||||
import javax.inject.Inject
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.map
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Encapsulates business logic for interacting with the lock-screen primary (pin/pattern/password)
|
||||
@@ -82,12 +81,6 @@ constructor(
|
||||
/** Runnable to show the primary bouncer. */
|
||||
val showRunnable = Runnable {
|
||||
repository.setPrimaryShow(true)
|
||||
primaryBouncerView.delegate?.showPromptReason(repository.bouncerPromptReason)
|
||||
(repository.bouncerErrorMessage as? String)?.let {
|
||||
repository.setShowMessage(
|
||||
BouncerShowMessageModel(message = it, Utils.getColorError(context))
|
||||
)
|
||||
}
|
||||
repository.setPrimaryShowingSoon(false)
|
||||
primaryBouncerCallbackInteractor.dispatchVisibilityChanged(View.VISIBLE)
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ object KeyguardBouncerViewBinder {
|
||||
securityContainerController.showPrimarySecurityScreen(
|
||||
/* turningOff= */ false
|
||||
)
|
||||
securityContainerController.setInitialMessage()
|
||||
securityContainerController.appear()
|
||||
securityContainerController.onResume(
|
||||
KeyguardSecurityView.SCREEN_ON
|
||||
|
||||
@@ -152,19 +152,16 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testReset() {
|
||||
mKeyguardAbsKeyInputViewController.reset();
|
||||
verify(mKeyguardMessageAreaController).setMessage("", false);
|
||||
verify(mAbsKeyInputView).resetPasswordText(false, false);
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onResume_Reset() {
|
||||
public void testResume() {
|
||||
mKeyguardAbsKeyInputViewController.onResume(KeyguardSecurityView.VIEW_REVEALED);
|
||||
verify(mKeyguardMessageAreaController).setMessage("", false);
|
||||
verify(mAbsKeyInputView).resetPasswordText(false, false);
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,23 +121,9 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun reset() {
|
||||
mKeyguardPatternViewController.reset()
|
||||
verify(mLockPatternView).setInStealthMode(anyBoolean())
|
||||
verify(mLockPatternView).enableInput()
|
||||
verify(mLockPatternView).setEnabled(true)
|
||||
verify(mLockPatternView).clearPattern()
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resume() {
|
||||
mKeyguardPatternViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||
verify(mLockPatternView).setInStealthMode(anyBoolean())
|
||||
verify(mLockPatternView).enableInput()
|
||||
verify(mLockPatternView).setEnabled(true)
|
||||
verify(mLockPatternView).clearPattern()
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ class FakeKeyguardBouncerRepository : KeyguardBouncerRepository {
|
||||
override val showMessage = _showMessage.asStateFlow()
|
||||
private val _resourceUpdateRequests = MutableStateFlow(false)
|
||||
override val resourceUpdateRequests = _resourceUpdateRequests.asStateFlow()
|
||||
override val bouncerPromptReason = 0
|
||||
override val bouncerErrorMessage: CharSequence? = null
|
||||
private val _isAlternateBouncerVisible = MutableStateFlow(false)
|
||||
override val alternateBouncerVisible = _isAlternateBouncerVisible.asStateFlow()
|
||||
override var lastAlternateBouncerVisibleTime: Long = 0L
|
||||
|
||||
Reference in New Issue
Block a user