Loading core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -9127,6 +9127,15 @@ public final class Settings { public static final String ACCESSIBILITY_MAGNIFICATION_CAPABILITY = "accessibility_magnification_capability"; /** * Whether to show the window magnification prompt dialog when the user uses full-screen * magnification first time after database is upgraded . * * @hide */ public static final String ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT = "accessibility_show_window_magnification_prompt"; /** * Whether the Adaptive connectivity option is enabled. * Loading packages/SettingsProvider/res/values/defaults.xml +3 −0 Original line number Diff line number Diff line Loading @@ -240,4 +240,7 @@ <!-- Default for setting for Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED --> <bool name="def_hdmiControlAutoDeviceOff">false</bool> <!-- Default for Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY --> <integer name="def_accessibility_magnification_capabilities">3</integer> </resources> packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +71 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVE import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; import static com.android.providers.settings.SettingsState.FALLBACK_FILE_SUFFIX; import android.Manifest; Loading Loading @@ -3341,7 +3342,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 192; private static final int SETTINGS_VERSION = 193; private final int mUserId; Loading Loading @@ -4724,6 +4725,35 @@ public class SettingsProvider extends ContentProvider { currentVersion = 192; } if (currentVersion == 192) { // Version 192: set the default value for magnification capabilities. If // magnification is enabled by the user, set it to full-screen, and set a value // to show a prompt when using the magnification first time after upgrading. final SettingsState secureSettings = getSecureSettingsLocked(userId); final Setting magnificationCapabilities = secureSettings.getSettingLocked( Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY); if (magnificationCapabilities.isNull()) { secureSettings.insertSettingLocked( Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, String.valueOf(getContext().getResources().getInteger( R.integer.def_accessibility_magnification_capabilities)), null, true, SettingsState.SYSTEM_PACKAGE_NAME); if (isMagnificationSettingsOn(secureSettings)) { secureSettings.insertSettingLocked( Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, String.valueOf( Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN), null, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); secureSettings.insertSettingLocked( Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT, "1", null, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); } } currentVersion = 193; } // vXXX: Add new settings above this point. if (currentVersion != newVersion) { Loading Loading @@ -4862,5 +4892,45 @@ public class SettingsProvider extends ContentProvider { } } } private boolean isMagnificationSettingsOn(SettingsState secureSettings) { if ("1".equals(secureSettings.getSettingLocked( Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED).getValue())) { return true; } final Set<String> a11yButtonTargets = transformColonDelimitedStringToSet( secureSettings.getSettingLocked( Secure.ACCESSIBILITY_BUTTON_TARGETS).getValue()); if (a11yButtonTargets != null && a11yButtonTargets.contains( MAGNIFICATION_CONTROLLER_NAME)) { return true; } final Set<String> a11yShortcutServices = transformColonDelimitedStringToSet( secureSettings.getSettingLocked( Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE).getValue()); if (a11yShortcutServices != null && a11yShortcutServices.contains( MAGNIFICATION_CONTROLLER_NAME)) { return true; } return false; } @Nullable private Set<String> transformColonDelimitedStringToSet(String value) { if (TextUtils.isEmpty(value)) return null; final TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(':'); splitter.setString(value); final Set<String> items = new HashSet<>(); while (splitter.hasNext()) { final String str = splitter.next(); if (TextUtils.isEmpty(str)) { continue; } items.add(str); } return items; } } } packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -748,7 +748,8 @@ public class SettingsBackupTest { Settings.Secure.WINDOW_MAGNIFICATION, Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER, Settings.Secure.SUPPRESS_DOZE, Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED); Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, Settings.Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT); @Test public void systemSettingsBackedUpOrDenied() { Loading Loading
core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -9127,6 +9127,15 @@ public final class Settings { public static final String ACCESSIBILITY_MAGNIFICATION_CAPABILITY = "accessibility_magnification_capability"; /** * Whether to show the window magnification prompt dialog when the user uses full-screen * magnification first time after database is upgraded . * * @hide */ public static final String ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT = "accessibility_show_window_magnification_prompt"; /** * Whether the Adaptive connectivity option is enabled. * Loading
packages/SettingsProvider/res/values/defaults.xml +3 −0 Original line number Diff line number Diff line Loading @@ -240,4 +240,7 @@ <!-- Default for setting for Settings.Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED --> <bool name="def_hdmiControlAutoDeviceOff">false</bool> <!-- Default for Settings.Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY --> <integer name="def_accessibility_magnification_capabilities">3</integer> </resources>
packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java +71 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_2BUTTON_OVE import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL; import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY; import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME; import static com.android.providers.settings.SettingsState.FALLBACK_FILE_SUFFIX; import android.Manifest; Loading Loading @@ -3341,7 +3342,7 @@ public class SettingsProvider extends ContentProvider { } private final class UpgradeController { private static final int SETTINGS_VERSION = 192; private static final int SETTINGS_VERSION = 193; private final int mUserId; Loading Loading @@ -4724,6 +4725,35 @@ public class SettingsProvider extends ContentProvider { currentVersion = 192; } if (currentVersion == 192) { // Version 192: set the default value for magnification capabilities. If // magnification is enabled by the user, set it to full-screen, and set a value // to show a prompt when using the magnification first time after upgrading. final SettingsState secureSettings = getSecureSettingsLocked(userId); final Setting magnificationCapabilities = secureSettings.getSettingLocked( Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY); if (magnificationCapabilities.isNull()) { secureSettings.insertSettingLocked( Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, String.valueOf(getContext().getResources().getInteger( R.integer.def_accessibility_magnification_capabilities)), null, true, SettingsState.SYSTEM_PACKAGE_NAME); if (isMagnificationSettingsOn(secureSettings)) { secureSettings.insertSettingLocked( Secure.ACCESSIBILITY_MAGNIFICATION_CAPABILITY, String.valueOf( Secure.ACCESSIBILITY_MAGNIFICATION_MODE_FULLSCREEN), null, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); secureSettings.insertSettingLocked( Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT, "1", null, false /* makeDefault */, SettingsState.SYSTEM_PACKAGE_NAME); } } currentVersion = 193; } // vXXX: Add new settings above this point. if (currentVersion != newVersion) { Loading Loading @@ -4862,5 +4892,45 @@ public class SettingsProvider extends ContentProvider { } } } private boolean isMagnificationSettingsOn(SettingsState secureSettings) { if ("1".equals(secureSettings.getSettingLocked( Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED).getValue())) { return true; } final Set<String> a11yButtonTargets = transformColonDelimitedStringToSet( secureSettings.getSettingLocked( Secure.ACCESSIBILITY_BUTTON_TARGETS).getValue()); if (a11yButtonTargets != null && a11yButtonTargets.contains( MAGNIFICATION_CONTROLLER_NAME)) { return true; } final Set<String> a11yShortcutServices = transformColonDelimitedStringToSet( secureSettings.getSettingLocked( Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE).getValue()); if (a11yShortcutServices != null && a11yShortcutServices.contains( MAGNIFICATION_CONTROLLER_NAME)) { return true; } return false; } @Nullable private Set<String> transformColonDelimitedStringToSet(String value) { if (TextUtils.isEmpty(value)) return null; final TextUtils.SimpleStringSplitter splitter = new TextUtils.SimpleStringSplitter(':'); splitter.setString(value); final Set<String> items = new HashSet<>(); while (splitter.hasNext()) { final String str = splitter.next(); if (TextUtils.isEmpty(str)) { continue; } items.add(str); } return items; } } }
packages/SettingsProvider/test/src/android/provider/SettingsBackupTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -748,7 +748,8 @@ public class SettingsBackupTest { Settings.Secure.WINDOW_MAGNIFICATION, Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_MAGNIFICATION_CONTROLLER, Settings.Secure.SUPPRESS_DOZE, Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED); Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, Settings.Secure.ACCESSIBILITY_SHOW_WINDOW_MAGNIFICATION_PROMPT); @Test public void systemSettingsBackedUpOrDenied() { Loading