Merge "Race condition while injecting ACTION_OUTSIDE" into qt-dev
This commit is contained in:
@@ -682,14 +682,6 @@ public final class AccessibilityInteractionController {
|
||||
// Handle this hidden action separately
|
||||
succeeded = handleClickableSpanActionUiThread(
|
||||
target, virtualDescendantId, arguments);
|
||||
} else if (action == R.id.accessibilityActionOutsideTouch) {
|
||||
// trigger ACTION_OUTSIDE to notify windows
|
||||
final long now = SystemClock.uptimeMillis();
|
||||
MotionEvent event = MotionEvent.obtain(now, now, MotionEvent.ACTION_OUTSIDE,
|
||||
0, 0, 0);
|
||||
event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
|
||||
mViewRootImpl.dispatchInputEvent(event);
|
||||
succeeded = true;
|
||||
} else {
|
||||
AccessibilityNodeProvider provider = target.getAccessibilityNodeProvider();
|
||||
if (provider != null) {
|
||||
@@ -756,6 +748,33 @@ public final class AccessibilityInteractionController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify outside touch event to the target window.
|
||||
*/
|
||||
public void notifyOutsideTouchClientThread() {
|
||||
final Message message = mHandler.obtainMessage();
|
||||
message.what = PrivateHandler.MSG_NOTIFY_OUTSIDE_TOUCH;
|
||||
|
||||
// Don't care about pid and tid because there's no interrogating client for this message.
|
||||
scheduleMessage(message, 0, 0, CONSIDER_REQUEST_PREPARERS);
|
||||
}
|
||||
|
||||
private void notifyOutsideTouchUiThread() {
|
||||
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null
|
||||
|| mViewRootImpl.mStopped || mViewRootImpl.mPausedForTransition) {
|
||||
return;
|
||||
}
|
||||
final View root = mViewRootImpl.mView;
|
||||
if (root != null && isShown(root)) {
|
||||
// trigger ACTION_OUTSIDE to notify windows
|
||||
final long now = SystemClock.uptimeMillis();
|
||||
final MotionEvent event = MotionEvent.obtain(now, now, MotionEvent.ACTION_OUTSIDE,
|
||||
0, 0, 0);
|
||||
event.setSource(InputDevice.SOURCE_TOUCHSCREEN);
|
||||
mViewRootImpl.dispatchInputEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
private View findViewByAccessibilityId(int accessibilityId) {
|
||||
if (accessibilityId == AccessibilityNodeInfo.ROOT_ITEM_ID) {
|
||||
return mViewRootImpl.mView;
|
||||
@@ -1328,6 +1347,8 @@ public final class AccessibilityInteractionController {
|
||||
private static final int FIRST_NO_ACCESSIBILITY_CALLBACK_MSG = 100;
|
||||
private static final int MSG_CLEAR_ACCESSIBILITY_FOCUS =
|
||||
FIRST_NO_ACCESSIBILITY_CALLBACK_MSG + 1;
|
||||
private static final int MSG_NOTIFY_OUTSIDE_TOUCH =
|
||||
FIRST_NO_ACCESSIBILITY_CALLBACK_MSG + 2;
|
||||
|
||||
public PrivateHandler(Looper looper) {
|
||||
super(looper);
|
||||
@@ -1357,6 +1378,8 @@ public final class AccessibilityInteractionController {
|
||||
return "MSG_APP_PREPARATION_TIMEOUT";
|
||||
case MSG_CLEAR_ACCESSIBILITY_FOCUS:
|
||||
return "MSG_CLEAR_ACCESSIBILITY_FOCUS";
|
||||
case MSG_NOTIFY_OUTSIDE_TOUCH:
|
||||
return "MSG_NOTIFY_OUTSIDE_TOUCH";
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown message type: " + type);
|
||||
}
|
||||
@@ -1396,6 +1419,9 @@ public final class AccessibilityInteractionController {
|
||||
case MSG_CLEAR_ACCESSIBILITY_FOCUS: {
|
||||
clearAccessibilityFocusUiThread();
|
||||
} break;
|
||||
case MSG_NOTIFY_OUTSIDE_TOUCH: {
|
||||
notifyOutsideTouchUiThread();
|
||||
} break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unknown message type: " + type);
|
||||
}
|
||||
|
||||
@@ -8819,6 +8819,15 @@ public final class ViewRootImpl implements ViewParent,
|
||||
.clearAccessibilityFocusClientThread();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOutsideTouch() {
|
||||
ViewRootImpl viewRootImpl = mViewRootImpl.get();
|
||||
if (viewRootImpl != null && viewRootImpl.mView != null) {
|
||||
viewRootImpl.getAccessibilityInteractionController()
|
||||
.notifyOutsideTouchClientThread();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SendWindowContentChangedAccessibilityEvent implements Runnable {
|
||||
|
||||
@@ -57,4 +57,6 @@ oneway interface IAccessibilityInteractionConnection {
|
||||
int interrogatingPid, long interrogatingTid);
|
||||
|
||||
void clearAccessibilityFocus();
|
||||
|
||||
void notifyOutsideTouch();
|
||||
}
|
||||
|
||||
@@ -185,9 +185,6 @@
|
||||
<!-- Accessibility action identifier for {@link android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction#ACTION_HIDE_TOOLTIP}. -->
|
||||
<item type="id" name="accessibilityActionHideTooltip" />
|
||||
|
||||
<!-- Accessibility action to notify a window there is an outside touch. -->
|
||||
<item type="id" name="accessibilityActionOutsideTouch" />
|
||||
|
||||
<!-- A tag used to save the view added to a transition overlay -->
|
||||
<item type="id" name="transition_overlay_view_tag" />
|
||||
|
||||
|
||||
@@ -245,7 +245,6 @@
|
||||
<java-symbol type="id" name="selection_end_handle" />
|
||||
<java-symbol type="id" name="insertion_handle" />
|
||||
<java-symbol type="id" name="accessibilityActionClickOnClickableSpan" />
|
||||
<java-symbol type="id" name="accessibilityActionOutsideTouch" />
|
||||
<java-symbol type="id" name="camera" />
|
||||
<java-symbol type="id" name="mic" />
|
||||
<java-symbol type="id" name="overlay" />
|
||||
|
||||
@@ -170,6 +170,11 @@ public class PipAccessibilityInteractionConnection
|
||||
// We should not be here.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOutsideTouch() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public static AccessibilityNodeInfo obtainRootAccessibilityNodeInfo() {
|
||||
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain();
|
||||
info.setSourceNodeId(AccessibilityNodeInfo.ROOT_NODE_ID,
|
||||
|
||||
@@ -2722,9 +2722,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void notifyOutsideTouchIfNeeded(int targetWindowId, int action, Bundle arguments,
|
||||
int interactionId, IAccessibilityInteractionConnectionCallback callback, int fetchFlags,
|
||||
int interrogatingPid, long interrogatingTid) {
|
||||
private void notifyOutsideTouchIfNeeded(int targetWindowId, int action) {
|
||||
if (action != ACTION_CLICK && action != ACTION_LONG_CLICK) {
|
||||
return;
|
||||
}
|
||||
@@ -2741,13 +2739,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
final RemoteAccessibilityConnection connection = connectionList.get(i);
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.mConnection.performAccessibilityAction(
|
||||
AccessibilityNodeInfo.ROOT_ITEM_ID,
|
||||
R.id.accessibilityActionOutsideTouch, arguments, interactionId,
|
||||
callback, fetchFlags, interrogatingPid, interrogatingTid);
|
||||
connection.getRemote().notifyOutsideTouch();
|
||||
} catch (RemoteException re) {
|
||||
if (DEBUG) {
|
||||
Slog.e(LOG_TAG, "Error calling performAccessibilityAction: " + re);
|
||||
Slog.e(LOG_TAG, "Error calling notifyOutsideTouch()");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2833,8 +2828,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
mPowerManager.userActivity(SystemClock.uptimeMillis(),
|
||||
PowerManager.USER_ACTIVITY_EVENT_ACCESSIBILITY, 0);
|
||||
|
||||
notifyOutsideTouchIfNeeded(resolvedWindowId, action, arguments, interactionId, callback,
|
||||
fetchFlags, interrogatingPid, interrogatingTid);
|
||||
notifyOutsideTouchIfNeeded(resolvedWindowId, action);
|
||||
if (activityToken != null) {
|
||||
LocalServices.getService(ActivityTaskManagerInternal.class)
|
||||
.setFocusedActivity(activityToken);
|
||||
@@ -3790,7 +3784,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
|
||||
private List<Integer> getWatchOutsideTouchWindowIdLocked(int targetWindowId) {
|
||||
final WindowInfo targetWindow = mWindowInfoById.get(targetWindowId);
|
||||
if (targetWindow != null && mWindowInfoById != null && mHasWatchOutsideTouchWindow) {
|
||||
if (targetWindow != null && mHasWatchOutsideTouchWindow) {
|
||||
final List<Integer> outsideWindowsId = new ArrayList<>();
|
||||
for (int i = 0; i < mWindowInfoById.size(); i++) {
|
||||
WindowInfo window = mWindowInfoById.valueAt(i);
|
||||
|
||||
Reference in New Issue
Block a user