Android GPS学习笔记—重要结构体及接口

本文详细介绍了Android系统中GPS相关的头文件`gps.h`的内容,包括定位模式、工作状态定义,以及GpsLocation、GpsSvInfo等关键数据结构。同时,讨论了GPS的回调函数指针、GpsInterface等接口结构体,对于理解和实现Android GPS模块至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

gps.h文件中定义了GPS底层相关的结构体和接口。

目录:hardware/libhardware/include/hardware/gps.h


1. 相关宏定义

  • 定位模式定义:GpsPositionMode

GPS定位模式分为:独立定位,MSB,MSA,其中独立定位表示只使用GPS芯片进行定位,MSB和MSA是AGPS定位的两种模式

<pre name="code" class="cpp">/** Requested operational mode for GPS operation. */
typedef uint32_t GpsPositionMode;
// IMPORTANT: Note that the following values must match
// constants in GpsLocationProvider.java.
/** Mode for running GPS standalone (no assistance). */
#define GPS_POSITION_MODE_STANDALONE    0
/** AGPS MS-Based mode. */
#define GPS_POSITION_MODE_MS_BASED      1
/** AGPS MS-Assisted mode. */
#define GPS_POSITION_MODE_MS_ASSISTED   2
  • GPS工作模式定义:GpsPositionRecurrence

GPS工作模式分为周期定位和单次定位

<pre name="code" class="cpp">/** Requested recurrence mode for GPS operation. */
typedef uint32_t GpsPositionRecurrence;
// IMPORTANT: Note that the following values must match
// constants in GpsLocationProvider.java.
/** Receive GPS fixes on a recurring basis at a specified period. 周期性定位*/
#define GPS_POSITION_RECURRENCE_PERIODIC    0
/** Request a single shot GPS fix. 单次定位*/
#define GPS_POSITION_RECURRENCE_SINGLE      1
  • GPS工作状态:GpsStatusValue

GPS工作状态分为:未知,正在定位,停止定位,启动未定义,未启动。

<pre name="code" class="cpp">/** 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. */
#define GPS_STATUS_ENGINE_OFF       4
  • Location信息标志位

表明位置信息中哪些信息是可获得的

<pre name="code" class="cpp">/** 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
  • gps_set_capabilities 回调标志位

表示GPS芯片可以处理的能力

<pre name="code" class="cpp">/** Flags for the gps_set_capabilities callback. */

/** GPS HAL schedules fixes
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值