summaryrefslogtreecommitdiff
path: root/framework/java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/java')
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudio.java29
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java18
2 files changed, 42 insertions, 5 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()));
+ }
+ }
}
}
diff --git a/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java b/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java
index dea0642041..399ffa743c 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudioCodecStatus.java
@@ -109,8 +109,15 @@ public final class BluetoothLeAudioCodecStatus implements Parcelable {
* @return {@code true} if the codec config matches, {@code false} otherwise
*/
public boolean isCodecConfigSelectable(@Nullable BluetoothLeAudioCodecConfig codecConfig) {
- // TODO: Add the implementation to check the config is selectable
- return true;
+ if (codecConfig == null) {
+ return false;
+ }
+ for (BluetoothLeAudioCodecConfig selectableConfig : mCodecsSelectableCapabilities) {
+ if (codecConfig.equals(selectableConfig)) {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -171,6 +178,8 @@ public final class BluetoothLeAudioCodecStatus implements Parcelable {
/**
* Returns the current codec configuration.
+ *
+ * @return The current codec config.
*/
public @Nullable BluetoothLeAudioCodecConfig getCodecConfig() {
return mCodecConfig;
@@ -178,6 +187,8 @@ public final class BluetoothLeAudioCodecStatus implements Parcelable {
/**
* Returns the codecs local capabilities.
+ *
+ * @return The list of codec config that supported by the local system.
*/
public @NonNull List<BluetoothLeAudioCodecConfig> getCodecLocalCapabilities() {
return (mCodecsLocalCapabilities == null)
@@ -186,6 +197,9 @@ public final class BluetoothLeAudioCodecStatus implements Parcelable {
/**
* Returns the codecs selectable capabilities.
+ *
+ * @return The list of codec config that supported by both of the local system and
+ * remote devices.
*/
public @NonNull List<BluetoothLeAudioCodecConfig> getCodecSelectableCapabilities() {
return (mCodecsSelectableCapabilities == null)