Merge "Shows LE audio hearing aid device in a11y settings page (3/3)"

This commit is contained in:
Angela Wang
2022-11-28 07:16:25 +00:00
committed by Android (Google) Code Review
15 changed files with 215 additions and 124 deletions

View File

@@ -27,6 +27,7 @@ import static org.mockito.Mockito.when;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHapClient;
import android.bluetooth.BluetoothHearingAid;
import android.bluetooth.BluetoothProfile;
import android.content.BroadcastReceiver;
@@ -44,6 +45,7 @@ import com.android.settings.testutils.shadow.ShadowBluetoothUtils;
import com.android.settingslib.bluetooth.BluetoothEventManager;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
import com.android.settingslib.bluetooth.HapClientProfile;
import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
@@ -61,13 +63,16 @@ import org.robolectric.shadow.api.Shadow;
import org.robolectric.shadows.ShadowApplication;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/** Tests for {@link AccessibilityHearingAidPreferenceController}. */
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowBluetoothAdapter.class, ShadowBluetoothUtils.class})
public class AccessibilityHearingAidPreferenceControllerTest {
private static final String TEST_DEVICE_ADDRESS = "00:A1:A1:A1:A1:A1";
private static final String TEST_DEVICE_ADDRESS_2 = "00:A2:A2:A2:A2:A2";
private static final String TEST_DEVICE_NAME = "TEST_HEARING_AID_BT_DEVICE_NAME";
private static final String HEARING_AID_PREFERENCE = "hearing_aid_preference";
@@ -93,6 +98,8 @@ public class AccessibilityHearingAidPreferenceControllerTest {
private LocalBluetoothProfileManager mLocalBluetoothProfileManager;
@Mock
private HearingAidProfile mHearingAidProfile;
@Mock
private HapClientProfile mHapClientProfile;
@Before
public void setUp() {
@@ -115,10 +122,11 @@ public class AccessibilityHearingAidPreferenceControllerTest {
}
@Test
public void getSummary_connectedHearingAidRightSide_connectedRightSideSummary() {
public void getSummary_connectedAshaHearingAidRightSide_connectedRightSideSummary() {
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
HearingAidProfile.DeviceSide.SIDE_RIGHT);
when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
mPreferenceController.onStart();
Intent intent = new Intent(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHearingAid.STATE_CONNECTED);
@@ -129,12 +137,13 @@ public class AccessibilityHearingAidPreferenceControllerTest {
}
@Test
public void getSummary_connectedHearingAidBothSide_connectedBothSideSummary() {
public void getSummary_connectedAshaHearingAidBothSide_connectedBothSideSummary() {
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
HearingAidProfile.DeviceSide.SIDE_LEFT);
when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true);
when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mCachedSubBluetoothDevice);
when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
mPreferenceController.onStart();
Intent intent = new Intent(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHearingAid.STATE_CONNECTED);
@@ -145,13 +154,43 @@ public class AccessibilityHearingAidPreferenceControllerTest {
}
@Test
public void getSummary_connectedMultipleHearingAids_connectedBothSideSummary() {
public void getSummary_connectedLeAudioHearingAidOneSide_connectedOneSideSummary() {
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
HearingAidProfile.DeviceSide.SIDE_INVALID);
when(mCachedBluetoothDevice.getMemberDevice()).thenReturn(new HashSet<>());
when(mHapClientProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
mPreferenceController.onStart();
Intent intent = new Intent(BluetoothHapClient.ACTION_HAP_CONNECTION_STATE_CHANGED);
intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHapClient.STATE_CONNECTED);
sendIntent(intent);
assertThat(mHearingAidPreference.getSummary().toString().contentEquals(
"TEST_HEARING_AID_BT_DEVICE_NAME active")).isTrue();
}
@Test
public void getSummary_connectedLeAudioHearingAidBothSide_connectedBothSideSummary() {
when(mCachedBluetoothDevice.getMemberDevice()).thenReturn(generateMemberDevices());
when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true);
when(mHapClientProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
mPreferenceController.onStart();
Intent intent = new Intent(BluetoothHapClient.ACTION_HAP_CONNECTION_STATE_CHANGED);
intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHapClient.STATE_CONNECTED);
sendIntent(intent);
assertThat(mHearingAidPreference.getSummary().toString()).isEqualTo(
"TEST_HEARING_AID_BT_DEVICE_NAME, left and right");
}
@Test
public void getSummary_connectedMultipleHearingAids_connectedMultipleDevicesSummary() {
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
HearingAidProfile.DeviceSide.SIDE_LEFT);
when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true);
when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mCachedSubBluetoothDevice);
when(mHearingAidProfile.getConnectedDevices()).thenReturn(
generateMultipleHearingAidDeviceList());
mPreferenceController.onStart();
Intent intent = new Intent(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHearingAid.STATE_CONNECTED);
@@ -161,17 +200,6 @@ public class AccessibilityHearingAidPreferenceControllerTest {
"TEST_HEARING_AID_BT_DEVICE_NAME +1 more")).isTrue();
}
@Test
public void getSummary_disconnectedHearingAid_disconnectedSummary() {
mPreferenceController.onStart();
Intent intent = new Intent(BluetoothHearingAid.ACTION_CONNECTION_STATE_CHANGED);
intent.putExtra(BluetoothHearingAid.EXTRA_STATE, BluetoothHearingAid.STATE_DISCONNECTED);
sendIntent(intent);
assertThat(mHearingAidPreference.getSummary()).isEqualTo(
mContext.getText(R.string.accessibility_hearingaid_not_connected_summary));
}
@Test
public void getSummary_bluetoothOff_disconnectedSummary() {
mPreferenceController.onStart();
@@ -208,8 +236,29 @@ public class AccessibilityHearingAidPreferenceControllerTest {
}
@Test
public void onNotSupportHearingAidProfile_isNotAvailable() {
//clear bluetooth supported profile
public void onSupportHearingAidProfile_isAvailable() {
mShadowBluetoothAdapter.clearSupportedProfiles();
mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HEARING_AID);
mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext,
HEARING_AID_PREFERENCE);
mPreferenceController.setPreference(mHearingAidPreference);
assertThat(mPreferenceController.isAvailable()).isTrue();
}
@Test
public void onSupportHapClientProfile_isAvailable() {
mShadowBluetoothAdapter.clearSupportedProfiles();
mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HAP_CLIENT);
mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext,
HEARING_AID_PREFERENCE);
mPreferenceController.setPreference(mHearingAidPreference);
assertThat(mPreferenceController.isAvailable()).isTrue();
}
@Test
public void onNotSupportAnyHearingAidRelatedProfile_isNotAvailable() {
mShadowBluetoothAdapter.clearSupportedProfiles();
mPreferenceController = new AccessibilityHearingAidPreferenceController(mContext,
HEARING_AID_PREFERENCE);
@@ -231,7 +280,7 @@ public class AccessibilityHearingAidPreferenceControllerTest {
@Config(shadows = ShadowAlertDialogCompat.class)
public void onActiveDeviceChanged_hearingAidProfile_launchHearingAidPairingDialog() {
final FragmentActivity mActivity = Robolectric.setupActivity(FragmentActivity.class);
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
@@ -246,27 +295,38 @@ public class AccessibilityHearingAidPreferenceControllerTest {
}
@Test
public void onServiceConnected_updateSummary() {
mPreferenceController.onStart();
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_BINAURAL);
public void onServiceConnected_onHearingAidProfileConnected_updateSummary() {
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
HearingAidProfile.DeviceSide.SIDE_LEFT);
when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
mPreferenceController.onStart();
mPreferenceController.onServiceConnected();
assertThat(mHearingAidPreference.getSummary().toString()).isEqualTo(
"TEST_HEARING_AID_BT_DEVICE_NAME, left only");
}
@Test
public void onServiceConnected_onHapClientProfileConnected_updateSummary() {
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
HearingAidProfile.DeviceSide.SIDE_INVALID);
when(mHapClientProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList());
mPreferenceController.onStart();
mPreferenceController.onServiceConnected();
assertThat(mHearingAidPreference.getSummary().toString()).isEqualTo(
"TEST_HEARING_AID_BT_DEVICE_NAME active");
}
private void setupEnvironment() {
ShadowBluetoothUtils.sLocalBluetoothManager = mLocalBluetoothManager;
mLocalBluetoothManager = Utils.getLocalBtManager(mContext);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mShadowBluetoothAdapter = Shadow.extract(mBluetoothAdapter);
mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HEARING_AID);
mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HAP_CLIENT);
mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS);
mBluetoothAdapter.enable();
@@ -274,10 +334,12 @@ public class AccessibilityHearingAidPreferenceControllerTest {
when(mLocalBluetoothManager.getCachedDeviceManager()).thenReturn(mCachedDeviceManager);
when(mLocalBluetoothManager.getProfileManager()).thenReturn(mLocalBluetoothProfileManager);
when(mLocalBluetoothProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
when(mLocalBluetoothProfileManager.getHapClientProfile()).thenReturn(mHapClientProfile);
when(mHearingAidProfile.isProfileReady()).thenReturn(true);
when(mHapClientProfile.isProfileReady()).thenReturn(true);
when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice);
when(mCachedBluetoothDevice.getAddress()).thenReturn(TEST_DEVICE_ADDRESS);
when(mCachedBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME);
when(mHearingAidProfile.isProfileReady()).thenReturn(true);
}
private void sendIntent(Intent intent) {
@@ -293,9 +355,16 @@ public class AccessibilityHearingAidPreferenceControllerTest {
}
private List<BluetoothDevice> generateMultipleHearingAidDeviceList() {
// Generates different Bluetooth devices for testing multiple devices
final List<BluetoothDevice> deviceList = new ArrayList<>(2);
deviceList.add(mBluetoothDevice);
deviceList.add(mBluetoothDevice);
deviceList.add(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2));
return deviceList;
}
private Set<CachedBluetoothDevice> generateMemberDevices() {
final Set<CachedBluetoothDevice> memberDevices = new HashSet<>();
memberDevices.add(mCachedSubBluetoothDevice);
return memberDevices;
}
}

View File

@@ -143,8 +143,8 @@ public class HearingAidPairingDialogFragmentTest {
}
@Test
public void onDeviceAttributesChanged_subHearingAidDeviceConnected_dialogDismiss() {
when(mCachedSubBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
public void onDeviceAttributesChanged_subAshaHearingAidDeviceConnected_dialogDismiss() {
when(mCachedSubBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mCachedSubBluetoothDevice);
mFragment.onDeviceAttributesChanged();

View File

@@ -86,8 +86,8 @@ public class HearingAidUtilsTest {
}
@Test
public void launchHearingAidPairingDialog_deviceNotConnectedHearingAid_noDialog() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(false);
public void launchHearingAidPairingDialog_deviceIsNotConnectedAshaHearingAid_noDialog() {
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(false);
HearingAidUtils.launchHearingAidPairingDialog(mFragmentManager, mCachedBluetoothDevice);
@@ -96,8 +96,8 @@ public class HearingAidUtilsTest {
}
@Test
public void launchHearingAidPairingDialog_deviceIsModeMonaural_noDialog() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
public void launchHearingAidPairingDialog_deviceIsMonauralMode_noDialog() {
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_MONAURAL);
@@ -109,7 +109,7 @@ public class HearingAidUtilsTest {
@Test
public void launchHearingAidPairingDialog_deviceHasSubDevice_noDialog() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mSubCachedBluetoothDevice);
@@ -122,7 +122,7 @@ public class HearingAidUtilsTest {
@Test
public void launchHearingAidPairingDialog_deviceIsInvalidSide_noDialog() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(
@@ -136,7 +136,7 @@ public class HearingAidUtilsTest {
@Test
public void launchHearingAidPairingDialog_dialogShown() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(

View File

@@ -205,12 +205,11 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_hearingAidDeviceConnected_notInCall_addPreference()
{
public void onProfileConnectionStateChanged_ashaHearingAidConnected_notInCall_addPreference() {
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.HEARING_AID);
@@ -219,11 +218,11 @@ public class AvailableMediaBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_hearingAidDeviceConnected_inCall_addPreference() {
public void onProfileConnectionStateChanged_ashaHearingAidConnected_inCall_addPreference() {
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.HEARING_AID);

View File

@@ -81,8 +81,8 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
}
@Test
public void init_isNotConnectedHearingAidDevice_notVisiblePreference() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
public void init_isNotConnectedAshaHearingAidDevice_notVisiblePreference() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(false);
mController.init(mScreen);
@@ -91,35 +91,35 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
}
@Test
public void isAvailable_isNotConnectedHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
public void isAvailable_isNotConnectedAshaHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_notConnectedHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
public void isAvailable_isConnectedAshaHearingAidDevice_isMonaural_notAvailable() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_MONAURAL);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_subDeviceIsConnectedHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
public void isAvailable_subDeviceIsConnectedAshaHearingAidDevice_notAvailable() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mSubCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mSubCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getSubDevice()).thenReturn(mSubCachedDevice);
assertThat(mController.isAvailable()).isFalse();
}
@Test
public void isAvailable_subDeviceNotConnectedHearingAidDevice_available() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
public void isAvailable_subDeviceIsNotConnectedAshaHearingAidDevice_available() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mSubCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
when(mSubCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(false);
when(mCachedDevice.getSubDevice()).thenReturn(mSubCachedDevice);
assertThat(mController.isAvailable()).isTrue();
@@ -127,7 +127,7 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
@Test
public void isAvailable_subDeviceNotExist_available() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedDevice.getDeviceMode()).thenReturn(HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedDevice.getSubDevice()).thenReturn(null);
@@ -146,8 +146,8 @@ public class BluetoothDetailsPairOtherControllerTest extends BluetoothDetailsCon
}
@Test
public void refresh_isNotConnectedHearingAidDevice_notVisiblePreference() {
when(mCachedDevice.isConnectedHearingAidDevice()).thenReturn(false);
public void refresh_isNotConnectedAshaHearingAidDevice_notVisiblePreference() {
when(mCachedDevice.isConnectedAshaHearingAidDevice()).thenReturn(false);
mController.init(mScreen);
mController.refresh();

View File

@@ -89,7 +89,7 @@ public class BluetoothDetailsRelatedToolsControllerTest extends BluetoothDetails
}
@Test
public void isAvailable_notHearingAidDevice_notAvailable() {
public void isAvailable_isNotHearingAidDevice_notAvailable() {
when(mCachedDevice.isHearingAidDevice()).thenReturn(false);
assertThat(mController.isAvailable()).isFalse();

View File

@@ -218,12 +218,12 @@ public class ConnectedBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_hearingAidDeviceConnected_inCall_removePreference()
public void onProfileConnectionStateChanged_ashaHearingAidConnected_inCall_removePreference()
{
mAudioManager.setMode(AudioManager.MODE_IN_CALL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.HEARING_AID);
@@ -232,12 +232,12 @@ public class ConnectedBluetoothDeviceUpdaterTest {
}
@Test
public void onProfileConnectionStateChanged_hearingAidDeviceConnected_notInCall_removePreference
() {
public void onProfileConnectionStateChanged_ashaHearingAidConnected_notInCall_removePreference()
{
mAudioManager.setMode(AudioManager.MODE_NORMAL);
when(mBluetoothDeviceUpdater.
isDeviceConnected(any(CachedBluetoothDevice.class))).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
mBluetoothDeviceUpdater.onProfileConnectionStateChanged(mCachedBluetoothDevice,
BluetoothProfile.STATE_CONNECTED, BluetoothProfile.HEARING_AID);

View File

@@ -244,7 +244,7 @@ public class AvailableMediaDeviceGroupControllerTest {
@Test
@Config(shadows = ShadowAlertDialogCompat.class)
public void onActiveDeviceChanged_hearingAidProfile_launchHearingAidPairingDialog() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.isConnectedAshaHearingAidDevice()).thenReturn(true);
when(mCachedBluetoothDevice.getDeviceMode()).thenReturn(
HearingAidProfile.DeviceMode.MODE_BINAURAL);
when(mCachedBluetoothDevice.getDeviceSide()).thenReturn(

View File

@@ -191,7 +191,7 @@ public class BluetoothDevicesSliceTest {
public void getSlice_hasAvailableMediaDevice_shouldBuildPrimaryBluetoothAction() {
mockBluetoothDeviceList(1);
when(mBluetoothDeviceList.get(0).getDevice().isConnected()).thenReturn(true);
doReturn(true).when(mBluetoothDeviceList.get(0)).isConnectedHearingAidDevice();
doReturn(true).when(mBluetoothDeviceList.get(0)).isConnectedAshaHearingAidDevice();
doReturn(mBluetoothDeviceList).when(mBluetoothDevicesSlice).getPairedBluetoothDevices();
mBluetoothDevicesSlice.getSlice();