Merge "[DO NOT MERGE] AccessibilityInputFilter: retain service gesture detection state when rebuilding."
This commit is contained in:
@@ -176,6 +176,7 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
|
||||
private boolean mSendMotionEvents;
|
||||
|
||||
private SparseArray<Boolean> mServiceDetectsGestures = new SparseArray<>(0);
|
||||
boolean mRequestFilterKeyEvents;
|
||||
|
||||
boolean mRetrieveInteractiveWindows;
|
||||
@@ -2344,9 +2345,17 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
}
|
||||
|
||||
public void setServiceDetectsGesturesEnabled(int displayId, boolean mode) {
|
||||
mServiceDetectsGestures.put(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) {
|
||||
mSystemSupport.requestTouchExploration(displayId);
|
||||
}
|
||||
|
||||
@@ -176,6 +176,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
|
||||
private int mEnabledFeatures;
|
||||
|
||||
// Display-specific features
|
||||
private SparseArray<Boolean> mServiceDetectsGestures = new SparseArray<>();
|
||||
private final SparseArray<EventStreamState> mMouseStreamStates = 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 int displayId = display.getDisplayId();
|
||||
|
||||
if (!mServiceDetectsGestures.contains(displayId)) {
|
||||
mServiceDetectsGestures.put(displayId, false);
|
||||
}
|
||||
if ((mEnabledFeatures & FLAG_FEATURE_AUTOCLICK) != 0) {
|
||||
if (mAutoclickController == null) {
|
||||
mAutoclickController = new AutoclickController(
|
||||
@@ -481,6 +485,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
if ((mEnabledFeatures & FLAG_SEND_MOTION_EVENTS) != 0) {
|
||||
explorer.setSendMotionEventsEnabled(true);
|
||||
}
|
||||
explorer.setServiceDetectsGestures(mServiceDetectsGestures.get(displayId));
|
||||
addFirstEventHandler(displayId, explorer);
|
||||
mTouchExplorer.put(displayId, explorer);
|
||||
}
|
||||
@@ -565,7 +570,8 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
mTouchExplorer.remove(displayId);
|
||||
}
|
||||
|
||||
final MagnificationGestureHandler handler = mMagnificationGestureHandler.get(displayId);
|
||||
final MagnificationGestureHandler handler =
|
||||
mMagnificationGestureHandler.get(displayId);
|
||||
if (handler != null) {
|
||||
handler.onDestroy();
|
||||
mMagnificationGestureHandler.remove(displayId);
|
||||
@@ -897,6 +903,7 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
if (mTouchExplorer.contains(displayId)) {
|
||||
mTouchExplorer.get(displayId).setServiceDetectsGestures(mode);
|
||||
}
|
||||
mServiceDetectsGestures.put(displayId, mode);
|
||||
}
|
||||
|
||||
public void requestTouchExploration(int displayId) {
|
||||
|
||||
@@ -1721,31 +1721,34 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
|
||||
private boolean scheduleNotifyMotionEvent(MotionEvent event) {
|
||||
boolean result = false;
|
||||
int displayId = event.getDisplayId();
|
||||
synchronized (mLock) {
|
||||
AccessibilityUserState state = getCurrentUserStateLocked();
|
||||
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
|
||||
AccessibilityServiceConnection service = state.mBoundServices.get(i);
|
||||
if (service.mRequestTouchExplorationMode) {
|
||||
if (service.isServiceDetectsGesturesEnabled(displayId)) {
|
||||
service.notifyMotionEvent(event);
|
||||
return true;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean scheduleNotifyTouchState(int displayId, int touchState) {
|
||||
boolean result = false;
|
||||
synchronized (mLock) {
|
||||
AccessibilityUserState state = getCurrentUserStateLocked();
|
||||
for (int i = state.mBoundServices.size() - 1; i >= 0; i--) {
|
||||
AccessibilityServiceConnection service = state.mBoundServices.get(i);
|
||||
if (service.mRequestTouchExplorationMode) {
|
||||
if (service.isServiceDetectsGesturesEnabled(displayId)) {
|
||||
service.notifyTouchState(displayId, touchState);
|
||||
return true;
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void notifyClearAccessibilityCacheLocked() {
|
||||
@@ -2301,7 +2304,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
if (userState.isTwoFingerPassthroughEnabledLocked()) {
|
||||
flags |= AccessibilityInputFilter.FLAG_REQUEST_2_FINGER_PASSTHROUGH;
|
||||
}
|
||||
}
|
||||
if (userState.isFilterKeyEventsEnabledLocked()) {
|
||||
flags |= AccessibilityInputFilter.FLAG_FEATURE_FILTER_KEY_EVENTS;
|
||||
}
|
||||
@@ -2314,6 +2316,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
if (userState.isPerformGesturesEnabledLocked()) {
|
||||
flags |= AccessibilityInputFilter.FLAG_FEATURE_INJECT_MOTION_EVENTS;
|
||||
}
|
||||
|
||||
if (flags != 0) {
|
||||
if (!mHasInputFilter) {
|
||||
mHasInputFilter = true;
|
||||
@@ -2326,9 +2329,20 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, flags);
|
||||
} else {
|
||||
if (mHasInputFilter) {
|
||||
mHasInputFilter = false;
|
||||
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, 0);
|
||||
if (mHasInputFilter) {
|
||||
mHasInputFilter = false;
|
||||
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;
|
||||
setInputFilter = true;
|
||||
}
|
||||
@@ -4304,6 +4318,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
|
||||
private void setServiceDetectsGesturesInternal(int displayId, boolean mode) {
|
||||
synchronized (mLock) {
|
||||
getCurrentUserStateLocked().setServiceDetectsGesturesEnabled(displayId, mode);
|
||||
if (mHasInputFilter && mInputFilter != null) {
|
||||
mInputFilter.setServiceDetectsGesturesEnabled(displayId, mode);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArraySet;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.SparseIntArray;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.accessibility.IAccessibilityManagerClient;
|
||||
@@ -118,6 +119,7 @@ class AccessibilityUserState {
|
||||
private boolean mRequestMultiFingerGestures;
|
||||
private boolean mRequestTwoFingerPassthrough;
|
||||
private boolean mSendMotionEventsEnabled;
|
||||
private SparseArray<Boolean> mServiceDetectsGestures = new SparseArray<>(0);
|
||||
private int mUserInteractiveUiTimeout;
|
||||
private int mUserNonInteractiveUiTimeout;
|
||||
private int mNonInteractiveUiTimeout = 0;
|
||||
@@ -987,4 +989,15 @@ class AccessibilityUserState {
|
||||
mFocusStrokeWidth = strokeWidth;
|
||||
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