Merge "Disable input filter features for a display if it is proxy-ed"
This commit is contained in:
@@ -229,17 +229,12 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
}
|
||||
|
||||
void onDisplayAdded(@NonNull Display display) {
|
||||
if (mInstalled) {
|
||||
resetStreamStateForDisplay(display.getDisplayId());
|
||||
enableFeaturesForDisplay(display);
|
||||
}
|
||||
enableFeaturesForDisplayIfInstalled(display);
|
||||
|
||||
}
|
||||
|
||||
void onDisplayRemoved(int displayId) {
|
||||
if (mInstalled) {
|
||||
disableFeaturesForDisplay(displayId);
|
||||
resetStreamStateForDisplay(displayId);
|
||||
}
|
||||
disableFeaturesForDisplayIfInstalled(displayId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -479,6 +474,9 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
|
||||
final Context displayContext = mContext.createDisplayContext(display);
|
||||
final int displayId = display.getDisplayId();
|
||||
if (mAms.isDisplayProxyed(displayId)) {
|
||||
return;
|
||||
}
|
||||
if (!mServiceDetectsGestures.contains(displayId)) {
|
||||
mServiceDetectsGestures.put(displayId, false);
|
||||
}
|
||||
@@ -613,6 +611,18 @@ class AccessibilityInputFilter extends InputFilter implements EventStreamTransfo
|
||||
mEventHandler.remove(displayId);
|
||||
}
|
||||
}
|
||||
void enableFeaturesForDisplayIfInstalled(Display display) {
|
||||
if (mInstalled) {
|
||||
resetStreamStateForDisplay(display.getDisplayId());
|
||||
enableFeaturesForDisplay(display);
|
||||
}
|
||||
}
|
||||
void disableFeaturesForDisplayIfInstalled(int displayId) {
|
||||
if (mInstalled) {
|
||||
disableFeaturesForDisplay(displayId);
|
||||
resetStreamStateForDisplay(displayId);
|
||||
}
|
||||
}
|
||||
|
||||
private void disableDisplayIndependentFeatures() {
|
||||
if (mAutoclickController != null) {
|
||||
|
||||
@@ -474,7 +474,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
new MagnificationScaleProvider(mContext));
|
||||
mMagnificationProcessor = new MagnificationProcessor(mMagnificationController);
|
||||
mCaptioningManagerImpl = new CaptioningManagerImpl(mContext);
|
||||
mProxyManager = new ProxyManager(mLock, mA11yWindowManager);
|
||||
mProxyManager = new ProxyManager(mLock, mA11yWindowManager, mContext);
|
||||
mFlashNotificationsController = new FlashNotificationsController(mContext);
|
||||
init();
|
||||
}
|
||||
@@ -2495,6 +2495,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
}
|
||||
inputFilter = mInputFilter;
|
||||
setInputFilter = true;
|
||||
mProxyManager.setAccessibilityInputFilter(mInputFilter);
|
||||
}
|
||||
mInputFilter.setUserAndEnabledFeatures(userState.mUserId, flags);
|
||||
mInputFilter.setCombinedGenericMotionEventSources(
|
||||
@@ -3885,6 +3886,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
||||
return mProxyManager.unregisterProxy(displayId);
|
||||
}
|
||||
|
||||
boolean isDisplayProxyed(int displayId) {
|
||||
return mProxyManager.isProxyed(displayId);
|
||||
}
|
||||
|
||||
@Override public float getUiContrast() {
|
||||
if (mTraceManager.isA11yTracingEnabledForTypes(FLAGS_ACCESSIBILITY_MANAGER)) {
|
||||
mTraceManager.logTrace(LOG_TAG + ".getUiContrast", FLAGS_ACCESSIBILITY_MANAGER);
|
||||
|
||||
@@ -19,10 +19,12 @@ import android.accessibilityservice.AccessibilityTrace;
|
||||
import android.accessibilityservice.IAccessibilityServiceClient;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.util.SparseArray;
|
||||
import android.view.Display;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
@@ -47,6 +49,8 @@ public class ProxyManager {
|
||||
|
||||
private final Object mLock;
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
// Used to determine if we should notify AccessibilityManager clients of updates.
|
||||
// TODO(254545943): Separate this so each display id has its own state. Currently there is no
|
||||
// way to identify from AccessibilityManager which proxy state should be returned.
|
||||
@@ -57,9 +61,12 @@ public class ProxyManager {
|
||||
|
||||
private AccessibilityWindowManager mA11yWindowManager;
|
||||
|
||||
ProxyManager(Object lock, AccessibilityWindowManager awm) {
|
||||
private AccessibilityInputFilter mA11yInputFilter;
|
||||
|
||||
ProxyManager(Object lock, AccessibilityWindowManager awm, Context context) {
|
||||
mLock = lock;
|
||||
mA11yWindowManager = awm;
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +116,9 @@ public class ProxyManager {
|
||||
connection.mSystemSupport.onClientChangeLocked(true);
|
||||
}
|
||||
|
||||
if (mA11yInputFilter != null) {
|
||||
mA11yInputFilter.disableFeaturesForDisplayIfInstalled(displayId);
|
||||
}
|
||||
connection.initializeServiceInterface(client);
|
||||
}
|
||||
|
||||
@@ -120,14 +130,25 @@ public class ProxyManager {
|
||||
}
|
||||
|
||||
private boolean clearConnection(int displayId) {
|
||||
boolean removed = false;
|
||||
synchronized (mLock) {
|
||||
if (mProxyA11yServiceConnections.contains(displayId)) {
|
||||
mProxyA11yServiceConnections.remove(displayId);
|
||||
return true;
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
mA11yWindowManager.stopTrackingDisplayProxy(displayId);
|
||||
return false;
|
||||
if (removed) {
|
||||
mA11yWindowManager.stopTrackingDisplayProxy(displayId);
|
||||
if (mA11yInputFilter != null) {
|
||||
final DisplayManager displayManager = (DisplayManager)
|
||||
mContext.getSystemService(Context.DISPLAY_SERVICE);
|
||||
final Display proxyDisplay = displayManager.getDisplay(displayId);
|
||||
if (proxyDisplay != null) {
|
||||
mA11yInputFilter.enableFeaturesForDisplayIfInstalled(proxyDisplay);
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,4 +272,8 @@ public class ProxyManager {
|
||||
proxy.notifyClearAccessibilityNodeInfoCache();
|
||||
}
|
||||
}
|
||||
|
||||
void setAccessibilityInputFilter(AccessibilityInputFilter filter) {
|
||||
mA11yInputFilter = filter;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user