libaudiohal: implement supportsBluetoothVariableLatency for HIDL

Implement supportsBluetoothVariableLatency for HIDL by way of
getParameters API.

Bug: 287695426
Test: verify that low latency mode is requested when TalkBack is playing
Change-Id: Ibacbdf6cefbcb96b6ac3cfd82b6d26a0e36c8a08
Merged-In: Ibacbdf6cefbcb96b6ac3cfd82b6d26a0e36c8a08
(cherry picked from commit 321b5c9d45a1d15bb289dcd139e43287185dbd36)
diff --git a/media/libaudiohal/impl/DeviceHalHidl.cpp b/media/libaudiohal/impl/DeviceHalHidl.cpp
index f96d419..0d71fd3 100644
--- a/media/libaudiohal/impl/DeviceHalHidl.cpp
+++ b/media/libaudiohal/impl/DeviceHalHidl.cpp
@@ -684,4 +684,26 @@
 }
 #endif
 
+status_t DeviceHalHidl::supportsBluetoothVariableLatency(bool* supports) {
+    if (supports == nullptr) {
+        return BAD_VALUE;
+    }
+    *supports = false;
+
+    String8 reply;
+    status_t status = getParameters(
+            String8(AUDIO_PARAMETER_BT_VARIABLE_LATENCY_SUPPORTED), &reply);
+    if (status != NO_ERROR) {
+        return status;
+    }
+    AudioParameter replyParams(reply);
+    String8 trueOrFalse;
+    status = replyParams.get(
+            String8(AUDIO_PARAMETER_BT_VARIABLE_LATENCY_SUPPORTED), trueOrFalse);
+    if (status != NO_ERROR) {
+        return status;
+    }
+    *supports = trueOrFalse == AudioParameter::valueTrue;
+    return NO_ERROR;
+}
 } // namespace android