From 01b6f815b8050446f02270c8966a2e3af31190eb Mon Sep 17 00:00:00 2001 From: jasonwshsu Date: Thu, 9 Feb 2023 19:47:56 +0800 Subject: [PATCH] Add key HEARING_AID_RINGTONE_ROUTING, HEARING_AID_CALL_ROUTING, HEARING_AID_MEDIA_ROUTING, HEARING_AID_SYSTEM_SOUNDS_ROUTING These keys handle different audio routing preference for hearing aids. Bug: 237625815 Test: atest SettingsProviderTest Change-Id: I012f8336d15e1d40c268529969389dc16e3a648e --- core/java/android/provider/Settings.java | 52 +++++++++++++++++++ .../android/providers/settings/secure.proto | 4 ++ .../settings/backup/SecureSettings.java | 6 ++- .../validators/SecureSettingsValidators.java | 8 +++ .../settings/SettingsProtoDumpUtil.java | 12 +++++ 5 files changed, 81 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index cf685720d2411..e994b7e5a9d38 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -6999,6 +6999,58 @@ public final class Settings { public static final String BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME = "bluetooth_le_broadcast_app_source_name"; + /** + * Ringtone routing value for hearing aid. It routes ringtone to hearing aid or device + * speaker. + * + * @hide + */ + public static final String HEARING_AID_RINGTONE_ROUTING = + "hearing_aid_ringtone_routing"; + + /** + * Phone call routing value for hearing aid. It routes phone call to hearing aid or + * device speaker. + * + * @hide + */ + public static final String HEARING_AID_CALL_ROUTING = + "hearing_aid_call_routing"; + + /** + * Media routing value for hearing aid. It routes media to hearing aid or device + * speaker. + * + * @hide + */ + public static final String HEARING_AID_MEDIA_ROUTING = + "hearing_aid_media_routing"; + + /** + * System sounds routing value for hearing aid. It routes system sounds to hearing aid + * or device speaker. + * + * @hide + */ + public static final String HEARING_AID_SYSTEM_SOUNDS_ROUTING = + "hearing_aid_system_sounds_routing"; + /** * Setting to indicate that on device captions are enabled. * diff --git a/core/proto/android/providers/settings/secure.proto b/core/proto/android/providers/settings/secure.proto index 68267db87a5ce..56627878dee85 100644 --- a/core/proto/android/providers/settings/secure.proto +++ b/core/proto/android/providers/settings/secure.proto @@ -90,6 +90,10 @@ message SecureSettingsProto { optional SettingProto accessibility_magnification_follow_typing_enabled = 43 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto contrast_level = 44 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto accessibility_magnification_always_on_enabled = 45 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto hearing_aid_ringtone_routing = 46 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto hearing_aid_call_routing = 47 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto hearing_aid_media_routing = 48 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto hearing_aid_system_sounds_routing = 49 [ (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 a08d7cd16b74f..6b5e19983949f 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SecureSettings.java @@ -230,6 +230,10 @@ public class SecureSettings { Settings.Secure.BLUETOOTH_LE_BROADCAST_APP_SOURCE_NAME, Settings.Secure.CUSTOM_BUGREPORT_HANDLER_APP, Settings.Secure.CUSTOM_BUGREPORT_HANDLER_USER, - Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED + Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED, + Settings.Secure.HEARING_AID_RINGTONE_ROUTING, + Settings.Secure.HEARING_AID_CALL_ROUTING, + Settings.Secure.HEARING_AID_MEDIA_ROUTING, + Settings.Secure.HEARING_AID_SYSTEM_SOUNDS_ROUTING, }; } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java index 154987dad7360..8dbf3d4b0abdc 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SecureSettingsValidators.java @@ -363,5 +363,13 @@ public class SecureSettingsValidators { VALIDATORS.put(Secure.CUSTOM_BUGREPORT_HANDLER_APP, ANY_STRING_VALIDATOR); VALIDATORS.put(Secure.CUSTOM_BUGREPORT_HANDLER_USER, ANY_INTEGER_VALIDATOR); VALIDATORS.put(Secure.LOCK_SCREEN_WEATHER_ENABLED, BOOLEAN_VALIDATOR); + VALIDATORS.put(Secure.HEARING_AID_RINGTONE_ROUTING, + new DiscreteValueValidator(new String[] {"0", "1", "2"})); + VALIDATORS.put(Secure.HEARING_AID_CALL_ROUTING, + new DiscreteValueValidator(new String[] {"0", "1", "2"})); + VALIDATORS.put(Secure.HEARING_AID_MEDIA_ROUTING, + new DiscreteValueValidator(new String[] {"0", "1", "2"})); + VALIDATORS.put(Secure.HEARING_AID_SYSTEM_SOUNDS_ROUTING, + new DiscreteValueValidator(new String[] {"0", "1", "2"})); } } diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index 159f2dd52586c..6db4dcc8b87f3 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -1836,6 +1836,18 @@ class SettingsProtoDumpUtil { Settings.Secure.ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED, SecureSettingsProto.Accessibility .ACCESSIBILITY_MAGNIFICATION_ALWAYS_ON_ENABLED); + dumpSetting(s, p, + Settings.Secure.HEARING_AID_RINGTONE_ROUTING, + SecureSettingsProto.Accessibility.HEARING_AID_RINGTONE_ROUTING); + dumpSetting(s, p, + Settings.Secure.HEARING_AID_CALL_ROUTING, + SecureSettingsProto.Accessibility.HEARING_AID_CALL_ROUTING); + dumpSetting(s, p, + Settings.Secure.HEARING_AID_MEDIA_ROUTING, + SecureSettingsProto.Accessibility.HEARING_AID_MEDIA_ROUTING); + dumpSetting(s, p, + Settings.Secure.HEARING_AID_SYSTEM_SOUNDS_ROUTING, + SecureSettingsProto.Accessibility.HEARING_AID_SYSTEM_SOUNDS_ROUTING); p.end(accessibilityToken); final long adaptiveSleepToken = p.start(SecureSettingsProto.ADAPTIVE_SLEEP);