From 26b424b6448fbaddc86d11377ca44ff3169a5d7e Mon Sep 17 00:00:00 2001 From: alanv Date: Wed, 29 Aug 2012 13:07:37 -0700 Subject: [PATCH] Fix key info reported by keyboard accessibility node provider. Bug: 6704529 Change-Id: I519881a96767a8858c11da7c0abac3e276a45cf5 --- .../AccessibilityEntityProvider.java | 9 ++++----- .../AccessibleKeyboardViewProxy.java | 17 +++++++++++++++-- .../inputmethod/keyboard/MainKeyboardView.java | 3 +++ .../com/android/inputmethod/latin/LatinIME.java | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java index 70e38fdb0..56f9c2ab2 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java @@ -195,8 +195,7 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat info.setSource(mKeyboardView, virtualViewId); info.setBoundsInScreen(boundsInScreen); info.setEnabled(true); - info.setClickable(true); - info.addAction(AccessibilityNodeInfoCompat.ACTION_CLICK); + info.setVisibleToUser(true); if (mAccessibilityFocusedView == virtualViewId) { info.addAction(AccessibilityNodeInfoCompat.ACTION_CLEAR_ACCESSIBILITY_FOCUS); @@ -225,6 +224,9 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat mKeyboardView.onTouchEvent(downEvent); mKeyboardView.onTouchEvent(upEvent); + + downEvent.recycle(); + upEvent.recycle(); } @Override @@ -251,9 +253,6 @@ public class AccessibilityEntityProvider extends AccessibilityNodeProviderCompat final int virtualViewId = generateVirtualViewIdForKey(key); switch (action) { - case AccessibilityNodeInfoCompat.ACTION_CLICK: - simulateKeyPress(key); - return true; case AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS: if (mAccessibilityFocusedView == virtualViewId) { return false; diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java index 2fff73154..ed3468afb 100644 --- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java +++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java @@ -105,8 +105,21 @@ public class AccessibleKeyboardViewProxy extends AccessibilityDelegateCompat { } /** - * Receives hover events when accessibility is turned on in SDK versions ICS - * and higher. + * Receives motion events when touch exploration is turned on in SDK + * versions ICS and higher. + * + * @param event The motion event. + * @return {@code true} if the event is handled + */ + public boolean onTouchEvent(MotionEvent event) { + // To avoid accidental key presses during touch exploration, always drop + // non-hover touch events. + return false; + } + + /** + * Receives hover events when touch exploration is turned on in SDK versions + * ICS and higher. * * @param event The hover event. * @return {@code true} if the event is handled diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 9590290ea..0a929f33f 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -672,6 +672,9 @@ public class MainKeyboardView extends KeyboardView implements PointerTracker.Key if (getKeyboard() == null) { return false; } + if (AccessibilityUtils.getInstance().isTouchExplorationEnabled()) { + return AccessibleKeyboardViewProxy.getInstance().onTouchEvent(me); + } return mTouchScreenRegulator.onTouchEvent(me); } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 4a7d0403b..446d44e7a 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -667,7 +667,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // Forward this event to the accessibility utilities, if enabled. final AccessibilityUtils accessUtils = AccessibilityUtils.getInstance(); if (accessUtils.isTouchExplorationEnabled()) { - accessUtils.onStartInputViewInternal(inputView, editorInfo, restarting); + accessUtils.onStartInputViewInternal(mainKeyboardView, editorInfo, restarting); } if (!restarting) {