Merge "Invalid accessibility state if UI test process crashes in a bad time." into lmp-dev
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 1253bc7c..cc17422 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -2004,7 +2004,15 @@
} else {
userState.mBindingServices.add(mComponentName);
mService = userState.mUiAutomationServiceClient.asBinder();
- onServiceConnected(mComponentName, mService);
+ mMainHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ // Simulate asynchronous connection since in onServiceConnected
+ // we may modify the state data in case of an error but bind is
+ // called while iterating over the data and bad things can happen.
+ onServiceConnected(mComponentName, mService);
+ }
+ });
userState.mUiAutomationService = this;
}
return false;