Merge "Ask users with a11y services enabled to swipe up" into tm-d1-dev

This commit is contained in:
TreeHugger Robot
2022-06-09 14:27:03 +00:00
committed by Android (Google) Code Review
2 changed files with 74 additions and 14 deletions

View File

@@ -62,6 +62,7 @@ import android.text.format.Formatter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.Nullable;
@@ -142,6 +143,7 @@ public class KeyguardIndicationController {
private final IActivityManager mIActivityManager;
private final FalsingManager mFalsingManager;
private final KeyguardBypassController mKeyguardBypassController;
private final AccessibilityManager mAccessibilityManager;
private final Handler mHandler;
protected KeyguardIndicationRotateTextViewController mRotateTextViewController;
@@ -218,7 +220,8 @@ public class KeyguardIndicationController {
LockPatternUtils lockPatternUtils,
ScreenLifecycle screenLifecycle,
IActivityManager iActivityManager,
KeyguardBypassController keyguardBypassController) {
KeyguardBypassController keyguardBypassController,
AccessibilityManager accessibilityManager) {
mContext = context;
mBroadcastDispatcher = broadcastDispatcher;
mDevicePolicyManager = devicePolicyManager;
@@ -236,6 +239,7 @@ public class KeyguardIndicationController {
mIActivityManager = iActivityManager;
mFalsingManager = falsingManager;
mKeyguardBypassController = keyguardBypassController;
mAccessibilityManager = accessibilityManager;
mScreenLifecycle = screenLifecycle;
mScreenLifecycle.addObserver(mScreenObserver);
@@ -905,7 +909,9 @@ public class KeyguardIndicationController {
mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState);
}
} else {
if (mKeyguardUpdateMonitor.isUdfpsSupported()
if (!mAccessibilityManager.isEnabled()
&& !mAccessibilityManager.isTouchExplorationEnabled()
&& mKeyguardUpdateMonitor.isUdfpsSupported()
&& mKeyguardUpdateMonitor.getUserCanSkipBouncer(
KeyguardUpdateMonitor.getCurrentUser())) {
final int stringId = mKeyguardUpdateMonitor.getIsFaceAuthenticated()
@@ -918,15 +924,6 @@ public class KeyguardIndicationController {
}
}
private void showFaceFailedTryFingerprintMsg(int msgId, String a11yString) {
showBiometricMessage(R.string.keyguard_face_failed_use_fp);
// Although we suppress face auth errors visually, we still announce them for a11y
if (!TextUtils.isEmpty(a11yString)) {
mLockScreenIndicationView.announceForAccessibility(a11yString);
}
}
public void dump(PrintWriter pw, String[] args) {
pw.println("KeyguardIndicationController:");
pw.println(" mInitialTextColorState: " + mInitialTextColorState);

View File

@@ -71,6 +71,7 @@ import android.os.UserManager;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityManager;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
@@ -124,7 +125,6 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
private static final int TEST_STRING_RES = R.string.keyguard_indication_trust_unlocked;
private String mKeyguardTryFingerprintMsg;
private String mDisclosureWithOrganization;
private String mDisclosureGeneric;
private String mFinancedDisclosureWithOrganization;
@@ -164,6 +164,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
@Mock
private KeyguardBypassController mKeyguardBypassController;
@Mock
private AccessibilityManager mAccessibilityManager;
@Mock
private ScreenLifecycle mScreenLifecycle;
@Captor
private ArgumentCaptor<DockManager.AlignmentStateListener> mAlignmentListener;
@@ -203,7 +205,6 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
mContext.addMockSystemService(UserManager.class, mUserManager);
mContext.addMockSystemService(Context.TRUST_SERVICE, mock(TrustManager.class));
mContext.addMockSystemService(Context.FINGERPRINT_SERVICE, mock(FingerprintManager.class));
mKeyguardTryFingerprintMsg = mContext.getString(R.string.keyguard_try_fingerprint);
mDisclosureWithOrganization = mContext.getString(R.string.do_disclosure_with_name,
ORGANIZATION_NAME);
mDisclosureGeneric = mContext.getString(R.string.do_disclosure_generic);
@@ -254,7 +255,8 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
mKeyguardStateController, mStatusBarStateController, mKeyguardUpdateMonitor,
mDockManager, mBroadcastDispatcher, mDevicePolicyManager, mIBatteryStats,
mUserManager, mExecutor, mExecutor, mFalsingManager, mLockPatternUtils,
mScreenLifecycle, mIActivityManager, mKeyguardBypassController);
mScreenLifecycle, mIActivityManager, mKeyguardBypassController,
mAccessibilityManager);
mController.init();
mController.setIndicationArea(mIndicationArea);
verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
@@ -925,6 +927,67 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
trustGrantedMsg);
}
@Test
public void nonBypassFaceSuccess_touchExplorationEnabled_showsSwipeToOpen() {
// GIVEN non bypass face auth and touch exploration is enabled
when(mKeyguardBypassController.canBypass()).thenReturn(false);
when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(true);
when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false);
createController();
String swipeToOpen = mContext.getString(R.string.keyguard_unlock);
mController.setVisible(true);
// WHEN face authenticated
mController.getKeyguardCallback().onBiometricAuthenticated(0,
BiometricSourceType.FACE, false);
// THEN show 'swipe up to open' message
verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen);
}
@Test
public void nonBypassFaceSuccess_a11yEnabled_showsSwipeToOpen() {
// GIVEN non bypass face auth and a11y is enabled
when(mKeyguardBypassController.canBypass()).thenReturn(false);
when(mAccessibilityManager.isEnabled()).thenReturn(true);
when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false);
createController();
String swipeToOpen = mContext.getString(R.string.keyguard_unlock);
mController.setVisible(true);
// WHEN face auth is successful
mController.getKeyguardCallback().onBiometricAuthenticated(0,
BiometricSourceType.FACE, false);
// THEN show 'swipe up to open' message
verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, swipeToOpen);
}
@Test
public void coEx_nonBypassFaceSuccess_showsPressLockIcon() {
// GIVEN udfps is supported, non-bypass face auth, and no a11y enabled
when(mKeyguardUpdateMonitor.isUdfpsSupported()).thenReturn(true);
when(mKeyguardBypassController.canBypass()).thenReturn(false);
when(mKeyguardUpdateMonitor.getIsFaceAuthenticated()).thenReturn(true);
when(mAccessibilityManager.isEnabled()).thenReturn(false);
when(mAccessibilityManager.isTouchExplorationEnabled()).thenReturn(false);
when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(false);
when(mKeyguardUpdateMonitor.getUserCanSkipBouncer(KeyguardUpdateMonitor.getCurrentUser()))
.thenReturn(true);
createController();
mController.setVisible(true);
// WHEN face auth succeeds
mController.getKeyguardCallback().onBiometricAuthenticated(0,
BiometricSourceType.FACE, false);
// THEN press unlock icon to open message shows
String pressLockIcon = mContext.getString(R.string.keyguard_face_successful_unlock_press);
verifyIndicationMessage(INDICATION_TYPE_BIOMETRIC_MESSAGE, pressLockIcon);
assertThat(mTextView.getText()).isNotEqualTo(pressLockIcon);
}
private void sendUpdateDisclosureBroadcast() {
mBroadcastReceiver.onReceive(mContext, new Intent());
}