From 1a21ef3fe1b80958430e0e2473142a48a6c5a7a9 Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 11 May 2021 11:35:19 -0400 Subject: [PATCH 1/2] Lock screen a11y updates When a11y features are enabled, inform the user when the state of the lock screen changes. Remove the window accessibility title on the udfps icon so that it won't announce its window each time the udfps area receives focus. (ie: previously was announcing "fingerprint sensor, SystemUI") Add a label to the wallet affordance on the lock screen. Test: manual Fixes: 187139663 Fixes: 187190642 Fixes: 187082618 Fixes: 187080405 Change-Id: I4269b1943ec4d2e82eac9525947bb1903886f4f8 --- .../res/layout/keyguard_bottom_area.xml | 1 + packages/SystemUI/res/values/strings.xml | 6 +++- .../keyguard/LockIconViewController.java | 31 ++++++++++--------- .../systemui/biometrics/UdfpsController.java | 4 ++- .../UdfpsKeyguardViewController.java | 3 ++ .../UdfpsKeyguardViewControllerTest.java | 6 ++++ 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/res/layout/keyguard_bottom_area.xml b/packages/SystemUI/res/layout/keyguard_bottom_area.xml index 69d73c1b94e14..95483f13ec6a6 100644 --- a/packages/SystemUI/res/layout/keyguard_bottom_area.xml +++ b/packages/SystemUI/res/layout/keyguard_bottom_area.xml @@ -95,6 +95,7 @@ android:background="@drawable/wallet_lockscreen_bg" android:layout_marginEnd="@dimen/keyguard_affordance_horizontal_offset" android:layout_marginBottom="@dimen/keyguard_affordance_vertical_offset" + android:contentDescription="@string/accessibility_wallet_button" android:visibility="gone" /> Phone Voice Assist + + Wallet Unlock @@ -2965,7 +2967,9 @@ enter device - + Use fingerprint to open + + Authentication required. Touch the fingerprint sensor to authenticate. diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index b5f2ab2135595..b367bdf08886e 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -50,6 +50,7 @@ import com.android.systemui.util.ViewController; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.Objects; import javax.inject.Inject; @@ -75,6 +76,9 @@ public class LockIconViewController extends ViewController impleme @NonNull private final Drawable mButton; @NonNull private final Drawable mUnlockIcon; @NonNull private final Drawable mLockIcon; + @NonNull private final CharSequence mDisabledLabel; + @NonNull private final CharSequence mUnlockedLabel; + @NonNull private final CharSequence mLockedLabel; private boolean mIsDozing; private boolean mIsBouncerShowing; @@ -121,6 +125,10 @@ public class LockIconViewController extends ViewController impleme com.android.internal.R.drawable.ic_lock, context.getTheme()), context.getResources().getDimensionPixelSize( com.android.systemui.R.dimen.udfps_unlock_icon_inset)); + mDisabledLabel = context.getResources().getString( + R.string.accessibility_udfps_disabled_button); + mUnlockedLabel = context.getResources().getString(R.string.accessibility_unlock_button); + mLockedLabel = context.getResources().getString(R.string.accessibility_lock_icon); dumpManager.registerDumpable("LockIconViewController", this); } @@ -225,25 +233,27 @@ public class LockIconViewController extends ViewController impleme && mFaceAuthEnrolled; updateClickListener(); + final CharSequence prevContentDescription = mView.getContentDescription(); if (mShowButton) { mView.setImageDrawable(mButton); mView.setVisibility(View.VISIBLE); - mView.setContentDescription(getResources().getString( - R.string.accessibility_udfps_disabled_button)); + mView.setContentDescription(mDisabledLabel); } else if (mShowUnlockIcon) { mView.setImageDrawable(mUnlockIcon); mView.setVisibility(View.VISIBLE); - mView.setContentDescription(getResources().getString( - R.string.accessibility_unlock_button)); + mView.setContentDescription(mUnlockedLabel); } else if (mShowLockIcon) { mView.setImageDrawable(mLockIcon); mView.setVisibility(View.VISIBLE); - mView.setContentDescription(getResources().getString( - R.string.accessibility_lock_icon)); + mView.setContentDescription(mLockedLabel); } else { mView.setVisibility(View.INVISIBLE); mView.setContentDescription(null); } + if (!Objects.equals(prevContentDescription, mView.getContentDescription()) + && mView.getContentDescription() != null) { + mView.announceForAccessibility(mView.getContentDescription()); + } } private final View.AccessibilityDelegate mAccessibilityDelegate = @@ -258,20 +268,12 @@ public class LockIconViewController extends ViewController impleme getResources().getString(R.string.accessibility_enter_hint)); public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(v, info); - removeAllActions(info); if (mShowButton || mShowLockIcon) { info.addAction(mAccessibilityAuthenticateHint); } else if (mShowUnlockIcon) { info.addAction(mAccessibilityEnterHint); } } - - private void removeAllActions(AccessibilityNodeInfo info) { - info.removeAction(mAccessibilityAuthenticateHint); - info.removeAction(mAccessibilityEnterHint); - info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK); - mView.setLongClickable(false); - } }; private boolean isLockScreen() { @@ -286,6 +288,7 @@ public class LockIconViewController extends ViewController impleme mView.setOnClickListener(v -> onAffordanceClick()); if (mAccessibilityManager.isTouchExplorationEnabled()) { mView.setOnLongClickListener(null); + mView.setLongClickable(false); } else { mView.setOnLongClickListener(v -> onAffordanceClick()); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 5f27400741a95..fc1a34fe3f89e 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -331,7 +331,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback { switch (event.getActionMasked()) { case MotionEvent.ACTION_OUTSIDE: udfpsView.onTouchOutsideView(); - break; + return true; case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_HOVER_ENTER: // To simplify the lifecycle of the velocity tracker, make sure it's never null @@ -588,6 +588,8 @@ public class UdfpsController implements DozeReceiver, HbmCallback { default: // Do nothing to stay in portrait mode. } + // avoid announcing window title + mCoreLayoutParams.accessibilityTitle = " "; return mCoreLayoutParams; } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java index 33d0d0c5b5ffd..819e829c53b09 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java @@ -27,6 +27,7 @@ import androidx.annotation.Nullable; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.systemui.R; import com.android.systemui.dump.DumpManager; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.plugins.statusbar.StatusBarStateController; @@ -165,6 +166,8 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController mKeyguardViewManager.cancelPostAuthActions()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java index 3a657c816937f..a1f283b9a26b1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java @@ -18,10 +18,12 @@ package com.android.systemui.biometrics; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import android.content.Context; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper.RunWithLooper; @@ -55,6 +57,8 @@ public class UdfpsKeyguardViewControllerTest extends SysuiTestCase { @Mock private UdfpsKeyguardView mView; @Mock + private Context mResourceContext; + @Mock private StatusBarStateController mStatusBarStateController; @Mock private StatusBar mStatusBar; @@ -90,6 +94,8 @@ public class UdfpsKeyguardViewControllerTest extends SysuiTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); + when(mView.getContext()).thenReturn(mResourceContext); + when(mResourceContext.getString(anyInt())).thenReturn("test string"); when(mKeyguardViewMediator.isAnimatingScreenOff()).thenReturn(false); when(mKeyguardUpdateMonitor.isKeyguardVisible()).thenReturn(true); mController = new UdfpsKeyguardViewController( From 46ea9f0152cb719bbf8cde697e6830fd945e139e Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 11 May 2021 15:12:10 -0400 Subject: [PATCH 2/2] Fix udfps auth scrim state Keep notification scrim of the previous state Test: manual Fixes: 187734161 Change-Id: I255c033f0f8dda354b87a263054346765b0de6f5 --- .../com/android/systemui/statusbar/phone/ScrimState.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java index 1469cdab2d626..35dda44268498 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -96,11 +96,14 @@ public enum ScrimState { AUTH_SCRIMMED { @Override public void prepare(ScrimState previousState) { - mFrontTint = Color.BLACK; + mNotifTint = previousState.mNotifTint; + mNotifAlpha = previousState.mNotifAlpha; - mBehindAlpha = 0f; + mBehindTint = previousState.mBehindTint; + mBehindAlpha = previousState.mBehindAlpha; + + mFrontTint = Color.BLACK; mFrontAlpha = .66f; - mBubbleAlpha = 0f; } },