有关Android HAL及相关Android GPS的介绍,网上很多,我这里就不在复制粘贴了,呵呵。 笔者是在hardware/libhardware/modules/添加了gps目录。
1. 修改hardware/libhardware/Android.mk - modules/gralloc \ + modules/gralloc modules/gps \ tests \
2. gps/gps_xxxx.c
(1) 必须包含下面两个头文件 #include <hardware/hardware.h> #include <hardware/gps.h>
(2) 一些重要的结构体 struct gps_context_t { struct gps_device_t device; // our private state goes below here };
struct gps_module_t { struct hw_module_t common; };
static struct hw_module_methods_t gps_module_methods = { open: gps_device_open };
struct gps_module_t HAL_MODULE_INFO_SYM = { common: { tag: HARDWARE_MODULE_TAG, version_major: 1, version_minor: 0, id: GPS_HARDWARE_MODULE_ID, name: "GPS hardware module", author: "Shrek" methods: &gps_module_methods, } };
(3) 一些重要的函数 static const GpsInterface *gps_get_interface(); static int gps_device_open(const struct hw_module_t *module, const char *name struct hw_device_t **device);
static const GpsInterface xxxxGpsInterface = { |