Skip to content

Commit dee456f

Browse files
inthewavesu-fred
authored andcommitted
[bugfix] fixup! add second factor UI
There is new code in Android 16 that gets called when hardware keyboard gets added / updated / removed if the com.android.internal.widget.flags.hide_last_char_with_physical_input aconfig flag is enabled. When this happens, it seems it will always use LockDomain.Primary's setting for enhanced PIN privacy when the external keyboard state changes; the`isPinEnhancedPrivacyEnabled` method uses Primary by default via a method override if a LockDomain is not passed. Fix this by passing the stored mLockDomain field. Also fixes test failures due to mocking a function that never gets called from 2FA changes. Test: atest SystemUITests:com.android.keyguard.KeyguardPinBasedInputViewControllerTest
1 parent 63b2e55 commit dee456f

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

packages/SystemUI/multivalentTests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import androidx.test.filters.SmallTest;
3737

3838
import com.android.internal.util.LatencyTracker;
39+
import com.android.internal.widget.LockDomain;
3940
import com.android.internal.widget.LockPatternUtils;
4041
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
4142
import com.android.keyguard.domain.interactor.KeyguardKeyboardInteractor;
@@ -127,7 +128,7 @@ public void setup() {
127128
new KeyguardKeyboardInteractor(new FakeKeyboardRepository());
128129
FakeFeatureFlags featureFlags = new FakeFeatureFlags();
129130
mSetFlagsRule.enableFlags(com.android.systemui.Flags.FLAG_REVAMPED_BOUNCER_MESSAGES);
130-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
131+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(false);
131132
mKeyguardPinViewController = new KeyguardPinBasedInputViewController(mPinBasedInputView,
132133
mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
133134
mKeyguardMessageAreaControllerFactory, mLatencyTracker,
@@ -162,7 +163,7 @@ public void testMessageIsSetWhenReset() {
162163
@Test
163164
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
164165
public void updateAnimations_addDevice_notKeyboard() {
165-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
166+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(false);
166167
verify(mPasswordEntry, times(1)).setShowPassword(true);
167168
mKeyguardPinViewController.onViewAttached();
168169
mKeyguardPinViewController.onInputDeviceAdded(1);
@@ -172,7 +173,7 @@ public void updateAnimations_addDevice_notKeyboard() {
172173
@Test
173174
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
174175
public void updateAnimations_addDevice_keyboard() {
175-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true);
176+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(true);
176177
verify(mPasswordEntry, times(1)).setShowPassword(true);
177178
mKeyguardPinViewController.onViewAttached();
178179
mKeyguardPinViewController.onInputDeviceAdded(1);
@@ -182,7 +183,7 @@ public void updateAnimations_addDevice_keyboard() {
182183
@Test
183184
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
184185
public void updateAnimations_addDevice_multipleKeyboards() {
185-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true);
186+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(true);
186187
verify(mPasswordEntry, times(1)).setShowPassword(true);
187188
mKeyguardPinViewController.onViewAttached();
188189
mKeyguardPinViewController.onInputDeviceAdded(1);
@@ -194,7 +195,7 @@ public void updateAnimations_addDevice_multipleKeyboards() {
194195
@Test
195196
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
196197
public void updateAnimations_removeDevice_notKeyboard() {
197-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
198+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(false);
198199
verify(mPasswordEntry, times(1)).setShowPassword(true);
199200
mKeyguardPinViewController.onViewAttached();
200201
mKeyguardPinViewController.onInputDeviceRemoved(1);
@@ -204,7 +205,7 @@ public void updateAnimations_removeDevice_notKeyboard() {
204205
@Test
205206
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
206207
public void updateAnimations_removeDevice_keyboard() {
207-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, false);
208+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(true, false);
208209
verify(mPasswordEntry, times(1)).setShowPassword(true);
209210
verify(mPasswordEntry, times(0)).setShowPassword(false);
210211
mKeyguardPinViewController.onViewAttached();
@@ -218,7 +219,7 @@ public void updateAnimations_removeDevice_keyboard() {
218219
@Test
219220
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
220221
public void updateAnimations_removeDevice_multipleKeyboards() {
221-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, true);
222+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(true, true);
222223
verify(mPasswordEntry, times(1)).setShowPassword(true);
223224
verify(mPasswordEntry, times(0)).setShowPassword(false);
224225
mKeyguardPinViewController.onViewAttached();
@@ -232,7 +233,7 @@ public void updateAnimations_removeDevice_multipleKeyboards() {
232233
@Test
233234
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
234235
public void updateAnimations_updateDevice_notKeyboard() {
235-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(false);
236+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(false);
236237
verify(mPasswordEntry, times(1)).setShowPassword(true);
237238
mKeyguardPinViewController.onViewAttached();
238239
mKeyguardPinViewController.onInputDeviceChanged(1);
@@ -242,7 +243,7 @@ public void updateAnimations_updateDevice_notKeyboard() {
242243
@Test
243244
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
244245
public void updateAnimations_updateDevice_keyboard() {
245-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, false);
246+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(true, false);
246247
verify(mPasswordEntry, times(1)).setShowPassword(true);
247248
verify(mPasswordEntry, times(0)).setShowPassword(false);
248249
mKeyguardPinViewController.onViewAttached();
@@ -256,7 +257,7 @@ public void updateAnimations_updateDevice_keyboard() {
256257
@Test
257258
@EnableFlags(FLAG_HIDE_LAST_CHAR_WITH_PHYSICAL_INPUT)
258259
public void updateAnimations_updateDevice_multipleKeyboards() {
259-
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt())).thenReturn(true, true);
260+
when(mLockPatternUtils.isPinEnhancedPrivacyEnabled(anyInt(), any(LockDomain.class))).thenReturn(true, true);
260261
verify(mPasswordEntry, times(1)).setShowPassword(true);
261262
verify(mPasswordEntry, times(0)).setShowPassword(false);
262263
mKeyguardPinViewController.onViewAttached();

packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ private void updateAnimations(Boolean showAnimations) {
117117

118118
if (showAnimations == null) {
119119
showAnimations = !mLockPatternUtils
120-
.isPinEnhancedPrivacyEnabled(mSelectedUserInteractor.getSelectedUserId());
120+
.isPinEnhancedPrivacyEnabled(mSelectedUserInteractor.getSelectedUserId(),
121+
mLockDomain);
121122
}
122123
if (mShowAnimations != null && showAnimations.equals(mShowAnimations)) return;
123124
mShowAnimations = showAnimations;

0 commit comments

Comments
 (0)