Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 015fe4ff authored by Phil Weaver's avatar Phil Weaver Committed by android-build-merger
Browse files

Merge "a11y: don't crash the system when illegal component name encounted" am: f4d1789b

am: 411b5233

Change-Id: Idb8ffd83b4d8b89ebba52ad6fe5e7037ac61b4b7
parents 6f92395e 411b5233
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ public class SettingsStringUtil {

        @Override
        protected String itemToString(ComponentName item) {
            return item.flattenToString();
            return item != null ? item.flattenToString() : "null";
        }

        public static String add(String delimitedElements, ComponentName element) {
+12 −14
Original line number Diff line number Diff line
@@ -82,8 +82,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManagerInternal;
import android.provider.Settings;
import android.provider.SettingsStringUtil;
import android.provider.SettingsStringUtil.ComponentNameSet;
import android.provider.SettingsStringUtil.SettingStringHelper;
import android.text.TextUtils;
import android.text.TextUtils.SimpleStringSplitter;
@@ -2436,12 +2434,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
     * Enables accessibility service specified by {@param componentName} for the {@param userId}.
     */
    private void enableAccessibilityServiceLocked(ComponentName componentName, int userId) {
        final SettingStringHelper setting =
                new SettingStringHelper(
                        mContext.getContentResolver(),
                        Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                        userId);
        setting.write(ComponentNameSet.add(setting.read(), componentName));
        mTempComponentNameSet.clear();
        readComponentNamesFromSettingLocked(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                userId, mTempComponentNameSet);
        mTempComponentNameSet.add(componentName);
        persistComponentNamesToSettingLocked(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                mTempComponentNameSet, userId);

        UserState userState = getUserStateLocked(userId);
        if (userState.mEnabledServices.add(componentName)) {
@@ -2453,12 +2451,12 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
     * Disables accessibility service specified by {@param componentName} for the {@param userId}.
     */
    private void disableAccessibilityServiceLocked(ComponentName componentName, int userId) {
        final SettingsStringUtil.SettingStringHelper setting =
                new SettingStringHelper(
                        mContext.getContentResolver(),
                        Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                        userId);
        setting.write(ComponentNameSet.remove(setting.read(), componentName));
        mTempComponentNameSet.clear();
        readComponentNamesFromSettingLocked(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                userId, mTempComponentNameSet);
        mTempComponentNameSet.remove(componentName);
        persistComponentNamesToSettingLocked(Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES,
                mTempComponentNameSet, userId);

        UserState userState = getUserStateLocked(userId);
        if (userState.mEnabledServices.remove(componentName)) {