Loading android/app/src/com/android/bluetooth/hap/HapClientService.java +12 −6 Original line number Diff line number Diff line Loading @@ -785,12 +785,14 @@ public class HapClientService extends ProfileService { } } private void notifyActivePresetChanged(BluetoothDevice device, int presetIndex) { private void notifyActivePresetChanged(BluetoothDevice device, int presetIndex, int reasonCode) { if (mCallbacks != null) { int n = mCallbacks.beginBroadcast(); for (int i = 0; i < n; i++) { try { mCallbacks.getBroadcastItem(i).onPresetSelected(device, presetIndex); mCallbacks.getBroadcastItem(i).onPresetSelected(device, presetIndex, reasonCode); } catch (RemoteException e) { continue; } Loading @@ -799,10 +801,10 @@ public class HapClientService extends ProfileService { } } private void notifyActivePresetChangedForGroup(int groupId, int presetIndex) { private void notifyActivePresetChangedForGroup(int groupId, int presetIndex, int reasonCode) { List<BluetoothDevice> all_group_devices = getGroupDevices(groupId); for (BluetoothDevice dev : all_group_devices) { notifyActivePresetChanged(dev, presetIndex); notifyActivePresetChanged(dev, presetIndex, reasonCode); } } Loading Loading @@ -1103,14 +1105,18 @@ public class HapClientService extends ProfileService { if (device != null) { mDeviceCurrentPresetMap.put(device, currentPresetIndex); notifyActivePresetChanged(device, currentPresetIndex); // FIXME: Add app request queueing to support other reasons int reasonCode = BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST; notifyActivePresetChanged(device, currentPresetIndex, reasonCode); } else if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) { List<BluetoothDevice> all_group_devices = getGroupDevices(groupId); for (BluetoothDevice dev : all_group_devices) { mDeviceCurrentPresetMap.put(dev, currentPresetIndex); } notifyActivePresetChangedForGroup(groupId, currentPresetIndex); // FIXME: Add app request queueing to support other reasons int reasonCode = BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST; notifyActivePresetChangedForGroup(groupId, currentPresetIndex, reasonCode); } } return; Loading android/app/tests/unit/src/com/android/bluetooth/hap/HapClientTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -697,7 +697,7 @@ public class HapClientTest { * Test that native callback generates proper callback call. */ @Test public void testOtackEventonPresetSelected() { public void testStackEventOnPresetSelected() { doReturn(new ParcelUuid[]{BluetoothUuid.HAS}).when(mAdapterService) .getRemoteUuids(any(BluetoothDevice.class)); Loading @@ -705,7 +705,7 @@ public class HapClientTest { try { verify(mCallback, after(TIMEOUT_MS).times(1)).onPresetSelected(eq(mDevice), eq(0x01)); eq(0x01), eq(BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -988,7 +988,7 @@ public class HapClientTest { try { verify(mCallback, after(TIMEOUT_MS).times(1)).onPresetSelected(eq(device), eq(evt.valueInt1)); eq(evt.valueInt1), eq(BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading framework/api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ package android.bluetooth { public static interface BluetoothHapClient.Callback { method public void onPresetInfoChanged(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.List<android.bluetooth.BluetoothHapPresetInfo>, int); method public void onPresetSelected(@NonNull android.bluetooth.BluetoothDevice, int); method public void onPresetSelected(@NonNull android.bluetooth.BluetoothDevice, int, int); method public void onPresetSelectionFailed(@NonNull android.bluetooth.BluetoothDevice, int); method public void onPresetSelectionForGroupFailed(int, int); method public void onSetPresetNameFailed(@NonNull android.bluetooth.BluetoothDevice, int); Loading framework/java/android/bluetooth/BluetoothHapClient.java +10 −7 Original line number Diff line number Diff line Loading @@ -94,11 +94,13 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable * * @param device remote device, * @param presetIndex the currently active preset index. * @param statusCode reason for the selected preset change * * @hide */ @SystemApi void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex); void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex, @Status int statusCode); /** * Invoked inform about the result of a failed preset change attempt. Loading Loading @@ -175,13 +177,14 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable @SuppressLint("AndroidFrameworkBluetoothPermission") private final IBluetoothHapClientCallback mCallback = new IBluetoothHapClientCallback.Stub() { @Override public void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex) { public void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex, int reasonCode) { Attributable.setAttributionSource(device, mAttributionSource); for (Map.Entry<BluetoothHapClient.Callback, Executor> callbackExecutorEntry: mCallbackExecutorMap.entrySet()) { BluetoothHapClient.Callback callback = callbackExecutorEntry.getKey(); Executor executor = callbackExecutorEntry.getValue(); executor.execute(() -> callback.onPresetSelected(device, presetIndex)); executor.execute(() -> callback.onPresetSelected(device, presetIndex, reasonCode)); } } Loading Loading @@ -866,7 +869,7 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable /** * Selects the currently active preset for a HA device * * On success, {@link Callback#onPresetSelected(BluetoothDevice, int)} will be called with * On success, {@link Callback#onPresetSelected(BluetoothDevice, int, int)} will be called with * reason code {@link BluetoothStatusCodes#REASON_LOCAL_APP_REQUEST} * On failure, {@link Callback#onPresetSelectionFailed(BluetoothDevice, int)} will be called. * Loading Loading @@ -900,11 +903,11 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable * <p> This group call may replace multiple device calls if those are part of the * valid HAS group. Note that binaural HA devices may or may not support group. * * On success, {@link Callback#onPresetSelected(BluetoothDevice, int)} will be called * On success, {@link Callback#onPresetSelected(BluetoothDevice, int, int)} will be called * for each device within the group with reason code * {@link BluetoothStatusCodes#REASON_LOCAL_APP_REQUEST} * On failure, {@link Callback#onPresetSelectionFailed(BluetoothDevice, int)} will be called * for each device within the group. * On failure, {@link Callback#onPresetSelectionForGroupFailed(int, int)} will be * called for the group. * * @param groupId is the device group identifier for which want to set the active preset * @param presetIndex is an index of one of the available presets Loading system/binder/android/bluetooth/IBluetoothHapClientCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ import java.util.List; * @hide */ oneway interface IBluetoothHapClientCallback { void onPresetSelected(in BluetoothDevice device, in int presetIndex); void onPresetSelected(in BluetoothDevice device, in int presetIndex, in int reasonCode); void onPresetSelectionFailed(in BluetoothDevice device, in int statusCode); void onPresetSelectionForGroupFailed(in int hapGroupId, in int statusCode); void onPresetInfoChanged(in BluetoothDevice device, Loading Loading
android/app/src/com/android/bluetooth/hap/HapClientService.java +12 −6 Original line number Diff line number Diff line Loading @@ -785,12 +785,14 @@ public class HapClientService extends ProfileService { } } private void notifyActivePresetChanged(BluetoothDevice device, int presetIndex) { private void notifyActivePresetChanged(BluetoothDevice device, int presetIndex, int reasonCode) { if (mCallbacks != null) { int n = mCallbacks.beginBroadcast(); for (int i = 0; i < n; i++) { try { mCallbacks.getBroadcastItem(i).onPresetSelected(device, presetIndex); mCallbacks.getBroadcastItem(i).onPresetSelected(device, presetIndex, reasonCode); } catch (RemoteException e) { continue; } Loading @@ -799,10 +801,10 @@ public class HapClientService extends ProfileService { } } private void notifyActivePresetChangedForGroup(int groupId, int presetIndex) { private void notifyActivePresetChangedForGroup(int groupId, int presetIndex, int reasonCode) { List<BluetoothDevice> all_group_devices = getGroupDevices(groupId); for (BluetoothDevice dev : all_group_devices) { notifyActivePresetChanged(dev, presetIndex); notifyActivePresetChanged(dev, presetIndex, reasonCode); } } Loading Loading @@ -1103,14 +1105,18 @@ public class HapClientService extends ProfileService { if (device != null) { mDeviceCurrentPresetMap.put(device, currentPresetIndex); notifyActivePresetChanged(device, currentPresetIndex); // FIXME: Add app request queueing to support other reasons int reasonCode = BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST; notifyActivePresetChanged(device, currentPresetIndex, reasonCode); } else if (groupId != BluetoothCsipSetCoordinator.GROUP_ID_INVALID) { List<BluetoothDevice> all_group_devices = getGroupDevices(groupId); for (BluetoothDevice dev : all_group_devices) { mDeviceCurrentPresetMap.put(dev, currentPresetIndex); } notifyActivePresetChangedForGroup(groupId, currentPresetIndex); // FIXME: Add app request queueing to support other reasons int reasonCode = BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST; notifyActivePresetChangedForGroup(groupId, currentPresetIndex, reasonCode); } } return; Loading
android/app/tests/unit/src/com/android/bluetooth/hap/HapClientTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -697,7 +697,7 @@ public class HapClientTest { * Test that native callback generates proper callback call. */ @Test public void testOtackEventonPresetSelected() { public void testStackEventOnPresetSelected() { doReturn(new ParcelUuid[]{BluetoothUuid.HAS}).when(mAdapterService) .getRemoteUuids(any(BluetoothDevice.class)); Loading @@ -705,7 +705,7 @@ public class HapClientTest { try { verify(mCallback, after(TIMEOUT_MS).times(1)).onPresetSelected(eq(mDevice), eq(0x01)); eq(0x01), eq(BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading Loading @@ -988,7 +988,7 @@ public class HapClientTest { try { verify(mCallback, after(TIMEOUT_MS).times(1)).onPresetSelected(eq(device), eq(evt.valueInt1)); eq(evt.valueInt1), eq(BluetoothStatusCodes.REASON_LOCAL_STACK_REQUEST)); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
framework/api/system-current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ package android.bluetooth { public static interface BluetoothHapClient.Callback { method public void onPresetInfoChanged(@NonNull android.bluetooth.BluetoothDevice, @NonNull java.util.List<android.bluetooth.BluetoothHapPresetInfo>, int); method public void onPresetSelected(@NonNull android.bluetooth.BluetoothDevice, int); method public void onPresetSelected(@NonNull android.bluetooth.BluetoothDevice, int, int); method public void onPresetSelectionFailed(@NonNull android.bluetooth.BluetoothDevice, int); method public void onPresetSelectionForGroupFailed(int, int); method public void onSetPresetNameFailed(@NonNull android.bluetooth.BluetoothDevice, int); Loading
framework/java/android/bluetooth/BluetoothHapClient.java +10 −7 Original line number Diff line number Diff line Loading @@ -94,11 +94,13 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable * * @param device remote device, * @param presetIndex the currently active preset index. * @param statusCode reason for the selected preset change * * @hide */ @SystemApi void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex); void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex, @Status int statusCode); /** * Invoked inform about the result of a failed preset change attempt. Loading Loading @@ -175,13 +177,14 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable @SuppressLint("AndroidFrameworkBluetoothPermission") private final IBluetoothHapClientCallback mCallback = new IBluetoothHapClientCallback.Stub() { @Override public void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex) { public void onPresetSelected(@NonNull BluetoothDevice device, int presetIndex, int reasonCode) { Attributable.setAttributionSource(device, mAttributionSource); for (Map.Entry<BluetoothHapClient.Callback, Executor> callbackExecutorEntry: mCallbackExecutorMap.entrySet()) { BluetoothHapClient.Callback callback = callbackExecutorEntry.getKey(); Executor executor = callbackExecutorEntry.getValue(); executor.execute(() -> callback.onPresetSelected(device, presetIndex)); executor.execute(() -> callback.onPresetSelected(device, presetIndex, reasonCode)); } } Loading Loading @@ -866,7 +869,7 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable /** * Selects the currently active preset for a HA device * * On success, {@link Callback#onPresetSelected(BluetoothDevice, int)} will be called with * On success, {@link Callback#onPresetSelected(BluetoothDevice, int, int)} will be called with * reason code {@link BluetoothStatusCodes#REASON_LOCAL_APP_REQUEST} * On failure, {@link Callback#onPresetSelectionFailed(BluetoothDevice, int)} will be called. * Loading Loading @@ -900,11 +903,11 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable * <p> This group call may replace multiple device calls if those are part of the * valid HAS group. Note that binaural HA devices may or may not support group. * * On success, {@link Callback#onPresetSelected(BluetoothDevice, int)} will be called * On success, {@link Callback#onPresetSelected(BluetoothDevice, int, int)} will be called * for each device within the group with reason code * {@link BluetoothStatusCodes#REASON_LOCAL_APP_REQUEST} * On failure, {@link Callback#onPresetSelectionFailed(BluetoothDevice, int)} will be called * for each device within the group. * On failure, {@link Callback#onPresetSelectionForGroupFailed(int, int)} will be * called for the group. * * @param groupId is the device group identifier for which want to set the active preset * @param presetIndex is an index of one of the available presets Loading
system/binder/android/bluetooth/IBluetoothHapClientCallback.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ import java.util.List; * @hide */ oneway interface IBluetoothHapClientCallback { void onPresetSelected(in BluetoothDevice device, in int presetIndex); void onPresetSelected(in BluetoothDevice device, in int presetIndex, in int reasonCode); void onPresetSelectionFailed(in BluetoothDevice device, in int statusCode); void onPresetSelectionForGroupFailed(in int hapGroupId, in int statusCode); void onPresetInfoChanged(in BluetoothDevice device, Loading