From 31348f23ddc47bf1d54309d6f0ea0cd41c00e1be Mon Sep 17 00:00:00 2001 From: Chen Chen Date: Thu, 13 Jan 2022 17:57:01 -0800 Subject: SpatialAudio: Provide API to allow/disallow low latency audio Bug: 214615268 Test: Manually test signal passing from framework to bluetooth/system Tag: #feature Change-Id: If7e1706c54bc6652698b0f5d5570de13ae54b519 --- .../java/android/bluetooth/BluetoothDevice.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothDevice.java') diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index 1edf5cc96b..70971a0c22 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -2828,4 +2828,34 @@ public final class BluetoothDevice implements Parcelable, Attributable { public static @MetadataKey int getMaxMetadataKey() { return METADATA_UNTETHERED_CASE_LOW_BATTERY_THRESHOLD; } + + /** + * Enable or disable audio low latency for this {@link BluetoothDevice}. + * + * @param allowed true if low latency is allowed, false if low latency is disallowed. + * @return true if the value is successfully set, + * false if there is a error when setting the value. + * @hide + */ + @SystemApi + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.BLUETOOTH_PRIVILEGED, + }) + public boolean setLowLatencyAudioAllowed(boolean allowed) { + final IBluetooth service = sService; + Log.i(TAG, "Allowing bluetooth audio low latency: " + allowed); + if (service == null) { + Log.e(TAG, "Bluetooth is not enabled. Cannot allow low latency"); + return false; + } + try { + service.allowLowLatencyAudio(allowed, this); + } catch (RemoteException e) { + Log.e(TAG, "allowLowLatencyAudio fail ", e); + e.rethrowFromSystemServer(); + } + return true; + } } -- cgit v1.2.3