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

Commit d53cbefc authored by Jason Hsu's avatar Jason Hsu Committed by Android (Google) Code Review
Browse files

Merge "Accessibility shortcut secondary action - handle all preferred shortcut type key"

parents d5095abc fb576356
Loading
Loading
Loading
Loading
+66 −9
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.text.TextUtils;


import androidx.annotation.IntDef;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;


import com.android.settings.R;
import com.android.settings.R;


@@ -160,41 +161,76 @@ final class AccessibilityUtil {
    }
    }


    /**
    /**
     * Opts in component name into colon-separated {@code shortcutType} key's string in Settings.
     * Opts in component name into multiple {@code shortcutTypes} colon-separated string in
     * Settings.
     *
     * @param context The current context.
     * @param shortcutTypes  A combination of {@link UserShortcutType}.
     * @param componentName The component name that need to be opted in Settings.
     */
    static void optInAllValuesToSettings(Context context, int shortcutTypes,
            @NonNull ComponentName componentName) {
        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
            optInValueToSettings(context, UserShortcutType.SOFTWARE, componentName);
        }
        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
            optInValueToSettings(context, UserShortcutType.HARDWARE, componentName);
        }
    }

    /**
     * Opts in component name into {@code shortcutType} colon-separated string in Settings.
     *
     *
     * @param context The current context.
     * @param context The current context.
     * @param shortcutType The preferred shortcut type user selected.
     * @param shortcutType The preferred shortcut type user selected.
     * @param componentName The component name that need to be opted in Settings.
     * @param componentName The component name that need to be opted in Settings.
     */
     */
    @VisibleForTesting
    static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
    static void optInValueToSettings(Context context, @UserShortcutType int shortcutType,
            @NonNull ComponentName componentName) {
            @NonNull ComponentName componentName) {
        final String targetKey = convertKeyFromSettings(shortcutType);
        final String targetKey = convertKeyFromSettings(shortcutType);
        final String targetString = Settings.Secure.getString(context.getContentResolver(),
        final String targetString = Settings.Secure.getString(context.getContentResolver(),
                targetKey);
                targetKey);


        if (TextUtils.isEmpty(targetString)) {
            return;
        }

        if (hasValueInSettings(context, shortcutType, componentName)) {
        if (hasValueInSettings(context, shortcutType, componentName)) {
            return;
            return;
        }
        }


        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));

        if (!TextUtils.isEmpty(targetString)) {
            joiner.add(targetString);
            joiner.add(targetString);
        }
        joiner.add(componentName.flattenToString());
        joiner.add(componentName.flattenToString());


        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
    }
    }


    /**
    /**
     * Opts out component name into colon-separated {@code shortcutType} key's string in Settings.
     * Opts out component name into multiple {@code shortcutTypes} colon-separated string in
     * Settings.
     *
     * @param context The current context.
     * @param shortcutTypes A combination of {@link UserShortcutType}.
     * @param componentName The component name that need to be opted out from Settings.
     */
    static void optOutAllValuesFromSettings(Context context, int shortcutTypes,
            @NonNull ComponentName componentName) {
        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
            optOutValueFromSettings(context, UserShortcutType.SOFTWARE, componentName);
        }
        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
            optOutValueFromSettings(context, UserShortcutType.HARDWARE, componentName);
        }
    }

    /**
     * Opts out component name into {@code shortcutType} colon-separated string in Settings.
     *
     *
     * @param context The current context.
     * @param context The current context.
     * @param shortcutType The preferred shortcut type user selected.
     * @param shortcutType The preferred shortcut type user selected.
     * @param componentName The component name that need to be opted out from Settings.
     * @param componentName The component name that need to be opted out from Settings.
     */
     */
    @VisibleForTesting
    static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType,
    static void optOutValueFromSettings(Context context, @UserShortcutType int shortcutType,
            @NonNull ComponentName componentName) {
            @NonNull ComponentName componentName) {
        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
@@ -219,13 +255,34 @@ final class AccessibilityUtil {
    }
    }


    /**
    /**
     * Returns if component name existed in Settings.
     * Returns if component name existed in one of {@code shortcutTypes} string in Settings.
     *
     * @param context The current context.
     * @param shortcutTypes A combination of {@link UserShortcutType}.
     * @param componentName The component name that need to be checked existed in Settings.
     * @return {@code true} if componentName existed in Settings.
     */
    static boolean hasValuesInSettings(Context context, int shortcutTypes,
            @NonNull ComponentName componentName) {
        boolean exist = false;
        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
            exist = hasValueInSettings(context, UserShortcutType.SOFTWARE, componentName);
        }
        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
            exist |= hasValueInSettings(context, UserShortcutType.HARDWARE, componentName);
        }
        return exist;
    }

    /**
     * Returns if component name existed in {@code shortcutType} string Settings.
     *
     *
     * @param context The current context.
     * @param context The current context.
     * @param shortcutType The preferred shortcut type user selected.
     * @param shortcutType The preferred shortcut type user selected.
     * @param componentName The component name that need to be checked existed in Settings.
     * @param componentName The component name that need to be checked existed in Settings.
     * @return {@code true} if componentName existed in Settings.
     * @return {@code true} if componentName existed in Settings.
     */
     */
    @VisibleForTesting
    static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType,
    static boolean hasValueInSettings(Context context, @UserShortcutType int shortcutType,
            @NonNull ComponentName componentName) {
            @NonNull ComponentName componentName) {
        final String targetKey = convertKeyFromSettings(shortcutType);
        final String targetKey = convertKeyFromSettings(shortcutType);
+15 −17
Original line number Original line Diff line number Diff line
@@ -317,6 +317,12 @@ public class ToggleAccessibilityServicePreferenceFragment extends
        updateUserShortcutType(/* saveChanges= */ true);
        updateUserShortcutType(/* saveChanges= */ true);
        mShortcutPreference.setSummary(
        mShortcutPreference.setSummary(
                getShortcutTypeSummary(getPrefContext()));
                getShortcutTypeSummary(getPrefContext()));
        if (mShortcutPreference.getChecked()) {
            AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
                    mComponentName);
            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
                    mComponentName);
        }
    }
    }


    @Override
    @Override
@@ -346,8 +352,7 @@ public class ToggleAccessibilityServicePreferenceFragment extends
    }
    }


    private void initShortcutPreference(Bundle savedInstanceState) {
    private void initShortcutPreference(Bundle savedInstanceState) {
        mUserShortcutType = getUserShortcutType(getPrefContext(),
        mUserShortcutType = getUserShortcutType(getPrefContext(), UserShortcutType.SOFTWARE);
                UserShortcutType.SOFTWARE);


        // Restore the user shortcut type
        // Restore the user shortcut type
        if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
        if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_SHORTCUT_TYPE)) {
@@ -366,7 +371,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
        mShortcutPreference.setOnClickListener(this);
        mShortcutPreference.setOnClickListener(this);
        // Put the shortcutPreference before settingsPreference.
        // Put the shortcutPreference before settingsPreference.
        mShortcutPreference.setOrder(-1);
        mShortcutPreference.setOrder(-1);
        // TODO(b/142530063): Check the new key to decide whether checkbox should be checked.
        preferenceScreen.addPreference(mShortcutPreference);
        preferenceScreen.addPreference(mShortcutPreference);
    }
    }


@@ -376,11 +380,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
                getShortcutPreferenceKey());
                getShortcutPreferenceKey());


        if (shortcutPreference != null) {
        if (shortcutPreference != null) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
            //  preferred key.
            shortcutPreference.setChecked(
            shortcutPreference.setChecked(
                    AccessibilityUtil.hasValueInSettings(getContext(),
                    AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
                            UserShortcutType.SOFTWARE,
                            mComponentName));
                            mComponentName));
        }
        }
    }
    }
@@ -473,20 +475,17 @@ public class ToggleAccessibilityServicePreferenceFragment extends


    @Override
    @Override
    public void onCheckboxClicked(ShortcutPreference preference) {
    public void onCheckboxClicked(ShortcutPreference preference) {
        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
        if (preference.getChecked()) {
        if (preference.getChecked()) {
            if (!getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
            if (!getArguments().getBoolean(AccessibilitySettings.EXTRA_CHECKED)) {
                preference.setChecked(false);
                preference.setChecked(false);
                showPopupDialog(DialogType.ENABLE_WARNING_FROM_SHORTCUT);
                showPopupDialog(DialogType.ENABLE_WARNING_FROM_SHORTCUT);
            } else {
            } else {
                // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog
                AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
                //  shortcut preferred key.
                AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
                        mComponentName);
                        mComponentName);
            }
            }
        } else {
        } else {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
            //  preferred key.
            AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
                    mComponentName);
                    mComponentName);
        }
        }
    }
    }
@@ -578,10 +577,9 @@ public class ToggleAccessibilityServicePreferenceFragment extends
    private void onAllowButtonFromShortcutClicked() {
    private void onAllowButtonFromShortcutClicked() {
        final ShortcutPreference shortcutPreference = findPreference(getShortcutPreferenceKey());
        final ShortcutPreference shortcutPreference = findPreference(getShortcutPreferenceKey());
        shortcutPreference.setChecked(true);
        shortcutPreference.setChecked(true);
        // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut

        //  preferred key.
        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
        AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
        AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes, mComponentName);
                mComponentName);


        mDialog.dismiss();
        mDialog.dismiss();
    }
    }
+11 −10
Original line number Original line Diff line number Diff line
@@ -273,6 +273,12 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
        updateUserShortcutType(/* saveChanges= */ true);
        updateUserShortcutType(/* saveChanges= */ true);
        mShortcutPreference.setSummary(
        mShortcutPreference.setSummary(
                getShortcutTypeSummary(getPrefContext()));
                getShortcutTypeSummary(getPrefContext()));
        if (mShortcutPreference.getChecked()) {
            AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
                    getComponentName());
            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
                    getComponentName());
        }
    }
    }


    @Override
    @Override
@@ -315,11 +321,9 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
                getShortcutPreferenceKey());
                getShortcutPreferenceKey());


        if (shortcutPreference != null) {
        if (shortcutPreference != null) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
            //  preferred key.
            shortcutPreference.setChecked(
            shortcutPreference.setChecked(
                    AccessibilityUtil.hasValueInSettings(getContext(),
                    AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
                            UserShortcutType.SOFTWARE,
                            getComponentName()));
                            getComponentName()));
        }
        }
    }
    }
@@ -334,15 +338,12 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere


    @Override
    @Override
    public void onCheckboxClicked(ShortcutPreference preference) {
    public void onCheckboxClicked(ShortcutPreference preference) {
        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
        if (preference.getChecked()) {
        if (preference.getChecked()) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
            //  preferred key.
            AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
                    getComponentName());
                    getComponentName());
        } else {
        } else {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
            //  preferred key.
            AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
                    getComponentName());
                    getComponentName());
        }
        }
    }
    }
+11 −10
Original line number Original line Diff line number Diff line
@@ -245,6 +245,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
        updateUserShortcutType(/* saveChanges= */ true);
        updateUserShortcutType(/* saveChanges= */ true);
        mShortcutPreference.setSummary(
        mShortcutPreference.setSummary(
                getShortcutTypeSummary(getPrefContext()));
                getShortcutTypeSummary(getPrefContext()));
        if (mShortcutPreference.getChecked()) {
            AccessibilityUtil.optInAllValuesToSettings(getContext(), mUserShortcutType,
                    getComponentName());
            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), ~mUserShortcutType,
                    getComponentName());
        }
    }
    }


    @Override
    @Override
@@ -303,15 +309,12 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe


    @Override
    @Override
    public void onCheckboxClicked(ShortcutPreference preference) {
    public void onCheckboxClicked(ShortcutPreference preference) {
        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
        if (preference.getChecked()) {
        if (preference.getChecked()) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            AccessibilityUtil.optInAllValuesToSettings(getContext(), shortcutTypes,
            //  preferred key.
            AccessibilityUtil.optInValueToSettings(getContext(), UserShortcutType.SOFTWARE,
                    getComponentName());
                    getComponentName());
        } else {
        } else {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            AccessibilityUtil.optOutAllValuesFromSettings(getContext(), shortcutTypes,
            //  preferred key.
            AccessibilityUtil.optOutValueFromSettings(getContext(), UserShortcutType.SOFTWARE,
                    getComponentName());
                    getComponentName());
        }
        }
    }
    }
@@ -355,11 +358,9 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
                getShortcutPreferenceKey());
                getShortcutPreferenceKey());


        if (shortcutPreference != null) {
        if (shortcutPreference != null) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
            //  preferred key.
            shortcutPreference.setChecked(
            shortcutPreference.setChecked(
                    AccessibilityUtil.hasValueInSettings(getContext(),
                    AccessibilityUtil.hasValuesInSettings(getContext(), shortcutTypes,
                            UserShortcutType.SOFTWARE,
                            getComponentName()));
                            getComponentName()));
        }
        }


+52 −40
Original line number Original line Diff line number Diff line
@@ -372,6 +372,10 @@ public class ToggleScreenMagnificationPreferenceFragment extends
        updateUserShortcutType(/* saveChanges= */ true);
        updateUserShortcutType(/* saveChanges= */ true);
        mShortcutPreference.setSummary(
        mShortcutPreference.setSummary(
                getShortcutTypeSummary(getPrefContext()));
                getShortcutTypeSummary(getPrefContext()));
        if (mShortcutPreference.getChecked()) {
            optInAllMagnificationValuesToSettings(getContext(), mUserShortcutType);
            optOutAllMagnificationValuesFromSettings(getContext(), ~mUserShortcutType);
        }
    }
    }


    private String getComponentName() {
    private String getComponentName() {
@@ -435,38 +439,11 @@ public class ToggleScreenMagnificationPreferenceFragment extends


    @Override
    @Override
    public void onCheckboxClicked(ShortcutPreference preference) {
    public void onCheckboxClicked(ShortcutPreference preference) {
        final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
        if (preference.getChecked()) {
        if (preference.getChecked()) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            optInAllMagnificationValuesToSettings(getContext(), shortcutTypes);
            //  preferred key.
            optInMagnificationValueToSettings(getContext(), UserShortcutType.SOFTWARE);

            // TODO(b/142531156): ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED need to be treated
            //  as special case in this file.
            if ((mUserShortcutType & UserShortcutType.SOFTWARE)
                    == UserShortcutType.SOFTWARE) {
                MagnificationPreferenceFragment.setChecked(getContentResolver(),
                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
                        /* isChecked= */ true);
            }
            if ((mUserShortcutType & UserShortcutType.TRIPLETAP)
                    == UserShortcutType.TRIPLETAP) {
                MagnificationPreferenceFragment.setChecked(getContentResolver(),
                        Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
                        /* isChecked= */ true);
            }
        } else {
        } else {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            optOutAllMagnificationValuesFromSettings(getContext(), shortcutTypes);
            //  preferred key.
            optOutMagnificationValueFromSettings(getContext(), UserShortcutType.SOFTWARE);

            // TODO(b/142531156): ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED need to be treated
            //  as special case in this file.
            MagnificationPreferenceFragment.setChecked(getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED,
                    /* isChecked= */ false);
            MagnificationPreferenceFragment.setChecked(getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
                    /* isChecked= */ false);
        }
        }
    }
    }


@@ -505,11 +482,9 @@ public class ToggleScreenMagnificationPreferenceFragment extends
                getShortcutPreferenceKey());
                getShortcutPreferenceKey());


        if (shortcutPreference != null) {
        if (shortcutPreference != null) {
            // TODO(b/142531156): Replace UserShortcutType.SOFTWARE value with dialog shortcut
            final int shortcutTypes = getUserShortcutType(getContext(), UserShortcutType.SOFTWARE);
            //  preferred key.
            shortcutPreference.setChecked(
            shortcutPreference.setChecked(
                    hasMagnificationValueInSettings(getContext(),
                    hasMagnificationValuesInSettings(getContext(), shortcutTypes));
                            UserShortcutType.SOFTWARE));
        }
        }
    }
    }


@@ -534,28 +509,50 @@ public class ToggleScreenMagnificationPreferenceFragment extends
        int EDIT_SHORTCUT = 3;
        int EDIT_SHORTCUT = 3;
    }
    }


    private static void optInAllMagnificationValuesToSettings(Context context, int shortcutTypes) {
        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
            optInMagnificationValueToSettings(context, UserShortcutType.SOFTWARE);
        }
        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
            optInMagnificationValueToSettings(context, UserShortcutType.HARDWARE);
        }
        if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
            optInMagnificationValueToSettings(context, UserShortcutType.TRIPLETAP);
        }
    }

    private static void optInMagnificationValueToSettings(Context context,
    private static void optInMagnificationValueToSettings(Context context,
            @UserShortcutType int shortcutType) {
            @UserShortcutType int shortcutType) {
        final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
        final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
        final String targetString = Settings.Secure.getString(context.getContentResolver(),
        final String targetString = Settings.Secure.getString(context.getContentResolver(),
                targetKey);
                targetKey);


        if (TextUtils.isEmpty(targetString)) {
            return;
        }

        if (hasMagnificationValueInSettings(context, shortcutType)) {
        if (hasMagnificationValueInSettings(context, shortcutType)) {
            return;
            return;
        }
        }


        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));

        if (TextUtils.isEmpty(targetString)) {
        joiner.add(Settings.Secure.getString(context.getContentResolver(), targetKey));
            joiner.add(targetString);
        }
        joiner.add(MAGNIFICATION_CONTROLLER_NAME);
        joiner.add(MAGNIFICATION_CONTROLLER_NAME);


        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
    }
    }


    private static void optOutAllMagnificationValuesFromSettings(Context context,
            int shortcutTypes) {
        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
            optOutMagnificationValueFromSettings(context, UserShortcutType.SOFTWARE);
        }
        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
            optOutMagnificationValueFromSettings(context, UserShortcutType.HARDWARE);
        }
        if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
            optOutMagnificationValueFromSettings(context, UserShortcutType.TRIPLETAP);
        }
    }

    private static void optOutMagnificationValueFromSettings(Context context,
    private static void optOutMagnificationValueFromSettings(Context context,
            @UserShortcutType int shortcutType) {
            @UserShortcutType int shortcutType) {
        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
        final StringJoiner joiner = new StringJoiner(String.valueOf(COMPONENT_NAME_SEPARATOR));
@@ -579,6 +576,21 @@ public class ToggleScreenMagnificationPreferenceFragment extends
        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
        Settings.Secure.putString(context.getContentResolver(), targetKey, joiner.toString());
    }
    }


    private static boolean hasMagnificationValuesInSettings(Context context, int shortcutTypes) {
        boolean exist = false;

        if ((shortcutTypes & UserShortcutType.SOFTWARE) == UserShortcutType.SOFTWARE) {
            exist = hasMagnificationValueInSettings(context, UserShortcutType.SOFTWARE);
        }
        if (((shortcutTypes & UserShortcutType.HARDWARE) == UserShortcutType.HARDWARE)) {
            exist |= hasMagnificationValueInSettings(context, UserShortcutType.HARDWARE);
        }
        if (((shortcutTypes & UserShortcutType.TRIPLETAP) == UserShortcutType.TRIPLETAP)) {
            exist |= hasMagnificationValueInSettings(context, UserShortcutType.TRIPLETAP);
        }
        return exist;
    }

    private static boolean hasMagnificationValueInSettings(Context context,
    private static boolean hasMagnificationValueInSettings(Context context,
            @UserShortcutType int shortcutType) {
            @UserShortcutType int shortcutType) {
        final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
        final String targetKey = AccessibilityUtil.convertKeyFromSettings(shortcutType);
Loading