Loading src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java +2 −2 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC // Check if another side of LE audio hearing aid is connected as a pair final Set<CachedBluetoothDevice> memberDevices = device.getMemberDevice(); if (memberDevices.stream().anyMatch(m -> m.isConnected())) { if (memberDevices.stream().anyMatch(m -> m.getDevice().isConnected())) { return mContext.getString( R.string.accessibility_hearingaid_left_and_right_side_device_summary, name); Loading @@ -156,7 +156,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC // Check if another side of ASHA hearing aid is connected as a pair final CachedBluetoothDevice subDevice = device.getSubDevice(); if (subDevice != null && subDevice.isConnected()) { if (subDevice != null && subDevice.getDevice().isConnected()) { return mContext.getString( R.string.accessibility_hearingaid_left_and_right_side_device_summary, name); } Loading tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java +12 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; Loading Loading @@ -82,6 +83,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { private BluetoothAdapter mBluetoothAdapter; private ShadowBluetoothAdapter mShadowBluetoothAdapter; private BluetoothDevice mBluetoothDevice; private BluetoothDevice mSubBluetoothDevice; private final Context mContext = ApplicationProvider.getApplicationContext(); private Preference mHearingAidPreference; Loading Loading @@ -143,8 +146,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { public void getSummary_connectedAshaHearingAidBothSide_connectedBothSideSummary() { when(mCachedBluetoothDevice.getDeviceSide()).thenReturn( HearingAidInfo.DeviceSide.SIDE_LEFT); when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true); when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mCachedSubBluetoothDevice); when(mSubBluetoothDevice.isConnected()).thenReturn(true); when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList()); mPreferenceController.onStart(); Loading Loading @@ -211,8 +214,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { @Test public void getSummary_connectedLeAudioHearingAidBothSide_connectedBothSideSummary() { when(mCachedBluetoothDevice.getMemberDevice()).thenReturn(generateMemberDevices()); when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true); when(mHapClientProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList()); when(mSubBluetoothDevice.isConnected()).thenReturn(true); mPreferenceController.onStart(); Intent intent = new Intent(BluetoothHapClient.ACTION_HAP_CONNECTION_STATE_CHANGED); Loading Loading @@ -288,7 +291,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { mShadowBluetoothAdapter = Shadow.extract(mBluetoothAdapter); mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HEARING_AID); mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HAP_CLIENT); mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS); mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS)); mSubBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2)); mBluetoothAdapter.enable(); doReturn(mEventManager).when(mLocalBluetoothManager).getEventManager(); Loading @@ -299,8 +303,12 @@ public class AccessibilityHearingAidPreferenceControllerTest { when(mHearingAidProfile.isProfileReady()).thenReturn(true); when(mHapClientProfile.isProfileReady()).thenReturn(true); when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getAddress()).thenReturn(TEST_DEVICE_ADDRESS); when(mCachedBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME); when(mCachedDeviceManager.findDevice(mSubBluetoothDevice)).thenReturn( mCachedSubBluetoothDevice); when(mCachedSubBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice); } private void sendIntent(Intent intent) { Loading @@ -319,7 +327,7 @@ public class AccessibilityHearingAidPreferenceControllerTest { // Generates different Bluetooth devices for testing multiple devices final List<BluetoothDevice> deviceList = new ArrayList<>(2); deviceList.add(mBluetoothDevice); deviceList.add(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2)); deviceList.add(mSubBluetoothDevice); return deviceList; } Loading Loading
src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceController.java +2 −2 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC // Check if another side of LE audio hearing aid is connected as a pair final Set<CachedBluetoothDevice> memberDevices = device.getMemberDevice(); if (memberDevices.stream().anyMatch(m -> m.isConnected())) { if (memberDevices.stream().anyMatch(m -> m.getDevice().isConnected())) { return mContext.getString( R.string.accessibility_hearingaid_left_and_right_side_device_summary, name); Loading @@ -156,7 +156,7 @@ public class AccessibilityHearingAidPreferenceController extends BasePreferenceC // Check if another side of ASHA hearing aid is connected as a pair final CachedBluetoothDevice subDevice = device.getSubDevice(); if (subDevice != null && subDevice.isConnected()) { if (subDevice != null && subDevice.getDevice().isConnected()) { return mContext.getString( R.string.accessibility_hearingaid_left_and_right_side_device_summary, name); } Loading
tests/robotests/src/com/android/settings/accessibility/AccessibilityHearingAidPreferenceControllerTest.java +12 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.settings.accessibility; import static com.google.common.truth.Truth.assertThat; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import static org.robolectric.Shadows.shadowOf; Loading Loading @@ -82,6 +83,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { private BluetoothAdapter mBluetoothAdapter; private ShadowBluetoothAdapter mShadowBluetoothAdapter; private BluetoothDevice mBluetoothDevice; private BluetoothDevice mSubBluetoothDevice; private final Context mContext = ApplicationProvider.getApplicationContext(); private Preference mHearingAidPreference; Loading Loading @@ -143,8 +146,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { public void getSummary_connectedAshaHearingAidBothSide_connectedBothSideSummary() { when(mCachedBluetoothDevice.getDeviceSide()).thenReturn( HearingAidInfo.DeviceSide.SIDE_LEFT); when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true); when(mCachedBluetoothDevice.getSubDevice()).thenReturn(mCachedSubBluetoothDevice); when(mSubBluetoothDevice.isConnected()).thenReturn(true); when(mHearingAidProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList()); mPreferenceController.onStart(); Loading Loading @@ -211,8 +214,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { @Test public void getSummary_connectedLeAudioHearingAidBothSide_connectedBothSideSummary() { when(mCachedBluetoothDevice.getMemberDevice()).thenReturn(generateMemberDevices()); when(mCachedSubBluetoothDevice.isConnected()).thenReturn(true); when(mHapClientProfile.getConnectedDevices()).thenReturn(generateHearingAidDeviceList()); when(mSubBluetoothDevice.isConnected()).thenReturn(true); mPreferenceController.onStart(); Intent intent = new Intent(BluetoothHapClient.ACTION_HAP_CONNECTION_STATE_CHANGED); Loading Loading @@ -288,7 +291,8 @@ public class AccessibilityHearingAidPreferenceControllerTest { mShadowBluetoothAdapter = Shadow.extract(mBluetoothAdapter); mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HEARING_AID); mShadowBluetoothAdapter.addSupportedProfiles(BluetoothProfile.HAP_CLIENT); mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS); mBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS)); mSubBluetoothDevice = spy(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2)); mBluetoothAdapter.enable(); doReturn(mEventManager).when(mLocalBluetoothManager).getEventManager(); Loading @@ -299,8 +303,12 @@ public class AccessibilityHearingAidPreferenceControllerTest { when(mHearingAidProfile.isProfileReady()).thenReturn(true); when(mHapClientProfile.isProfileReady()).thenReturn(true); when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getAddress()).thenReturn(TEST_DEVICE_ADDRESS); when(mCachedBluetoothDevice.getName()).thenReturn(TEST_DEVICE_NAME); when(mCachedDeviceManager.findDevice(mSubBluetoothDevice)).thenReturn( mCachedSubBluetoothDevice); when(mCachedSubBluetoothDevice.getDevice()).thenReturn(mSubBluetoothDevice); } private void sendIntent(Intent intent) { Loading @@ -319,7 +327,7 @@ public class AccessibilityHearingAidPreferenceControllerTest { // Generates different Bluetooth devices for testing multiple devices final List<BluetoothDevice> deviceList = new ArrayList<>(2); deviceList.add(mBluetoothDevice); deviceList.add(mBluetoothAdapter.getRemoteDevice(TEST_DEVICE_ADDRESS_2)); deviceList.add(mSubBluetoothDevice); return deviceList; } Loading