audio policy: Add call screen audio mode.
Add new audio mode AUDIO_MODE_CALL_SCREEN allowing call screening
to take place while other audio use cases are still active.
Also add API and audio policy configuration attribute to
indicate if the platform supports this audio mode.
Bug: 140384450
Test: make
Change-Id: If2fc56dbbd10aae2cf1498480471b35de0940228
diff --git a/services/audiopolicy/AudioPolicyInterface.h b/services/audiopolicy/AudioPolicyInterface.h
index 0d3e614..6c9588b 100644
--- a/services/audiopolicy/AudioPolicyInterface.h
+++ b/services/audiopolicy/AudioPolicyInterface.h
@@ -270,6 +270,8 @@
virtual status_t getVolumeGroupFromAudioAttributes(const AudioAttributes &aa,
volume_group_t &volumeGroup) = 0;
+
+ virtual bool isCallScreenModeSupported() = 0;
};
diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioPolicyConfig.h b/services/audiopolicy/common/managerdefinitions/include/AudioPolicyConfig.h
index 56596f5..e59386f 100644
--- a/services/audiopolicy/common/managerdefinitions/include/AudioPolicyConfig.h
+++ b/services/audiopolicy/common/managerdefinitions/include/AudioPolicyConfig.h
@@ -45,7 +45,8 @@
mAvailableOutputDevices(availableOutputDevices),
mAvailableInputDevices(availableInputDevices),
mDefaultOutputDevice(defaultOutputDevice),
- mIsSpeakerDrcEnabled(false)
+ mIsSpeakerDrcEnabled(false),
+ mIsCallScreenModeSupported(false)
{}
const std::string& getSource() const {
@@ -95,6 +96,14 @@
mIsSpeakerDrcEnabled = isSpeakerDrcEnabled;
}
+ bool isCallScreenModeSupported() const { return mIsCallScreenModeSupported; }
+
+ void setCallScreenModeSupported(bool isCallScreenModeSupported)
+ {
+ mIsCallScreenModeSupported = isCallScreenModeSupported;
+ }
+
+
const HwModuleCollection getHwModules() const { return mHwModules; }
const DeviceVector &getAvailableInputDevices() const
@@ -189,6 +198,7 @@
// DEVICE_CATEGORY_SPEAKER path to boost soft sounds, used to adjust volume curves accordingly.
// Note: remove also speaker_drc_enabled from global configuration of XML config file.
bool mIsSpeakerDrcEnabled;
+ bool mIsCallScreenModeSupported;
SurroundFormats mSurroundFormats;
};
diff --git a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
index 3b27cf6..7e26bc9 100644
--- a/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/Serializer.cpp
@@ -199,6 +199,7 @@
struct Attributes
{
static constexpr const char *speakerDrcEnabled = "speaker_drc_enabled";
+ static constexpr const char *callScreenModeSupported= "call_screen_mode_supported";
};
static status_t deserialize(const xmlNode *root, AudioPolicyConfig *config);
@@ -685,14 +686,17 @@
{
for (const xmlNode *cur = root->xmlChildrenNode; cur != NULL; cur = cur->next) {
if (!xmlStrcmp(cur->name, reinterpret_cast<const xmlChar*>(tag))) {
- std::string speakerDrcEnabled =
- getXmlAttribute(cur, Attributes::speakerDrcEnabled);
- bool isSpeakerDrcEnabled;
- if (!speakerDrcEnabled.empty() &&
- convertTo<std::string, bool>(speakerDrcEnabled, isSpeakerDrcEnabled)) {
- config->setSpeakerDrcEnabled(isSpeakerDrcEnabled);
+ bool value;
+ std::string attr = getXmlAttribute(cur, Attributes::speakerDrcEnabled);
+ if (!attr.empty() &&
+ convertTo<std::string, bool>(attr, value)) {
+ config->setSpeakerDrcEnabled(value);
}
- return NO_ERROR;
+ attr = getXmlAttribute(cur, Attributes::callScreenModeSupported);
+ if (!attr.empty() &&
+ convertTo<std::string, bool>(attr, value)) {
+ config->setCallScreenModeSupported(value);
+ }
}
}
return NO_ERROR;
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 3223530..dc34cc7 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -4207,6 +4207,12 @@
return false;
}
+bool AudioPolicyManager::isCallScreenModeSupported()
+{
+ return getConfig().isCallScreenModeSupported();
+}
+
+
status_t AudioPolicyManager::disconnectAudioSource(const sp<SourceClientDescriptor>& sourceDesc)
{
ALOGV("%s port Id %d", __FUNCTION__, sourceDesc->portId());
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h
index 707e4b0..bd4662a 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.h
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h
@@ -306,6 +306,8 @@
return volumeGroup != VOLUME_GROUP_NONE ? NO_ERROR : BAD_VALUE;
}
+ bool isCallScreenModeSupported() override;
+
status_t initialize();
protected:
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index 875f51d..10355bf 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -1329,4 +1329,15 @@
return NO_ERROR;
}
+bool AudioPolicyService::isCallScreenModeSupported()
+{
+ if (mAudioPolicyManager == NULL) {
+ ALOGW("%s, mAudioPolicyManager == NULL", __func__);
+ return false;
+ }
+ Mutex::Autolock _l(mLock);
+ AutoCallerClear acc;
+ return mAudioPolicyManager->isCallScreenModeSupported();
+}
+
} // namespace android
diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h
index 17e0437..2bd02c8 100644
--- a/services/audiopolicy/service/AudioPolicyService.h
+++ b/services/audiopolicy/service/AudioPolicyService.h
@@ -259,6 +259,8 @@
virtual status_t setRttEnabled(bool enabled);
+ bool isCallScreenModeSupported() override;
+
status_t doStopOutput(audio_port_handle_t portId);
void doReleaseOutput(audio_port_handle_t portId);