diff options
| author | Chen Chen <cncn@google.com> | 2022-01-13 17:57:01 -0800 |
|---|---|---|
| committer | Chen Chen <cncn@google.com> | 2022-01-20 17:59:59 -0800 |
| commit | 31348f23ddc47bf1d54309d6f0ea0cd41c00e1be (patch) | |
| tree | b6d2518d74c36523be54cc009bde0dc05a0b1746 /framework/java/android | |
| parent | e08c6a59957172be671dc3b499e601e38ce64c17 (diff) | |
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
Diffstat (limited to 'framework/java/android')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothDevice.java | 30 |
1 files changed, 30 insertions, 0 deletions
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; + } } |
