From 746cd79b371f989cad13375f23d54725a7e4ff50 Mon Sep 17 00:00:00 2001 From: Beverly Date: Mon, 21 Mar 2022 15:30:22 +0000 Subject: [PATCH] Update lock icon a11y click handler on a11y change Previously, it would only update when the lock icon view was attached; however, a11y services can change while the view is attached. Test: turn on tbon via adb while on the LS and see that "double tap to activate" works adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.android.talkback.TalkBackService adb shell settings put secure enabled_accessibility_services com.google.android.marvin.talkback/com.google.android.marvin.talkback.TalkBackService adb shell settings put secure accessibility_enabled 1 Fixes: 224530029 Fixes: 215294494 Change-Id: I490c2a5867ffcb2bac56968af038e298f30f0b8e --- .../keyguard/LockIconViewController.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java index e36e984380e21..a4a0105fae3d3 100644 --- a/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/LockIconViewController.java @@ -212,19 +212,14 @@ public class LockIconViewController extends ViewController impleme updateBurnInOffsets(); updateVisibility(); + mAccessibilityManager.addTouchExplorationStateChangeListener( + mTouchExplorationStateChangeListener); updateAccessibility(); } private void updateAccessibility() { if (mAccessibilityManager.isTouchExplorationEnabled()) { - mView.setOnClickListener( - new View.OnClickListener() { - @Override - public void onClick(View v) { - onLongPress(); - } - } - ); + mView.setOnClickListener(mA11yClickListener); } else { mView.setOnClickListener(null); } @@ -242,6 +237,9 @@ public class LockIconViewController extends ViewController impleme mCancelDelayedUpdateVisibilityRunnable.run(); mCancelDelayedUpdateVisibilityRunnable = null; } + + mAccessibilityManager.removeTouchExplorationStateChangeListener( + mTouchExplorationStateChangeListener); } public float getTop() { @@ -267,7 +265,6 @@ public class LockIconViewController extends ViewController impleme return; } - boolean wasShowingUnlock = mShowUnlockIcon; boolean wasShowingFpIcon = mUdfpsEnrolled && !mShowUnlockIcon && !mShowLockIcon && !mShowAodUnlockedIcon && !mShowAodLockIcon; mShowLockIcon = !mCanDismissLockScreen && !mUserUnlockedWithBiometric && isLockScreen() @@ -702,6 +699,14 @@ public class LockIconViewController extends ViewController impleme mView.setAlpha(alpha); } + private void updateUdfpsConfig() { + // must be called from the main thread since it may update the views + mExecutor.execute(() -> { + updateIsUdfpsEnrolled(); + updateConfiguration(); + }); + } + private final AuthController.Callback mAuthControllerCallback = new AuthController.Callback() { @Override public void onAllAuthenticatorsRegistered() { @@ -714,11 +719,8 @@ public class LockIconViewController extends ViewController impleme } }; - private void updateUdfpsConfig() { - // must be called from the main thread since it may update the views - mExecutor.execute(() -> { - updateIsUdfpsEnrolled(); - updateConfiguration(); - }); - } + private final View.OnClickListener mA11yClickListener = v -> onLongPress(); + + private final AccessibilityManager.TouchExplorationStateChangeListener + mTouchExplorationStateChangeListener = enabled -> updateAccessibility(); }