soundtrigger: require RECORD_AUDIO permission for DSP hotword
Check android.permission.RECORD_AUDIO permission in addition to
android.permission.CAPTURE_AUDIO_HOTWORD for DSP hotword operations
as those require access to device microphone.
Bug: 62265680
Test: check "OK Google" detection with and without DSP
Change-Id: Icba2520331164bcd618e91916ca701e677d419b8
diff --git a/services/soundtrigger/SoundTriggerHwService.cpp b/services/soundtrigger/SoundTriggerHwService.cpp
index 5b8d990..8891aba 100644
--- a/services/soundtrigger/SoundTriggerHwService.cpp
+++ b/services/soundtrigger/SoundTriggerHwService.cpp
@@ -89,7 +89,8 @@
uint32_t *numModules)
{
ALOGV("listModules");
- if (!captureHotwordAllowed()) {
+ if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(),
+ IPCThreadState::self()->getCallingUid())) {
return PERMISSION_DENIED;
}
@@ -110,7 +111,8 @@
sp<ISoundTrigger>& moduleInterface)
{
ALOGV("attach module %d", handle);
- if (!captureHotwordAllowed()) {
+ if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(),
+ IPCThreadState::self()->getCallingUid())) {
return PERMISSION_DENIED;
}
@@ -942,7 +944,8 @@
void SoundTriggerHwService::ModuleClient::detach() {
ALOGV("detach()");
- if (!captureHotwordAllowed()) {
+ if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(),
+ IPCThreadState::self()->getCallingUid())) {
return;
}
@@ -965,7 +968,8 @@
sound_model_handle_t *handle)
{
ALOGV("loadSoundModel() handle");
- if (!captureHotwordAllowed()) {
+ if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(),
+ IPCThreadState::self()->getCallingUid())) {
return PERMISSION_DENIED;
}
@@ -979,7 +983,8 @@
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;
}
@@ -994,7 +999,8 @@
const sp<IMemory>& dataMemory)
{
ALOGV("startRecognition() model handle %d", handle);
- if (!captureHotwordAllowed()) {
+ if (!captureHotwordAllowed(IPCThreadState::self()->getCallingPid(),
+ IPCThreadState::self()->getCallingUid())) {
return PERMISSION_DENIED;
}
@@ -1008,7 +1014,8 @@
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;
}