Skip to content

Commit 78bd983

Browse files
committed
Accessibility focus drawing does not take into account view's transformation matrix.
1. We are using the view drawing bounds but did not take into account the transformation matrix. This leads to showing ugly artifacts on the launcher's hotseat which is pretty much the first thing we see. 2. Updated the documentation of View.getDrawingRect to be more explicit that the results does not have the transformation matrix applied. bug:7354033 Change-Id: Ief2e0ea8da05471d71e215ce4497d94ff6e92d1a
1 parent 7789c9b commit 78bd983

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

core/java/android/view/View.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4906,7 +4906,7 @@ public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
49064906
*
49074907
* @param outRect The output location
49084908
*/
4909-
private void getBoundsOnScreen(Rect outRect) {
4909+
void getBoundsOnScreen(Rect outRect) {
49104910
if (mAttachInfo == null) {
49114911
return;
49124912
}
@@ -8661,7 +8661,9 @@ public final int getHeight() {
86618661
/**
86628662
* Return the visible drawing bounds of your view. Fills in the output
86638663
* rectangle with the values from getScrollX(), getScrollY(),
8664-
* getWidth(), and getHeight().
8664+
* getWidth(), and getHeight(). These bounds do not account for any
8665+
* transformation properties currently set on the view, such as
8666+
* {@link #setScaleX(float)} or {@link #setRotation(float)}.
86658667
*
86668668
* @param outRect The (scrolled) drawing bounds of the view.
86678669
*/

core/java/android/view/ViewRootImpl.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
import android.content.res.Configuration;
3030
import android.content.res.Resources;
3131
import android.graphics.Canvas;
32+
import android.graphics.Matrix;
3233
import android.graphics.Paint;
3334
import android.graphics.PixelFormat;
3435
import android.graphics.Point;
3536
import android.graphics.PointF;
3637
import android.graphics.PorterDuff;
3738
import android.graphics.Rect;
39+
import android.graphics.RectF;
3840
import android.graphics.Region;
3941
import android.graphics.drawable.Drawable;
4042
import android.media.AudioManager;
@@ -2319,24 +2321,14 @@ private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) {
23192321
mAccessibilityFocusedHost.getAccessibilityNodeProvider();
23202322
Rect bounds = mView.mAttachInfo.mTmpInvalRect;
23212323
if (provider == null) {
2322-
mAccessibilityFocusedHost.getDrawingRect(bounds);
2323-
if (mView instanceof ViewGroup) {
2324-
ViewGroup viewGroup = (ViewGroup) mView;
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-
}
2332-
}
2324+
mAccessibilityFocusedHost.getBoundsOnScreen(bounds);
23332325
} else {
23342326
if (mAccessibilityFocusedVirtualView == null) {
23352327
return;
23362328
}
23372329
mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
2338-
bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
23392330
}
2331+
bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
23402332
drawable.setBounds(bounds);
23412333
drawable.draw(canvas);
23422334
}

0 commit comments

Comments
 (0)