audio: add API for querying the Ultrasound support
Bug: 200256985
Test: Check the return value with/without the Ultrasound
Output/Input in audio_policy_configuration.xml
Signed-off-by: Carter Hsu <carterhsu@google.com>
Change-Id: I681491bc21788e7eb75a052025a3feed89033524
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 1929f31..5590ba2 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -4890,6 +4890,37 @@
return false;
}
+bool AudioPolicyManager::isUltrasoundSupported()
+{
+ bool hasUltrasoundOutput = false;
+ bool hasUltrasoundInput = false;
+ for (const auto& hwModule : mHwModules) {
+ const OutputProfileCollection &outputProfiles = hwModule->getOutputProfiles();
+ if (!hasUltrasoundOutput) {
+ for (const auto &outProfile : outputProfiles) {
+ if (outProfile->getFlags() & AUDIO_OUTPUT_FLAG_ULTRASOUND) {
+ hasUltrasoundOutput = true;
+ break;
+ }
+ }
+ }
+
+ const InputProfileCollection &inputProfiles = hwModule->getInputProfiles();
+ if (!hasUltrasoundInput) {
+ for (const auto &inputProfile : inputProfiles) {
+ if (inputProfile->getFlags() & AUDIO_INPUT_FLAG_ULTRASOUND) {
+ hasUltrasoundInput = true;
+ break;
+ }
+ }
+ }
+
+ if (hasUltrasoundOutput && hasUltrasoundInput)
+ return true;
+ }
+ return false;
+}
+
bool AudioPolicyManager::isCallScreenModeSupported()
{
return getConfig().isCallScreenModeSupported();