Better guarantee a11y service initial state
I've see flakiness in the gesture dispatch test with magnification enabled. It turned out that the state of the input filter was in flux when onServiceConnected was called back. Now delaying that call until the input filter's state is stable. Also fixing the return value of getCenterX and Y when a service isn't actively controlling magnification. Bug: 65012944 Test: A11y CTS and unit tests. Change-Id: I64260ebb72ee95307d777a9e4b70876c14f99e9c (cherry picked from commit 53b690b5bc72ac5cd34300c9965707edd0b217cd)
This commit is contained in:
parent
1fab6234c0
commit
8fd2e29c41
@ -2397,6 +2397,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
public static final int MSG_SEND_RELEVANT_EVENTS_CHANGED_TO_CLIENTS = 12;
|
||||
public static final int MSG_SEND_ACCESSIBILITY_BUTTON_TO_INPUT_FILTER = 13;
|
||||
public static final int MSG_SHOW_ACCESSIBILITY_BUTTON_CHOOSER = 14;
|
||||
public static final int MSG_INIT_SERVICE = 15;
|
||||
|
||||
public MainHandler(Looper looper) {
|
||||
super(looper);
|
||||
@ -2495,6 +2496,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
case MSG_SHOW_ACCESSIBILITY_BUTTON_CHOOSER: {
|
||||
showAccessibilityButtonTargetSelection();
|
||||
} break;
|
||||
|
||||
case MSG_INIT_SERVICE: {
|
||||
final Service service = (Service) msg.obj;
|
||||
service.initializeService();
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2950,20 +2956,31 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
if (userState.mBindingServices.contains(mComponentName) || mWasConnectedAndDied) {
|
||||
userState.mBindingServices.remove(mComponentName);
|
||||
mWasConnectedAndDied = false;
|
||||
try {
|
||||
mServiceInterface.init(this, mId, mOverlayWindowToken);
|
||||
onUserStateChangedLocked(userState);
|
||||
} catch (RemoteException re) {
|
||||
Slog.w(LOG_TAG, "Error while setting connection for service: "
|
||||
+ service, re);
|
||||
binderDied();
|
||||
}
|
||||
onUserStateChangedLocked(userState);
|
||||
// Initialize the service on the main handler after we're done setting up for
|
||||
// the new configuration (for example, initializing the input filter).
|
||||
mMainHandler.obtainMessage(MainHandler.MSG_INIT_SERVICE, this).sendToTarget();
|
||||
} else {
|
||||
binderDied();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeService() {
|
||||
final IAccessibilityServiceClient serviceInterface;
|
||||
synchronized (mLock) {
|
||||
serviceInterface = mServiceInterface;
|
||||
}
|
||||
if (serviceInterface == null) return;
|
||||
try {
|
||||
serviceInterface.init(this, mId, mOverlayWindowToken);
|
||||
} catch (RemoteException re) {
|
||||
Slog.w(LOG_TAG, "Error while setting connection for service: "
|
||||
+ serviceInterface, re);
|
||||
binderDied();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCalledForCurrentUserLocked() {
|
||||
// We treat calls from a profile as if made by its parent as profiles
|
||||
// share the accessibility state of the parent. The call below
|
||||
@ -3313,8 +3330,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
}
|
||||
if (mMotionEventInjector != null) {
|
||||
List<GestureDescription.GestureStep> steps = gestureSteps.getList();
|
||||
mMotionEventInjector.injectEvents(steps, mServiceInterface, sequence);
|
||||
return;
|
||||
mMotionEventInjector.injectEvents(steps, mServiceInterface, sequence);
|
||||
return;
|
||||
} else {
|
||||
Slog.e(LOG_TAG, "MotionEventInjector installation timed out");
|
||||
}
|
||||
@ -3456,18 +3473,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
return region;
|
||||
}
|
||||
MagnificationController magnificationController = getMagnificationController();
|
||||
boolean forceRegistration = mSecurityPolicy.canControlMagnification(this);
|
||||
boolean initiallyRegistered = magnificationController.isRegisteredLocked();
|
||||
if (!initiallyRegistered && forceRegistration) {
|
||||
magnificationController.register();
|
||||
}
|
||||
boolean registeredJustForThisCall =
|
||||
registerMagnificationIfNeeded(magnificationController);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
magnificationController.getMagnificationRegion(region);
|
||||
return region;
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
if (!initiallyRegistered && forceRegistration) {
|
||||
if (registeredJustForThisCall) {
|
||||
magnificationController.unregister();
|
||||
}
|
||||
}
|
||||
@ -3481,11 +3495,17 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
MagnificationController magnificationController = getMagnificationController();
|
||||
boolean registeredJustForThisCall =
|
||||
registerMagnificationIfNeeded(magnificationController);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return getMagnificationController().getCenterX();
|
||||
return magnificationController.getCenterX();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
if (registeredJustForThisCall) {
|
||||
magnificationController.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3496,14 +3516,30 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
MagnificationController magnificationController = getMagnificationController();
|
||||
boolean registeredJustForThisCall =
|
||||
registerMagnificationIfNeeded(magnificationController);
|
||||
final long identity = Binder.clearCallingIdentity();
|
||||
try {
|
||||
return getMagnificationController().getCenterY();
|
||||
return magnificationController.getCenterY();
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
if (registeredJustForThisCall) {
|
||||
magnificationController.unregister();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean registerMagnificationIfNeeded(
|
||||
MagnificationController magnificationController) {
|
||||
if (!magnificationController.isRegisteredLocked()
|
||||
&& mSecurityPolicy.canControlMagnification(this)) {
|
||||
magnificationController.register();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean resetMagnification(boolean animate) {
|
||||
synchronized (mLock) {
|
||||
|
@ -429,6 +429,8 @@ final class AccessibilityController {
|
||||
}
|
||||
|
||||
public void getMagnificationRegionLocked(Region outMagnificationRegion) {
|
||||
// Make sure we're working with the most current bounds
|
||||
mMagnifedViewport.recomputeBoundsLocked();
|
||||
mMagnifedViewport.getMagnificationRegionLocked(outMagnificationRegion);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user