diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-20 18:00:26 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-20 18:00:26 -0700 |
commit | 4a03e91aa0d1033261290d11b00ca5a269bb92f6 (patch) | |
tree | 4c0a2e4ea4e052a324a8a36bb4863190e10deb4d /services | |
parent | a1d2790747d092ae9bd4db64ecde2d9d975d9996 (diff) | |
parent | 1e741b2705023be64389ac3e31c5f63d330470a5 (diff) | |
download | frameworks_base-4a03e91aa0d1033261290d11b00ca5a269bb92f6.zip frameworks_base-4a03e91aa0d1033261290d11b00ca5a269bb92f6.tar.gz frameworks_base-4a03e91aa0d1033261290d11b00ca5a269bb92f6.tar.bz2 |
Merge "System not checking if enabled services are installed when disabling accessibility."
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/accessibility/AccessibilityManagerService.java | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 6830055..ed8fa40 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -718,8 +718,14 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub */ private void manageServicesLocked() { populateEnabledServicesLocked(mEnabledServices); - updateServicesStateLocked(mInstalledServices, mEnabledServices); - disableAccessibilityIfNoEnabledServices(mEnabledServices); + final int enabledInstalledServicesCount = updateServicesStateLocked(mInstalledServices, + mEnabledServices); + // No enabled installed services => disable accessibility to avoid + // sending accessibility events with no recipient across processes. + if (mIsAccessibilityEnabled && enabledInstalledServicesCount == 0) { + Settings.Secure.putInt(mContext.getContentResolver(), + Settings.Secure.ACCESSIBILITY_ENABLED, 0); + } } /** @@ -771,13 +777,15 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub * * @param installedServices All installed {@link AccessibilityService}s. * @param enabledServices The {@link ComponentName}s of the enabled services. + * @return The number of enabled installed services. */ - private void updateServicesStateLocked(List<AccessibilityServiceInfo> installedServices, + private int updateServicesStateLocked(List<AccessibilityServiceInfo> installedServices, Set<ComponentName> enabledServices) { Map<ComponentName, Service> componentNameToServiceMap = mComponentNameToServiceMap; boolean isEnabled = mIsAccessibilityEnabled; + int enabledInstalledServices = 0; for (int i = 0, count = installedServices.size(); i < count; i++) { AccessibilityServiceInfo installedService = installedServices.get(i); ComponentName componentName = ComponentName.unflattenFromString( @@ -790,6 +798,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub service = new Service(componentName, installedService, false); } service.bind(); + enabledInstalledServices++; } else { if (service != null) { service.unbind(); @@ -801,19 +810,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub } } } - } - /** - * Disables accessibility if there are no enabled accessibility services which - * to consume the generated accessibility events. - * - * @param enabledServices The set of enabled services. - */ - private void disableAccessibilityIfNoEnabledServices(Set<ComponentName> enabledServices) { - if (enabledServices.isEmpty()) { - Settings.Secure.putInt(mContext.getContentResolver(), - Settings.Secure.ACCESSIBILITY_ENABLED, 0); - } + return enabledInstalledServices; } /** |