Fix bugs revolving around user switching.
When switching users in the bouncer, we do no invoke startAppearAnimation. Additionally, the theme color change was delayed for roughly 3 seconds after the user switch completes, which reinflates the bouncer view. In order to handle this case, I've moved some logic from startAppearAnimation to onViewAttached. Additionally, when the user switch occurs, we opt to reinflate the bouncer. When the color changes, we do not reinflate the view. Although the view will not adopt the new theme changes, it will change when we leave the bouncer and enter again. Fixes: 292255597 Fixes: 294035459 Fixes: 292123727 Test: switch users from auto confirmation pin to pin and then back. Test: switch users from locked out pattern to pin and then back. Test: switch users from password to pin and then back. Change-Id: I5b851598c09a0587dd241838b4af256b6c533aaa
This commit is contained in:
@@ -102,6 +102,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
super.onViewAttached();
|
||||
mView.setKeyDownListener(mKeyDownListener);
|
||||
mEmergencyButtonController.setEmergencyButtonCallback(mEmergencyButtonCallback);
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (shouldLockout(deadline)) {
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,12 +284,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
mResumed = true;
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (shouldLockout(deadline)) {
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,13 +30,13 @@ import com.android.internal.util.LatencyTracker;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
|
||||
import com.android.systemui.bouncer.ui.BouncerMessageView;
|
||||
import com.android.systemui.bouncer.ui.binder.BouncerMessageViewBinder;
|
||||
import com.android.systemui.classifier.FalsingCollector;
|
||||
import com.android.systemui.dagger.qualifiers.Main;
|
||||
import com.android.systemui.flags.FeatureFlags;
|
||||
import com.android.systemui.flags.Flags;
|
||||
import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor;
|
||||
import com.android.systemui.bouncer.ui.BouncerMessageView;
|
||||
import com.android.systemui.bouncer.ui.binder.BouncerMessageViewBinder;
|
||||
import com.android.systemui.log.BouncerLogger;
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||
import com.android.systemui.util.ViewController;
|
||||
@@ -95,6 +95,12 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
@CallSuper
|
||||
protected void onViewAttached() {
|
||||
updateMessageAreaVisibility();
|
||||
if (TextUtils.isEmpty(mMessageAreaController.getMessage())
|
||||
&& getInitialMessageResId() != 0) {
|
||||
mMessageAreaController.setMessage(
|
||||
mView.getResources().getString(getInitialMessageResId()),
|
||||
/* animate= */ false);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMessageAreaVisibility() {
|
||||
@@ -147,12 +153,6 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
}
|
||||
|
||||
public void startAppearAnimation() {
|
||||
if (TextUtils.isEmpty(mMessageAreaController.getMessage())
|
||||
&& getInitialMessageResId() != 0) {
|
||||
mMessageAreaController.setMessage(
|
||||
mView.getResources().getString(getInitialMessageResId()),
|
||||
/* animate= */ false);
|
||||
}
|
||||
mView.startAppearAnimation();
|
||||
}
|
||||
|
||||
|
||||
@@ -238,6 +238,12 @@ public class KeyguardPatternViewController
|
||||
}
|
||||
mView.onDevicePostureChanged(mPostureController.getDevicePosture());
|
||||
mPostureController.addCallback(mPostureCallback);
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (deadline != 0) {
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -268,12 +274,6 @@ public class KeyguardPatternViewController
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
super.onResume(reason);
|
||||
// if the user is currently locked out, enforce it.
|
||||
long deadline = mLockPatternUtils.getLockoutAttemptDeadline(
|
||||
KeyguardUpdateMonitor.getCurrentUser());
|
||||
if (deadline != 0) {
|
||||
handleAttemptLockout(deadline);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,6 +79,10 @@ public class KeyguardPinViewController
|
||||
mPasswordEntry.setUserActivityListener(this::onUserInput);
|
||||
mView.onDevicePostureChanged(mPostureController.getDevicePosture());
|
||||
mPostureController.addCallback(mPostureCallback);
|
||||
if (mFeatureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)) {
|
||||
mPasswordEntry.setUsePinShapes(true);
|
||||
updateAutoConfirmationState();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onUserInput() {
|
||||
@@ -100,10 +104,6 @@ public class KeyguardPinViewController
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
if (mFeatureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)) {
|
||||
mPasswordEntry.setUsePinShapes(true);
|
||||
updateAutoConfirmationState();
|
||||
}
|
||||
super.startAppearAnimation();
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +145,19 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
private int mLastOrientation;
|
||||
|
||||
private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
|
||||
private int mCurrentUser = UserHandle.USER_NULL;
|
||||
private UserSwitcherController.UserSwitchCallback mUserSwitchCallback =
|
||||
() -> showPrimarySecurityScreen(false);
|
||||
new UserSwitcherController.UserSwitchCallback() {
|
||||
@Override
|
||||
public void onUserSwitched() {
|
||||
if (mCurrentUser == KeyguardUpdateMonitor.getCurrentUser()) {
|
||||
return;
|
||||
}
|
||||
mCurrentUser = KeyguardUpdateMonitor.getCurrentUser();
|
||||
showPrimarySecurityScreen(false);
|
||||
reinflateViewFlipper((l) -> {});
|
||||
}
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
final Gefingerpoken mGlobalTouchListener = new Gefingerpoken() {
|
||||
@@ -338,7 +349,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
@Override
|
||||
public void onThemeChanged() {
|
||||
reloadColors();
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1156,7 +1166,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
}
|
||||
|
||||
private void reloadColors() {
|
||||
reinflateViewFlipper(controller -> mView.reloadColors());
|
||||
mView.reloadColors();
|
||||
}
|
||||
|
||||
/** Handles density or font scale changes. */
|
||||
|
||||
@@ -180,8 +180,9 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResume() {
|
||||
mKeyguardAbsKeyInputViewController.onResume(KeyguardSecurityView.VIEW_REVEALED);
|
||||
public void testOnViewAttached() {
|
||||
reset(mLockPatternUtils);
|
||||
mKeyguardAbsKeyInputViewController.onViewAttached();
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt());
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.testing.AndroidTestingRunner
|
||||
import android.testing.TestableLooper
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import androidx.test.filters.SmallTest
|
||||
import com.android.internal.util.LatencyTracker
|
||||
import com.android.internal.widget.LockPatternUtils
|
||||
@@ -29,6 +30,7 @@ import com.android.systemui.classifier.FalsingCollector
|
||||
import com.android.systemui.flags.FakeFeatureFlags
|
||||
import com.android.systemui.flags.Flags
|
||||
import com.android.systemui.util.concurrency.DelayableExecutor
|
||||
import com.android.systemui.util.mockito.whenever
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -36,6 +38,7 @@ import org.mockito.ArgumentMatchers.anyBoolean
|
||||
import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when`
|
||||
@@ -45,104 +48,109 @@ import org.mockito.MockitoAnnotations
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@TestableLooper.RunWithLooper
|
||||
class KeyguardPasswordViewControllerTest : SysuiTestCase() {
|
||||
@Mock private lateinit var keyguardPasswordView: KeyguardPasswordView
|
||||
@Mock private lateinit var passwordEntry: EditText
|
||||
@Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
@Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode
|
||||
@Mock lateinit var lockPatternUtils: LockPatternUtils
|
||||
@Mock lateinit var keyguardSecurityCallback: KeyguardSecurityCallback
|
||||
@Mock lateinit var messageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
||||
@Mock lateinit var latencyTracker: LatencyTracker
|
||||
@Mock lateinit var inputMethodManager: InputMethodManager
|
||||
@Mock lateinit var emergencyButtonController: EmergencyButtonController
|
||||
@Mock lateinit var mainExecutor: DelayableExecutor
|
||||
@Mock lateinit var falsingCollector: FalsingCollector
|
||||
@Mock lateinit var keyguardViewController: KeyguardViewController
|
||||
@Mock private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
|
||||
@Mock
|
||||
private lateinit var mKeyguardMessageAreaController:
|
||||
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
||||
@Mock private lateinit var keyguardPasswordView: KeyguardPasswordView
|
||||
@Mock private lateinit var passwordEntry: EditText
|
||||
@Mock lateinit var keyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
@Mock lateinit var securityMode: KeyguardSecurityModel.SecurityMode
|
||||
@Mock lateinit var lockPatternUtils: LockPatternUtils
|
||||
@Mock lateinit var keyguardSecurityCallback: KeyguardSecurityCallback
|
||||
@Mock lateinit var messageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
||||
@Mock lateinit var latencyTracker: LatencyTracker
|
||||
@Mock lateinit var inputMethodManager: InputMethodManager
|
||||
@Mock lateinit var emergencyButtonController: EmergencyButtonController
|
||||
@Mock lateinit var mainExecutor: DelayableExecutor
|
||||
@Mock lateinit var falsingCollector: FalsingCollector
|
||||
@Mock lateinit var keyguardViewController: KeyguardViewController
|
||||
@Mock private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea
|
||||
@Mock
|
||||
private lateinit var mKeyguardMessageAreaController:
|
||||
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
||||
|
||||
private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController
|
||||
private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
Mockito.`when`(
|
||||
keyguardPasswordView.requireViewById<BouncerKeyguardMessageArea>(
|
||||
R.id.bouncer_message_area))
|
||||
.thenReturn(mKeyguardMessageArea)
|
||||
Mockito.`when`(messageAreaControllerFactory.create(mKeyguardMessageArea))
|
||||
.thenReturn(mKeyguardMessageAreaController)
|
||||
Mockito.`when`(keyguardPasswordView.passwordTextViewId).thenReturn(R.id.passwordEntry)
|
||||
Mockito.`when`(keyguardPasswordView.findViewById<EditText>(R.id.passwordEntry))
|
||||
.thenReturn(passwordEntry)
|
||||
`when`(keyguardPasswordView.resources).thenReturn(context.resources)
|
||||
val fakeFeatureFlags = FakeFeatureFlags()
|
||||
fakeFeatureFlags.set(Flags.REVAMPED_BOUNCER_MESSAGES, true)
|
||||
keyguardPasswordViewController =
|
||||
KeyguardPasswordViewController(
|
||||
keyguardPasswordView,
|
||||
keyguardUpdateMonitor,
|
||||
securityMode,
|
||||
lockPatternUtils,
|
||||
keyguardSecurityCallback,
|
||||
messageAreaControllerFactory,
|
||||
latencyTracker,
|
||||
inputMethodManager,
|
||||
emergencyButtonController,
|
||||
mainExecutor,
|
||||
mContext.resources,
|
||||
falsingCollector,
|
||||
keyguardViewController,
|
||||
fakeFeatureFlags)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testFocusWhenBouncerIsShown() {
|
||||
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(true)
|
||||
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
||||
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||
keyguardPasswordView.post {
|
||||
verify(keyguardPasswordView).requestFocus()
|
||||
verify(keyguardPasswordView).showKeyboard()
|
||||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
Mockito.`when`(
|
||||
keyguardPasswordView.requireViewById<BouncerKeyguardMessageArea>(
|
||||
R.id.bouncer_message_area
|
||||
)
|
||||
)
|
||||
.thenReturn(mKeyguardMessageArea)
|
||||
Mockito.`when`(messageAreaControllerFactory.create(mKeyguardMessageArea))
|
||||
.thenReturn(mKeyguardMessageAreaController)
|
||||
Mockito.`when`(keyguardPasswordView.passwordTextViewId).thenReturn(R.id.passwordEntry)
|
||||
Mockito.`when`(keyguardPasswordView.findViewById<EditText>(R.id.passwordEntry))
|
||||
.thenReturn(passwordEntry)
|
||||
whenever(keyguardPasswordView.findViewById<ImageView>(R.id.switch_ime_button))
|
||||
.thenReturn(mock(ImageView::class.java))
|
||||
`when`(keyguardPasswordView.resources).thenReturn(context.resources)
|
||||
val fakeFeatureFlags = FakeFeatureFlags()
|
||||
fakeFeatureFlags.set(Flags.REVAMPED_BOUNCER_MESSAGES, true)
|
||||
keyguardPasswordViewController =
|
||||
KeyguardPasswordViewController(
|
||||
keyguardPasswordView,
|
||||
keyguardUpdateMonitor,
|
||||
securityMode,
|
||||
lockPatternUtils,
|
||||
keyguardSecurityCallback,
|
||||
messageAreaControllerFactory,
|
||||
latencyTracker,
|
||||
inputMethodManager,
|
||||
emergencyButtonController,
|
||||
mainExecutor,
|
||||
mContext.resources,
|
||||
falsingCollector,
|
||||
keyguardViewController,
|
||||
fakeFeatureFlags
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDoNotFocusWhenBouncerIsHidden() {
|
||||
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(false)
|
||||
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
||||
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||
verify(keyguardPasswordView, never()).requestFocus()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testHideKeyboardWhenOnPause() {
|
||||
keyguardPasswordViewController.onPause()
|
||||
keyguardPasswordView.post {
|
||||
verify(keyguardPasswordView).clearFocus()
|
||||
verify(keyguardPasswordView).hideKeyboard()
|
||||
@Test
|
||||
fun testFocusWhenBouncerIsShown() {
|
||||
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(true)
|
||||
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
||||
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||
keyguardPasswordView.post {
|
||||
verify(keyguardPasswordView).requestFocus()
|
||||
verify(keyguardPasswordView).showKeyboard()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation() {
|
||||
keyguardPasswordViewController.startAppearAnimation()
|
||||
verify(mKeyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_password), false)
|
||||
}
|
||||
@Test
|
||||
fun testDoNotFocusWhenBouncerIsHidden() {
|
||||
Mockito.`when`(keyguardViewController.isBouncerShowing).thenReturn(false)
|
||||
Mockito.`when`(keyguardPasswordView.isShown).thenReturn(true)
|
||||
keyguardPasswordViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||
verify(keyguardPasswordView, never()).requestFocus()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withExistingMessage() {
|
||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
keyguardPasswordViewController.startAppearAnimation()
|
||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
||||
}
|
||||
@Test
|
||||
fun testHideKeyboardWhenOnPause() {
|
||||
keyguardPasswordViewController.onPause()
|
||||
keyguardPasswordView.post {
|
||||
verify(keyguardPasswordView).clearFocus()
|
||||
verify(keyguardPasswordView).hideKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMessageIsSetWhenReset() {
|
||||
keyguardPasswordViewController.resetState()
|
||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_password)
|
||||
}
|
||||
@Test
|
||||
fun testOnViewAttached() {
|
||||
keyguardPasswordViewController.onViewAttached()
|
||||
verify(mKeyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_password), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnViewAttached_withExistingMessage() {
|
||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
keyguardPasswordViewController.onViewAttached()
|
||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMessageIsSetWhenReset() {
|
||||
keyguardPasswordViewController.resetState()
|
||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_password)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.mockito.ArgumentMatchers.anyString
|
||||
import org.mockito.Captor
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.never
|
||||
import org.mockito.Mockito.reset
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.MockitoAnnotations
|
||||
@@ -54,35 +55,35 @@ import org.mockito.MockitoAnnotations
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
@TestableLooper.RunWithLooper
|
||||
class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
private lateinit var mKeyguardPatternView: KeyguardPatternView
|
||||
private lateinit var mKeyguardPatternView: KeyguardPatternView
|
||||
|
||||
@Mock private lateinit var mKeyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
@Mock private lateinit var mKeyguardUpdateMonitor: KeyguardUpdateMonitor
|
||||
|
||||
@Mock private lateinit var mSecurityMode: KeyguardSecurityModel.SecurityMode
|
||||
@Mock private lateinit var mSecurityMode: KeyguardSecurityModel.SecurityMode
|
||||
|
||||
@Mock private lateinit var mLockPatternUtils: LockPatternUtils
|
||||
@Mock private lateinit var mLockPatternUtils: LockPatternUtils
|
||||
|
||||
@Mock private lateinit var mKeyguardSecurityCallback: KeyguardSecurityCallback
|
||||
@Mock private lateinit var mKeyguardSecurityCallback: KeyguardSecurityCallback
|
||||
|
||||
@Mock private lateinit var mLatencyTracker: LatencyTracker
|
||||
private var mFalsingCollector: FalsingCollector = FalsingCollectorFake()
|
||||
@Mock private lateinit var mLatencyTracker: LatencyTracker
|
||||
private var mFalsingCollector: FalsingCollector = FalsingCollectorFake()
|
||||
|
||||
@Mock private lateinit var mEmergencyButtonController: EmergencyButtonController
|
||||
@Mock private lateinit var mEmergencyButtonController: EmergencyButtonController
|
||||
|
||||
@Mock
|
||||
private lateinit var mKeyguardMessageAreaControllerFactory: KeyguardMessageAreaController.Factory
|
||||
@Mock
|
||||
private lateinit var mKeyguardMessageAreaControllerFactory:
|
||||
KeyguardMessageAreaController.Factory
|
||||
|
||||
@Mock
|
||||
private lateinit var mKeyguardMessageAreaController:
|
||||
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
||||
@Mock
|
||||
private lateinit var mKeyguardMessageAreaController:
|
||||
KeyguardMessageAreaController<BouncerKeyguardMessageArea>
|
||||
|
||||
@Mock private lateinit var mPostureController: DevicePostureController
|
||||
@Mock private lateinit var mPostureController: DevicePostureController
|
||||
|
||||
private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController
|
||||
private lateinit var fakeFeatureFlags: FakeFeatureFlags
|
||||
private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController
|
||||
private lateinit var fakeFeatureFlags: FakeFeatureFlags
|
||||
|
||||
@Captor
|
||||
lateinit var postureCallbackCaptor: ArgumentCaptor<DevicePostureController.Callback>
|
||||
@Captor lateinit var postureCallbackCaptor: ArgumentCaptor<DevicePostureController.Callback>
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
@@ -91,9 +92,8 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
.thenReturn(mKeyguardMessageAreaController)
|
||||
fakeFeatureFlags = FakeFeatureFlags()
|
||||
fakeFeatureFlags.set(Flags.REVAMPED_BOUNCER_MESSAGES, false)
|
||||
mKeyguardPatternView = View.inflate(mContext, R.layout.keyguard_pattern_view, null)
|
||||
as KeyguardPatternView
|
||||
|
||||
mKeyguardPatternView =
|
||||
View.inflate(mContext, R.layout.keyguard_pattern_view, null) as KeyguardPatternView
|
||||
|
||||
mKeyguardPatternViewController =
|
||||
KeyguardPatternViewController(
|
||||
@@ -125,8 +125,7 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun onDevicePostureChanged_deviceOpened_propagatedToPatternView() {
|
||||
overrideResource(R.dimen.half_opened_bouncer_height_ratio, 0.5f)
|
||||
whenever(mPostureController.devicePosture)
|
||||
.thenReturn(DEVICE_POSTURE_HALF_OPENED)
|
||||
whenever(mPostureController.devicePosture).thenReturn(DEVICE_POSTURE_HALF_OPENED)
|
||||
|
||||
mKeyguardPatternViewController.onViewAttached()
|
||||
|
||||
@@ -159,39 +158,37 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
return mContext.resources.getFloat(R.dimen.half_opened_bouncer_height_ratio)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun withFeatureFlagOn_oldMessage_isHidden() {
|
||||
fakeFeatureFlags.set(Flags.REVAMPED_BOUNCER_MESSAGES, true)
|
||||
@Test
|
||||
fun withFeatureFlagOn_oldMessage_isHidden() {
|
||||
fakeFeatureFlags.set(Flags.REVAMPED_BOUNCER_MESSAGES, true)
|
||||
|
||||
mKeyguardPatternViewController.onViewAttached()
|
||||
mKeyguardPatternViewController.onViewAttached()
|
||||
|
||||
verify<KeyguardMessageAreaController<*>>(mKeyguardMessageAreaController).disable()
|
||||
}
|
||||
verify<KeyguardMessageAreaController<*>>(mKeyguardMessageAreaController).disable()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onPause_resetsText() {
|
||||
mKeyguardPatternViewController.init()
|
||||
mKeyguardPatternViewController.onPause()
|
||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
||||
}
|
||||
@Test
|
||||
fun onPause_resetsText() {
|
||||
mKeyguardPatternViewController.init()
|
||||
mKeyguardPatternViewController.onPause()
|
||||
verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pattern)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation() {
|
||||
mKeyguardPatternViewController.startAppearAnimation()
|
||||
verify(mKeyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pattern), false)
|
||||
}
|
||||
@Test
|
||||
fun testOnViewAttached() {
|
||||
reset(mKeyguardMessageAreaController)
|
||||
reset(mLockPatternUtils)
|
||||
mKeyguardPatternViewController.onViewAttached()
|
||||
verify(mKeyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pattern), false)
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withExistingMessage() {
|
||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
mKeyguardPatternViewController.startAppearAnimation()
|
||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resume() {
|
||||
mKeyguardPatternViewController.onResume(KeyguardSecurityView.VIEW_REVEALED)
|
||||
verify(mLockPatternUtils).getLockoutAttemptDeadline(anyInt())
|
||||
}
|
||||
@Test
|
||||
fun testOnViewAttached_withExistingMessage() {
|
||||
reset(mKeyguardMessageAreaController)
|
||||
`when`(mKeyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
mKeyguardPatternViewController.onViewAttached()
|
||||
verify(mKeyguardMessageAreaController, never()).setMessage(anyString(), anyBoolean())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
|
||||
.thenReturn(mDeleteButton);
|
||||
when(mPinBasedInputView.findViewById(R.id.key_enter))
|
||||
.thenReturn(mOkButton);
|
||||
|
||||
when(mPinBasedInputView.getResources()).thenReturn(getContext().getResources());
|
||||
FakeFeatureFlags featureFlags = new FakeFeatureFlags();
|
||||
featureFlags.set(Flags.REVAMPED_BOUNCER_MESSAGES, true);
|
||||
|
||||
|
||||
@@ -185,27 +185,27 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation() {
|
||||
fun testOnViewAttached() {
|
||||
val pinViewController = constructPinViewController(mockKeyguardPinView)
|
||||
|
||||
pinViewController.startAppearAnimation()
|
||||
pinViewController.onViewAttached()
|
||||
|
||||
verify(keyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pin), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withExistingMessage() {
|
||||
fun testOnViewAttached_withExistingMessage() {
|
||||
val pinViewController = constructPinViewController(mockKeyguardPinView)
|
||||
Mockito.`when`(keyguardMessageAreaController.message).thenReturn("Unlock to continue.")
|
||||
|
||||
pinViewController.startAppearAnimation()
|
||||
pinViewController.onViewAttached()
|
||||
|
||||
verify(keyguardMessageAreaController, Mockito.never()).setMessage(anyString(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withAutoPinConfirmationFailedPasswordAttemptsLessThan5() {
|
||||
fun testOnViewAttached_withAutoPinConfirmationFailedPasswordAttemptsLessThan5() {
|
||||
val pinViewController = constructPinViewController(mockKeyguardPinView)
|
||||
`when`(featureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)).thenReturn(true)
|
||||
`when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6)
|
||||
@@ -213,7 +213,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
|
||||
`when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(3)
|
||||
`when`(passwordTextView.text).thenReturn("")
|
||||
|
||||
pinViewController.startAppearAnimation()
|
||||
pinViewController.onViewAttached()
|
||||
|
||||
verify(deleteButton).visibility = View.INVISIBLE
|
||||
verify(enterButton).visibility = View.INVISIBLE
|
||||
@@ -222,7 +222,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun startAppearAnimation_withAutoPinConfirmationFailedPasswordAttemptsMoreThan5() {
|
||||
fun testOnViewAttached_withAutoPinConfirmationFailedPasswordAttemptsMoreThan5() {
|
||||
val pinViewController = constructPinViewController(mockKeyguardPinView)
|
||||
`when`(featureFlags.isEnabled(Flags.AUTO_PIN_CONFIRMATION)).thenReturn(true)
|
||||
`when`(lockPatternUtils.getPinLength(anyInt())).thenReturn(6)
|
||||
@@ -230,7 +230,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
|
||||
`when`(lockPatternUtils.getCurrentFailedPasswordAttempts(anyInt())).thenReturn(6)
|
||||
`when`(passwordTextView.text).thenReturn("")
|
||||
|
||||
pinViewController.startAppearAnimation()
|
||||
pinViewController.onViewAttached()
|
||||
|
||||
verify(deleteButton).visibility = View.VISIBLE
|
||||
verify(enterButton).visibility = View.VISIBLE
|
||||
|
||||
@@ -61,6 +61,8 @@ import com.android.systemui.user.domain.interactor.UserInteractor
|
||||
import com.android.systemui.util.kotlin.JavaAdapter
|
||||
import com.android.systemui.util.mockito.any
|
||||
import com.android.systemui.util.mockito.argThat
|
||||
import com.android.systemui.util.mockito.argumentCaptor
|
||||
import com.android.systemui.util.mockito.capture
|
||||
import com.android.systemui.util.mockito.mock
|
||||
import com.android.systemui.util.mockito.whenever
|
||||
import com.android.systemui.util.settings.GlobalSettings
|
||||
@@ -587,18 +589,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
|
||||
ArgumentCaptor.forClass(ConfigurationController.ConfigurationListener::class.java)
|
||||
underTest.onViewAttached()
|
||||
verify(configurationController).addCallback(configurationListenerArgumentCaptor.capture())
|
||||
clearInvocations(viewFlipperController)
|
||||
configurationListenerArgumentCaptor.value.onThemeChanged()
|
||||
verify(viewFlipperController).clearViews()
|
||||
verify(viewFlipperController)
|
||||
.asynchronouslyInflateView(
|
||||
eq(SecurityMode.PIN),
|
||||
any(),
|
||||
onViewInflatedCallbackArgumentCaptor.capture()
|
||||
)
|
||||
onViewInflatedCallbackArgumentCaptor.value.onViewInflated(inputViewController)
|
||||
verify(view).reset()
|
||||
verify(viewFlipperController).reset()
|
||||
verify(view).reloadColors()
|
||||
}
|
||||
|
||||
@@ -608,16 +599,7 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
|
||||
ArgumentCaptor.forClass(ConfigurationController.ConfigurationListener::class.java)
|
||||
underTest.onViewAttached()
|
||||
verify(configurationController).addCallback(configurationListenerArgumentCaptor.capture())
|
||||
clearInvocations(viewFlipperController)
|
||||
configurationListenerArgumentCaptor.value.onUiModeChanged()
|
||||
verify(viewFlipperController).clearViews()
|
||||
verify(viewFlipperController)
|
||||
.asynchronouslyInflateView(
|
||||
eq(SecurityMode.PIN),
|
||||
any(),
|
||||
onViewInflatedCallbackArgumentCaptor.capture()
|
||||
)
|
||||
onViewInflatedCallbackArgumentCaptor.value.onViewInflated(inputViewController)
|
||||
verify(view).reloadColors()
|
||||
}
|
||||
|
||||
@@ -849,6 +831,17 @@ class KeyguardSecurityContainerControllerTest : SysuiTestCase() {
|
||||
verify(userSwitcher).setAlpha(0f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOnUserSwitched() {
|
||||
val userSwitchCallbackArgumentCaptor =
|
||||
argumentCaptor<UserSwitcherController.UserSwitchCallback>()
|
||||
underTest.onViewAttached()
|
||||
verify(userSwitcherController)
|
||||
.addUserSwitchCallback(capture(userSwitchCallbackArgumentCaptor))
|
||||
userSwitchCallbackArgumentCaptor.value.onUserSwitched()
|
||||
verify(viewFlipperController).asynchronouslyInflateView(any(), any(), any())
|
||||
}
|
||||
|
||||
private val registeredSwipeListener: KeyguardSecurityContainer.SwipeListener
|
||||
get() {
|
||||
underTest.onViewAttached()
|
||||
|
||||
@@ -97,6 +97,8 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun onViewAttached() {
|
||||
underTest.onViewAttached()
|
||||
verify(keyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pin), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,8 +122,6 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun startAppearAnimation() {
|
||||
underTest.startAppearAnimation()
|
||||
verify(keyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pin), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -98,6 +98,8 @@ class KeyguardSimPukViewControllerTest : SysuiTestCase() {
|
||||
underTest.onViewAttached()
|
||||
Mockito.verify(keyguardUpdateMonitor)
|
||||
.registerCallback(any(KeyguardUpdateMonitorCallback::class.java))
|
||||
Mockito.verify(keyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pin), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,8 +122,6 @@ class KeyguardSimPukViewControllerTest : SysuiTestCase() {
|
||||
@Test
|
||||
fun startAppearAnimation() {
|
||||
underTest.startAppearAnimation()
|
||||
Mockito.verify(keyguardMessageAreaController)
|
||||
.setMessage(context.resources.getString(R.string.keyguard_enter_your_pin), false)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user