Android的GPS的代码分析(一)
来源:互联网 发布:linux 多线程下载 编辑:程序博客网 时间:2024/05/23 19:16
这里主要是用来被App调用的,API包是android.location。
这个目录是Framework对Location服务的内部实现。
这个目录只有一个文件
是Location服务对内部实现的一种封装。
JNI:
frameworks/base/core/jni/android_location_GpsLocationProvider.cpp
JNI层只有一个文件,起到承上启下的作用。上层承接Framework,下层调用HAL层具体硬件抽象实现。
HAL: Hardware Abstract Layer 硬件抽象层
hardware/libhardware_legacy/gps
hardware/libhardware_legacy/include/hardware_legacy/gps.h
HAL层相当于一个linux应用程序接口,通过open,close等操作,操作硬件设备。Android的源代码只实现了模拟器的gps接口,具体在文件gps_qemu.c中。在2.2版本中提供了对QCOM公司的gps的实现,在以下目录:
/hardware/qcom
/** Represents the standard GPS interface. */
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, floataccuracy) ;
/**
* 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;
2. GpsCallbacks回调函数
这个是回调函数结构体,定义也在 gps.h 中。 它们的实现是在 android_location_GpsLocationProvider.cpp 中,google已经实现了,我们不需要做任何动作。
/** GPS callback structure. */
typedef struct {
gps_location_callback location_cb;
gps_status_callback status_cb;
gps_sv_status_callback sv_status_cb;
gps_nmea_callback nmea_cb;
} GpsCallbacks;
/** 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) ;
/** Callback for reporting NMEA sentences. */
typedef void ( * gps_nmea_callback) ( GpsUtcTime timestamp, const char * nmea,int length) ;
3. GpsLocation
表示Locatin数据信息,底层驱动获得Location的raw信息,通常是nmea码,然后通过解析就得到了location信息。
/** Represents a location. */
typedef struct {
/** Contains GpsLocationFlags bits. */
uint16_t flags;
/** Represents latitude in degrees. */
double latitude;
/** Represents longitude in degrees. */
double longitude;
/** Represents altitude in meters above the WGS 84 reference
* ellipsoid. */
double altitude;
/** Represents speed in meters per second. */
float speed;
/** Represents heading in degrees. */
float bearing;
/** Represents expected accuracy in meters. */
float accuracy;
/** Timestamp for the location fix. */
GpsUtcTime timestamp;
} GpsLocation;
这是从大体上来解析gps的架构,下面就让我们看看各个模块的解析。。。。。。。。。
- Android的GPS的代码分析(一)
- Android的GPS的代码分析(一)
- Android的GPS的代码分析(二)
- Android的GPS的代码分析(三)
- Android的gps的代码分析(四)
- Android的GPS的代码分析(五)
- Android的GPS的代码分析(二)
- Android的GPS的代码分析(三)
- Android的gps的代码分析(四)
- Android的GPS的代码分析(五)
- Android GPS架构分析(一)
- Android GPS架构分析(一)
- Android系统Gps分析(一)
- Android GPS架构分析(转载一)
- Android系统Gps分析(一)
- Android系统Gps分析(一)
- Android系统Gps分析(一)
- Android系统Gps分析(一)
- getSession(true)和getSession(false)的区别介绍
- C# 如何实现热键注册 RegisterHotKey
- oracle sql日期比较
- 企业Windows服务器备份和灾难恢复案例
- SSH Secure Shell Client 远程,vim 显示语法高亮
- Android的GPS的代码分析(一)
- 设计语十一 五个设计技巧
- ubuntu下安装source insight
- ViewFilpper、Gesture 实现图片左右滑动切换
- JavaBean注意问题
- Sales Order 中的User Exit开发
- Sales Order 中的User Exit开发
- 基于DirectFB1.4.12的简单编程与调试
- validationEngine中文版 — jquery强大的表单验证插件