Loading android/app/src/com/android/bluetooth/hap/HapClientService.java +13 −13 Original line number Diff line number Diff line Loading @@ -620,22 +620,21 @@ public class HapClientService extends ProfileService { * @param presetIndex is an index of one of the available presets */ public void selectPresetForGroup(int groupId, int presetIndex) { int status = BluetoothStatusCodes.ERROR_UNKNOWN; int status = BluetoothStatusCodes.SUCCESS; if ((presetIndex == BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) || (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID)) { if (presetIndex == BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) { status = BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX; } else { if (!isGroupIdValid(groupId)) { status = BluetoothStatusCodes.ERROR_CSIP_INVALID_GROUP_ID; } else if (!isPresetIndexValid(groupId, presetIndex)) { status = BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX; } if (status != BluetoothStatusCodes.SUCCESS) { if (mCallbacks != null) { int n = mCallbacks.beginBroadcast(); for (int i = 0; i < n; i++) { try { mCallbacks.getBroadcastItem(i).onPresetSelectionForGroupFailed(groupId, BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX); mCallbacks.getBroadcastItem(i) .onPresetSelectionForGroupFailed(groupId, status); } catch (RemoteException e) { continue; } Loading Loading @@ -899,6 +898,8 @@ public class HapClientService extends ProfileService { private boolean isPresetIndexValid(int groupId, int presetIndex) { List<BluetoothDevice> all_group_devices = getGroupDevices(groupId); if (all_group_devices.isEmpty()) return false; for (BluetoothDevice device : all_group_devices) { if (!isPresetIndexValid(device, presetIndex)) return false; } Loading @@ -914,7 +915,7 @@ public class HapClientService extends ProfileService { List<Integer> groups = csipClient.getAllGroupIds(BluetoothUuid.CAP); return groups.contains(groupId); } return true; return false; } /** Loading Loading @@ -958,8 +959,7 @@ public class HapClientService extends ProfileService { if (!isGroupIdValid(groupId)) { status = BluetoothStatusCodes.ERROR_CSIP_INVALID_GROUP_ID; } if (!isPresetIndexValid(groupId, presetIndex)) { } else if (!isPresetIndexValid(groupId, presetIndex)) { status = BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX; } if (status != BluetoothStatusCodes.SUCCESS) { Loading android/app/tests/unit/src/com/android/bluetooth/hap/HapClientTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -466,8 +466,10 @@ public class HapClientTest { public void testGroupSelectActivePresetNative() { doReturn(new ParcelUuid[]{BluetoothUuid.HAS}).when(mAdapterService) .getRemoteUuids(any(BluetoothDevice.class)); testConnectingDevice(mDevice3); int flags = 0x01; mNativeInterface.onFeaturesUpdate(getByteAddress(mDevice), flags); mNativeInterface.onFeaturesUpdate(getByteAddress(mDevice3), flags); // Verify Native Interface call mService.selectPresetForGroup(0x03, 0x00); Loading Loading
android/app/src/com/android/bluetooth/hap/HapClientService.java +13 −13 Original line number Diff line number Diff line Loading @@ -620,22 +620,21 @@ public class HapClientService extends ProfileService { * @param presetIndex is an index of one of the available presets */ public void selectPresetForGroup(int groupId, int presetIndex) { int status = BluetoothStatusCodes.ERROR_UNKNOWN; int status = BluetoothStatusCodes.SUCCESS; if ((presetIndex == BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) || (groupId == BluetoothCsipSetCoordinator.GROUP_ID_INVALID)) { if (presetIndex == BluetoothHapClient.PRESET_INDEX_UNAVAILABLE) { status = BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX; } else { if (!isGroupIdValid(groupId)) { status = BluetoothStatusCodes.ERROR_CSIP_INVALID_GROUP_ID; } else if (!isPresetIndexValid(groupId, presetIndex)) { status = BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX; } if (status != BluetoothStatusCodes.SUCCESS) { if (mCallbacks != null) { int n = mCallbacks.beginBroadcast(); for (int i = 0; i < n; i++) { try { mCallbacks.getBroadcastItem(i).onPresetSelectionForGroupFailed(groupId, BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX); mCallbacks.getBroadcastItem(i) .onPresetSelectionForGroupFailed(groupId, status); } catch (RemoteException e) { continue; } Loading Loading @@ -899,6 +898,8 @@ public class HapClientService extends ProfileService { private boolean isPresetIndexValid(int groupId, int presetIndex) { List<BluetoothDevice> all_group_devices = getGroupDevices(groupId); if (all_group_devices.isEmpty()) return false; for (BluetoothDevice device : all_group_devices) { if (!isPresetIndexValid(device, presetIndex)) return false; } Loading @@ -914,7 +915,7 @@ public class HapClientService extends ProfileService { List<Integer> groups = csipClient.getAllGroupIds(BluetoothUuid.CAP); return groups.contains(groupId); } return true; return false; } /** Loading Loading @@ -958,8 +959,7 @@ public class HapClientService extends ProfileService { if (!isGroupIdValid(groupId)) { status = BluetoothStatusCodes.ERROR_CSIP_INVALID_GROUP_ID; } if (!isPresetIndexValid(groupId, presetIndex)) { } else if (!isPresetIndexValid(groupId, presetIndex)) { status = BluetoothStatusCodes.ERROR_HAP_INVALID_PRESET_INDEX; } if (status != BluetoothStatusCodes.SUCCESS) { Loading
android/app/tests/unit/src/com/android/bluetooth/hap/HapClientTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -466,8 +466,10 @@ public class HapClientTest { public void testGroupSelectActivePresetNative() { doReturn(new ParcelUuid[]{BluetoothUuid.HAS}).when(mAdapterService) .getRemoteUuids(any(BluetoothDevice.class)); testConnectingDevice(mDevice3); int flags = 0x01; mNativeInterface.onFeaturesUpdate(getByteAddress(mDevice), flags); mNativeInterface.onFeaturesUpdate(getByteAddress(mDevice3), flags); // Verify Native Interface call mService.selectPresetForGroup(0x03, 0x00); Loading