Try select preset independently after group operation failed

For some binaural models, when only one side is connected and call a group operation, the remote device will return ERROR_REMOTE_OPERATION_REJECTED. We can re-try to selectthe  preset for each device independently in this case. After the other device is reconnected, the preset should automatically sync in the remote side.

Bug: 300015207
Test: manual test with Gn Resound LE sample and verify it works
Test: atest BluetoothDetailsHearingAidsPresetsControllerTest
Change-Id: I3ea621577c248c974505b9ce65d8ef260f5b87e1
This commit is contained in:
Angela Wang
2024-03-26 09:19:18 +00:00
parent de9a888469
commit 4db16f1125
2 changed files with 76 additions and 40 deletions

View File

@@ -87,6 +87,7 @@ public class BluetoothDetailsHearingAidsPresetsControllerTest extends
when(mLocalManager.getProfileManager()).thenReturn(mProfileManager);
when(mProfileManager.getHapClientProfile()).thenReturn(mHapClientProfile);
when(mCachedDevice.getDevice()).thenReturn(mDevice);
when(mCachedDevice.getProfiles()).thenReturn(List.of(mHapClientProfile));
when(mCachedDevice.isConnectedHapClientDevice()).thenReturn(true);
when(mCachedChildDevice.getDevice()).thenReturn(mChildDevice);
@@ -251,6 +252,16 @@ public class BluetoothDetailsHearingAidsPresetsControllerTest extends
assertThat(mController.getPreference().getSummary()).isNotNull();
}
@Test
public void onPresetSelectionForGroupFailed_selectPresetIsCalled() {
when(mHapClientProfile.getHapGroup(mDevice)).thenReturn(TEST_HAP_GROUP_ID);
mController.getPreference().setValue(String.valueOf(TEST_PRESET_INDEX));
mController.onPresetSelectionForGroupFailed(TEST_HAP_GROUP_ID, TEST_PRESET_INDEX);
verify(mHapClientProfile).selectPreset(mDevice, TEST_PRESET_INDEX);
}
private BluetoothHapPresetInfo getTestPresetInfo() {
BluetoothHapPresetInfo info = mock(BluetoothHapPresetInfo.class);
when(info.getName()).thenReturn(TEST_PRESET_NAME);