Skip to content

Commit c886060

Browse files
committed
Incorrect temporary detach of accessibility focused view may lead to a crash.
1. If an app naither reattaches nor removes detached view that has accessibility focus, an exception in the drawing of accessibility focus occurs since we are trying to compute the focused rect by offseting the bounds of the focused view in coords of the root but the focused one is not attached. bug:7297191 Change-Id: Ib69d52e474b8ea365754f5311f5e809bd757dd1a
1 parent 8d0739d commit c886060

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

core/java/android/view/ViewGroup.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3912,7 +3912,6 @@ protected void attachViewToParent(View child, int index, LayoutParams params) {
39123912
* @see #removeDetachedView(View, boolean)
39133913
*/
39143914
protected void detachViewFromParent(View child) {
3915-
child.clearAccessibilityFocus();
39163915
removeFromArray(indexOfChild(child));
39173916
}
39183917

@@ -3934,7 +3933,6 @@ protected void detachViewFromParent(View child) {
39343933
* @see #removeDetachedView(View, boolean)
39353934
*/
39363935
protected void detachViewFromParent(int index) {
3937-
getChildAt(index).clearAccessibilityFocus();
39383936
removeFromArray(index);
39393937
}
39403938

core/java/android/view/ViewRootImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,13 @@ private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) {
23222322
mAccessibilityFocusedHost.getDrawingRect(bounds);
23232323
if (mView instanceof ViewGroup) {
23242324
ViewGroup viewGroup = (ViewGroup) mView;
2325-
viewGroup.offsetDescendantRectToMyCoords(mAccessibilityFocusedHost, bounds);
2325+
try {
2326+
viewGroup.offsetDescendantRectToMyCoords(mAccessibilityFocusedHost, bounds);
2327+
} catch (IllegalArgumentException iae) {
2328+
Log.e(TAG, "Temporary detached view that was neither removed not reattached: "
2329+
+ mAccessibilityFocusedHost);
2330+
return;
2331+
}
23262332
}
23272333
} else {
23282334
if (mAccessibilityFocusedVirtualView == null) {

0 commit comments

Comments
 (0)