[DO NOT MERGE] AccessibilityInputFilter: retain service gesture detection state when rebuilding.
Otherwise, as soon as we rebuild the input filter e.g. enable magnification, service gesture detection gets turned off. Bug: 243487199 Test: atest TouchInteractionControllerTest Change-Id: Ifdfaffd2ff2addc7a4dd7d69cf6128947efdacea
This commit is contained in:
@@ -176,6 +176,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
|||||||
|
|
||||||
private boolean mSendMotionEvents;
|
private boolean mSendMotionEvents;
|
||||||
|
|
||||||
|
private SparseArray<Boolean> mServiceDetectsGestures = new SparseArray<>(0);
|
||||||
boolean mRequestFilterKeyEvents;
|
boolean mRequestFilterKeyEvents;
|
||||||
|
|
||||||
boolean mRetrieveInteractiveWindows;
|
boolean mRetrieveInteractiveWindows;
|
||||||
@@ -2344,9 +2345,17 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setServiceDetectsGesturesEnabled(int displayId, boolean mode) {
|
public void setServiceDetectsGesturesEnabled(int displayId, boolean mode) {
|
||||||
|
mServiceDetectsGestures.put(displayId, mode);
|
||||||
mSystemSupport.setServiceDetectsGesturesEnabled(displayId, mode);
|
mSystemSupport.setServiceDetectsGesturesEnabled(displayId, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isServiceDetectsGesturesEnabled(int displayId) {
|
||||||
|
if (mServiceDetectsGestures.contains(displayId)) {
|
||||||
|
return mServiceDetectsGestures.get(displayId);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void requestTouchExploration(int displayId) {
|
public void requestTouchExploration(int displayId) {
|
||||||
mSystemSupport.requestTouchExploration(displayId);
|
mSystemSupport.requestTouchExploration(displayId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,6 +176,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
|
|
||||||
private int mEnabledFeatures;
|
private int mEnabledFeatures;
|
||||||
|
|
||||||
|
// Display-specific features
|
||||||
|
private SparseArray<Boolean> mServiceDetectsGestures = new SparseArray<>();
|
||||||
private final SparseArray<EventStreamState> mMouseStreamStates = new SparseArray<>(0);
|
private final SparseArray<EventStreamState> mMouseStreamStates = new SparseArray<>(0);
|
||||||
|
|
||||||
private final SparseArray<EventStreamState> mTouchScreenStreamStates = new SparseArray<>(0);
|
private final SparseArray<EventStreamState> mTouchScreenStreamStates = new SparseArray<>(0);
|
||||||
@@ -458,7 +460,9 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
|
|
||||||
final Context displayContext = mContext.createDisplayContext(display);
|
final Context displayContext = mContext.createDisplayContext(display);
|
||||||
final int displayId = display.getDisplayId();
|
final int displayId = display.getDisplayId();
|
||||||
|
if (!mServiceDetectsGestures.contains(displayId)) {
|
||||||
|
mServiceDetectsGestures.put(displayId, false);
|
||||||
|
}
|
||||||
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
|
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
|
||||||
if (mAutoclickController == null) {
|
if (mAutoclickController == null) {
|
||||||
mAutoclickController = new AutoclickController(
|
mAutoclickController = new AutoclickController(
|
||||||
@@ -481,6 +485,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
if ((mEnabledFeatures & FLAG_SEND_MOTION_EVENTS) != 0) {
|
if ((mEnabledFeatures & FLAG_SEND_MOTION_EVENTS) != 0) {
|
||||||
explorer.setSendMotionEventsEnabled(true);
|
explorer.setSendMotionEventsEnabled(true);
|
||||||
}
|
}
|
||||||
|
explorer.setServiceDetectsGestures(mServiceDetectsGestures.get(displayId));
|
||||||
addFirstEventHandler(displayId, explorer);
|
addFirstEventHandler(displayId, explorer);
|
||||||
mTouchExplorer.put(displayId, explorer);
|
mTouchExplorer.put(displayId, explorer);
|
||||||
}
|
}
|
||||||
@@ -565,7 +570,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
mTouchExplorer.remove(displayId);
|
mTouchExplorer.remove(displayId);
|
||||||
}
|
}
|
||||||
|
|
||||||
final MagnificationGestureHandler handler = mMagnificationGestureHandler.get(displayId);
|
final MagnificationGestureHandler handler =
|
||||||
|
mMagnificationGestureHandler.get(displayId);
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
handler.onDestroy();
|
handler.onDestroy();
|
||||||
mMagnificationGestureHandler.remove(displayId);
|
mMagnificationGestureHandler.remove(displayId);
|
||||||
@@ -897,6 +903,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
|||||||
if (mTouchExplorer.contains(displayId)) {
|
if (mTouchExplorer.contains(displayId)) {
|
||||||
mTouchExplorer.get(displayId).setServiceDetectsGestures(mode);
|
mTouchExplorer.get(displayId).setServiceDetectsGestures(mode);
|
||||||
}
|
}
|
||||||
|
mServiceDetectsGestures.put(displayId, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestTouchExploration(int displayId) {
|
public void requestTouchExploration(int displayId) {
|
||||||
|
|||||||
@@ -1721,31 +1721,34 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean scheduleNotifyMotionEvent(MotionEvent event) {
|
private boolean scheduleNotifyMotionEvent(MotionEvent event) {
|
||||||
|
boolean result = false;
|
||||||
|
int displayId = event.getDisplayId();
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
AccessibilityUserState state = getCurrentUserStateLocked();
|
AccessibilityUserState state = getCurrentUserStateLocked();
|
||||||
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
|
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
|
||||||
AccessibilityServiceConnection service = state.mBoundServices.get(i);
|
AccessibilityServiceConnection service = state.mBoundServices.get(i);
|
||||||
if (service.mRequestTouchExplorationMode) {
|
if (service.isServiceDetectsGesturesEnabled(displayId)) {
|
||||||
service.notifyMotionEvent(event);
|
service.notifyMotionEvent(event);
|
||||||
return true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean scheduleNotifyTouchState(int displayId, int touchState) {
|
private boolean scheduleNotifyTouchState(int displayId, int touchState) {
|
||||||
|
boolean result = false;
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
AccessibilityUserState state = getCurrentUserStateLocked();
|
AccessibilityUserState state = getCurrentUserStateLocked();
|
||||||
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
|
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
|
||||||
AccessibilityServiceConnection service = state.mBoundServices.get(i);
|
AccessibilityServiceConnection service = state.mBoundServices.get(i);
|
||||||
if (service.mRequestTouchExplorationMode) {
|
if (service.isServiceDetectsGesturesEnabled(displayId)) {
|
||||||
service.notifyTouchState(displayId, touchState);
|
service.notifyTouchState(displayId, touchState);
|
||||||
return true;
|
result = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyClearAccessibilityCacheLocked() {
|
private void notifyClearAccessibilityCacheLocked() {
|
||||||
@@ -2301,7 +2304,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
if (userState.isTwoFingerPassthroughEnabledLocked()) {
|
if (userState.isTwoFingerPassthroughEnabledLocked()) {
|
||||||
flags |= AccessibilityInputFilter.FLAG_REQUEST_2_FINGER_PASSTHROUGH;
|
flags |= AccessibilityInputFilter.FLAG_REQUEST_2_FINGER_PASSTHROUGH;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (userState.isFilterKeyEventsEnabledLocked()) {
|
if (userState.isFilterKeyEventsEnabledLocked()) {
|
||||||
flags |= AccessibilityInputFilter.FLAG_FEATURE_FILTER_KEY_EVENTS;
|
flags |= AccessibilityInputFilter.FLAG_FEATURE_FILTER_KEY_EVENTS;
|
||||||
}
|
}
|
||||||
@@ -2314,6 +2316,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
if (userState.isPerformGesturesEnabledLocked()) {
|
if (userState.isPerformGesturesEnabledLocked()) {
|
||||||
flags |= AccessibilityInputFilter.FLAG_FEATURE_INJECT_MOTION_EVENTS;
|
flags |= AccessibilityInputFilter.FLAG_FEATURE_INJECT_MOTION_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags != 0) {
|
if (flags != 0) {
|
||||||
if (!mHasInputFilter) {
|
if (!mHasInputFilter) {
|
||||||
mHasInputFilter = true;
|
mHasInputFilter = true;
|
||||||
@@ -2326,9 +2329,20 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
}
|
}
|
||||||
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, flags);
|
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, flags);
|
||||||
} else {
|
} else {
|
||||||
if (mHasInputFilter) {
|
if (mHasInputFilter) {
|
||||||
mHasInputFilter = false;
|
mHasInputFilter = false;
|
||||||
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, 0);
|
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, 0);
|
||||||
|
if (userState.isTouchExplorationEnabledLocked()) {
|
||||||
|
// Service gesture detection is turned on and off on a per-display
|
||||||
|
// basis.
|
||||||
|
final ArrayList<Display> displays = getValidDisplayList();
|
||||||
|
for (Display display : displays) {
|
||||||
|
int displayId = display.getDisplayId();
|
||||||
|
boolean mode = userState.isServiceDetectsGesturesEnabled(displayId);
|
||||||
|
mInputFilter.setServiceDetectsGesturesEnabled(displayId, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
inputFilter = null;
|
inputFilter = null;
|
||||||
setInputFilter = true;
|
setInputFilter = true;
|
||||||
}
|
}
|
||||||
@@ -4304,6 +4318,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
|
|
||||||
private void setServiceDetectsGesturesInternal(int displayId, boolean mode) {
|
private void setServiceDetectsGesturesInternal(int displayId, boolean mode) {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
getCurrentUserStateLocked().setServiceDetectsGesturesEnabled(displayId, mode);
|
||||||
if (mHasInputFilter && mInputFilter != null) {
|
if (mHasInputFilter && mInputFilter != null) {
|
||||||
mInputFilter.setServiceDetectsGesturesEnabled(displayId, mode);
|
mInputFilter.setServiceDetectsGesturesEnabled(displayId, mode);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import android.provider.Settings;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.util.SparseIntArray;
|
import android.util.SparseIntArray;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.view.accessibility.IAccessibilityManagerClient;
|
import android.view.accessibility.IAccessibilityManagerClient;
|
||||||
@@ -118,6 +119,7 @@ class AccessibilityUserState {
|
|||||||
private boolean mRequestMultiFingerGestures;
|
private boolean mRequestMultiFingerGestures;
|
||||||
private boolean mRequestTwoFingerPassthrough;
|
private boolean mRequestTwoFingerPassthrough;
|
||||||
private boolean mSendMotionEventsEnabled;
|
private boolean mSendMotionEventsEnabled;
|
||||||
|
private SparseArray<Boolean> mServiceDetectsGestures = new SparseArray<>(0);
|
||||||
private int mUserInteractiveUiTimeout;
|
private int mUserInteractiveUiTimeout;
|
||||||
private int mUserNonInteractiveUiTimeout;
|
private int mUserNonInteractiveUiTimeout;
|
||||||
private int mNonInteractiveUiTimeout = 0;
|
private int mNonInteractiveUiTimeout = 0;
|
||||||
@@ -987,4 +989,15 @@ class AccessibilityUserState {
|
|||||||
mFocusStrokeWidth = strokeWidth;
|
mFocusStrokeWidth = strokeWidth;
|
||||||
mFocusColor = color;
|
mFocusColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setServiceDetectsGesturesEnabled(int displayId, boolean mode) {
|
||||||
|
mServiceDetectsGestures.put(displayId, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isServiceDetectsGesturesEnabled(int displayId) {
|
||||||
|
if (mServiceDetectsGestures.contains(displayId)) {
|
||||||
|
return mServiceDetectsGestures.get(displayId);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user