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

Commit 129d419b authored by Rhed Jao's avatar Rhed Jao
Browse files

Accessibility shortcut improvement (8/n)

- Migrate magnification navibar enabled setting to a11y button targets
  list setting.
- Clear settings of a11y button targets list, since there's no need to
  track legacy ones.

Bug: 136293963
Test: atest SettingsProviderTest
Change-Id: I0e83ebe55e00b5c760e3df5180a5d3a67c429e6f
parent 3ead8093
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -6405,6 +6405,15 @@ public final class Settings {
        public static final String ACCESSIBILITY_BUTTON_TARGET_COMPONENT =
                "accessibility_button_target_component";
        /**
         * The system class name of magnification controller which is a target to be toggled via
         * accessibility shortcut or accessibility button.
         *
         * @hide
         */
        public static final String ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER =
                "com.android.server.accessibility.MagnificationController";
        /**
         * If touch exploration is enabled.
         */
+28 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.os.Process.INVALID_UID;
import static android.os.Process.ROOT_UID;
import static android.os.Process.SHELL_UID;
import static android.os.Process.SYSTEM_UID;
import static android.provider.Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVERLAY;

import android.Manifest;
@@ -3304,7 +3305,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 185;
            private static final int SETTINGS_VERSION = 186;

            private final int mUserId;

@@ -4547,6 +4548,32 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 185;
                }

                if (currentVersion == 185) {
                    // Deprecate ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED, and migrate it
                    // to ACCESSIBILITY_BUTTON_TARGET_COMPONENT.
                    final SettingsState secureSettings = getSecureSettingsLocked(userId);
                    final Setting magnifyNavbarEnabled = secureSettings.getSettingLocked(
                            Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
                    if ("1".equals(magnifyNavbarEnabled.getValue())) {
                        secureSettings.insertSettingLocked(
                                Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
                                ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER,
                                null /* tag */, false /* makeDefault */,
                                SettingsState.SYSTEM_PACKAGE_NAME);
                    } else {
                        // Clear a11y button targets list setting. A11yManagerService will end up
                        // adding all legacy enabled services that want the button to the list, so
                        // there's no need to keep tracking them.
                        secureSettings.insertSettingLocked(
                                Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT,
                                null, null /* tag */, false /* makeDefault */,
                                SettingsState.SYSTEM_PACKAGE_NAME);
                    }
                    secureSettings.deleteSettingLocked(
                            Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED);
                    currentVersion = 186;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {
+2 −1
Original line number Diff line number Diff line
@@ -734,7 +734,8 @@ public class SettingsBackupTest {
                 Settings.Secure.DOZE_WAKE_DISPLAY_GESTURE,
                 Settings.Secure.FACE_UNLOCK_RE_ENROLL,
                 Settings.Secure.TAP_GESTURE,
                 Settings.Secure.WINDOW_MAGNIFICATION);
                 Settings.Secure.WINDOW_MAGNIFICATION,
                 Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER);

    @Test
    public void systemSettingsBackedUpOrBlacklisted() {