天刀猎户怎么自己繁殖:android GPS 应用
来源:百度文库 编辑:中财网 时间:2024/05/03 05:57:48
HAL introdution:
HAL(hardware abstraction layer)存在的目的在与让android framework与linux device driver分离开来.上层应用通过Dalvik VM与core services【runtime】(如sensor service,camera service等)来加载动态库文件(*.so),这里的so文件指的是HAL的实现,core service通过JNI接口调用HAL层提供的接口,这样就实现了android 应用程序对硬件的操作。
在Android源码中,HAL的主要实现位于hardware/目录下,老的实现版本和新的实现版本并存,老的HAL实现是通过JNI层直接加载动态链接库的方式,如下图所示:
图引用自: http://www.jollen.org/blog/
新的HAL实现仍然是以加载动态链接库的方式来与linux device driver通信,不过libhardware屏蔽了具体的加载细节,每种应用以HAL stub的概念呈现给JNI层,一个HAL stub编译成一个动态链接库文件,结构如下图所示:
图引用自: http://www.jollen.org/blog/
移植一个新的HAL实现需要开发人员编写HAL module(stub),上层应用通过libhardware获取HAL module的一系列回调函数(callback ops),这一系列回调函数直接与底层的linux device driver通信(一般是通过读写设备文件来实现的)。
目前,HAL对上层还不能完全做到与硬件无关,往往厂家添加自己的硬件设备需要改动相应的runtime(service)实现,android手机一般情况下需要的实现的HAL功能有:
Camera
GPS
RIL
WLAN
BlueTooth
Sensor
vibrator等
GPS的HAL 实现:
在这里探讨的GPS HAL实例采用的是老的HAL实现方式,主要的实现代码位置:frameworks/base/location/* (client)
frameworks/base/core/jni/android_location_GpsLocationProvider.cpp (JNI )
frameworks/base/services/java/com/android/serverLocationManagerService .java(service)
hardware/libhardware_legacy/gps/* (HAL)
首先介绍几个重要的数据结构:/** Callback with location information. */
typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. */
typedef void (* gps_status_callback)(GpsStatus* status); /** Callback with SV status information. */
typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** GPS callback structure. */
typedef struct {
gps_location_callback location_cb;
gps_status_callback status_cb;
gps_sv_status_callback sv_status_cb;
} GpsCallbacks; /*GPS 接口*/
typedef struct {
/**
* Opens the interface and provides the callback routines
* to the implemenation of this interface.
*/
int ( * init) ( GpsCallbacks* callbacks ) ; /** Starts navigating. */
int ( * start) ( void ) ; /** Stops navigating. */
int ( * stop) ( void ) ; /** Closes the interface. */
void ( * cleanup) ( void ) ; /** Injects the current time. */
int ( * inject_time) ( GpsUtcTime time , int64_t timeReference,
int uncertainty) ; /** Injects current location from another location provider
* (typically cell ID).
* latitude and longitude are measured in degrees
* expected accuracy is measured in meters
*/
int ( * inject_location) ( double latitude, double longitude, float accuracy) ; /**
* Specifies that the next call to start will not use the
* information defined in the flags. GPS_DELETE_ALL is passed for
* a cold start.
*/
void ( * delete_aiding_data) ( GpsAidingData flags) ; /**
* fix_frequency represents the time between fixes in seconds.
* Set fix_frequency to zero for a single-shot fix.
*/
int ( * set_position_mode) ( GpsPositionMode mode, int fix_frequency) ; /** Get a pointer to extension information. */
const void * ( * get_extension) ( const char * name) ;
} GpsInterface;
GPS 的HAL 实现主要工作就是填充一个 GpsInterface结构,android应用启动 LOCATION_SERVICE时,将检测系统是否支持GPS应用,若支持GPS,则在JNI层初始化GPS设备时将返回一个 GpsInterface结构,然后通过JNI层的回调函数将GPS信息发送给framework层,调用过程如下所示:
在GpsInterface->Start后,启用读线程通过epoll检测GPS设备文件的状态,若受到数据则读取NEMA数据,将数据解析后,根据解析后的数据填充GpsStatus, GpsLocation和GpsSvInfo结构,然后调用相应的JNI层在Init时传进来的回调函数,service部分的代码将自动更新GPS信息。
HAL(hardware abstraction layer)存在的目的在与让android framework与linux device driver分离开来.上层应用通过Dalvik VM与core services【runtime】(如sensor service,camera service等)来加载动态库文件(*.so),这里的so文件指的是HAL的实现,core service通过JNI接口调用HAL层提供的接口,这样就实现了android 应用程序对硬件的操作。
在Android源码中,HAL的主要实现位于hardware/目录下,老的实现版本和新的实现版本并存,老的HAL实现是通过JNI层直接加载动态链接库的方式,如下图所示:
图引用自: http://www.jollen.org/blog/
新的HAL实现仍然是以加载动态链接库的方式来与linux device driver通信,不过libhardware屏蔽了具体的加载细节,每种应用以HAL stub的概念呈现给JNI层,一个HAL stub编译成一个动态链接库文件,结构如下图所示:
图引用自: http://www.jollen.org/blog/
移植一个新的HAL实现需要开发人员编写HAL module(stub),上层应用通过libhardware获取HAL module的一系列回调函数(callback ops),这一系列回调函数直接与底层的linux device driver通信(一般是通过读写设备文件来实现的)。
目前,HAL对上层还不能完全做到与硬件无关,往往厂家添加自己的硬件设备需要改动相应的runtime(service)实现,android手机一般情况下需要的实现的HAL功能有:
Camera
GPS
RIL
WLAN
BlueTooth
Sensor
vibrator等
GPS的HAL 实现:
在这里探讨的GPS HAL实例采用的是老的HAL实现方式,主要的实现代码位置:frameworks/base/location/* (client)
frameworks/base/core/jni/android_location_GpsLocationProvider.cpp (JNI )
frameworks/base/services/java/com/android/serverLocationManagerService .java(service)
hardware/libhardware_legacy/gps/* (HAL)
首先介绍几个重要的数据结构:/** Callback with location information. */
typedef void (* gps_location_callback)(GpsLocation* location); /** Callback with status information. */
typedef void (* gps_status_callback)(GpsStatus* status); /** Callback with SV status information. */
typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info); /** GPS callback structure. */
typedef struct {
gps_location_callback location_cb;
gps_status_callback status_cb;
gps_sv_status_callback sv_status_cb;
} GpsCallbacks; /*GPS 接口*/
typedef struct {
/**
* Opens the interface and provides the callback routines
* to the implemenation of this interface.
*/
int ( * init) ( GpsCallbacks* callbacks ) ; /** Starts navigating. */
int ( * start) ( void ) ; /** Stops navigating. */
int ( * stop) ( void ) ; /** Closes the interface. */
void ( * cleanup) ( void ) ; /** Injects the current time. */
int ( * inject_time) ( GpsUtcTime time , int64_t timeReference,
int uncertainty) ; /** Injects current location from another location provider
* (typically cell ID).
* latitude and longitude are measured in degrees
* expected accuracy is measured in meters
*/
int ( * inject_location) ( double latitude, double longitude, float accuracy) ; /**
* Specifies that the next call to start will not use the
* information defined in the flags. GPS_DELETE_ALL is passed for
* a cold start.
*/
void ( * delete_aiding_data) ( GpsAidingData flags) ; /**
* fix_frequency represents the time between fixes in seconds.
* Set fix_frequency to zero for a single-shot fix.
*/
int ( * set_position_mode) ( GpsPositionMode mode, int fix_frequency) ; /** Get a pointer to extension information. */
const void * ( * get_extension) ( const char * name) ;
} GpsInterface;
GPS 的HAL 实现主要工作就是填充一个 GpsInterface结构,android应用启动 LOCATION_SERVICE时,将检测系统是否支持GPS应用,若支持GPS,则在JNI层初始化GPS设备时将返回一个 GpsInterface结构,然后通过JNI层的回调函数将GPS信息发送给framework层,调用过程如下所示:
在GpsInterface->Start后,启用读线程通过epoll检测GPS设备文件的状态,若受到数据则读取NEMA数据,将数据解析后,根据解析后的数据填充GpsStatus, GpsLocation和GpsSvInfo结构,然后调用相应的JNI层在Init时传进来的回调函数,service部分的代码将自动更新GPS信息。
GPS应用基础
GPS技术应用的最新进展
GPS技术应用的最新进展
GPS在物流中的应用
paranoid android中文歌词
求论文 GPS全球定位系统在移动监控中的应用
GPS、GIS、GSM网络协同工作的应用前景如何?
radiohead 的 Paranoid Android 中文翻译
GPS定位系统在电子商务专业中有何应用,如果理解。
GPS系统在未来的应用 要求:不能符合实际,搞笑优先(作业)
求两篇关于"GPS技术二次开发及应用"的论文
关于98洪水GPS在清江隔河岩应用的专题片在哪里可以找到?好像中央电视台播放过。
gps是什么?
什么是gps?
什么是GPS
什么是gps
GPS是什么
什么是GPS
GPS是什么意思
GPS是什么
GPS电子地图
笔记本GPS
GPS导航?
什么是GPS