summaryrefslogtreecommitdiffstats
path: root/soundtrigger
diff options
context:
space:
mode:
authorjiabin <jiabin@google.com>2019-03-18 17:55:35 -0700
committerjiabin <jiabin@google.com>2019-04-02 17:31:42 -0700
commit68e0df70cdd57dbe32f11b5de50dd83c6492d075 (patch)
tree487ed1ea1849844493c436ccde9d432724fd652f /soundtrigger
parent63dc6cf50582fa13702c59f43155f6c18312178b (diff)
downloadframeworks_av-68e0df70cdd57dbe32f11b5de50dd83c6492d075.tar.gz
frameworks_av-68e0df70cdd57dbe32f11b5de50dd83c6492d075.tar.bz2
frameworks_av-68e0df70cdd57dbe32f11b5de50dd83c6492d075.zip
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
Diffstat (limited to 'soundtrigger')
-rw-r--r--soundtrigger/ISoundTriggerHwService.cpp22
-rw-r--r--soundtrigger/SoundTrigger.cpp15
2 files changed, 27 insertions, 10 deletions
diff --git a/soundtrigger/ISoundTriggerHwService.cpp b/soundtrigger/ISoundTriggerHwService.cpp
index d44f5cb3b1..bd107b4e87 100644
--- a/soundtrigger/ISoundTriggerHwService.cpp
+++ b/soundtrigger/ISoundTriggerHwService.cpp
@@ -50,7 +50,8 @@ public:
{
}
- 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 @@ public:
}
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 @@ public:
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 @@ status_t BnSoundTriggerHwService::onTransact(
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 @@ status_t BnSoundTriggerHwService::onTransact(
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 @@ status_t BnSoundTriggerHwService::onTransact(
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);
diff --git a/soundtrigger/SoundTrigger.cpp b/soundtrigger/SoundTrigger.cpp
index d1eb367763..9708ea726f 100644
--- a/soundtrigger/SoundTrigger.cpp
+++ b/soundtrigger/SoundTrigger.cpp
@@ -80,19 +80,21 @@ const sp<ISoundTriggerHwService> SoundTrigger::getSoundTriggerHwService()
}
// Static methods
-status_t SoundTrigger::listModules(struct sound_trigger_module_descriptor *modules,
- uint32_t *numModules)
+status_t SoundTrigger::listModules(const String16& opPackageName,
+ struct sound_trigger_module_descriptor *modules,
+ uint32_t *numModules)
{
ALOGV("listModules()");
const sp<ISoundTriggerHwService> service = getSoundTriggerHwService();
if (service == 0) {
return NO_INIT;
}
- return service->listModules(modules, numModules);
+ return service->listModules(opPackageName, modules, numModules);
}
-sp<SoundTrigger> SoundTrigger::attach(const sound_trigger_module_handle_t module,
- const sp<SoundTriggerCallback>& callback)
+sp<SoundTrigger> SoundTrigger::attach(const String16& opPackageName,
+ const sound_trigger_module_handle_t module,
+ const sp<SoundTriggerCallback>& callback)
{
ALOGV("attach()");
sp<SoundTrigger> soundTrigger;
@@ -101,7 +103,8 @@ sp<SoundTrigger> SoundTrigger::attach(const sound_trigger_module_handle_t module
return soundTrigger;
}
soundTrigger = new SoundTrigger(module, callback);
- status_t status = service->attach(module, soundTrigger, soundTrigger->mISoundTrigger);
+ status_t status = service->attach(opPackageName, module, soundTrigger,
+ soundTrigger->mISoundTrigger);
if (status == NO_ERROR && soundTrigger->mISoundTrigger != 0) {
IInterface::asBinder(soundTrigger->mISoundTrigger)->linkToDeath(soundTrigger);