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