Skip to content

Commit 1d74df2

Browse files
committed
Fixing crash when drawing accessibility focus indicator.
1. Added a lacking null check for the accessibility node info returned by an accessibility node provider. If the provider implementation is not correct this may happen. 2. Added clearing of the current accessibility focused node when the window focus changes. Now it is cleared in every case and if it happens that accessibility is enabled when the window gets focus, the accessibility focus will be properly set. bug:6381296 Change-Id: Ieea1b07762745e6d932fc4ed4febfe77760b25b7
1 parent a36b7ab commit 1d74df2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,8 @@ public void setView(View view, WindowManager.LayoutParams attrs, View panelParen
634634
if (view.getImportantForAccessibility() == View.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
635635
view.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
636636
}
637+
638+
setAccessibilityFocusedHost(null);
637639
}
638640
}
639641
}
@@ -2326,6 +2328,9 @@ private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) {
23262328
if (mAccessibilityFocusedVirtualView == null) {
23272329
mAccessibilityFocusedVirtualView = provider.findAccessibilitiyFocus(View.NO_ID);
23282330
}
2331+
if (mAccessibilityFocusedVirtualView == null) {
2332+
return;
2333+
}
23292334
mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
23302335
bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
23312336
}
@@ -2849,6 +2854,8 @@ public void handleMessage(Message msg) {
28492854
mHasHadWindowFocus = true;
28502855
}
28512856

2857+
setAccessibilityFocusedHost(null);
2858+
28522859
if (mView != null && mAccessibilityManager.isEnabled()) {
28532860
if (hasWindowFocus) {
28542861
mView.sendAccessibilityEvent(
@@ -2867,9 +2874,6 @@ public void handleMessage(Message msg) {
28672874
if (mAccessibilityFocusedHost == null) {
28682875
mView.requestAccessibilityFocus();
28692876
}
2870-
} else {
2871-
// Clear accessibility focus when the window loses input focus.
2872-
setAccessibilityFocusedHost(null);
28732877
}
28742878
}
28752879
}

0 commit comments

Comments
 (0)