summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/accessibility/TouchExplorer.java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2012-06-06 21:12:20 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2012-06-07 12:02:16 -0700
commit86783474fdec98a22bc22e224462767eab13e273 (patch)
tree38ca4f46402c35874a2960ea9bc2da16ca4eb2eb /services/java/com/android/server/accessibility/TouchExplorer.java
parentfefd48965c5f521f21c10aad86586cf68ae48f71 (diff)
downloadframeworks_base-86783474fdec98a22bc22e224462767eab13e273.zip
frameworks_base-86783474fdec98a22bc22e224462767eab13e273.tar.gz
frameworks_base-86783474fdec98a22bc22e224462767eab13e273.tar.bz2
Cannot interact with dialogs when IME is up and on not touch explored popups.
1. If the last touch explored location is within the active window we used to click on exact location if it is within the accessibility focus otherwise in the accessibility focus center. If the last touch explored location is not within the active window we used to just click there. This breaks in the case were one has touch explored at a given place in the current window and now a dialog opens *not* covering the touch explored location. If one uses swipes to move accessibility focus i.e. to traverse the dialog without touching it one cannot activate anything because the touch explorer is using the last touch explored location that is outside of the active window e.g the dialog. The solution is to clear the last touch explored location when a window opens or accessibility focus moves. If the last touch explored location is null we are clicking in the accessibility focus location. bug:6620911 2. There is a bug in the window manager that does not notify a window that its location has changed (bug:6623031). This breaks accessibility interaction with dialogs that have input because when the IME is up the dialog is moved but not notified. Now the accessibility layer gets incorrect location for the accessibility focus and the window bounds. The soluion is when the accessibility manager service calls into the remove thress to obtain some accessibility node infos it passes the window left and top which it gets from the window manager. These values are used to update the attach info window left and top so all accessibility node infos emitted from that window had correct bounds in screen coordinates. bug:6620796 Change-Id: I18914f2095c55cfc826acf5277bd94b776bda0c8
Diffstat (limited to 'services/java/com/android/server/accessibility/TouchExplorer.java')
-rw-r--r--services/java/com/android/server/accessibility/TouchExplorer.java138
1 files changed, 83 insertions, 55 deletions
diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java
index 7e88373..14784dc 100644
--- a/services/java/com/android/server/accessibility/TouchExplorer.java
+++ b/services/java/com/android/server/accessibility/TouchExplorer.java
@@ -33,6 +33,7 @@ import android.view.MotionEvent.PointerProperties;
import android.view.VelocityTracker;
import android.view.ViewConfiguration;
import android.view.WindowManagerPolicy;
+import android.view.accessibility.AccessibilityEvent;
import com.android.internal.R;
import com.android.server.input.InputFilter;
@@ -293,6 +294,21 @@ public class TouchExplorer {
}
}
+ public void onAccessibilityEvent(AccessibilityEvent event) {
+ // If a new window opens or the accessibility focus moves we no longer
+ // want to click/long press on the last touch explored location.
+ final int eventType = event.getEventType();
+ switch (eventType) {
+ case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
+ case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
+ if (mInjectedPointerTracker.mLastInjectedHoverEvent != null) {
+ mInjectedPointerTracker.mLastInjectedHoverEvent.recycle();
+ mInjectedPointerTracker.mLastInjectedHoverEvent = null;
+ }
+ } break;
+ }
+ }
+
/**
* Handles a motion event in touch exploring state.
*
@@ -1037,30 +1053,40 @@ public class TouchExplorer {
// is actually clicked.
sendExitEventsIfNeeded(policyFlags);
- // If the last touched explored location is not within the focused
- // window we will click at that exact spot, otherwise we find the
- // accessibility focus and if the tap is within its bounds we click
- // there, otherwise we pick the middle of the focus rectangle.
- MotionEvent lastEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
- if (lastEvent == null) {
- return;
- }
-
- final int exploreLocationX = (int) lastEvent.getX(lastEvent.getActionIndex());
- final int exploreLocationY = (int) lastEvent.getY(lastEvent.getActionIndex());
-
- Rect bounds = mTempRect;
- boolean useLastHoverLocation = false;
+ int clickLocationX;
+ int clickLocationY;
final int pointerId = secondTapUp.getPointerId(secondTapUp.getActionIndex());
final int pointerIndex = secondTapUp.findPointerIndex(pointerId);
- if (mAms.getAccessibilityFocusBounds(exploreLocationX, exploreLocationY, bounds)) {
- // If the user's last touch explored location is not
- // within the accessibility focus bounds we use the center
- // of the accessibility focused rectangle.
- if (!bounds.contains((int) secondTapUp.getX(pointerIndex),
- (int) secondTapUp.getY(pointerIndex))) {
- useLastHoverLocation = true;
+
+ MotionEvent lastExploreEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
+ if (lastExploreEvent == null) {
+ // No last touch explored event but there is accessibility focus in
+ // the active window. We click in the middle of the focus bounds.
+ Rect focusBounds = mTempRect;
+ if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
+ clickLocationX = focusBounds.centerX();
+ clickLocationY = focusBounds.centerY();
+ } else {
+ // Out of luck - do nothing.
+ return;
+ }
+ } else {
+ // If the click is within the active window but not within the
+ // accessibility focus bounds we click in the focus center.
+ final int lastExplorePointerIndex = lastExploreEvent.getActionIndex();
+ clickLocationX = (int) lastExploreEvent.getX(lastExplorePointerIndex);
+ clickLocationY = (int) lastExploreEvent.getY(lastExplorePointerIndex);
+ Rect activeWindowBounds = mTempRect;
+ mAms.getActiveWindowBounds(activeWindowBounds);
+ if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
+ Rect focusBounds = mTempRect;
+ if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
+ if (!focusBounds.contains(clickLocationX, clickLocationY)) {
+ clickLocationX = focusBounds.centerX();
+ clickLocationY = focusBounds.centerY();
+ }
+ }
}
}
@@ -1070,8 +1096,8 @@ public class TouchExplorer {
secondTapUp.getPointerProperties(pointerIndex, properties[0]);
PointerCoords[] coords = new PointerCoords[1];
coords[0] = new PointerCoords();
- coords[0].x = (useLastHoverLocation) ? bounds.centerX() : exploreLocationX;
- coords[0].y = (useLastHoverLocation) ? bounds.centerY() : exploreLocationY;
+ coords[0].x = clickLocationX;
+ coords[0].y = clickLocationY;
MotionEvent event = MotionEvent.obtain(secondTapUp.getDownTime(),
secondTapUp.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties,
coords, 0, 0, 1.0f, 1.0f, secondTapUp.getDeviceId(), 0,
@@ -1257,45 +1283,47 @@ public class TouchExplorer {
return;
}
- // If the last touched explored location is not within the focused
- // window we will long press at that exact spot, otherwise we find the
- // accessibility focus and if the tap is within its bounds we long press
- // there, otherwise we pick the middle of the focus rectangle.
- MotionEvent lastEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
- if (lastEvent == null) {
- return;
- }
-
- final int exploreLocationX = (int) lastEvent.getX(lastEvent.getActionIndex());
- final int exploreLocationY = (int) lastEvent.getY(lastEvent.getActionIndex());
-
- Rect bounds = mTempRect;
- boolean useFocusedBounds = false;
+ int clickLocationX;
+ int clickLocationY;
final int pointerId = mEvent.getPointerId(mEvent.getActionIndex());
final int pointerIndex = mEvent.findPointerIndex(pointerId);
- if (mAms.getAccessibilityFocusBounds(exploreLocationX, exploreLocationY, bounds)) {
- // If the user's last touch explored location is not
- // within the accessibility focus bounds we use the center
- // of the accessibility focused rectangle.
- if (!bounds.contains((int) mEvent.getX(pointerIndex),
- (int) mEvent.getY(pointerIndex))) {
- useFocusedBounds = true;
- }
- }
- mLongPressingPointerId = mEvent.getPointerId(pointerIndex);
-
- final int eventX = (int) mEvent.getX(pointerIndex);
- final int eventY = (int) mEvent.getY(pointerIndex);
- if (useFocusedBounds) {
- mLongPressingPointerDeltaX = eventX - bounds.centerX();
- mLongPressingPointerDeltaY = eventY - bounds.centerY();
+ MotionEvent lastExploreEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
+ if (lastExploreEvent == null) {
+ // No last touch explored event but there is accessibility focus in
+ // the active window. We click in the middle of the focus bounds.
+ Rect focusBounds = mTempRect;
+ if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
+ clickLocationX = focusBounds.centerX();
+ clickLocationY = focusBounds.centerY();
+ } else {
+ // Out of luck - do nothing.
+ return;
+ }
} else {
- mLongPressingPointerDeltaX = eventX - exploreLocationX;
- mLongPressingPointerDeltaY = eventY - exploreLocationY;
+ // If the click is within the active window but not within the
+ // accessibility focus bounds we click in the focus center.
+ final int lastExplorePointerIndex = lastExploreEvent.getActionIndex();
+ clickLocationX = (int) lastExploreEvent.getX(lastExplorePointerIndex);
+ clickLocationY = (int) lastExploreEvent.getY(lastExplorePointerIndex);
+ Rect activeWindowBounds = mTempRect;
+ mAms.getActiveWindowBounds(activeWindowBounds);
+ if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
+ Rect focusBounds = mTempRect;
+ if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
+ if (!focusBounds.contains(clickLocationX, clickLocationY)) {
+ clickLocationX = focusBounds.centerX();
+ clickLocationY = focusBounds.centerY();
+ }
+ }
+ }
}
+ mLongPressingPointerId = pointerId;
+ mLongPressingPointerDeltaX = (int) mEvent.getX(pointerIndex) - clickLocationX;
+ mLongPressingPointerDeltaY = (int) mEvent.getY(pointerIndex) - clickLocationY;
+
sendExitEventsIfNeeded(mPolicyFlags);
mCurrentState = STATE_DELEGATING;