Merge changes from topic "presubmit-am-5b208f5d997e40cd88391981653ea568" into tm-mainline-prod

* changes:
  [automerge] Service Gesture Detection: copy motion events when sending to the service. 2p: 2a7ab6e857
  Service Gesture Detection: copy motion events when sending to the service.
This commit is contained in:
Ameer Armaly
2022-03-28 20:21:46 +00:00
committed by Android (Google) Code Review

View File

@@ -1301,25 +1301,24 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
/** Send a motion event to the service to allow it to perform gesture detection. */ /** Send a motion event to the service to allow it to perform gesture detection. */
public boolean sendMotionEventToListeningServices(MotionEvent event) { public boolean sendMotionEventToListeningServices(MotionEvent event) {
synchronized (mLock) { boolean result;
if (DEBUG) { event = MotionEvent.obtain(event);
Slog.d(LOG_TAG, "Sending event to service: " + event); if (DEBUG) {
} Slog.d(LOG_TAG, "Sending event to service: " + event);
return notifyMotionEvent(event);
} }
result = scheduleNotifyMotionEvent(event);
return result;
} }
/** /**
* Notifies services that the touch state on a given display has changed. * Notifies services that the touch state on a given display has changed.
*/ */
public boolean onTouchStateChanged(int displayId, int state) { public boolean onTouchStateChanged(int displayId, int state) {
synchronized (mLock) {
if (DEBUG) { if (DEBUG) {
Slog.d(LOG_TAG, "Notifying touch state:" Slog.d(LOG_TAG, "Notifying touch state:"
+ TouchInteractionController.stateToString(state)); + TouchInteractionController.stateToString(state));
} }
return notifyTouchState(displayId, state); return scheduleNotifyTouchState(displayId, state);
}
} }
/** /**
@@ -1650,25 +1649,29 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
return false; return false;
} }
private boolean notifyMotionEvent(MotionEvent event) { private boolean scheduleNotifyMotionEvent(MotionEvent event) {
AccessibilityUserState state = getCurrentUserStateLocked(); synchronized (mLock) {
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) { AccessibilityUserState state = getCurrentUserStateLocked();
AccessibilityServiceConnection service = state.mBoundServices.get(i); for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
if (service.mRequestTouchExplorationMode) { AccessibilityServiceConnection service = state.mBoundServices.get(i);
service.notifyMotionEvent(event); if (service.mRequestTouchExplorationMode) {
return true; service.notifyMotionEvent(event);
return true;
}
} }
} }
return false; return false;
} }
private boolean notifyTouchState(int displayId, int touchState) { private boolean scheduleNotifyTouchState(int displayId, int touchState) {
AccessibilityUserState state = getCurrentUserStateLocked(); synchronized (mLock) {
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) { AccessibilityUserState state = getCurrentUserStateLocked();
AccessibilityServiceConnection service = state.mBoundServices.get(i); for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
if (service.mRequestTouchExplorationMode) { AccessibilityServiceConnection service = state.mBoundServices.get(i);
service.notifyTouchState(displayId, touchState); if (service.mRequestTouchExplorationMode) {
return true; service.notifyTouchState(displayId, touchState);
return true;
}
} }
} }
return false; return false;