Skip to content

Commit 28e8f76

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "Cannot click on partially visible views in touch exploration." into jb-mr1-dev
2 parents 37238e5 + a94c319 commit 28e8f76

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)