From 1437d59472ca56c8b5b7b6479d729bd9c29a2eff Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Wed, 29 Mar 2023 10:15:54 -0700 Subject: [PATCH 1/3] Revert "Set lockout in onResume." This reverts commit 4dc61959b8138da436ab96e1b2aa744ea4101bd1. Bug: 275079518 Test: fixes sim pin and sim puk Change-Id: Ia081a0ad87df51f654e89460cbeb500ad46ed3fa --- .../KeyguardAbsKeyInputViewController.java | 1 - .../KeyguardPatternViewController.java | 6 ------ ...KeyguardAbsKeyInputViewControllerTest.java | 12 +---------- .../KeyguardPatternViewControllerTest.kt | 21 ------------------- 4 files changed, 1 insertion(+), 39 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index 9f2333d8f4355..f8cb38d7488b9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -277,7 +277,6 @@ public abstract class KeyguardAbsKeyInputViewController Date: Wed, 29 Mar 2023 10:25:14 -0700 Subject: [PATCH 2/3] Set lockout in onResume. If bouncer is locked out, make sure that we check in onresume for all security types. Fixes: 275079518 Test: lock out in pin and pattern. Test: sim pin and sim puk are good to go Change-Id: I9fce3bb8087cd3b47ed57ae0f114b823de980356 --- .../KeyguardAbsKeyInputViewController.java | 15 +++++++-------- .../keyguard/KeyguardPatternViewController.java | 8 ++++++-- .../KeyguardAbsKeyInputViewControllerTest.java | 7 +++++++ .../keyguard/KeyguardPatternViewControllerTest.kt | 7 +++++++ 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index f8cb38d7488b9..1980f70d63a41 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -107,14 +107,7 @@ public abstract class KeyguardAbsKeyInputViewController Date: Wed, 29 Mar 2023 10:46:26 -0700 Subject: [PATCH 3/3] Set initial message after view is inflated. Do not tie it to a stateflow as it can cause multiple messages to show up during show. Fixes: 273402680 Test: with bouncer prompt after restart device. Change-Id: I838b47970278db4911c05278df6fe8c8de02c066 --- .../KeyguardPatternViewController.java | 20 +++++++++++-------- .../KeyguardSecurityContainerController.java | 12 +++++++++++ .../repository/KeyguardBouncerRepository.kt | 7 ------- .../interactor/PrimaryBouncerInteractor.kt | 11 +--------- .../ui/binder/KeyguardBouncerViewBinder.kt | 1 + .../FakeKeyguardBouncerRepository.kt | 2 -- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java index 72333cc9417df..5c56aab9a6112 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternViewController.java @@ -298,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 diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 1a572b729a6e4..85ea028d69602 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -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 val showMessage: StateFlow val resourceUpdateRequests: StateFlow - val bouncerPromptReason: Int - val bouncerErrorMessage: CharSequence? val alternateBouncerVisible: StateFlow val alternateBouncerUIAvailable: StateFlow val sideFpsShowing: StateFlow @@ -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() diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt index 77541e931e08a..24a5b3cd639e0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/PrimaryBouncerInteractor.kt @@ -21,15 +21,12 @@ import android.content.res.ColorStateList import android.hardware.biometrics.BiometricSourceType import android.os.Handler import android.os.Trace -import android.os.UserHandle -import android.os.UserManager import android.util.Log import android.view.View 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 @@ -44,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) @@ -84,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) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt index 468a6b52c5e5e..927df551aa45a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBouncerViewBinder.kt @@ -121,6 +121,7 @@ object KeyguardBouncerViewBinder { securityContainerController.showPrimarySecurityScreen( /* turningOff= */ false ) + securityContainerController.setInitialMessage() securityContainerController.appear() securityContainerController.onResume( KeyguardSecurityView.SCREEN_ON diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardBouncerRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardBouncerRepository.kt index 1dda47223dd66..8a6d2aa7dd210 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardBouncerRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/data/repository/FakeKeyguardBouncerRepository.kt @@ -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