diff options
author | Svetoslav <svetoslavganov@google.com> | 2015-02-13 03:41:55 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-02-13 03:41:55 +0000 |
commit | 610f0364552c0bf9002d39bbef9552f74201a072 (patch) | |
tree | 806b6e012c9160885b8cc6318c172fbed702e769 /core | |
parent | 598aa3dabad81b98da6413a71372b38dc953bb2a (diff) | |
parent | 27ad2e95b40fd0ca76de384695498ea114d627ca (diff) | |
download | frameworks_base-610f0364552c0bf9002d39bbef9552f74201a072.zip frameworks_base-610f0364552c0bf9002d39bbef9552f74201a072.tar.gz frameworks_base-610f0364552c0bf9002d39bbef9552f74201a072.tar.bz2 |
am 27ad2e95: Accessibility: Ensure fresh accessilbity focused and input focused nodes.
* commit '27ad2e95b40fd0ca76de384695498ea114d627ca':
Accessibility: Ensure fresh accessilbity focused and input focused nodes.
Diffstat (limited to 'core')
-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; } } |