Merge "Disable accessibility if all accessibility serivces are disbaled."

This commit is contained in:
Svetoslav Ganov
2011-09-14 11:07:36 -07:00
committed by Android (Google) Code Review

View File

@@ -225,7 +225,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
return false; return false;
} }
} }
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.getAction() == Intent.ACTION_BOOT_COMPLETED) { if (intent.getAction() == Intent.ACTION_BOOT_COMPLETED) {
@@ -697,6 +697,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
private void manageServicesLocked() { private void manageServicesLocked() {
populateEnabledServicesLocked(mEnabledServices); populateEnabledServicesLocked(mEnabledServices);
updateServicesStateLocked(mInstalledServices, mEnabledServices); updateServicesStateLocked(mInstalledServices, mEnabledServices);
disableAccessibilityIfNoEnabledServices(mEnabledServices);
} }
/** /**
@@ -780,6 +781,19 @@ 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);
}
}
/** /**
* Sends the state to the clients. * Sends the state to the clients.
*/ */