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

Commit 425c8680 authored by Annie Meng's avatar Annie Meng
Browse files

Add navbar magnification to critical accessibility check

If a user enables navbar magnification on their new device and the
setting was disabled on their old device, we don't want to overwrite
this setting and disable it on their new device during d2d restore.

Bug: 79189332
Test: 1) atest SettingsHelperRestoreTest
2) manual:
- Source device setting off -> target device turns setting on in SUW
-> d2d restore does not overwrite
- Source device setting on -> target device does not turn setting on
in SUW -> d2d restores setting properly

Change-Id: I58648010a9d4d3380c1c01cdaaab03828e3ea2c4
parent a92c8ad1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -251,6 +251,7 @@ public class SettingsHelper {
            case Settings.Secure.TOUCH_EXPLORATION_ENABLED:
            case Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED:
            case Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED:
            case Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED:
            case Settings.Secure.UI_NIGHT_MODE:
                return Settings.Secure.getInt(mContext.getContentResolver(), name, 0) != 0;
            case Settings.Secure.TOUCH_EXPLORATION_GRANTED_ACCESSIBILITY_SERVICES:
+44 −0
Original line number Diff line number Diff line
@@ -118,4 +118,48 @@ public class SettingsHelperRestoreTest {
                defaultSettingValue);
        return defaultSettingValue;
    }

    /** Tests for {@link Settings.Secure#ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED}. */
    @Test
    public void
            testRestoreAccessibilityDisplayMagnificationNavbarEnabled_alreadyConfigured_doesNotRestoreValue()
                    throws Exception {
        String settingName = Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED;
        // Simulate already configuring setting via SUW.
        int configuredSettingValue = 1;
        Settings.Secure.putInt(mContentResolver, settingName, configuredSettingValue);

        mSettingsHelper.restoreValue(
                mContext,
                mContentResolver,
                new ContentValues(2),
                Settings.Secure.getUriFor(settingName),
                settingName,
                String.valueOf(0),
                Build.VERSION.SDK_INT);

        assertEquals(configuredSettingValue, Settings.Secure.getInt(mContentResolver, settingName));
    }

    @Test
    public void
            testRestoreAccessibilityDisplayMagnificationNavbarEnabled_notAlreadyConfigured_restoresValue()
                    throws Exception {
        String settingName = Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_NAVBAR_ENABLED;
        int defaultSettingValue = 0;
        // Simulate system default at boot.
        Settings.Secure.putInt(mContentResolver, settingName, defaultSettingValue);

        int restoreSettingValue = 1;
        mSettingsHelper.restoreValue(
                mContext,
                mContentResolver,
                new ContentValues(2),
                Settings.Secure.getUriFor(settingName),
                settingName,
                String.valueOf(restoreSettingValue),
                Build.VERSION.SDK_INT);

        assertEquals(restoreSettingValue, Settings.Secure.getInt(mContentResolver, settingName));
    }
}