summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothLeAudio.java
diff options
context:
space:
mode:
authorPatty <plhuang@google.com>2022-03-03 19:06:33 +0800
committerPatty <plhuang@google.com>2022-03-07 19:06:18 +0800
commitfb679a0e1516a3e0333ee45e8f063d944094c72d (patch)
tree53e94819bf121b892a3217464d1d387bfb5c3412 /framework/java/android/bluetooth/BluetoothLeAudio.java
parent83c130f9017a5f043d50438c294da440955351bc (diff)
Add implementation for unimplemented APIs and add description for return value
1. Add implementation for getCodecStatus(), setCodecConfigPreference() and isCodecConfigSelectable() 2. Add description for the return value of getCodecLocalCapabilities() and getCodecSelectableCapabilities() Tag: #refactor Bug: 219875113 Test: atest BluetoothInstrumentationTests Change-Id: Ida32ff52990d2c062ef9f5cc965e20af030896bd
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeAudio.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudio.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java
index 2db1d1afe5..23e9a039f4 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudio.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudio.java
@@ -966,9 +966,22 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
Log.d(TAG, "getCodecStatus(" + device + ")");
}
+ final IBluetoothLeAudio service = getService();
final BluetoothLeAudioCodecStatus defaultValue = null;
- // TODO: Add the implementation to get codec status
+ if (service == null) {
+ Log.w(TAG, "Proxy not attached to service");
+ if (DBG) log(Log.getStackTraceString(new Throwable()));
+ } else if (mAdapter.isEnabled() && isValidDevice(device)) {
+ try {
+ final SynchronousResultReceiver<BluetoothLeAudioCodecStatus> recv =
+ new SynchronousResultReceiver();
+ service.getCodecStatus(device, mAttributionSource, recv);
+ return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(defaultValue);
+ } catch (RemoteException | TimeoutException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ }
+ }
return defaultValue;
}
@@ -994,8 +1007,18 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
throw new IllegalArgumentException("codecConfig cannot be null");
}
- // TODO: Add the implementation to set config preference
- return;
+ final IBluetoothLeAudio service = getService();
+
+ if (service == null) {
+ Log.w(TAG, "Proxy not attached to service");
+ if (DBG) log(Log.getStackTraceString(new Throwable()));
+ } else if (mAdapter.isEnabled() && isValidDevice(device)) {
+ try {
+ service.setCodecConfigPreference(device, codecConfig, mAttributionSource);
+ } catch (RemoteException e) {
+ Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
+ }
+ }
}
}