am 6b0d0fa3: am f8233ec3: Merge "Refresh Accessibility key mapping when KeyboardView changes Keyboards." into jb-dev

* commit '6b0d0fa3501247ccf3190c938dec580102fe0473':
  Refresh Accessibility key mapping when KeyboardView changes Keyboards.
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
index 9986f6e..ba08c59 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityEntityProvider.java
@@ -85,9 +85,20 @@
      */
     public void setView(KeyboardView keyboardView) {
         mKeyboardView = keyboardView;
-
-        assignVirtualViewIds();
         updateParentLocation();
+
+        // Since this class is constructed lazily, we might not get a subsequent
+        // call to setKeyboard() and therefore need to call it now.
+        setKeyboard(mKeyboardView.getKeyboard());
+    }
+
+    /**
+     * Sets the keyboard represented by this node provider.
+     *
+     * @param keyboard The keyboard to represent.
+     */
+    public void setKeyboard(Keyboard keyboard) {
+        assignVirtualViewIds();
     }
 
     /**
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
index 59f1eec..f6376d5 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibleKeyboardViewProxy.java
@@ -86,6 +86,12 @@
         }
     }
 
+    public void setKeyboard(Keyboard keyboard) {
+        if (mAccessibilityNodeProvider != null) {
+            mAccessibilityNodeProvider.setKeyboard(keyboard);
+        }
+    }
+
     /**
      * Proxy method for View.getAccessibilityNodeProvider(). This method is
      * called in SDK version 15 and higher to obtain the virtual node hierarchy
diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
index e917a81..383298d 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -468,6 +468,10 @@
         if (ProductionFlag.IS_EXPERIMENTAL) {
             ResearchLogger.latinKeyboardView_setKeyboard(keyboard);
         }
+
+        // This always needs to be set since the accessibility state can
+        // potentially change without the keyboard being set again.
+        AccessibleKeyboardViewProxy.getInstance().setKeyboard(keyboard);
     }
 
     /**