From c611e73406878907e7b216379f5ce3de42b8fe36 Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Mon, 14 Dec 2020 10:54:45 -0800 Subject: 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 --- .../java/android/bluetooth/BluetoothHeadset.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java') diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index adb7e2f773..f59ae338ee 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -681,6 +681,48 @@ public final class BluetoothHeadset implements BluetoothProfile { return BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } + /** + * 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 -- cgit v1.2.3