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

Commit a87f05d5 authored by jasonwshsu's avatar jasonwshsu
Browse files

Set default value of accessibility button mode

Set floating menu mode by default, but if the user uses accessibility button in the navigation bar to trigger their accessibility features before migration, then set it to keep the navigation button mode.

Bug: 173940304
Test: 1. Push old version of db and apk
      2. Enable/Disable accessibility features in navigation bar
      3. Push new version of db and apk
Change-Id: I465eb2190f0e1ca9a6a6be928752a07d5e9576da
parent 299e9b5a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -256,4 +256,8 @@

    <!-- Default for Settings.Global.DEVELOPMENT_ENABLE_NON_RESIZABLE_MULTI_WINDOW -->
    <bool name="def_enable_non_resizable_multi_window">true</bool>

    <!-- Default for Settings.Secure.ACCESSIBILITY_BUTTON_MODE -->
    <integer name="def_accessibility_button_mode">1</integer>

</resources>
+41 −1
Original line number Diff line number Diff line
@@ -3396,7 +3396,7 @@ public class SettingsProvider extends ContentProvider {
        }

        private final class UpgradeController {
            private static final int SETTINGS_VERSION = 198;
            private static final int SETTINGS_VERSION = 199;

            private final int mUserId;

@@ -4894,6 +4894,36 @@ public class SettingsProvider extends ContentProvider {
                    currentVersion = 198;
                }

                if (currentVersion == 198) {
                    // Version 198: Set the default value for accessibility button. If the user
                    // uses accessibility button in the navigation bar to trigger their
                    // accessibility features (check if ACCESSIBILITY_BUTTON_TARGETS has value)
                    // then leave accessibility button mode in the navigation bar, otherwise, set it
                    // to the floating menu.
                    final SettingsState secureSettings = getSecureSettingsLocked(userId);
                    final Setting accessibilityButtonMode = secureSettings.getSettingLocked(
                            Secure.ACCESSIBILITY_BUTTON_MODE);
                    if (accessibilityButtonMode.isNull()) {
                        if (isAccessibilityButtonInNavigationBarOn(secureSettings)) {
                            secureSettings.insertSettingLocked(Secure.ACCESSIBILITY_BUTTON_MODE,
                                    String.valueOf(
                                            Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR),
                                    /*tag= */ null, /* makeDefault= */ false,
                                    SettingsState.SYSTEM_PACKAGE_NAME);
                        } else {
                            final int defAccessibilityButtonMode =
                                    getContext().getResources().getInteger(
                                            R.integer.def_accessibility_button_mode);
                            secureSettings.insertSettingLocked(Secure.ACCESSIBILITY_BUTTON_MODE,
                                    String.valueOf(defAccessibilityButtonMode), /* tag= */
                                    null, /* makeDefault= */ true,
                                    SettingsState.SYSTEM_PACKAGE_NAME);
                        }
                    }

                    currentVersion = 199;
                }

                // vXXX: Add new settings above this point.

                if (currentVersion != newVersion) {
@@ -5072,5 +5102,15 @@ public class SettingsProvider extends ContentProvider {
            }
            return items;
        }

        private boolean isAccessibilityButtonInNavigationBarOn(SettingsState secureSettings) {
            final boolean hasValueInA11yBtnTargets = !TextUtils.isEmpty(
                    secureSettings.getSettingLocked(
                            Secure.ACCESSIBILITY_BUTTON_TARGETS).getValue());
            final int navigationMode = getContext().getResources().getInteger(
                    com.android.internal.R.integer.config_navBarInteractionMode);

            return hasValueInA11yBtnTargets && (navigationMode != NAV_BAR_MODE_GESTURAL);
        }
    }
}