summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Phil Weaver <pweaver@google.com> 2017-08-15 16:18:46 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-08-15 16:18:46 +0000
commit51faa4427d95a6bea1b8f1f45c07079a3a5d6ac4 (patch)
tree4cfdb1d9e17c45bbaf3e415c903ab508046d0525
parent3589216f471ba9c989754f308fc40069ea58798f (diff)
parent53b690b5bc72ac5cd34300c9965707edd0b217cd (diff)
Merge "Better guarantee a11y service initial state"
-rw-r--r--services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java72
-rw-r--r--services/core/java/com/android/server/wm/AccessibilityController.java2
2 files changed, 56 insertions, 18 deletions
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index a59844d2462b..1859d350c102 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -2394,6 +2394,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);
@@ -2492,6 +2493,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;
}
}
@@ -2947,20 +2953,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
@@ -3310,8 +3327,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");
}
@@ -3450,18 +3467,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();
}
}
@@ -3475,11 +3489,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();
+ }
}
}
@@ -3490,12 +3510,28 @@ 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
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index 805250ad96d4..6484a13d8c3e 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -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);
}