Ensure ViewRootImpl.setAccessibilityFocus() doesn't crash when reentrant.

Internal state must be cleared before calling any methods on the focus
host, since the method may be called again from the host and attempt to
recycle the same AccessibilityNodeInfo twice.

BUG: 8856860
Change-Id: I0410989fd6f3ce3ce29de8edebdfbf3847188843
This commit is contained in:
Alan Viverette
2013-05-07 17:17:35 -07:00
parent 81a8bb1ca9
commit 239a0c0e6a

View File

@@ -2709,7 +2709,6 @@ public final class ViewRootImpl implements ViewParent,
AccessibilityNodeInfo focusNode = mAccessibilityFocusedVirtualView;
View focusHost = mAccessibilityFocusedHost;
focusHost.clearAccessibilityFocusNoCallbacks();
// Wipe the state of the current accessibility focus since
// the call into the provider to clear accessibility focus
@@ -2719,6 +2718,10 @@ public final class ViewRootImpl implements ViewParent,
mAccessibilityFocusedHost = null;
mAccessibilityFocusedVirtualView = null;
// Clear accessibility focus on the host after clearing state since
// this method may be reentrant.
focusHost.clearAccessibilityFocusNoCallbacks();
AccessibilityNodeProvider provider = focusHost.getAccessibilityNodeProvider();
if (provider != null) {
// Invalidate the area of the cleared accessibility focus.