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;
|
||||
@@ -2369,9 +2370,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);
|
||||
}
|
||||
@@ -897,6 +902,11 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
if (mTouchExplorer.contains(displayId)) {
|
||||
mTouchExplorer.get(displayId).setServiceDetectsGestures(mode);
|
||||
}
|
||||
mServiceDetectsGestures.put(displayId, mode);
|
||||
}
|
||||
|
||||
public void resetServiceDetectsGestures() {
|
||||
mServiceDetectsGestures.clear();
|
||||
}
|
||||
|
||||
public void requestTouchExploration(int displayId) {
|
||||
|
||||
@@ -1695,31 +1695,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() {
|
||||
@@ -2292,8 +2295,9 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
if (!mHasInputFilter) {
|
||||
mHasInputFilter = true;
|
||||
if (mInputFilter == null) {
|
||||
mInputFilter = new AccessibilityInputFilter(mContext,
|
||||
AccessibilityManagerService.this);
|
||||
mInputFilter =
|
||||
new AccessibilityInputFilter(
|
||||
mContext, AccessibilityManagerService.this);
|
||||
}
|
||||
inputFilter = mInputFilter;
|
||||
setInputFilter = true;
|
||||
@@ -2303,6 +2307,17 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
if (mHasInputFilter) {
|
||||
mHasInputFilter = false;
|
||||
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, 0);
|
||||
mInputFilter.resetServiceDetectsGestures();
|
||||
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;
|
||||
}
|
||||
@@ -2618,6 +2633,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
}
|
||||
}
|
||||
// Service gesture detection is turned on and off on a per-display
|
||||
// basis.
|
||||
userState.resetServiceDetectsGestures();
|
||||
final ArrayList<Display> displays = getValidDisplayList();
|
||||
for (AccessibilityServiceConnection service: userState.mBoundServices) {
|
||||
for (Display display : displays) {
|
||||
int displayId = display.getDisplayId();
|
||||
if (service.isServiceDetectsGesturesEnabled(displayId)) {
|
||||
userState.setServiceDetectsGesturesEnabled(displayId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
userState.setServiceHandlesDoubleTapLocked(serviceHandlesDoubleTapEnabled);
|
||||
userState.setMultiFingerGesturesLocked(requestMultiFingerGestures);
|
||||
userState.setTwoFingerPassthroughLocked(requestTwoFingerPassthrough);
|
||||
@@ -4342,6 +4369,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;
|
||||
@@ -991,4 +993,19 @@ class AccessibilityUserState {
|
||||
mFocusStrokeWidth = strokeWidth;
|
||||
mFocusColor = color;
|
||||
}
|
||||
|
||||
public void setServiceDetectsGesturesEnabled(int displayId, boolean mode) {
|
||||
mServiceDetectsGestures.put(displayId, mode);
|
||||
}
|
||||
|
||||
public void resetServiceDetectsGestures() {
|
||||
mServiceDetectsGestures.clear();
|
||||
}
|
||||
|
||||
public boolean isServiceDetectsGesturesEnabled(int displayId) {
|
||||
if (mServiceDetectsGestures.contains(displayId)) {
|
||||
return mServiceDetectsGestures.get(displayId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user