memtrack: Make memtrack HAL compatible for HIDL passthrough mode.

Change-Id: I965972b936f2098c2e692afa4db8743355140a2c
This commit is contained in:
followmsi 2018-09-21 14:20:02 +02:00
parent 0d7b20f64c
commit 1f764fdd5b
1 changed files with 42 additions and 11 deletions

View File

@ -15,6 +15,7 @@
*/
#include <errno.h>
#include <log/log.h>
#include <hardware/memtrack.h>
@ -38,22 +39,52 @@ int msm_memtrack_get_memory(const struct memtrack_module *module,
return -EINVAL;
}
static int memtrack_open(const hw_module_t* module, const char* name,
hw_device_t** device)
{
ALOGD("%s: enter; name=%s", __FUNCTION__, name);
int retval = 0; /* 0 is ok; -1 is error */
if (strcmp(name, "memtrack") == 0) {
struct memtrack_module *dev = (struct memtrack_module *)calloc(1,
sizeof(struct memtrack_module));
if (dev) {
/* Common hw_device_t fields */
dev->common.tag = HARDWARE_DEVICE_TAG;
dev->common.module_api_version = MEMTRACK_MODULE_API_VERSION_0_1;
dev->common.module_api_version = HARDWARE_HAL_API_VERSION;
dev->init = msm_memtrack_init;
dev->getMemory = msm_memtrack_get_memory;
*device = (hw_device_t*)dev;
} else
retval = -ENOMEM;
} else {
retval = -EINVAL;
}
ALOGD("%s: exit %d", __FUNCTION__, retval);
return retval;
}
static struct hw_module_methods_t memtrack_module_methods = {
.open = NULL,
.open = memtrack_open,
};
struct memtrack_module HAL_MODULE_INFO_SYM = {
common: {
tag: HARDWARE_MODULE_TAG,
module_api_version: MEMTRACK_MODULE_API_VERSION_0_1,
hal_api_version: HARDWARE_HAL_API_VERSION,
id: MEMTRACK_HARDWARE_MODULE_ID,
name: "MSM Memory Tracker HAL",
author: "The Android Open Source Project",
methods: &memtrack_module_methods,
.common = {
.tag = HARDWARE_MODULE_TAG,
.module_api_version = MEMTRACK_MODULE_API_VERSION_0_1,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = MEMTRACK_HARDWARE_MODULE_ID,
.name = "MSM Memory Tracker HAL",
.author = "The Android Open Source Project",
.methods = &memtrack_module_methods,
},
init: msm_memtrack_init,
getMemory: msm_memtrack_get_memory,
.init = msm_memtrack_init,
.getMemory = msm_memtrack_get_memory,
};