diff options
author | Svetoslav <svetoslavganov@google.com> | 2015-02-13 03:37:00 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-02-13 03:37:00 +0000 |
commit | 599c1042896564906935bc688bbb85515a6dfa45 (patch) | |
tree | b5bc83ba01d733ddb8925843e2a7e332d67a1423 /core/java | |
parent | 41af9d592efbae88ed95ab77a856dd4e8fbab998 (diff) | |
parent | 27ad2e95b40fd0ca76de384695498ea114d627ca (diff) | |
download | frameworks_base-599c1042896564906935bc688bbb85515a6dfa45.zip frameworks_base-599c1042896564906935bc688bbb85515a6dfa45.tar.gz frameworks_base-599c1042896564906935bc688bbb85515a6dfa45.tar.bz2 |
Accessibility: Ensure fresh accessilbity focused and input focused nodes.
automerge: 27ad2e9
* commit '27ad2e95b40fd0ca76de384695498ea114d627ca':
Accessibility: Ensure fresh accessilbity focused and input focused nodes.
Diffstat (limited to 'core/java')
-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; } } |