summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/accessibility
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2014-08-25 18:35:57 -0700
committerSvetoslav <svetoslavganov@google.com>2014-08-26 10:06:22 -0700
commit04cab1bcc46b05cbb72632c53ad83943f705b494 (patch)
treed061e238253fdf9f6b4e6cbcecb7e7459da6f4be /core/java/android/view/accessibility
parent4b4d7efe522b01237b842c23a1d92559fe412a6e (diff)
downloadframeworks_base-04cab1bcc46b05cbb72632c53ad83943f705b494.zip
frameworks_base-04cab1bcc46b05cbb72632c53ad83943f705b494.tar.gz
frameworks_base-04cab1bcc46b05cbb72632c53ad83943f705b494.tar.bz2
Fix accessiblity CTS tests (framework).
1. An external contribution changed the ordering of views for accessibility. While it attempted to fix a platform issue for a comparator breaking transitivity, it changed the way we order views and results in very unnatural accessibility traversal order. It also broke CTS tets. This change tweaks the comparator which fixes the tests and improves traversal order. 2. If there is at least one accessibility service which cares about windows we register a callback in the window manager for window change notifications. We are updating the window list on this callback. There was a case where if the service requests window updates and immediately asks for the windows it gets none as we have not received a callback from the window manager yet. Now this call returns after we get the callback in a timed fashion. This is consistent with how the other introspection APIs work. 3. Window info objects are cached in the accessibility service process. When putting them in the cache a cloning call was missing resulting in some cases of clobbering windows given to the client. For example, we get some windows, cache them, and return these windows to the client. Now a call to clear the cache arrives while the user processes the windows and the client windows get clobbered. 4. Added API for checking if a window has accessiblity focus to be consistent to the API we have to check whether this window has input focus. 5. Removed some obsolete code. bug:16402352 Change-Id: Ided6da4a82cc0fc703008c58a2dff0119a3ff317
Diffstat (limited to 'core/java/android/view/accessibility')
-rw-r--r--core/java/android/view/accessibility/AccessibilityCache.java12
-rw-r--r--core/java/android/view/accessibility/AccessibilityWindowInfo.java21
2 files changed, 29 insertions, 4 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java
index ca6437a..ead757e 100644
--- a/core/java/android/view/accessibility/AccessibilityCache.java
+++ b/core/java/android/view/accessibility/AccessibilityCache.java
@@ -54,7 +54,12 @@ final class AccessibilityCache {
if (DEBUG) {
Log.i(LOG_TAG, "Caching window: " + window.getId());
}
- mWindowCache.put(window.getId(), window);
+ final int windowId = window.getId();
+ AccessibilityWindowInfo oldWindow = mWindowCache.get(windowId);
+ if (oldWindow != null) {
+ oldWindow.recycle();
+ }
+ mWindowCache.put(windowId, AccessibilityWindowInfo.obtain(window));
}
}
@@ -183,14 +188,13 @@ final class AccessibilityCache {
sortedWindows.put(window.getLayer(), window);
}
- List<AccessibilityWindowInfo> windows = new ArrayList<>();
+ List<AccessibilityWindowInfo> windows = new ArrayList<>(windowCount);
for (int i = windowCount - 1; i >= 0; i--) {
AccessibilityWindowInfo window = sortedWindows.valueAt(i);
windows.add(AccessibilityWindowInfo.obtain(window));
+ sortedWindows.removeAt(i);
}
- sortedWindows.clear();
-
return windows;
}
return null;
diff --git a/core/java/android/view/accessibility/AccessibilityWindowInfo.java b/core/java/android/view/accessibility/AccessibilityWindowInfo.java
index 80b5c50..ad55f5f 100644
--- a/core/java/android/view/accessibility/AccessibilityWindowInfo.java
+++ b/core/java/android/view/accessibility/AccessibilityWindowInfo.java
@@ -55,6 +55,7 @@ public final class AccessibilityWindowInfo implements Parcelable {
private static final int BOOLEAN_PROPERTY_ACTIVE = 1 << 0;
private static final int BOOLEAN_PROPERTY_FOCUSED = 1 << 1;
+ private static final int BOOLEAN_PROPERTY_ACCESSIBLITY_FOCUSED = 1 << 2;
// Housekeeping.
private static final int MAX_POOL_SIZE = 10;
@@ -258,6 +259,26 @@ public final class AccessibilityWindowInfo implements Parcelable {
}
/**
+ * Gets if this window has accessibility focus.
+ *
+ * @return Whether has accessibility focus.
+ */
+ public boolean isAccessibilityFocused() {
+ return getBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBLITY_FOCUSED);
+ }
+
+ /**
+ * Sets if this window has accessibility focus.
+ *
+ * @param Whether has accessibility focus.
+ *
+ * @hide
+ */
+ public void setAccessibilityFocused(boolean focused) {
+ setBooleanProperty(BOOLEAN_PROPERTY_ACCESSIBLITY_FOCUSED, focused);
+ }
+
+ /**
* Gets the number of child windows.
*
* @return The child count.