Merge "leaudio: Add set volume API" am: b49456ff77 am: 05dd4fbc03

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1850201

Change-Id: I89a2b91ec79917a7ba2c8a7cba58682210ec9657
This commit is contained in:
Jakub Pawlowski
2021-10-10 09:14:29 +00:00
committed by Automerger Merge Worker

View File

@@ -511,6 +511,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 * Set connection policy of the profile
* *