From 3e9fddd94fef5d7a195b4ad73d76eecddaf89406 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Thu, 22 Apr 2021 14:14:13 -0700 Subject: [PATCH 1/2] Disable guided enrollment for a11y Fixes: 186143173 Test: Enable talkback, enroll Change-Id: I25dacbfacac8d215c545d52a136b154a7d21591d --- .../systemui/biometrics/UdfpsEnrollHelper.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java index 521c495496531..470fb8c1a561d 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollHelper.java @@ -26,6 +26,7 @@ import android.os.UserHandle; import android.provider.Settings; import android.util.Log; import android.util.TypedValue; +import android.view.accessibility.AccessibilityManager; import java.util.ArrayList; import java.util.List; @@ -53,6 +54,7 @@ public class UdfpsEnrollHelper { @NonNull private final Context mContext; // IUdfpsOverlayController reason private final int mEnrollReason; + private final boolean mAccessibilityEnabled; @NonNull private final List mGuidedEnrollmentPoints; private int mTotalSteps = -1; @@ -67,6 +69,10 @@ public class UdfpsEnrollHelper { public UdfpsEnrollHelper(@NonNull Context context, int reason) { mContext = context; mEnrollReason = reason; + + final AccessibilityManager am = context.getSystemService(AccessibilityManager.class); + mAccessibilityEnabled = am.isEnabled(); + mGuidedEnrollmentPoints = new ArrayList<>(); // Number of pixels per mm @@ -148,6 +154,8 @@ public class UdfpsEnrollHelper { boolean isCenterEnrollmentComplete() { if (mTotalSteps == -1 || mRemainingSteps == -1) { return false; + } else if (mAccessibilityEnabled) { + return false; } final int stepsEnrolled = mTotalSteps - mRemainingSteps; return stepsEnrolled >= NUM_CENTER_TOUCHES; @@ -155,6 +163,10 @@ public class UdfpsEnrollHelper { @NonNull PointF getNextGuidedEnrollmentPoint() { + if (mAccessibilityEnabled) { + return new PointF(0f, 0f); + } + float scale = SCALE; if (Build.IS_ENG || Build.IS_USERDEBUG) { scale = Settings.Secure.getFloatForUser(mContext.getContentResolver(), From 4c83e679c9141aadd70959e2c63dfff7d4b92f37 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Thu, 13 May 2021 17:29:12 -0700 Subject: [PATCH 2/2] Prevent UdfpsView from being selectable during a11y enrollment Touching the sensor area also selects the UdfpsView, which triggers unnecessary feedback. Fixes: 187324285 Test: manual Change-Id: I9761c313d917f11fd42e0d584d6303d2150ce1a0 --- .../com/android/systemui/biometrics/UdfpsController.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 5a50f0eed8338..5805afc3564bb 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -624,6 +624,14 @@ public class UdfpsController implements DozeReceiver, HbmCallback { animation.init(); mView.setAnimationViewController(animation); + // This view overlaps the sensor area, so prevent it from being selectable + // during a11y. + if (reason == IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR + || reason == IUdfpsOverlayController.REASON_ENROLL_ENROLLING) { + mView.setImportantForAccessibility( + View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + } + mWindowManager.addView(mView, computeLayoutParams(animation)); mAccessibilityManager.addTouchExplorationStateChangeListener( mTouchExplorationStateChangeListener);