From 9934740a5fd85ad0ea6126328ba9015069d2fdc0 Mon Sep 17 00:00:00 2001
From: "Tadashi G. Takaoka" <takaoka@google.com>
Date: Fri, 13 Jun 2014 16:33:54 +0900
Subject: [PATCH] Return an empty accessibility node info for a keyboard

Because a keyboard handling hover events and determining a virtual
node by itself, there is no need to supply whole virtual nodes info
for the keyboard. Just returning an empty accessibility node info
supresses annoucements of all keys.

This CL also fixes the undefined virtual id value.

Bug: 15582251
Change-Id: Ie033d21ef878d272417cf2b20f8eec1e516587f6
---
 .../KeyboardAccessibilityNodeProvider.java     | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java
index 18673a366c..cb13483f2b 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java
@@ -49,7 +49,9 @@ import java.util.List;
  */
 final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderCompat {
     private static final String TAG = KeyboardAccessibilityNodeProvider.class.getSimpleName();
-    private static final int UNDEFINED = Integer.MIN_VALUE;
+
+    // From {@link android.view.accessibility.AccessibilityNodeInfo#UNDEFINED_ITEM_ID}.
+    private static final int UNDEFINED = Integer.MAX_VALUE;
 
     private final KeyCodeDescriptionMapper mKeyCodeDescriptionMapper;
     private final AccessibilityUtils mAccessibilityUtils;
@@ -167,22 +169,10 @@ final class KeyboardAccessibilityNodeProvider extends AccessibilityNodeProviderC
         }
         if (virtualViewId == View.NO_ID) {
             // We are requested to create an AccessibilityNodeInfo describing
-            // this View, i.e. the root of the virtual sub-tree.
+            // this View. Returning an empty info is sufficient for a keyboard.
             final AccessibilityNodeInfoCompat rootInfo =
                     AccessibilityNodeInfoCompat.obtain(mKeyboardView);
             ViewCompat.onInitializeAccessibilityNodeInfo(mKeyboardView, rootInfo);
-
-            // Add the virtual children of the root View.
-            final List<Key> sortedKeys = mKeyboard.getSortedKeys();
-            final int size = sortedKeys.size();
-            for (int index = 0; index < size; index++) {
-                final Key key = sortedKeys.get(index);
-                if (key.isSpacer()) {
-                    continue;
-                }
-                // Use an index of the sorted keys list as a virtual view id.
-                rootInfo.addChild(mKeyboardView, index);
-            }
             return rootInfo;
         }
 
-- 
GitLab