From 511ddd3d05521d9c3047d0fec1a6b79b7b2e3e27 Mon Sep 17 00:00:00 2001 From: Aurélien Pomini Date: Fri, 11 Nov 2022 13:43:43 +0000 Subject: Add contrast level in settings Test: treehugger Bug: 259091608 Change-Id: Ib68b6688fdc06843b80a2582a78942b514149f3e --- core/java/android/provider/Settings.java | 7 +++++++ core/proto/android/providers/settings/secure.proto | 1 + .../src/android/provider/settings/backup/SecureSettings.java | 1 + .../provider/settings/validators/SecureSettingsValidators.java | 1 + .../src/com/android/providers/settings/SettingsProtoDumpUtil.java | 3 +++ 5 files changed, 13 insertions(+) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index fd45fca53722..ed59456e2281 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -7775,6 +7775,13 @@ public final class Settings { public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED = "high_text_contrast_enabled"; + /** + * The color contrast, float in [-1, 1], 1 being the highest contrast. + * + * @hide + */ + public static final String CONTRAST_LEVEL = "contrast_level"; + /** * Setting that specifies whether the display magnification is enabled via a system-wide * triple tap gesture. Display magnifications allows the user to zoom in the display content diff --git a/core/proto/android/providers/settings/secure.proto b/core/proto/android/providers/settings/secure.proto index 285258a979e4..556636ddd210 100644 --- a/core/proto/android/providers/settings/secure.proto +++ b/core/proto/android/providers/settings/secure.proto @@ -88,6 +88,7 @@ message SecureSettingsProto { optional SettingProto odi_captions_volume_ui_enabled = 42 [ (android.privacy).dest = DEST_AUTOMATIC ]; // Setting for accessibility magnification for following typing. optional SettingProto accessibility_magnification_follow_typing_enabled = 43 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto contrast_level = 44 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Accessibility accessibility = 2; diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java index 8946516af8a2..92a938cb0b47 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java @@ -53,6 +53,7 @@ public class SecureSettings { Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, + Settings.Secure.CONTRAST_LEVEL, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, Settings.Secure.ACCESSIBILITY_CAPTIONING_ENABLED, Settings.Secure.ACCESSIBILITY_CAPTIONING_LOCALE, diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java index cbf79530a6b6..eabf4cc8edfd 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -86,6 +86,7 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, BOOLEAN_VALIDATOR); VALIDATORS.put(Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.CONTRAST_LEVEL, new InclusiveFloatRangeValidator(-1f, 1f)); VALIDATORS.put( Secure.ACCESSIBILITY_CAPTIONING_PRESET, new DiscreteValueValidator(new String[] {"-1", "0", "1", "2", "3", "4"})); diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index aa3a983e9971..a78faaf90c37 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -1755,6 +1755,9 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, SecureSettingsProto.Accessibility.HIGH_TEXT_CONTRAST_ENABLED); + dumpSetting(s, p, + Settings.Secure.CONTRAST_LEVEL, + SecureSettingsProto.Accessibility.CONTRAST_LEVEL); dumpSetting(s, p, Settings.Secure.FONT_WEIGHT_ADJUSTMENT, SecureSettingsProto.FONT_WEIGHT_ADJUSTMENT); -- cgit v1.2.3-59-g8ed1b