diff --git a/res/values/strings.xml b/res/values/strings.xml
index 80b0e8aad8e..d7336a96739 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -5733,8 +5733,12 @@
Continue
Hearing devices
-
+
Set up and manage ASHA and LE Audio hearing aids, cochlear implants, and other amplification devices
+
+ Set up and manage ASHA hearing aids, cochlear implants, and other amplification devices
+
+ Set up and manage LE Audio hearing aids, cochlear implants, and other amplification devices
No hearing devices connected
@@ -5769,10 +5773,18 @@
Improves compatibility with telecoils and reduces unwanted noise
About hearing devices
-
+
Pair new device > See more devices]]>
-
+
To find other hearing devices that aren’t supported by ASHA or LE Audio, tap Pair new device then See more devices
+
+ Pair new device > See more devices]]>
+
+ To find other hearing devices that aren’t supported by ASHA, tap Pair new device then See more devices
+
+ Pair new device > See more devices]]>
+
+ To find other hearing devices that aren’t supported by LE Audio, tap Pair new device then See more devices
Pair hearing device
diff --git a/res/xml/accessibility_hearing_aids.xml b/res/xml/accessibility_hearing_aids.xml
index b3418c35486..501fe3c27d0 100644
--- a/res/xml/accessibility_hearing_aids.xml
+++ b/res/xml/accessibility_hearing_aids.xml
@@ -20,8 +20,10 @@
android:title="@string/accessibility_hearingaid_title">
+ settings:searchable="false"
+ settings:controller="com.android.settings.accessibility.HearingDeviceIntroPreferenceController"/>
supportedList = mBluetoothAdapter.getSupportedProfiles();
+ return supportedList.contains(BluetoothProfile.HEARING_AID);
+ }
+
+ /**
+ * Checks if {@link BluetoothProfile#HAP_CLIENT} supported.
+ */
+ public boolean isHapClientProfileSupported() {
+ final List supportedList = mBluetoothAdapter.getSupportedProfiles();
+ return supportedList.contains(BluetoothProfile.HAP_CLIENT);
+ }
+
/**
* Checks if {@link BluetoothProfile#HEARING_AID} or {@link BluetoothProfile#HAP_CLIENT}
* profiles all ready.
diff --git a/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java b/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java
index f72555a9b11..5a5ca71a3c3 100644
--- a/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java
+++ b/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceController.java
@@ -24,12 +24,27 @@ import androidx.preference.PreferenceScreen;
import com.android.settings.R;
+import com.google.common.annotations.VisibleForTesting;
+
/** Preference controller for footer in hearing device page. */
public class HearingDeviceFooterPreferenceController extends
AccessibilityFooterPreferenceController {
- public HearingDeviceFooterPreferenceController(Context context,
- String key) {
+ private final HearingAidHelper mHelper;
+
+ public HearingDeviceFooterPreferenceController(
+ @NonNull Context context,
+ @NonNull String key) {
super(context, key);
+ mHelper = new HearingAidHelper(context);
+ }
+
+ @VisibleForTesting
+ public HearingDeviceFooterPreferenceController(
+ @NonNull Context context,
+ @NonNull String key,
+ @NonNull HearingAidHelper hearingAidHelper) {
+ super(context, key);
+ mHelper = hearingAidHelper;
}
@Override
@@ -37,22 +52,47 @@ public class HearingDeviceFooterPreferenceController extends
return mContext.getString(R.string.accessibility_hearing_device_about_title);
}
+ @Override
+ public int getAvailabilityStatus() {
+ return mHelper.isHearingAidSupported() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
@Override
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
final AccessibilityFooterPreference footerPreference =
screen.findPreference(getPreferenceKey());
+ final boolean isAshaProfileSupported = mHelper.isAshaProfileSupported();
+ final boolean isHapClientProfileSupported = mHelper.isHapClientProfileSupported();
+ final String summary;
+ final String summaryTts;
+ if (isAshaProfileSupported && isHapClientProfileSupported) {
+ summary = mContext.getString(R.string.accessibility_hearing_device_footer_summary);
+ summaryTts = mContext.getString(
+ R.string.accessibility_hearing_device_footer_summary_tts);
+ } else if (isAshaProfileSupported) {
+ summary = mContext.getString(
+ R.string.accessibility_hearing_device_footer_asha_only_summary);
+ summaryTts = mContext.getString(
+ R.string.accessibility_hearing_device_footer_asha_only_summary_tts);
+ } else if (isHapClientProfileSupported) {
+ summary = mContext.getString(
+ R.string.accessibility_hearing_device_footer_hap_only_summary);
+ summaryTts = mContext.getString(
+ R.string.accessibility_hearing_device_footer_hap_only_summary_tts);
+ } else {
+ return;
+ }
+
// We use html tag inside footer string, so it is better to load from html to have better
// html tag support.
final CharSequence title = Html.fromHtml(
- mContext.getString(R.string.accessibility_hearing_device_footer_summary),
+ summary,
Html.FROM_HTML_MODE_COMPACT, /* imageGetter= */ null, /* tagHandler= */ null);
footerPreference.setTitle(title);
// Need to update contentDescription string to announce "than" rather than ">"
- final String summaryTts = mContext.getString(
- R.string.accessibility_hearing_device_footer_summary_tts);
final String contentDescription = getIntroductionTitle() + "\n\n" + summaryTts;
footerPreference.setContentDescription(contentDescription);
}
diff --git a/src/com/android/settings/accessibility/HearingDeviceIntroPreferenceController.java b/src/com/android/settings/accessibility/HearingDeviceIntroPreferenceController.java
new file mode 100644
index 00000000000..2b67ac1dadb
--- /dev/null
+++ b/src/com/android/settings/accessibility/HearingDeviceIntroPreferenceController.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+
+import com.google.common.annotations.VisibleForTesting;
+
+public class HearingDeviceIntroPreferenceController extends BasePreferenceController {
+ private final HearingAidHelper mHelper;
+
+ public HearingDeviceIntroPreferenceController(
+ @NonNull Context context,
+ @NonNull String preferenceKey) {
+ super(context, preferenceKey);
+ mHelper = new HearingAidHelper(context);
+ }
+
+ @VisibleForTesting
+ public HearingDeviceIntroPreferenceController(
+ @NonNull Context context,
+ @NonNull String preferenceKey,
+ @NonNull HearingAidHelper hearingAidHelper) {
+ super(context, preferenceKey);
+ mHelper = hearingAidHelper;
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return mHelper.isHearingAidSupported() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public void displayPreference(@NonNull PreferenceScreen screen) {
+ super.displayPreference(screen);
+
+ final Preference introPreference = screen.findPreference(getPreferenceKey());
+ final boolean isAshaProfileSupported = mHelper.isAshaProfileSupported();
+ final boolean isHapClientProfileSupported = mHelper.isHapClientProfileSupported();
+ if (isAshaProfileSupported && isHapClientProfileSupported) {
+ introPreference.setTitle(mContext.getString(R.string.accessibility_hearingaid_intro));
+ } else if (isAshaProfileSupported) {
+ introPreference.setTitle(
+ mContext.getString(R.string.accessibility_hearingaid_asha_only_intro));
+ } else if (isHapClientProfileSupported) {
+ introPreference.setTitle(
+ mContext.getString(R.string.accessibility_hearingaid_hap_only_intro));
+ } else {
+ // Intentionally blank, getAvailabilityStatus() should handle visibility for
+ // none-supported case.
+ }
+ }
+}
diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsController.java b/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsController.java
index 7e5f3b1a78f..e578ca1f786 100644
--- a/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsController.java
+++ b/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsController.java
@@ -53,7 +53,7 @@ public class BluetoothDetailsHearingDeviceSettingsController extends BluetoothDe
@Override
public boolean isAvailable() {
- return mCachedDevice.isHearingAidDevice();
+ return mCachedDevice.isHearingDevice();
}
@Override
diff --git a/tests/robotests/src/com/android/settings/accessibility/HearingAidHelperTest.java b/tests/robotests/src/com/android/settings/accessibility/HearingAidHelperTest.java
index 3889cf04e02..94660edfc7e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/HearingAidHelperTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/HearingAidHelperTest.java
@@ -117,6 +117,22 @@ public class HearingAidHelperTest {
assertThat(mHelper.isHearingAidSupported()).isFalse();
}
+ @Test
+ public void isAshaProfileSupported_supported_returnTrue() {
+ mShadowBluetoothAdapter.clearSupportedProfiles();
+ mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HEARING_AID);
+
+ assertThat(mHelper.isAshaProfileSupported()).isTrue();
+ }
+
+ @Test
+ public void isHapClientProfileSupported_supported_returnTrue() {
+ mShadowBluetoothAdapter.clearSupportedProfiles();
+ mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HAP_CLIENT);
+
+ assertThat(mHelper.isHapClientProfileSupported()).isTrue();
+ }
+
@Test
public void isAllHearingAidRelatedProfilesReady_allReady_returnTrue() {
when(mHearingAidProfile.isProfileReady()).thenReturn(true);
diff --git a/tests/robotests/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceControllerTest.java
new file mode 100644
index 00000000000..d04abc1b415
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/HearingDeviceFooterPreferenceControllerTest.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/**
+ * Tests for {@link HearingDeviceFooterPreferenceController}.
+ */
+@RunWith(RobolectricTestRunner.class)
+public class HearingDeviceFooterPreferenceControllerTest {
+
+ @Rule
+ public final MockitoRule mockito = MockitoJUnit.rule();
+
+ @Spy
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ @Spy
+ private final Resources mResources = mContext.getResources();
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private HearingAidHelper mHelper;
+ private HearingDeviceFooterPreferenceController mController;
+ private AccessibilityFooterPreference mPreference;
+
+ @Before
+ public void setUp() {
+ mController = new HearingDeviceFooterPreferenceController(mContext, "test_key", mHelper);
+ mPreference = new AccessibilityFooterPreference(mContext);
+ mPreference.setKey("test_key");
+
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ when(mContext.getResources()).thenReturn(mResources);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hearingAidSupported_available() {
+ when(mHelper.isHearingAidSupported()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hearingAidNotSupported_unsupportedOnDevice() {
+ when(mHelper.isHearingAidSupported()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void displayPreference_ashaHapSupported_expectedContentDescription() {
+ when(mHelper.isAshaProfileSupported()).thenReturn(true);
+ when(mHelper.isHapClientProfileSupported()).thenReturn(true);
+
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getContentDescription().toString()).isEqualTo(
+ mController.getIntroductionTitle() + "\n\n" + mContext.getString(
+ R.string.accessibility_hearing_device_footer_summary_tts));
+ }
+
+ @Test
+ public void displayPreference_ashaSupported_expectedContentDescription() {
+ when(mHelper.isAshaProfileSupported()).thenReturn(true);
+ when(mHelper.isHapClientProfileSupported()).thenReturn(false);
+
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getContentDescription().toString()).isEqualTo(
+ mController.getIntroductionTitle() + "\n\n" + mContext.getString(
+ R.string.accessibility_hearing_device_footer_asha_only_summary_tts));
+ }
+
+ @Test
+ public void displayPreference_hapSupported_expectedContentDescription() {
+ when(mHelper.isAshaProfileSupported()).thenReturn(false);
+ when(mHelper.isHapClientProfileSupported()).thenReturn(true);
+
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getContentDescription().toString()).isEqualTo(
+ mController.getIntroductionTitle() + "\n\n" + mContext.getString(
+ R.string.accessibility_hearing_device_footer_hap_only_summary_tts));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/HearingDeviceIntroPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/HearingDeviceIntroPreferenceControllerTest.java
new file mode 100644
index 00000000000..ad9ff5505e3
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/HearingDeviceIntroPreferenceControllerTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.settings.accessibility;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+import androidx.preference.PreferenceScreen;
+import androidx.test.core.app.ApplicationProvider;
+
+import com.android.settings.R;
+import com.android.settingslib.widget.TopIntroPreference;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+/**
+ * Tests for {@link HearingDeviceIntroPreferenceController}.
+ */
+@RunWith(RobolectricTestRunner.class)
+public class HearingDeviceIntroPreferenceControllerTest {
+
+ @Rule
+ public final MockitoRule mockito = MockitoJUnit.rule();
+
+ @Spy
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ @Spy
+ private final Resources mResources = mContext.getResources();
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private HearingAidHelper mHelper;
+ private HearingDeviceIntroPreferenceController mController;
+ private TopIntroPreference mPreference;
+
+ @Before
+ public void setUp() {
+ mController = new HearingDeviceIntroPreferenceController(mContext, "test_key", mHelper);
+ mPreference = new TopIntroPreference(mContext);
+ mPreference.setKey("test_key");
+
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
+ when(mContext.getResources()).thenReturn(mResources);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hearingAidSupported_available() {
+ when(mHelper.isHearingAidSupported()).thenReturn(true);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_hearingAidNotSupported_unsupportedOnDevice() {
+ when(mHelper.isHearingAidSupported()).thenReturn(false);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void displayPreference_ashaHapSupported_expectedTitle() {
+ when(mHelper.isAshaProfileSupported()).thenReturn(true);
+ when(mHelper.isHapClientProfileSupported()).thenReturn(true);
+
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getTitle().toString()).isEqualTo(
+ mContext.getString(R.string.accessibility_hearingaid_intro));
+ }
+
+ @Test
+ public void displayPreference_ashaSupported_expectedTitle() {
+ when(mHelper.isAshaProfileSupported()).thenReturn(true);
+ when(mHelper.isHapClientProfileSupported()).thenReturn(false);
+
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getTitle().toString()).isEqualTo(
+ mContext.getString(R.string.accessibility_hearingaid_asha_only_intro));
+ }
+
+ @Test
+ public void displayPreference_hapSupported_expectedTitle() {
+ when(mHelper.isAshaProfileSupported()).thenReturn(false);
+ when(mHelper.isHapClientProfileSupported()).thenReturn(true);
+
+ mController.displayPreference(mScreen);
+
+ assertThat(mPreference.getTitle().toString()).isEqualTo(
+ mContext.getString(R.string.accessibility_hearingaid_hap_only_intro));
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsControllerTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsControllerTest.java
index b420717d397..151232705d9 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsControllerTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothDetailsHearingDeviceSettingsControllerTest.java
@@ -62,15 +62,15 @@ public class BluetoothDetailsHearingDeviceSettingsControllerTest extends
}
@Test
- public void isAvailable_isHearingAidDevice_available() {
- when(mCachedDevice.isHearingAidDevice()).thenReturn(true);
+ public void isAvailable_isHearingDevice_available() {
+ when(mCachedDevice.isHearingDevice()).thenReturn(true);
assertThat(mController.isAvailable()).isTrue();
}
@Test
- public void isAvailable_isNotHearingAidDevice_notAvailable() {
- when(mCachedDevice.isHearingAidDevice()).thenReturn(false);
+ public void isAvailable_isNotHearingDevice_notAvailable() {
+ when(mCachedDevice.isHearingDevice()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();
}