diff options
author | Alice Kuo <aliceypkuo@google.com> | 2022-01-19 13:05:51 +0800 |
---|---|---|
committer | Jack He <siyuanh@google.com> | 2022-01-20 23:26:23 +0000 |
commit | 41e93a2f2973460a16b9a942ada5663aa77ce87f (patch) | |
tree | 5b9a9ac1ff6979d81f6a8e3db30c02dafabd31ff /framework/java/android/bluetooth/BluetoothLeAudio.java | |
parent | 966c88d10d78a4288ebfc88075f141b2b65542ed (diff) |
Add getAudioLocation API
The API provide the audio location to integrate
with the battery information and show the audio location in UI
Bug: 150670922
Bug: 197199736
Test: make build
Change-Id: I686aa4f630592429f58282c631af2c1135318fd3
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothLeAudio.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothLeAudio.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothLeAudio.java b/framework/java/android/bluetooth/BluetoothLeAudio.java index 15db686b3b..02df543445 100644 --- a/framework/java/android/bluetooth/BluetoothLeAudio.java +++ b/framework/java/android/bluetooth/BluetoothLeAudio.java @@ -25,6 +25,7 @@ import android.annotation.Nullable; import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; +import android.annotation.SystemApi; import android.bluetooth.annotations.RequiresBluetoothConnectPermission; import android.bluetooth.annotations.RequiresLegacyBluetoothPermission; import android.content.AttributionSource; @@ -243,6 +244,13 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { public static final int GROUP_ID_INVALID = IBluetoothLeAudio.LE_AUDIO_GROUP_ID_INVALID; /** + * This represents an invalid audio location. + * + * @hide + */ + public static final int AUDIO_LOCATION_INVALID = -1; + + /** * Contains group id. * @hide */ @@ -723,6 +731,39 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable { } /** + * Get the audio location for the device. The return value is a bit field. The bit definition + * is included in Bluetooth SIG Assigned Numbers - Generic Audio - Audio Location Definitions. + * ex. Front Left: 0x00000001 + * Front Right: 0x00000002 + * Front Left | Front Right: 0x00000003 + * + * @param device the bluetooth device + * @return The bit field of audio location for the device, if bluetooth is off, return + * AUDIO_LOCATION_INVALID. + * + * @hide + */ + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED + }) + @SystemApi + public int getAudioLocation(@NonNull BluetoothDevice device) { + if (VDBG) log("getAudioLocation()"); + final IBluetoothLeAudio service = getService(); + final int defaultLocation = AUDIO_LOCATION_INVALID; + if (service == null) { + Log.w(TAG, "Proxy not attached to service"); + if (DBG) log(Log.getStackTraceString(new Throwable())); + } else if (mAdapter.isEnabled()) { + //TODO: add the implementation. + if (VDBG) log("getAudioLocation() from LE audio service"); + } + return defaultLocation; + } + + /** * Set connection policy of the profile * * <p> The device should already be paired. |