Android系统Gps分析.docx

上传人:b****4 文档编号:3737602 上传时间:2022-11-25 格式:DOCX 页数:57 大小:71.53KB
下载 相关 举报
Android系统Gps分析.docx_第1页
第1页 / 共57页
Android系统Gps分析.docx_第2页
第2页 / 共57页
Android系统Gps分析.docx_第3页
第3页 / 共57页
Android系统Gps分析.docx_第4页
第4页 / 共57页
Android系统Gps分析.docx_第5页
第5页 / 共57页
点击查看更多>>
下载资源
资源描述

Android系统Gps分析.docx

《Android系统Gps分析.docx》由会员分享,可在线阅读,更多相关《Android系统Gps分析.docx(57页珍藏版)》请在冰豆网上搜索。

Android系统Gps分析.docx

Android系统Gps分析

Android系统Gps分析

1.

2.GPS架构

3.GPS分析

1.头文件

2.硬件适配层

3.JNI适配层

4.JavaFramework

1.接口和类简介

2.使用Gps编程接口

3.接口和类分析

4.参考文章

1GPS架构

2GPS分析

2.1头文件

头文件定义在:

hardware/libhardware/include/hardware/gps.h,定义了GPS底层相关的结构体和接口

∙GpsLocation

GPS位置信息结构体,包含经纬度,高度,速度,方位角等。

/** Flags to indicate which values are valid in a GpsLocation. */  

typedef uint16_t GpsLocationFlags;  

// IMPORTANT:

 Note that the following values must match  

// constants in GpsLocationProvider.java.  

/** GpsLocation has valid latitude and longitude. */  

#define GPS_LOCATION_HAS_LAT_LONG   0x0001  

/** GpsLocation has valid altitude. */  

#define GPS_LOCATION_HAS_ALTITUDE   0x0002  

/** GpsLocation has valid speed. */  

#define GPS_LOCATION_HAS_SPEED      0x0004  

/** GpsLocation has valid bearing. */  

#define GPS_LOCATION_HAS_BEARING    0x0008  

/** GpsLocation has valid accuracy. */  

#define GPS_LOCATION_HAS_ACCURACY   0x0010  

  

/** Represents a location. */  

typedef struct {  

    /** set to sizeof(GpsLocation) */  

    size_t          size;  

    /** 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;  

/**FlagstoindicatewhichvaluesarevalidinaGpsLocation.*/

typedefuint16_tGpsLocationFlags;

//IMPORTANT:

Notethatthefollowingvaluesmustmatch

//constantsinGpsLocationProvider.java.

/**GpsLocationhasvalidlatitudeandlongitude.*/

#defineGPS_LOCATION_HAS_LAT_LONG0x0001

/**GpsLocationhasvalidaltitude.*/

#defineGPS_LOCATION_HAS_ALTITUDE0x0002

/**GpsLocationhasvalidspeed.*/

#defineGPS_LOCATION_HAS_SPEED0x0004

/**GpsLocationhasvalidbearing.*/

#defineGPS_LOCATION_HAS_BEARING0x0008

/**GpsLocationhasvalidaccuracy.*/

#defineGPS_LOCATION_HAS_ACCURACY0x0010

/**Representsalocation.*/

typedefstruct{

/**settosizeof(GpsLocation)*/

size_tsize;

/**ContainsGpsLocationFlagsbits.*/

uint16_tflags;

/**Representslatitudeindegrees.*/

doublelatitude;

/**Representslongitudeindegrees.*/

doublelongitude;

/**RepresentsaltitudeinmetersabovetheWGS84reference

*ellipsoid.*/

doublealtitude;

/**Representsspeedinmeterspersecond.*/

floatspeed;

/**Representsheadingindegrees.*/

floatbearing;

/**Representsexpectedaccuracyinmeters.*/

floataccuracy;

/**Timestampforthelocationfix.*/

GpsUtcTimetimestamp;

}GpsLocation;

∙GpsStatus

GPS状态包括5种状态,分别为未知,正在定位,停止定位,启动未定义,未启动。

/** GPS status event values. */  

typedef uint16_t GpsStatusValue;  

// IMPORTANT:

 Note that the following values must match  

// constants in GpsLocationProvider.java.  

/** GPS status unknown. */  

#define GPS_STATUS_NONE             0  

/** GPS has begun navigating. */  

#define GPS_STATUS_SESSION_BEGIN    1  

/** GPS has stopped navigating. */  

#define GPS_STATUS_SESSION_END      2  

/** GPS has powered on but is not navigating. */  

#define GPS_STATUS_ENGINE_ON        3  

/** GPS is powered off. */AgpsCallbacks  

  

AgpsInterface  

#define GPS_STATUS_ENGINE_OFF       4  

  

/** Represents the status. */  

typedef struct {  

    /** set to sizeof(GpsStatus) */  

    size_t          size;  

    GpsStatusValue status;  

} GpsStatus;  

/**GPSstatuseventvalues.*/

typedefuint16_tGpsStatusValue;

//IMPORTANT:

Notethatthefollowingvaluesmustmatch

//constantsinGpsLocationProvider.java.

/**GPSstatusunknown.*/

#defineGPS_STATUS_NONE0

/**GPShasbegunnavigating.*/

#defineGPS_STATUS_SESSION_BEGIN1

/**GPShasstoppednavigating.*/

#defineGPS_STATUS_SESSION_END2

/**GPShaspoweredonbutisnotnavigating.*/

#defineGPS_STATUS_ENGINE_ON3

/**GPSispoweredoff.*/AgpsCallbacks

AgpsInterface

#defineGPS_STATUS_ENGINE_OFF4

/**Representsthestatus.*/

typedefstruct{

/**settosizeof(GpsStatus)*/

size_tsize;

GpsStatusValuestatus;

}GpsStatus;

∙GpsSvInfo

GPS卫星信息,包含卫星编号,信号强度,卫星仰望角,方位角等。

/** Represents SV information. */  

typedef struct {  

    /** set to sizeof(GpsSvInfo) */  

    size_t          size;  

    /** Pseudo-random number for the SV. */  

    int     prn;  

    /** Signal to noise ratio. */  

    float   snr;  

    /** Elevation of SV in degrees. */  

    float   elevation;  

    /** Azimuth of SV in degrees. */  

    float   azimuth;  

} GpsSvInfo;  

/**RepresentsSVinformation.*/

typedefstruct{

/**settosizeof(GpsSvInfo)*/

size_tsize;

/**Pseudo-randomnumberfortheSV.*/

intprn;

/**Signaltonoiseratio.*/

floatsnr;

/**ElevationofSVindegrees.*/

floatelevation;

/**AzimuthofSVindegrees.*/

floatazimuth;

}GpsSvInfo;

∙GpsSvStatus

GPS卫星状态,包含可见卫星数和信息,星历时间,年历时间等。

/** Represents SV status. */  

typedef struct {  

    /** set to sizeof(GpsSvStatus) */  

    size_t          size;  

  

    /** Number of SVs currently visible. */  

    int         num_svs;  

  

    /** Contains an array of SV information. */  

    GpsSvInfo   sv_list[GPS_MAX_SVS];  

  

    /** Represents a bit mask indicating which SVs 

     * have ephemeris data. 

     */  

    uint32_t    ephemeris_mask;  

  

    /** Represents a bit mask indicating which SVs 

     * have almanac data. 

     */  

    uint32_t    almanac_mask;  

  

    /** 

     * Represents a bit mask indicating which SVs 

     * were used for computing the most recent position fix. 

     */  

    uint32_t    used_in_fix_mask;  

} GpsSvStatus;  

/**RepresentsSVstatus.*/

typedefstruct{

/**settosizeof(GpsSvStatus)*/

size_tsize;

/**NumberofSVscurrentlyvisible.*/

intnum_svs;

/**ContainsanarrayofSVinformation.*/

GpsSvInfosv_list[GPS_MAX_SVS];

/**RepresentsabitmaskindicatingwhichSVs

*haveephemerisdata.

*/

uint32_tephemeris_mask;

/**RepresentsabitmaskindicatingwhichSVs

*havealmanacdata.

*/

uint32_talmanac_mask;

/**

*RepresentsabitmaskindicatingwhichSVs

*wereusedforcomputingthemostrecentpositionfix.

*/

uint32_tused_in_fix_mask;

}GpsSvStatus;

∙GpsCallbacks

回调函数定义

/** Callback with location information. 向上层传递GPS位置信息 

 *  Can only be called from a thread created by create_thread_cb. 

 */  

typedef void (* gps_location_callback)(GpsLocation* location);  

  

/** Callback with status information. 向上层传递GPS状态信息 

 *  Can only be called from a thread created by create_thread_cb. 

 */  

typedef void (* gps_status_callback)(GpsStatus* status);  

  

/** Callback with SV status information. 向上层传递GPS卫星信息 

 *  Can only be called from a thread created by create_thread_cb. 

 */  

typedef void (* gps_sv_status_callback)(GpsSvStatus* sv_info);  

  

/** Callback for reporting NMEA sentences. 向上层传递MEMA数据 

 *  Can only be called from a thread created by create_thread_cb. 

 */  

typedef void (* gps_nmea_callback)(GpsUtcTime timestamp, const char* nmea, int length);  

  

/** Callback to inform framework of the GPS engine's capabilities.告知GPS模块可以实现的功能 

 *  Capability parameter is a bit field of GPS_CAPABILITY_* flags. 

 */  

typedef void (* gps_set_capabilities)(uint32_t capabilities);  

  

/** Callback utility for acquiring the GPS wakelock.上锁,防止处理GPS事件时中止。

 

 *  This can be used to prevent the CPU from suspending while handling GPS events. 

 */  

typedef void (* gps_acquire_wakelock)();  

  

/** Callback utility for releasing the GPS wakelock. */释放锁  

typedef void (* gps_release_wakelock)();  

  

/** Callback for creating a thread that can call into the Java framework code.等待上层请求 

 *  This must be used to create any threads that report events up to the framework. 

 */  

typedef pthread_t (* gps_create_thread)(const char* name, void (*start)(void *), void* arg);  

  

/** GPS callback structure. */  

typedef struct {  

    /** set to sizeof(GpsCallbacks) */  

    size_t      size;  

    gps_location_callback location_cb;  

    gps_status_callback status_cb;  

    gps_sv_status_callback sv_status_cb;  

    gps_nmea_callback nmea_cb;  

    gps_set_capabilities set_capabilities_cb;  

    gps_acquire_wakelock acquire_wakelock_cb;  

    gps_release_wakelock release_wakelock_cb;  

    gps_create_thread create_thread_cb;  

} GpsCallbacks;  

/**Callbackwithlocationinformation.向上层传递GPS位置信息

*Canonlybecalledfromathreadcreatedbycreate_thread_cb.

*/

typedefvoid(*gps_location_callback)(GpsLocation*location);

/**Callbackwithstatusinformation.向上层传递GPS状态信息

*Canonlybecalledfromathreadcreatedbycreate_thread_cb.

*/

typedefvoid(*gps_status_callback)(GpsStatus*status);

/**CallbackwithSVstatusinformation.向上层传递GPS卫星信息

*Canonlybecalledfromathreadcreatedbycreate_thread_cb.

*/

typedefvoid(*gps_sv_status_callback)(GpsSvStatus*sv_info);

/**CallbackforreportingNMEAsentences.向上层传递MEMA数据

*Canonlybecalledfromathreadcreatedbycreate_thread_cb.

*/

typedefvoid(*gps_nmea_callback)(GpsUtcTimetimestamp,constchar*nmea,intlength);

/**CallbacktoinformframeworkoftheGPSengine'scapabilities.告知GPS模块可以实现的功能

*CapabilityparameterisabitfieldofGPS_CAPABILITY_*flags.

*/

typedefvoid(*gps_set_capabilities)(uint32_tcapabilities);

/**CallbackutilityforacquiringtheGPSwakelock.上锁,防止处理GPS事件时中止。

*ThiscanbeusedtopreventtheCPUfromsuspendingw

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 简历

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1