Loading services/audioflinger/ServiceUtilities.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -113,10 +113,15 @@ bool captureAudioOutputAllowed(pid_t pid, uid_t uid) { return ok; } bool captureHotwordAllowed() { bool captureHotwordAllowed(pid_t pid, uid_t uid) { // CAPTURE_AUDIO_HOTWORD permission implies RECORD_AUDIO permission bool ok = recordingAllowed(String16(""), pid, uid); if (ok) { static const String16 sCaptureHotwordAllowed("android.permission.CAPTURE_AUDIO_HOTWORD"); // IMPORTANT: Use PermissionCache - not a runtime permission and may not change. bool ok = PermissionCache::checkCallingPermission(sCaptureHotwordAllowed); ok = PermissionCache::checkCallingPermission(sCaptureHotwordAllowed); } if (!ok) ALOGE("android.permission.CAPTURE_AUDIO_HOTWORD"); return ok; } Loading services/audioflinger/ServiceUtilities.h +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ extern pid_t getpid_cached; bool isTrustedCallingUid(uid_t uid); bool recordingAllowed(const String16& opPackageName, pid_t pid, uid_t uid); bool captureAudioOutputAllowed(pid_t pid, uid_t uid); bool captureHotwordAllowed(); bool captureHotwordAllowed(pid_t pid, uid_t uid); bool settingsAllowed(); bool modifyAudioRoutingAllowed(); bool dumpAllowed(); Loading services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +8 −7 Original line number Diff line number Diff line Loading @@ -289,13 +289,6 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, return BAD_VALUE; } if ((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) { return BAD_VALUE; } sp<AudioPolicyEffects>audioPolicyEffects; status_t status; AudioPolicyInterface::input_type_t inputType; bool updatePid = (pid == -1); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); if (!isTrustedCallingUid(callingUid)) { Loading @@ -313,7 +306,15 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, pid = callingPid; } if ((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed(pid, uid)) { return BAD_VALUE; } sp<AudioPolicyEffects>audioPolicyEffects; { status_t status; AudioPolicyInterface::input_type_t inputType; Mutex::Autolock _l(mLock); // the audio_in_acoustics_t parameter is ignored by get_input() status = mAudioPolicyManager->getInputForAttr(attr, input, session, uid, Loading services/soundtrigger/SoundTriggerHwService.cpp +14 −7 Original line number Diff line number Diff line Loading @@ -89,7 +89,8 @@ status_t SoundTriggerHwService::listModules(struct sound_trigger_module_descript uint32_t *numModules) { ALOGV("listModules"); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -110,7 +111,8 @@ status_t SoundTriggerHwService::attach(const sound_trigger_module_handle_t handl sp<ISoundTrigger>& moduleInterface) { ALOGV("attach module %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading Loading @@ -942,7 +944,8 @@ status_t SoundTriggerHwService::ModuleClient::dump(int fd __unused, void SoundTriggerHwService::ModuleClient::detach() { ALOGV("detach()"); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return; } Loading @@ -965,7 +968,8 @@ status_t SoundTriggerHwService::ModuleClient::loadSoundModel(const sp<IMemory>& sound_model_handle_t *handle) { ALOGV("loadSoundModel() handle"); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -979,7 +983,8 @@ status_t SoundTriggerHwService::ModuleClient::loadSoundModel(const sp<IMemory>& status_t SoundTriggerHwService::ModuleClient::unloadSoundModel(sound_model_handle_t handle) { ALOGV("unloadSoundModel() model handle %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -994,7 +999,8 @@ status_t SoundTriggerHwService::ModuleClient::startRecognition(sound_model_handl const sp<IMemory>& dataMemory) { ALOGV("startRecognition() model handle %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -1008,7 +1014,8 @@ status_t SoundTriggerHwService::ModuleClient::startRecognition(sound_model_handl status_t SoundTriggerHwService::ModuleClient::stopRecognition(sound_model_handle_t handle) { ALOGV("stopRecognition() model handle %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading Loading
services/audioflinger/ServiceUtilities.cpp +9 −4 Original line number Diff line number Diff line Loading @@ -113,10 +113,15 @@ bool captureAudioOutputAllowed(pid_t pid, uid_t uid) { return ok; } bool captureHotwordAllowed() { bool captureHotwordAllowed(pid_t pid, uid_t uid) { // CAPTURE_AUDIO_HOTWORD permission implies RECORD_AUDIO permission bool ok = recordingAllowed(String16(""), pid, uid); if (ok) { static const String16 sCaptureHotwordAllowed("android.permission.CAPTURE_AUDIO_HOTWORD"); // IMPORTANT: Use PermissionCache - not a runtime permission and may not change. bool ok = PermissionCache::checkCallingPermission(sCaptureHotwordAllowed); ok = PermissionCache::checkCallingPermission(sCaptureHotwordAllowed); } if (!ok) ALOGE("android.permission.CAPTURE_AUDIO_HOTWORD"); return ok; } Loading
services/audioflinger/ServiceUtilities.h +1 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ extern pid_t getpid_cached; bool isTrustedCallingUid(uid_t uid); bool recordingAllowed(const String16& opPackageName, pid_t pid, uid_t uid); bool captureAudioOutputAllowed(pid_t pid, uid_t uid); bool captureHotwordAllowed(); bool captureHotwordAllowed(pid_t pid, uid_t uid); bool settingsAllowed(); bool modifyAudioRoutingAllowed(); bool dumpAllowed(); Loading
services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +8 −7 Original line number Diff line number Diff line Loading @@ -289,13 +289,6 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, return BAD_VALUE; } if ((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed()) { return BAD_VALUE; } sp<AudioPolicyEffects>audioPolicyEffects; status_t status; AudioPolicyInterface::input_type_t inputType; bool updatePid = (pid == -1); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); if (!isTrustedCallingUid(callingUid)) { Loading @@ -313,7 +306,15 @@ status_t AudioPolicyService::getInputForAttr(const audio_attributes_t *attr, pid = callingPid; } if ((attr->source == AUDIO_SOURCE_HOTWORD) && !captureHotwordAllowed(pid, uid)) { return BAD_VALUE; } sp<AudioPolicyEffects>audioPolicyEffects; { status_t status; AudioPolicyInterface::input_type_t inputType; Mutex::Autolock _l(mLock); // the audio_in_acoustics_t parameter is ignored by get_input() status = mAudioPolicyManager->getInputForAttr(attr, input, session, uid, Loading
services/soundtrigger/SoundTriggerHwService.cpp +14 −7 Original line number Diff line number Diff line Loading @@ -89,7 +89,8 @@ status_t SoundTriggerHwService::listModules(struct sound_trigger_module_descript uint32_t *numModules) { ALOGV("listModules"); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -110,7 +111,8 @@ status_t SoundTriggerHwService::attach(const sound_trigger_module_handle_t handl sp<ISoundTrigger>& moduleInterface) { ALOGV("attach module %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading Loading @@ -942,7 +944,8 @@ status_t SoundTriggerHwService::ModuleClient::dump(int fd __unused, void SoundTriggerHwService::ModuleClient::detach() { ALOGV("detach()"); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return; } Loading @@ -965,7 +968,8 @@ status_t SoundTriggerHwService::ModuleClient::loadSoundModel(const sp<IMemory>& sound_model_handle_t *handle) { ALOGV("loadSoundModel() handle"); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -979,7 +983,8 @@ status_t SoundTriggerHwService::ModuleClient::loadSoundModel(const sp<IMemory>& status_t SoundTriggerHwService::ModuleClient::unloadSoundModel(sound_model_handle_t handle) { ALOGV("unloadSoundModel() model handle %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -994,7 +999,8 @@ status_t SoundTriggerHwService::ModuleClient::startRecognition(sound_model_handl const sp<IMemory>& dataMemory) { ALOGV("startRecognition() model handle %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading @@ -1008,7 +1014,8 @@ status_t SoundTriggerHwService::ModuleClient::startRecognition(sound_model_handl status_t SoundTriggerHwService::ModuleClient::stopRecognition(sound_model_handle_t handle) { ALOGV("stopRecognition() model handle %d", handle); if (!captureHotwordAllowed()) { if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(), IPCThreadState::self()->getCallingUid())) { return PERMISSION_DENIED; } Loading