diff options
author | Svetoslav <svetoslavganov@google.com> | 2015-02-12 17:54:15 -0800 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2015-02-13 01:59:11 +0000 |
commit | 27ad2e95b40fd0ca76de384695498ea114d627ca (patch) | |
tree | b36925d834198a0cb2369b2c21055f0a7fccf9ad | |
parent | d2ccbd43d24a79122e404206c528995600a6507d (diff) | |
download | frameworks_base-27ad2e95b40fd0ca76de384695498ea114d627ca.zip frameworks_base-27ad2e95b40fd0ca76de384695498ea114d627ca.tar.gz frameworks_base-27ad2e95b40fd0ca76de384695498ea114d627ca.tar.bz2 |
Accessibility: Ensure fresh accessilbity focused and input focused nodes.
Change-Id: Ia3c84284843a415cdbbc2b6a9b06d9ddffbe0e04
-rw-r--r-- | core/java/android/view/accessibility/AccessibilityCache.java | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/core/java/android/view/accessibility/AccessibilityCache.java b/core/java/android/view/accessibility/AccessibilityCache.java index 52912b1..d0dde00 100644 --- a/core/java/android/view/accessibility/AccessibilityCache.java +++ b/core/java/android/view/accessibility/AccessibilityCache.java @@ -40,6 +40,9 @@ final class AccessibilityCache { private final Object mLock = new Object(); + private long mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID; + private long mInputFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID; + private final SparseArray<AccessibilityWindowInfo> mWindowCache = new SparseArray<>(); @@ -73,9 +76,29 @@ final class AccessibilityCache { synchronized (mLock) { final int eventType = event.getEventType(); switch (eventType) { - case AccessibilityEvent.TYPE_VIEW_FOCUSED: - case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: - case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: + case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: { + if (mAccessibilityFocus != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) { + refreshCachedNodeLocked(event.getWindowId(), mAccessibilityFocus); + } + mAccessibilityFocus = event.getSourceNodeId(); + refreshCachedNodeLocked(event.getWindowId(), mAccessibilityFocus); + } break; + + case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED: { + if (mAccessibilityFocus == event.getSourceNodeId()) { + refreshCachedNodeLocked(event.getWindowId(), mAccessibilityFocus); + mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID; + } + } break; + + case AccessibilityEvent.TYPE_VIEW_FOCUSED: { + if (mInputFocus != AccessibilityNodeInfo.UNDEFINED_ITEM_ID) { + refreshCachedNodeLocked(event.getWindowId(), mInputFocus); + } + mInputFocus = event.getSourceNodeId(); + refreshCachedNodeLocked(event.getWindowId(), mInputFocus); + } break; + case AccessibilityEvent.TYPE_VIEW_SELECTED: case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED: case AccessibilityEvent.TYPE_VIEW_CLICKED: @@ -268,6 +291,9 @@ final class AccessibilityCache { final int windowId = mNodeCache.keyAt(i); clearNodesForWindowLocked(windowId); } + + mAccessibilityFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID; + mInputFocus = AccessibilityNodeInfo.UNDEFINED_ITEM_ID; } } |