Loading core/java/android/provider/Settings.java +12 −0 Original line number Diff line number Diff line Loading @@ -8949,6 +8949,18 @@ public final class Settings { public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED = "high_text_contrast_enabled"; /** * Setting that specifies the status of the High Contrast Text * rectangle refresh's one-time prompt. * 0 = UNKNOWN * 1 = PROMPT_SHOWN * 2 = PROMPT_UNNECESSARY * * @hide */ public static final String ACCESSIBILITY_HCT_RECT_PROMPT_STATUS = "accessibility_hct_rect_prompt_status"; /** * The color contrast, float in [-1, 1], 1 being the highest contrast. * Loading core/proto/android/providers/settings/secure.proto +1 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ message SecureSettingsProto { optional SettingProto accessibility_gesture_targets = 57 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto display_daltonizer_saturation_level = 58 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto accessibility_key_gesture_targets = 59 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto hct_rect_prompt_status = 60 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Accessibility accessibility = 2; Loading packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public class SecureSettings { Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, Settings.Secure.ACCESSIBILITY_HCT_RECT_PROMPT_STATUS, Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, Settings.Secure.CONTRAST_LEVEL, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, Loading packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,9 @@ 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.ACCESSIBILITY_HCT_RECT_PROMPT_STATUS, new DiscreteValueValidator(new String[] {"0", "1", "2"})); VALIDATORS.put(Secure.CONTRAST_LEVEL, new InclusiveFloatRangeValidator(-1f, 1f)); VALIDATORS.put( Secure.ACCESSIBILITY_CAPTIONING_PRESET, Loading packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +48 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.hardware.display.ColorDisplayManager; import android.icu.util.ULocale; Loading @@ -32,6 +34,7 @@ import android.media.AudioManager; import android.media.RingtoneManager; import android.media.Utils; import android.net.Uri; import android.os.Build; import android.os.LocaleList; import android.os.RemoteException; import android.os.ServiceManager; Loading @@ -50,6 +53,7 @@ import com.android.settingslib.devicestate.DeviceStateRotationLockSettingsManage import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Set; Loading @@ -69,6 +73,9 @@ public class SettingsHelper { private static final int LONG_PRESS_POWER_FOR_ASSISTANT = 5; /** See frameworks/base/core/res/res/values/config.xml#config_keyChordPowerVolumeUp **/ private static final int KEY_CHORD_POWER_VOLUME_UP_GLOBAL_ACTIONS = 2; @VisibleForTesting static final String HIGH_CONTRAST_TEXT_RESTORED_BROADCAST_ACTION = "com.android.settings.accessibility.ACTION_HIGH_CONTRAST_TEXT_RESTORED"; // Error messages for logging metrics. private static final String ERROR_REMOTE_EXCEPTION_SETTING_LOCALE_DATA = Loading Loading @@ -252,6 +259,23 @@ public class SettingsHelper { // Don't write it to setting. Let the broadcast receiver in // AccessibilityManagerService handle restore/merging logic. return; } else if (com.android.graphics.hwui.flags.Flags.highContrastTextSmallTextRect() && Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED.equals(name)) { final boolean currentlyEnabled = Settings.Secure.getInt( context.getContentResolver(), Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1; final boolean enabledInRestore = value != null && Integer.parseInt(value) == 1; // If restoring from Android 15 or earlier and the user didn't already enable HCT // on this new device, then don't restore and trigger custom migration logic. final boolean needsCustomMigration = !currentlyEnabled && restoredFromSdkInt < Build.VERSION_CODES.BAKLAVA && enabledInRestore; if (needsCustomMigration) { migrateHighContrastText(context); return; } // fall through to the ordinary write to settings } // Default case: write the restored value to settings Loading Loading @@ -529,6 +553,30 @@ public class SettingsHelper { } } private static void migrateHighContrastText(Context context) { final Intent intent = new Intent(HIGH_CONTRAST_TEXT_RESTORED_BROADCAST_ACTION) .setPackage(getSettingsAppPackage(context)); context.sendBroadcastAsUser(intent, context.getUser(), null); } /** * Returns the System Settings application's package name */ private static String getSettingsAppPackage(Context context) { String settingsAppPackage = null; PackageManager packageManager = context.getPackageManager(); if (packageManager != null) { List<ResolveInfo> results = packageManager.queryIntentActivities( new Intent(Settings.ACTION_SETTINGS), PackageManager.MATCH_SYSTEM_ONLY); if (!results.isEmpty()) { settingsAppPackage = results.getFirst().activityInfo.applicationInfo.packageName; } } return !TextUtils.isEmpty(settingsAppPackage) ? settingsAppPackage : "com.android.settings"; } /* package */ byte[] getLocaleData() { Configuration conf = mContext.getResources().getConfiguration(); return conf.getLocales().toLanguageTags().getBytes(); Loading Loading
core/java/android/provider/Settings.java +12 −0 Original line number Diff line number Diff line Loading @@ -8949,6 +8949,18 @@ public final class Settings { public static final String ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED = "high_text_contrast_enabled"; /** * Setting that specifies the status of the High Contrast Text * rectangle refresh's one-time prompt. * 0 = UNKNOWN * 1 = PROMPT_SHOWN * 2 = PROMPT_UNNECESSARY * * @hide */ public static final String ACCESSIBILITY_HCT_RECT_PROMPT_STATUS = "accessibility_hct_rect_prompt_status"; /** * The color contrast, float in [-1, 1], 1 being the highest contrast. * Loading
core/proto/android/providers/settings/secure.proto +1 −0 Original line number Diff line number Diff line Loading @@ -105,6 +105,7 @@ message SecureSettingsProto { optional SettingProto accessibility_gesture_targets = 57 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto display_daltonizer_saturation_level = 58 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto accessibility_key_gesture_targets = 59 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto hct_rect_prompt_status = 60 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Accessibility accessibility = 2; Loading
packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public class SecureSettings { Settings.Secure.ACCESSIBILITY_BUTTON_TARGET_COMPONENT, Settings.Secure.ACCESSIBILITY_SHORTCUT_DIALOG_SHOWN, Settings.Secure.ACCESSIBILITY_SHORTCUT_ON_LOCK_SCREEN, Settings.Secure.ACCESSIBILITY_HCT_RECT_PROMPT_STATUS, Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, Settings.Secure.CONTRAST_LEVEL, Settings.Secure.ACCESSIBILITY_CAPTIONING_PRESET, Loading
packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +3 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,9 @@ 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.ACCESSIBILITY_HCT_RECT_PROMPT_STATUS, new DiscreteValueValidator(new String[] {"0", "1", "2"})); VALIDATORS.put(Secure.CONTRAST_LEVEL, new InclusiveFloatRangeValidator(-1f, 1f)); VALIDATORS.put( Secure.ACCESSIBILITY_CAPTIONING_PRESET, Loading
packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java +48 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.hardware.display.ColorDisplayManager; import android.icu.util.ULocale; Loading @@ -32,6 +34,7 @@ import android.media.AudioManager; import android.media.RingtoneManager; import android.media.Utils; import android.net.Uri; import android.os.Build; import android.os.LocaleList; import android.os.RemoteException; import android.os.ServiceManager; Loading @@ -50,6 +53,7 @@ import com.android.settingslib.devicestate.DeviceStateRotationLockSettingsManage import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Set; Loading @@ -69,6 +73,9 @@ public class SettingsHelper { private static final int LONG_PRESS_POWER_FOR_ASSISTANT = 5; /** See frameworks/base/core/res/res/values/config.xml#config_keyChordPowerVolumeUp **/ private static final int KEY_CHORD_POWER_VOLUME_UP_GLOBAL_ACTIONS = 2; @VisibleForTesting static final String HIGH_CONTRAST_TEXT_RESTORED_BROADCAST_ACTION = "com.android.settings.accessibility.ACTION_HIGH_CONTRAST_TEXT_RESTORED"; // Error messages for logging metrics. private static final String ERROR_REMOTE_EXCEPTION_SETTING_LOCALE_DATA = Loading Loading @@ -252,6 +259,23 @@ public class SettingsHelper { // Don't write it to setting. Let the broadcast receiver in // AccessibilityManagerService handle restore/merging logic. return; } else if (com.android.graphics.hwui.flags.Flags.highContrastTextSmallTextRect() && Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED.equals(name)) { final boolean currentlyEnabled = Settings.Secure.getInt( context.getContentResolver(), Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED, 0) == 1; final boolean enabledInRestore = value != null && Integer.parseInt(value) == 1; // If restoring from Android 15 or earlier and the user didn't already enable HCT // on this new device, then don't restore and trigger custom migration logic. final boolean needsCustomMigration = !currentlyEnabled && restoredFromSdkInt < Build.VERSION_CODES.BAKLAVA && enabledInRestore; if (needsCustomMigration) { migrateHighContrastText(context); return; } // fall through to the ordinary write to settings } // Default case: write the restored value to settings Loading Loading @@ -529,6 +553,30 @@ public class SettingsHelper { } } private static void migrateHighContrastText(Context context) { final Intent intent = new Intent(HIGH_CONTRAST_TEXT_RESTORED_BROADCAST_ACTION) .setPackage(getSettingsAppPackage(context)); context.sendBroadcastAsUser(intent, context.getUser(), null); } /** * Returns the System Settings application's package name */ private static String getSettingsAppPackage(Context context) { String settingsAppPackage = null; PackageManager packageManager = context.getPackageManager(); if (packageManager != null) { List<ResolveInfo> results = packageManager.queryIntentActivities( new Intent(Settings.ACTION_SETTINGS), PackageManager.MATCH_SYSTEM_ONLY); if (!results.isEmpty()) { settingsAppPackage = results.getFirst().activityInfo.applicationInfo.packageName; } } return !TextUtils.isEmpty(settingsAppPackage) ? settingsAppPackage : "com.android.settings"; } /* package */ byte[] getLocaleData() { Configuration conf = mContext.getResources().getConfiguration(); return conf.getLocales().toLanguageTags().getBytes(); Loading