Merge "TouchExplorer: allow service to initiate touch exploration and there are no pointers on the screen" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c7600cee15
@@ -262,7 +262,7 @@ public final class TouchInteractionController {
|
|||||||
* interaction.
|
* interaction.
|
||||||
*/
|
*/
|
||||||
public void requestTouchExploration() {
|
public void requestTouchExploration() {
|
||||||
checkState();
|
validateTransitionRequest();
|
||||||
final IAccessibilityServiceConnection connection =
|
final IAccessibilityServiceConnection connection =
|
||||||
AccessibilityInteractionClient.getInstance()
|
AccessibilityInteractionClient.getInstance()
|
||||||
.getConnection(mService.getConnectionId());
|
.getConnection(mService.getConnectionId());
|
||||||
@@ -288,7 +288,7 @@ public final class TouchInteractionController {
|
|||||||
* @throws IllegalArgumentException if the pointer id is outside of the allowed range.
|
* @throws IllegalArgumentException if the pointer id is outside of the allowed range.
|
||||||
*/
|
*/
|
||||||
public void requestDragging(int pointerId) {
|
public void requestDragging(int pointerId) {
|
||||||
checkState();
|
validateTransitionRequest();
|
||||||
if (pointerId < 0 || pointerId > MAX_POINTER_COUNT) {
|
if (pointerId < 0 || pointerId > MAX_POINTER_COUNT) {
|
||||||
throw new IllegalArgumentException("Invalid pointer id: " + pointerId);
|
throw new IllegalArgumentException("Invalid pointer id: " + pointerId);
|
||||||
}
|
}
|
||||||
@@ -313,7 +313,7 @@ public final class TouchInteractionController {
|
|||||||
* the duration of this interaction.
|
* the duration of this interaction.
|
||||||
*/
|
*/
|
||||||
public void requestDelegating() {
|
public void requestDelegating() {
|
||||||
checkState();
|
validateTransitionRequest();
|
||||||
final IAccessibilityServiceConnection connection =
|
final IAccessibilityServiceConnection connection =
|
||||||
AccessibilityInteractionClient.getInstance()
|
AccessibilityInteractionClient.getInstance()
|
||||||
.getConnection(mService.getConnectionId());
|
.getConnection(mService.getConnectionId());
|
||||||
@@ -371,14 +371,14 @@ public final class TouchInteractionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkState() {
|
private void validateTransitionRequest() {
|
||||||
if (!mServiceDetectsGestures || mCallbacks.size() == 0) {
|
if (!mServiceDetectsGestures || mCallbacks.size() == 0) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"State transitions are not allowed without first adding a callback.");
|
"State transitions are not allowed without first adding a callback.");
|
||||||
}
|
}
|
||||||
if (mState != STATE_TOUCH_INTERACTING && mState != STATE_DRAGGING) {
|
if ((mState == STATE_DELEGATING || mState == STATE_TOUCH_EXPLORING)) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"State transitions are not allowed in " + stateToString(mState));
|
"State transition requests are not allowed in " + stateToString(mState));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1329,13 +1329,28 @@ public class TouchExplorer extends BaseEventStreamTransformation
|
|||||||
if (mState.isServiceDetectingGestures() && mState.isTouchInteracting()) {
|
if (mState.isServiceDetectingGestures() && mState.isTouchInteracting()) {
|
||||||
// Cancel without deleting events.
|
// Cancel without deleting events.
|
||||||
mHandler.removeCallbacks(mSendHoverEnterAndMoveDelayed);
|
mHandler.removeCallbacks(mSendHoverEnterAndMoveDelayed);
|
||||||
final int pointerId = mReceivedPointerTracker.getPrimaryPointerId();
|
int pointerId = mReceivedPointerTracker.getPrimaryPointerId();
|
||||||
|
if (pointerId == INVALID_POINTER_ID) {
|
||||||
|
MotionEvent event = mState.getLastReceivedEvent();
|
||||||
|
if (event != null) {
|
||||||
|
// Use the first pointer of the most recent event.
|
||||||
|
pointerId = event.getPointerId(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pointerId == INVALID_POINTER_ID) {
|
||||||
|
Slog.e(LOG_TAG, "Unable to find a valid pointer for touch exploration.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int pointerIdBits = (1 << pointerId);
|
final int pointerIdBits = (1 << pointerId);
|
||||||
final int policyFlags = mState.getLastReceivedPolicyFlags();
|
final int policyFlags = mState.getLastReceivedPolicyFlags();
|
||||||
mSendHoverEnterAndMoveDelayed.setPointerIdBits(pointerIdBits);
|
mSendHoverEnterAndMoveDelayed.setPointerIdBits(pointerIdBits);
|
||||||
mSendHoverEnterAndMoveDelayed.setPolicyFlags(policyFlags);
|
mSendHoverEnterAndMoveDelayed.setPolicyFlags(policyFlags);
|
||||||
mSendHoverEnterAndMoveDelayed.run();
|
mSendHoverEnterAndMoveDelayed.run();
|
||||||
mSendHoverEnterAndMoveDelayed.clear();
|
mSendHoverEnterAndMoveDelayed.clear();
|
||||||
|
if (mReceivedPointerTracker.getReceivedPointerDownCount() == 0) {
|
||||||
|
// We need to send hover exit because there will be no future ACTION_UP
|
||||||
|
sendHoverExitAndTouchExplorationGestureEndIfNeeded(policyFlags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user