diff options
author | Eric Laurent <elaurent@google.com> | 2015-04-21 17:37:00 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-04-30 12:43:06 -0700 |
commit | 8c7e6dac6f5eb38cef627dab92eac8b38513450c (patch) | |
tree | 6aede3a6ac013462a117ffb181d93439525eebeb /services/audiopolicy/service | |
parent | f62a067a5b21c840c915d36392679346ac0abfd7 (diff) | |
download | frameworks_av-8c7e6dac6f5eb38cef627dab92eac8b38513450c.zip frameworks_av-8c7e6dac6f5eb38cef627dab92eac8b38513450c.tar.gz frameworks_av-8c7e6dac6f5eb38cef627dab92eac8b38513450c.tar.bz2 |
audio policy: session routes continued.
- Clear session routes when client process dies.
- Enforce the route only when the requesting session is active.
- Fix requested route not working if an output mix change is required
(e.g forcing to SPEAKER when the default route is USB or A2DP).
- Make sure all sessions sharing the strategy with a rerouted session
have the same route (needed for volume control consistency)
Change-Id: I0ab347a8fb97e73e2c5965374544c5f4fe509ef1
Diffstat (limited to 'services/audiopolicy/service')
4 files changed, 29 insertions, 4 deletions
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp index 5ceb1cf..65639c3 100644 --- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp @@ -146,6 +146,7 @@ status_t AudioPolicyService::getOutputForAttr(const audio_attributes_t *attr, audio_io_handle_t *output, audio_session_t session, audio_stream_type_t *stream, + uid_t uid, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, @@ -158,7 +159,16 @@ status_t AudioPolicyService::getOutputForAttr(const audio_attributes_t *attr, } ALOGV("getOutput()"); Mutex::Autolock _l(mLock); - return mAudioPolicyManager->getOutputForAttr(attr, output, session, stream, samplingRate, + + // if the caller is us, trust the specified uid + if (IPCThreadState::self()->getCallingPid() != getpid_cached || uid == (uid_t)-1) { + uid_t newclientUid = IPCThreadState::self()->getCallingUid(); + if (uid != (uid_t)-1 && uid != newclientUid) { + ALOGW("%s uid %d tried to pass itself off as %d", __FUNCTION__, newclientUid, uid); + } + uid = newclientUid; + } + return mAudioPolicyManager->getOutputForAttr(attr, output, session, stream, uid, samplingRate, format, channelMask, flags, selectedDeviceId, offloadInfo); } @@ -248,6 +258,7 @@ void AudioPolicyService::doReleaseOutput(audio_io_handle_t output, status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, audio_io_handle_t *input, audio_session_t session, + uid_t uid, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, @@ -269,12 +280,22 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, sp<AudioPolicyEffects>audioPolicyEffects; status_t status; AudioPolicyInterface::input_type_t inputType; + // if the caller is us, trust the specified uid + if (IPCThreadState::self()->getCallingPid() != getpid_cached || uid == (uid_t)-1) { + uid_t newclientUid = IPCThreadState::self()->getCallingUid(); + if (uid != (uid_t)-1 && uid != newclientUid) { + ALOGW("%s uid %d tried to pass itself off as %d", __FUNCTION__, newclientUid, uid); + } + uid = newclientUid; + } + { Mutex::Autolock _l(mLock); // the audio_in_acoustics_t parameter is ignored by get_input() - status = mAudioPolicyManager->getInputForAttr(attr, input, session, + status = mAudioPolicyManager->getInputForAttr(attr, input, session, uid, samplingRate, format, channelMask, - flags, selectedDeviceId, &inputType); + flags, selectedDeviceId, + &inputType); audioPolicyEffects = mAudioPolicyEffects; if (status == NO_ERROR) { diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp index 433e712..13af3ef 100644 --- a/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp +++ b/services/audiopolicy/service/AudioPolicyInterfaceImplLegacy.cpp @@ -234,6 +234,7 @@ void AudioPolicyService::doReleaseOutput(audio_io_handle_t output, status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, audio_io_handle_t *input, audio_session_t session, + uid_t uid __unused, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, @@ -565,6 +566,7 @@ status_t AudioPolicyService::getOutputForAttr(const audio_attributes_t *attr, audio_io_handle_t *output, audio_session_t session __unused, audio_stream_type_t *stream, + uid_t uid __unused, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, diff --git a/services/audiopolicy/service/AudioPolicyService.cpp b/services/audiopolicy/service/AudioPolicyService.cpp index ccf9f9b..c5f4fb7 100644 --- a/services/audiopolicy/service/AudioPolicyService.cpp +++ b/services/audiopolicy/service/AudioPolicyService.cpp @@ -177,7 +177,7 @@ void AudioPolicyService::removeNotificationClient(uid_t uid) { Mutex::Autolock _l(mLock); if (mAudioPolicyManager) { - mAudioPolicyManager->clearAudioPatches(uid); + mAudioPolicyManager->releaseResourcesForUid(uid); } } #endif diff --git a/services/audiopolicy/service/AudioPolicyService.h b/services/audiopolicy/service/AudioPolicyService.h index 07ea96b..eb50cdd 100644 --- a/services/audiopolicy/service/AudioPolicyService.h +++ b/services/audiopolicy/service/AudioPolicyService.h @@ -80,6 +80,7 @@ public: audio_io_handle_t *output, audio_session_t session, audio_stream_type_t *stream, + uid_t uid, uint32_t samplingRate = 0, audio_format_t format = AUDIO_FORMAT_DEFAULT, audio_channel_mask_t channelMask = 0, @@ -98,6 +99,7 @@ public: virtual status_t getInputForAttr(const audio_attributes_t *attr, audio_io_handle_t *input, audio_session_t session, + uid_t uid, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, |