Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 181cb3a8 authored by Christoph Schlosser's avatar Christoph Schlosser Committed by Android (Google) Code Review
Browse files

Merge "Show/hide the animation on PIN entry when changing connected devices" into main

parents a0d91ba5 cf59cf80
Loading
Loading
Loading
Loading
+118 −1
Original line number Diff line number Diff line
@@ -16,12 +16,18 @@

package com.android.keyguard;

import static com.android.internal.widget.flags.Flags.FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;

import android.hardware.input.InputManager;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper.RunWithLooper;
import android.view.View;
import android.view.ViewGroup;
@@ -90,6 +96,8 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
    @Mock
    private UserActivityNotifier mUserActivityNotifier;
    private NumPadKey[] mButtons = new NumPadKey[]{};
    @Mock
    private InputManager mInputManager;

    private KeyguardPinBasedInputViewController mKeyguardPinViewController;

@@ -118,12 +126,13 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
                new KeyguardKeyboardInteractor(new FakeKeyboardRepository());
        FakeFeatureFlags featureFlags = new FakeFeatureFlags();
        mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_REVAMPED_BOUNCER_MESSAGES);
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
        mKeyguardPinViewController = new KeyguardPinBasedInputViewController(mPinBasedInputView,
                mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
                mKeyguardMessageAreaControllerFactory, mLatencyTracker,
                mEmergencyButtonController, mFalsingCollector, featureFlags,
                mSelectedUserInteractor, keyguardKeyboardInteractor, mBouncerHapticPlayer,
                mUserActivityNotifier) {
                mUserActivityNotifier, mInputManager) {
            @Override
            public void onResume(int reason) {
                super.onResume(reason);
@@ -148,4 +157,112 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase {
        mKeyguardPinViewController.resetState();
        verify(mKeyguardMessageAreaController).setMessage(R.string.keyguard_enter_your_pin);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_addDevice_notKeyboard() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        mKeyguardPinViewController.onViewAttached();
        mKeyguardPinViewController.onInputDeviceAdded(1);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_addDevice_keyboard() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        mKeyguardPinViewController.onViewAttached();
        mKeyguardPinViewController.onInputDeviceAdded(1);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_addDevice_multipleKeyboards() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        mKeyguardPinViewController.onViewAttached();
        mKeyguardPinViewController.onInputDeviceAdded(1);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
        mKeyguardPinViewController.onInputDeviceAdded(1);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_removeDevice_notKeyboard() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        mKeyguardPinViewController.onViewAttached();
        mKeyguardPinViewController.onInputDeviceRemoved(1);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_removeDevice_keyboard() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, false);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(0)).setShowPassword(false);
        mKeyguardPinViewController.onViewAttached();
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
        mKeyguardPinViewController.onInputDeviceRemoved(1);
        verify(mPasswordEntry, times(2)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_removeDevice_multipleKeyboards() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, true);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(0)).setShowPassword(false);
        mKeyguardPinViewController.onViewAttached();
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
        mKeyguardPinViewController.onInputDeviceRemoved(1);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_updateDevice_notKeyboard() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        mKeyguardPinViewController.onViewAttached();
        mKeyguardPinViewController.onInputDeviceChanged(1);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_updateDevice_keyboard() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, false);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(0)).setShowPassword(false);
        mKeyguardPinViewController.onViewAttached();
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
        mKeyguardPinViewController.onInputDeviceChanged(1);
        verify(mPasswordEntry, times(2)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
    }

    @Test
    @EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
    public void updateAnimations_updateDevice_multipleKeyboards() {
        when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, true);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(0)).setShowPassword(false);
        mKeyguardPinViewController.onViewAttached();
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
        mKeyguardPinViewController.onInputDeviceChanged(1);
        verify(mPasswordEntry, times(1)).setShowPassword(true);
        verify(mPasswordEntry, times(1)).setShowPassword(false);
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.keyguard

import android.hardware.input.InputManager
import android.testing.TestableLooper
import android.view.View
import android.view.ViewGroup
@@ -104,6 +105,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
    @Mock lateinit var enterButton: View
    @Mock lateinit var uiEventLogger: UiEventLogger
    @Mock lateinit var mUserActivityNotifier: UserActivityNotifier
    @Mock lateinit var inputManager: InputManager

    @Captor lateinit var postureCallbackCaptor: ArgumentCaptor<DevicePostureController.Callback>

@@ -154,6 +156,7 @@ class KeyguardPinViewControllerTest : SysuiTestCase() {
            keyguardKeyboardInteractor,
            kosmos.bouncerHapticPlayer,
            mUserActivityNotifier,
            inputManager,
        )
    }

+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.keyguard

import android.hardware.input.InputManager
import android.telephony.TelephonyManager
import android.testing.TestableLooper
import android.view.LayoutInflater
@@ -73,6 +74,7 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() {
    @Mock private lateinit var mUserActivityNotifier: UserActivityNotifier
    private val updateMonitorCallbackArgumentCaptor =
        ArgumentCaptor.forClass(KeyguardUpdateMonitorCallback::class.java)
    @Mock private lateinit var inputManager: InputManager

    private val kosmos = testKosmos()

@@ -107,6 +109,7 @@ class KeyguardSimPinViewControllerTest : SysuiTestCase() {
                keyguardKeyboardInteractor,
                kosmos.bouncerHapticPlayer,
                mUserActivityNotifier,
                inputManager,
            )
        underTest.init()
        underTest.onViewAttached()
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.keyguard

import android.hardware.input.InputManager
import android.telephony.PinResult
import android.telephony.TelephonyManager
import android.testing.TestableLooper
@@ -65,6 +66,7 @@ class KeyguardSimPukViewControllerTest : SysuiTestCase() {
    private lateinit var keyguardMessageAreaController:
        KeyguardMessageAreaController<BouncerKeyguardMessageArea>
    @Mock private lateinit var mUserActivityNotifier: UserActivityNotifier
    @Mock private lateinit var inputManager: InputManager

    private val kosmos = testKosmos()

@@ -102,6 +104,7 @@ class KeyguardSimPukViewControllerTest : SysuiTestCase() {
                keyguardKeyboardInteractor,
                kosmos.bouncerHapticPlayer,
                mUserActivityNotifier,
                inputManager,
            )
        underTest.init()
    }
+10 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.hardware.input.InputManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@@ -219,6 +220,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
        private final KeyguardKeyboardInteractor mKeyguardKeyboardInteractor;
        private final BouncerHapticPlayer mBouncerHapticPlayer;
        private final UserActivityNotifier mUserActivityNotifier;
        private final InputManager mInputManager;

        @Inject
        public Factory(KeyguardUpdateMonitor keyguardUpdateMonitor,
@@ -235,7 +237,8 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
                UiEventLogger uiEventLogger,
                KeyguardKeyboardInteractor keyguardKeyboardInteractor,
                BouncerHapticPlayer bouncerHapticPlayer,
                UserActivityNotifier userActivityNotifier) {
                UserActivityNotifier userActivityNotifier,
                InputManager inputManager) {
            mKeyguardUpdateMonitor = keyguardUpdateMonitor;
            mLockPatternUtils = lockPatternUtils;
            mLatencyTracker = latencyTracker;
@@ -254,6 +257,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
            mKeyguardKeyboardInteractor = keyguardKeyboardInteractor;
            mBouncerHapticPlayer = bouncerHapticPlayer;
            mUserActivityNotifier = userActivityNotifier;
            mInputManager = inputManager;
        }

        /** Create a new {@link KeyguardInputViewController}. */
@@ -285,22 +289,23 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
                        emergencyButtonController, mFalsingCollector,
                        mDevicePostureController, mFeatureFlags, mSelectedUserInteractor,
                        mUiEventLogger, mKeyguardKeyboardInteractor, mBouncerHapticPlayer,
                        mUserActivityNotifier);
                        mUserActivityNotifier, mInputManager);
            } else if (keyguardInputView instanceof KeyguardSimPinView) {
                return new KeyguardSimPinViewController((KeyguardSimPinView) keyguardInputView,
                        mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
                        keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker,
                        mTelephonyManager, mFalsingCollector,
                        emergencyButtonController, mFeatureFlags, mSelectedUserInteractor,
                        mKeyguardKeyboardInteractor, mBouncerHapticPlayer, mUserActivityNotifier);
                        mKeyguardKeyboardInteractor, mBouncerHapticPlayer, mUserActivityNotifier,
                        mInputManager);
            } else if (keyguardInputView instanceof KeyguardSimPukView) {
                return new KeyguardSimPukViewController((KeyguardSimPukView) keyguardInputView,
                        mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
                        keyguardSecurityCallback, mMessageAreaControllerFactory, mLatencyTracker,
                        mTelephonyManager, mFalsingCollector,
                        emergencyButtonController, mFeatureFlags, mSelectedUserInteractor,
                        mKeyguardKeyboardInteractor, mBouncerHapticPlayer, mUserActivityNotifier
                );
                        mKeyguardKeyboardInteractor, mBouncerHapticPlayer, mUserActivityNotifier,
                        mInputManager);
            }

            throw new RuntimeException("Unable to find controller for " + keyguardInputView);
Loading