Unifies constants accross hearing aid related profiles (2/2)

Hearing aid constants defined differently across different hearing aid
related profiles. For hearing aid device mode, HearingAidProfile and
HapClientProfile have different values for mode definition and there is also
a new BANDED hearing aid type in HapClientProfile spec. For hearing aid
device side, HearingAidProfile has only 2 kinds of side which is left
and right whereas BLE hearing aid can retrieve 27 different kinds of
audio location.

We therefore introduce a new class HearingAidInfo for mapping these
different constants across these profiles into a single unified set of
constants.

Bug: 253192350
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityHearingAidPreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidPairingDialogFragmentTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidUtilsTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothDetailsPairOtherControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AvailableMediaDeviceGroupControllerTest
Change-Id: Id14928dbc051fcf76fe0d66b43aefefb1b5f7baf
This commit is contained in:
Angela Wang
2022-10-13 09:27:37 +00:00
parent a6a7e029d7
commit 416b5bd63f
9 changed files with 79 additions and 42 deletions

View File

@@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
import com.android.settings.R;
import com.android.settings.applications.SpacePreference;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.bluetooth.HearingAidInfo;
import com.android.settingslib.widget.ButtonPreference;
import org.junit.Rule;
@@ -62,7 +62,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void init_leftSideDevice_rightSideButtonTitle() {
when(mCachedDevice.getDeviceSide()).thenReturn(HearingAidProfile.DeviceSide.SIDE_LEFT);
when(mCachedDevice.getDeviceSide()).thenReturn(HearingAidInfo.DeviceSide.SIDE_LEFT);
mController.init(mScreen);
@@ -72,7 +72,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void init_rightSideDevice_leftSideButtonTitle() {
when(mCachedDevice.getDeviceSide()).thenReturn(HearingAidProfile.DeviceSide.SIDE_RIGHT);
when(mCachedDevice.getDeviceSide()).thenReturn(HearingAidInfo.DeviceSide.SIDE_RIGHT);
mController.init(mScreen);
@@ -100,7 +100,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void isAvailable_isConnectedAshaHearingAidDevice_isMonaural_notAvailable() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_MONAURAL);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidInfo.DeviceMode.MODE_MONAURAL);
assertThat(mController.isAvailable()).isFalse();
}
@@ -108,7 +108,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void isAvailable_subDeviceIsConnectedAshaHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidInfo.DeviceMode.MODE_BINAURAL);
when(mSubCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getSubDevice()).thenReturn(mSubCachedDevice);
@@ -118,7 +118,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void isAvailable_subDeviceIsNotConnectedAshaHearingAidDevice_available() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidInfo.DeviceMode.MODE_BINAURAL);
when(mSubCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(false);
when(mCachedDevice.getSubDevice()).thenReturn(mSubCachedDevice);
@@ -128,7 +128,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void isAvailable_subDeviceNotExist_available() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidInfo.DeviceMode.MODE_BINAURAL);
when(mCachedDevice.getSubDevice()).thenReturn(null);
assertThat(mController.isAvailable()).isTrue();
@@ -136,7 +136,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void refresh_leftSideDevice_leftSideButtonTitle() {
when(mCachedDevice.getDeviceSide()).thenReturn(HearingAidProfile.DeviceSide.SIDE_RIGHT);
when(mCachedDevice.getDeviceSide()).thenReturn(HearingAidInfo.DeviceSide.SIDE_RIGHT);
mController.init(mScreen);
mController.refresh();