Merge "UI automation service disconnected upon package change."

This commit is contained in:
Svetoslav Ganov
2012-02-10 15:13:26 -08:00
committed by Android (Google) Code Review

View File

@@ -143,6 +143,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
private final SecurityPolicy mSecurityPolicy; private final SecurityPolicy mSecurityPolicy;
private Service mUiAutomationService;
/** /**
* Handler for delayed event dispatch. * Handler for delayed event dispatch.
*/ */
@@ -494,19 +496,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
} }
} }
// Hook the automation service up. // Hook the automation service up.
Service service = new Service(componentName, accessibilityServiceInfo, true); mUiAutomationService = new Service(componentName, accessibilityServiceInfo, true);
service.onServiceConnected(componentName, listener.asBinder()); mUiAutomationService.onServiceConnected(componentName, listener.asBinder());
} }
public void unregisterUiTestAutomationService(IEventListener listener) { public void unregisterUiTestAutomationService(IEventListener listener) {
synchronized (mLock) { synchronized (mLock) {
final int serviceCount = mServices.size(); // Automation service is not bound, so pretend it died to perform clean up.
for (int i = 0; i < serviceCount; i++) { if (mUiAutomationService != null) {
Service service = mServices.get(i); mUiAutomationService.binderDied();
if (service.mServiceInterface == listener && service.mIsAutomation) {
// Automation service is not bound, so pretend it died to perform clean up.
service.binderDied();
}
} }
} }
} }
@@ -741,7 +739,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
* Manages services by starting enabled ones and stopping disabled ones. * Manages services by starting enabled ones and stopping disabled ones.
*/ */
private void manageServicesLocked() { private void manageServicesLocked() {
unbindAutomationService(); // While the UI automation service is running it takes over.
if (mUiAutomationService != null) {
return;
}
populateEnabledServicesLocked(mEnabledServices); populateEnabledServicesLocked(mEnabledServices);
final int enabledInstalledServicesCount = updateServicesStateLocked(mInstalledServices, final int enabledInstalledServicesCount = updateServicesStateLocked(mInstalledServices,
mEnabledServices); mEnabledServices);
@@ -768,21 +769,6 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
} }
} }
/**
* Unbinds the automation service if such is running.
*/
private void unbindAutomationService() {
List<Service> runningServices = mServices;
int runningServiceCount = mServices.size();
for (int i = 0; i < runningServiceCount; i++) {
Service service = runningServices.get(i);
if (service.mIsAutomation) {
service.unbind();
return;
}
}
}
/** /**
* Populates a list with the {@link ComponentName}s of all enabled * Populates a list with the {@link ComponentName}s of all enabled
* {@link AccessibilityService}s. * {@link AccessibilityService}s.
@@ -1248,6 +1234,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
// We no longer have an automation service, so restore // We no longer have an automation service, so restore
// the state based on values in the settings database. // the state based on values in the settings database.
if (mIsAutomation) { if (mIsAutomation) {
mUiAutomationService = null;
handleAccessibilityEnabledSettingChangedLocked(); handleAccessibilityEnabledSettingChangedLocked();
} }
} }