Skip to content

Commit a94c319

Browse files
committed
Cannot click on partially visible views in touch exploration.
1. In touch exploration mode the system clicks in the center of the accessibility focus rectangle. However, if this rectangle is only partially shown on the window or on the screen the system may not be able to perform the click, if the accessibility focus center is not on the screen, or click on the wrong window, if the access focus center is outside of the window. This change clips the rectangle to the window bounds which and the display bounds. This will ensure no clicks are sent to the wrong window and no clicks are sent outside of the screen. bug:7453839 Change-Id: I79f98971e7ebcbb391c37284467dc76076172c5f
1 parent 7ab7f53 commit a94c319

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,7 @@ private void drawAccessibilityFocusedDrawableIfNeeded(Canvas canvas) {
23382338
mAccessibilityFocusedVirtualView.getBoundsInScreen(bounds);
23392339
}
23402340
bounds.offset(-mAttachInfo.mWindowLeft, -mAttachInfo.mWindowTop);
2341+
bounds.intersect(0, 0, mAttachInfo.mViewRootImpl.mWidth, mAttachInfo.mViewRootImpl.mHeight);
23412342
drawable.setBounds(bounds);
23422343
drawable.draw(canvas);
23432344
}

services/java/com/android/server/accessibility/AccessibilityManagerService.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
import android.content.pm.ResolveInfo;
4141
import android.content.pm.ServiceInfo;
4242
import android.database.ContentObserver;
43+
import android.graphics.Point;
4344
import android.graphics.Rect;
45+
import android.hardware.display.DisplayManager;
4446
import android.hardware.input.InputManager;
4547
import android.net.Uri;
4648
import android.os.Binder;
@@ -62,6 +64,7 @@
6264
import android.text.TextUtils.SimpleStringSplitter;
6365
import android.util.Slog;
6466
import android.util.SparseArray;
67+
import android.view.Display;
6568
import android.view.IWindow;
6669
import android.view.IWindowManager;
6770
import android.view.InputDevice;
@@ -137,6 +140,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
137140
private final List<AccessibilityServiceInfo> mEnabledServicesForFeedbackTempList =
138141
new ArrayList<AccessibilityServiceInfo>();
139142

143+
private final Rect mTempRect = new Rect();
144+
145+
private final Point mTempPoint = new Point();
146+
147+
private final Display mDefaultDisplay;
148+
140149
private final PackageManager mPackageManager;
141150

142151
private final IWindowManager mWindowManagerService;
@@ -194,6 +203,10 @@ public AccessibilityManagerService(Context context) {
194203
mWindowManagerService = (IWindowManager) ServiceManager.getService(Context.WINDOW_SERVICE);
195204
mSecurityPolicy = new SecurityPolicy();
196205
mMainHandler = new MainHandler(mContext.getMainLooper());
206+
//TODO: (multi-display) We need to support multiple displays.
207+
DisplayManager displayManager = (DisplayManager)
208+
mContext.getSystemService(Context.DISPLAY_SERVICE);
209+
mDefaultDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
197210
registerBroadcastReceivers();
198211
new AccessibilityContentObserver(mMainHandler).register(
199212
context.getContentResolver());
@@ -582,6 +595,7 @@ boolean onGesture(int gestureId) {
582595
* @param outBounds The output to which to write the focus bounds.
583596
* @return Whether accessibility focus was found and the bounds are populated.
584597
*/
598+
// TODO: (multi-display) Make sure this works for multiple displays.
585599
boolean getAccessibilityFocusBoundsInActiveWindow(Rect outBounds) {
586600
// Instead of keeping track of accessibility focus events per
587601
// window to be able to find the focus in the active window,
@@ -603,6 +617,13 @@ boolean getAccessibilityFocusBoundsInActiveWindow(Rect outBounds) {
603617
return false;
604618
}
605619
focus.getBoundsInScreen(outBounds);
620+
// Clip to the window rectangle.
621+
Rect windowBounds = mTempRect;
622+
getActiveWindowBounds(windowBounds);
623+
outBounds.intersect(windowBounds);
624+
// Clip to the screen rectangle.
625+
mDefaultDisplay.getRealSize(mTempPoint);
626+
outBounds.intersect(0, 0, mTempPoint.x, mTempPoint.y);
606627
return true;
607628
} finally {
608629
client.removeConnection(connectionId);

0 commit comments

Comments
 (0)