From 1d3b83664a20ed6a3d8249b5c695d288e8b29e9d Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Tue, 27 Jul 2021 15:49:04 -0700 Subject: [PATCH] Require calls to BluetoothA2dp#setBufferLengthMillis to pass a non-negative value Tag: #feature Bug: 194837771 Test: Manual Change-Id: I3c1d2da1d28a494d8b393c4502521b3f0699adf6 --- core/java/android/bluetooth/BluetoothA2dp.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/java/android/bluetooth/BluetoothA2dp.java b/core/java/android/bluetooth/BluetoothA2dp.java index 65cdca9eb7d86..1dd32fec25109 100644 --- a/core/java/android/bluetooth/BluetoothA2dp.java +++ b/core/java/android/bluetooth/BluetoothA2dp.java @@ -1025,6 +1025,10 @@ public final class BluetoothA2dp implements BluetoothProfile { public boolean setBufferLengthMillis(@BluetoothCodecConfig.SourceCodecType int codec, int value) { if (VDBG) log("setBufferLengthMillis(" + codec + ", " + value + ")"); + if (value < 0) { + Log.e(TAG, "Trying to set audio buffer length to a negative value: " + value); + return false; + } try { final IBluetoothA2dp service = getService(); if (service != null && isEnabled()) {