Enabled accessibility services settings may end with a separator.

SetupWizard was adding a separator after the last service name while
building the enabled accessibility services string. This case was not
handled by the settings. Added code to handle that case since it is
possible to have not well-formed settings backed up.

bug:5098493

Change-Id: I8381872037611a7456ca31526c85effdb9949885
This commit is contained in:
Svetoslav Ganov
2011-09-15 15:26:52 -07:00
parent 85eeb1c16a
commit efe27bfcdb

View File

@@ -84,7 +84,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
// the AccessibilityServiceInfo we need for proper presentation.
private static final long DELAY_UPDATE_SERVICES_PREFERENCES_MILLIS = 1000;
private static final char ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR = ':';
private static final String ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR = ":";
private static final String KEY_ACCESSIBILITY_TUTORIAL_LAUNCHED_ONCE =
"key_accessibility_tutorial_launched_once";
@@ -126,7 +126,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
// Auxiliary members.
private final SimpleStringSplitter mStringColonSplitter =
new SimpleStringSplitter(ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR);
new SimpleStringSplitter(ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR.charAt(0));
private final Map<String, String> mLongPressTimeoutValuetoTitleMap =
new HashMap<String, String>();
@@ -572,6 +572,11 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
if (enabledServices == null) {
enabledServices = "";
}
// Due to a legacy bug we can get an enabled services value ending with a
// separator. Make sure to catch and fix that before handling.
if (enabledServices.endsWith(ENABLED_ACCESSIBILITY_SERVICES_SEPARATOR)) {
enabledServices = enabledServices.substring(0, enabledServices.length() - 1);
}
final int length = enabledServices.length();
if (enabled) {
if (enabledServices.contains(preferenceKey)) {