summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothLeAudio.java
diff options
context:
space:
mode:
authorPatty <plhuang@google.com>2022-01-25 19:58:37 +0800
committerJack He <siyuanh@google.com>2022-02-02 15:17:34 -0800
commit5aa4bd22ff59c9a3910fc60e6f4876b8bbad571d (patch)
treef89851acb542ccaf05f1295246b982de97a6d0af /framework/java/android/bluetooth/BluetoothLeAudio.java
parent14c9fcd9e9047314c8ea7d95fe9cf8cc087c1447 (diff)
Add API to set the codec preference for specific device
Add the APIs that would use in developer optin for setting the codec config preference and getiting the codec status. Expose the APIs first, some of the implementations will be done later. Add equals function to BluetoothLeAudioCodecConfig for comparison usage Tag: #feature Bug: 216276721 Bug: 150670922 Test: atest BluetoothInstrumentationTests Change-Id: Iaa9b7b1278f06228b7a22a1c61668b879b6f3dc9 Merged-In: Iaa9b7b1278f06228b7a22a1c61668b879b6f3dc9 (cherry picked from commit 7cf686a443eb2a1d036ba89c874a328fa24bb425)
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeAudio.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothLeAudio.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java
index 0fda7e7a36..cb543bdbb9 100644
--- a/framework/java/android/bluetooth/BluetoothLeAudio.java
+++ b/framework/java/android/bluetooth/BluetoothLeAudio.java
@@ -159,6 +159,24 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
"android.bluetooth.action.LE_AUDIO_CONF_CHANGED";
/**
+ * Intent used to broadcast the audio codec config changed information.
+ *
+ * <p>This intent will have 2 extras:
+ * <ul>
+ * <li> {@link BluetoothLeAudioCodecStatus#EXTRA_LE_AUDIO_CODEC_STATUS} - The codec status.
+ * </li>
+ * <li> {@link BluetoothDevice#EXTRA_DEVICE} - The remote device if the device is currently
+ * connected, otherwise it is not included.</li>
+ * </ul>
+ *
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
+ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
+ public static final String ACTION_LE_AUDIO_CODEC_CONFIG_CHANGED =
+ "android.bluetooth.action.LE_AUDIO_CODEC_CONFIG_CHANGED";
+
+ /**
* Indicates unspecified audio content.
* @hide
*/
@@ -906,4 +924,53 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
private static void log(String msg) {
Log.d(TAG, msg);
}
+
+ /**
+ * Gets the current codec status (configuration and capability).
+ *
+ * @param device the remote Bluetooth device.
+ * @return the current codec status
+ * @hide
+ */
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED
+ })
+ public BluetoothLeAudioCodecStatus getCodecStatus(@NonNull BluetoothDevice device) {
+ if (DBG) {
+ Log.d(TAG, "getCodecStatus(" + device + ")");
+ }
+
+ final BluetoothLeAudioCodecStatus defaultValue = null;
+
+ // TODO: Add the implementation to get codec status
+ return defaultValue;
+ }
+
+ /**
+ * Sets the codec configuration preference.
+ *
+ * @param device the remote Bluetooth device.
+ * @param codecConfig the codec configuration preference
+ * @hide
+ */
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf = {
+ android.Manifest.permission.BLUETOOTH_CONNECT,
+ android.Manifest.permission.BLUETOOTH_PRIVILEGED
+ })
+ public void setCodecConfigPreference(@NonNull BluetoothDevice device,
+ @NonNull BluetoothLeAudioCodecConfig codecConfig) {
+ if (DBG) Log.d(TAG, "setCodecConfigPreference(" + device + ")");
+
+ if (codecConfig == null) {
+ Log.e(TAG, "setCodecConfigPreference: Codec config can't be null");
+ throw new IllegalArgumentException("codecConfig cannot be null");
+ }
+
+ // TODO: Add the implementation to set config preference
+ return;
+ }
+
}