HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
Chaining HALs ABS 2015 PRELIMINARY HY Research LLC - - PowerPoint PPT Presentation
Chaining HALs ABS 2015 PRELIMINARY HY Research LLC http://www.hy-research.com/ Mar 15, 2015 (C) 2015 HY Research LLC Agenda * Introduction - Why chain a HAL? * Android HAL basics * Overview of chaining a HAL * HAL loader * Exampling:
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
err = hw_get_module(SENSORS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
static struct hw_module_methods_t chain_sensors_module_methods = {
}; struct sensors_module_t HAL_MODULE_INFO_SYM = { common: { tag: HARDWARE_MODULE_TAG, version_major: 1, version_minor: 0, id: SENSORS_HARDWARE_MODULE_ID, name: "Sensor module", author: "HY Research LLC", methods: &chain_sensors_module_methods, }, get_sensors_list: chain_sensors__get_sensors_list, };
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
static int chain_open_sensors(const struct hw_module_t* module, const char* id, struct hw_device_t** device) { [Declarations removed/error handlign removed.] ... const char *sym = HAL_MODULE_INFO_SYM_AS_STR; snprintf(old_sensorHAL_path, 2048, "%s/sensors.old.so", "/system/lib/hw"); handle = dlopen(old_sensorHAL_path, RTLD_NOW); ...
... if (strcmp(SENSORS_HARDWARE_MODULE_ID, old_hmi->common.id) != 0) { dlclose(handle); return -EINVAL; } ChainHALinfo.old_handle = handle; ChainHALinfo.get_sensors_list = old_hmi->get_sensors_list;
ChainHALinfo.old_poll = old_device->poll;
return old_status; }
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
static int chain_poll__poll(struct sensors_poll_device_t *dev, sensors_event_t* data, int count) { int old_ret; int i; /* Acquire data */
/* Modify data if needed */ if (old_ret > 0) { /* There is data! */ for (i = 0; i < old_ret; i++) { if (data[i].type == SENSOR_TYPE_ACCELEROMETER) { data[i].data[0] = -data[i].data[0]; data[i].data[1] = -data[i].data[1]; data[i].data[2] = -data[i].data[2]; } } } return old_ret; }
HY Research LLC
http://www.hy-research.com/
(C) 2015 HY Research LLC Mar 15, 2015
HY Research LLC
http://www.hy-research.com/
(C) 2013 HY Research LLC Feb 11, 2013