summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2021-10-10 08:44:04 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2021-10-10 08:44:04 +0000
commitb49456ff77a8ce91252562ad92da7e7646a97c6b (patch)
tree0997f493f1dd00f9adb6e6898eb29d44807953a1
parentb6cf963be912f91b25c6967c1c10a28996809c38 (diff)
parentbc3859a4821e450b69f2f32005010562381b5d05 (diff)
Merge "leaudio: Add set volume API"
-rw-r--r--core/java/android/bluetooth/BluetoothLeAudio.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothLeAudio.java b/core/java/android/bluetooth/BluetoothLeAudio.java
index 41617000805f..a139eba34518 100644
--- a/core/java/android/bluetooth/BluetoothLeAudio.java
+++ b/core/java/android/bluetooth/BluetoothLeAudio.java
@@ -512,6 +512,30 @@ public final class BluetoothLeAudio implements BluetoothProfile, AutoCloseable {
}
/**
+ * Set volume for the streaming devices
+ *
+ * @param volume volume to set
+ * @hide
+ */
+ @RequiresBluetoothConnectPermission
+ @RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.BLUETOOTH_PRIVILEGED})
+ public void setVolume(int volume) {
+ if (VDBG) log("setVolume(vol: " + volume + " )");
+ try {
+ final IBluetoothLeAudio service = getService();
+ if (service != null && mAdapter.isEnabled()) {
+ service.setVolume(volume, mAttributionSource);
+ return;
+ }
+ if (service == null) Log.w(TAG, "Proxy not attached to service");
+ return;
+ } catch (RemoteException e) {
+ Log.e(TAG, "Stack:" + Log.getStackTraceString(new Throwable()));
+ return;
+ }
+ }
+
+ /**
* Set connection policy of the profile
*
* <p> The device should already be paired.