Use package name, pid, uid to check permission of capturing hotword.
Package name will be cached in ModuleClient when attaching a client. It
will be used when querying permission of capturing hotword.
Test: test with logging.
Bug: 74078996
Bug: 122721589
Change-Id: Icd2911f5d331d243c9eb5d58003ce5525c70c81e
diff --git a/soundtrigger/ISoundTriggerHwService.cpp b/soundtrigger/ISoundTriggerHwService.cpp
index d44f5cb..bd107b4 100644
--- a/soundtrigger/ISoundTriggerHwService.cpp
+++ b/soundtrigger/ISoundTriggerHwService.cpp
@@ -50,7 +50,8 @@
{
}
- virtual status_t listModules(struct sound_trigger_module_descriptor *modules,
+ virtual status_t listModules(const String16& opPackageName,
+ struct sound_trigger_module_descriptor *modules,
uint32_t *numModules)
{
if (numModules == NULL || (*numModules != 0 && modules == NULL)) {
@@ -58,6 +59,7 @@
}
Parcel data, reply;
data.writeInterfaceToken(ISoundTriggerHwService::getInterfaceDescriptor());
+ data.writeString16(opPackageName);
unsigned int numModulesReq = (modules == NULL) ? 0 : *numModules;
data.writeInt32(numModulesReq);
status_t status = remote()->transact(LIST_MODULES, data, &reply);
@@ -77,12 +79,14 @@
return status;
}
- virtual status_t attach(const sound_trigger_module_handle_t handle,
+ virtual status_t attach(const String16& opPackageName,
+ const sound_trigger_module_handle_t handle,
const sp<ISoundTriggerClient>& client,
sp<ISoundTrigger>& module)
{
Parcel data, reply;
data.writeInterfaceToken(ISoundTriggerHwService::getInterfaceDescriptor());
+ data.writeString16(opPackageName);
data.write(&handle, sizeof(sound_trigger_module_handle_t));
data.writeStrongBinder(IInterface::asBinder(client));
status_t status = remote()->transact(ATTACH, data, &reply);
@@ -120,6 +124,11 @@
switch(code) {
case LIST_MODULES: {
CHECK_INTERFACE(ISoundTriggerHwService, data, reply);
+ String16 opPackageName;
+ status_t status = data.readString16(&opPackageName);
+ if (status != NO_ERROR) {
+ return status;
+ }
unsigned int numModulesReq = data.readInt32();
if (numModulesReq > MAX_ITEMS_PER_LIST) {
numModulesReq = MAX_ITEMS_PER_LIST;
@@ -133,7 +142,7 @@
reply->writeInt32(0);
return NO_ERROR;
}
- status_t status = listModules(modules, &numModules);
+ status = listModules(opPackageName, modules, &numModules);
reply->writeInt32(status);
reply->writeInt32(numModules);
ALOGV("LIST_MODULES status %d got numModules %d", status, numModules);
@@ -151,12 +160,17 @@
case ATTACH: {
CHECK_INTERFACE(ISoundTriggerHwService, data, reply);
+ String16 opPackageName;
+ status_t status = data.readString16(&opPackageName);
+ if (status != NO_ERROR) {
+ return status;
+ }
sound_trigger_module_handle_t handle;
data.read(&handle, sizeof(sound_trigger_module_handle_t));
sp<ISoundTriggerClient> client =
interface_cast<ISoundTriggerClient>(data.readStrongBinder());
sp<ISoundTrigger> module;
- status_t status = attach(handle, client, module);
+ status = attach(opPackageName, handle, client, module);
reply->writeInt32(status);
if (module != 0) {
reply->writeInt32(1);