diff options
| author | Phil Weaver <pweaver@google.com> | 2016-04-07 21:01:57 -0700 |
|---|---|---|
| committer | Phil Weaver <pweaver@google.com> | 2016-04-08 13:06:44 -0700 |
| commit | e37cfab6c65ec0997b07089e70fa0ad47d2fbd83 (patch) | |
| tree | da944d70c8f0520f6fb4d9bb424b02c5d38965e9 /core/java/android/view/View.java | |
| parent | 4a62effbfe8ad9a0eb7049c2f52a57d39bb64e29 (diff) | |
Reduce unnecessary accessibility cache clearing.
Tracking if accessibility focus is being cleared because it is being
set to another view in the same window. In this case, leave
accessibility focus on the window.
This change greatly reduces the amount of cache re-indexing.
Previously we flushed the cache every time accessibility focus moved.
Bug: 28077283
Change-Id: If80899d36e7f58b22635f844bdd4ea37a55b875e
Diffstat (limited to 'core/java/android/view/View.java')
| -rw-r--r-- | core/java/android/view/View.java | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index b0aa5c3a77e0..7e5109637855 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8877,7 +8877,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * @hide */ public void clearAccessibilityFocus() { - clearAccessibilityFocusNoCallbacks(); + clearAccessibilityFocusNoCallbacks(0); // Clear the global reference of accessibility focus if this view or // any of its descendants had accessibility focus. This will NOT send @@ -8920,14 +8920,27 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Clears accessibility focus without calling any callback methods * normally invoked in {@link #clearAccessibilityFocus()}. This method - * is used for clearing accessibility focus when giving this focus to - * another view. + * is used separately from that one for clearing accessibility focus when + * giving this focus to another view. + * + * @param action The action, if any, that led to focus being cleared. Set to + * AccessibilityNodeInfo#ACTION_ACCESSIBILITY_FOCUS to specify that focus is moving within + * the window. */ - void clearAccessibilityFocusNoCallbacks() { + void clearAccessibilityFocusNoCallbacks(int action) { if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) != 0) { mPrivateFlags2 &= ~PFLAG2_ACCESSIBILITY_FOCUSED; invalidate(); - sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED); + if (AccessibilityManager.getInstance(mContext).isEnabled()) { + AccessibilityEvent event = AccessibilityEvent.obtain( + AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED); + event.setAction(action); + if (mAccessibilityDelegate != null) { + mAccessibilityDelegate.sendAccessibilityEventUnchecked(this, event); + } else { + sendAccessibilityEventUnchecked(event); + } + } } } |
