diff options
| author | Rahul Sabnis <rahulsabnis@google.com> | 2020-12-14 10:54:45 -0800 |
|---|---|---|
| committer | Rahul Sabnis <rahulsabnis@google.com> | 2021-01-06 17:20:19 -0800 |
| commit | 2b2f76b7bb1c7cb45374e904de0ba76d4f9b1a20 (patch) | |
| tree | 9e51de811cd6e02a90c52de5edfe711228235acc /core/java/android/bluetooth/BluetoothHeadset.java | |
| parent | 659ccfc928e11f613559665b37d61c9d0f3dee64 (diff) | |
Introduce public APIs to check whether a remote bluetooth headset
supports voice recognition as well as echo cancellation and/or noise
reduction via the AT+BRSF bitmask
Tag: #feature
Bug: 172960943
Test: Manual
Change-Id: I40579d9b6d493d2b32fb260983eeb7c79cc0d525
Diffstat (limited to 'core/java/android/bluetooth/BluetoothHeadset.java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothHeadset.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java index adb7e2f773a9..f59ae338ee2f 100644 --- a/core/java/android/bluetooth/BluetoothHeadset.java +++ b/core/java/android/bluetooth/BluetoothHeadset.java @@ -682,6 +682,48 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** + * Checks whether the headset supports some form of noise reduction + * + * @param device Bluetooth device + * @return true if echo cancellation and/or noise reduction is supported, false otherwise + */ + @RequiresPermission(Manifest.permission.BLUETOOTH) + public boolean isNoiseReductionSupported(@NonNull BluetoothDevice device) { + if (DBG) log("isNoiseReductionSupported()"); + final IBluetoothHeadset service = mService; + if (service != null && isEnabled() && isValidDevice(device)) { + try { + return service.isNoiseReductionSupported(device); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return false; + } + + /** + * Checks whether the headset supports voice recognition + * + * @param device Bluetooth device + * @return true if voice recognition is supported, false otherwise + */ + @RequiresPermission(Manifest.permission.BLUETOOTH) + public boolean isVoiceRecognitionSupported(@NonNull BluetoothDevice device) { + if (DBG) log("isVoiceRecognitionSupported()"); + final IBluetoothHeadset service = mService; + if (service != null && isEnabled() && isValidDevice(device)) { + try { + return service.isVoiceRecognitionSupported(device); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return false; + } + + /** * Start Bluetooth voice recognition. This methods sends the voice * recognition AT command to the headset and establishes the * audio connection. |
