audio policy: add permission for routing APIs.
Add check for signature or system permission
"android.permission.MODIFY_AUDIO_ROUTING" for routing
APIs.
Bug: 14815883.
Change-Id: Iefa0b9d90127a53e03a2e6d50dc93d8f4ae63e2f
diff --git a/services/audiopolicy/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
index 2b33703..8cc386a 100644
--- a/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/AudioPolicyInterfaceImpl.cpp
@@ -470,6 +470,9 @@
unsigned int *generation)
{
Mutex::Autolock _l(mLock);
+ if(!modifyAudioRoutingAllowed()) {
+ return PERMISSION_DENIED;
+ }
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
@@ -480,6 +483,9 @@
status_t AudioPolicyService::getAudioPort(struct audio_port *port)
{
Mutex::Autolock _l(mLock);
+ if(!modifyAudioRoutingAllowed()) {
+ return PERMISSION_DENIED;
+ }
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
@@ -491,6 +497,9 @@
audio_patch_handle_t *handle)
{
Mutex::Autolock _l(mLock);
+ if(!modifyAudioRoutingAllowed()) {
+ return PERMISSION_DENIED;
+ }
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
@@ -501,6 +510,9 @@
status_t AudioPolicyService::releaseAudioPatch(audio_patch_handle_t handle)
{
Mutex::Autolock _l(mLock);
+ if(!modifyAudioRoutingAllowed()) {
+ return PERMISSION_DENIED;
+ }
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
@@ -514,6 +526,9 @@
unsigned int *generation)
{
Mutex::Autolock _l(mLock);
+ if(!modifyAudioRoutingAllowed()) {
+ return PERMISSION_DENIED;
+ }
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}
@@ -524,6 +539,9 @@
status_t AudioPolicyService::setAudioPortConfig(const struct audio_port_config *config)
{
Mutex::Autolock _l(mLock);
+ if(!modifyAudioRoutingAllowed()) {
+ return PERMISSION_DENIED;
+ }
if (mAudioPolicyManager == NULL) {
return NO_INIT;
}