android gps 代码 分析(2)
发布时间:2021-06-08
发布时间:2021-06-08
android
Log.d(TAG,"provider enable");
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
Log.d(TAG,"status changed");
}
}
另外一部分就是hardware/libhardware_legacy/gps
部分的实现,这个主要就是实现一个gps.h里面的几个数据结构:
typedef struct {
gps_location_callback location_cb;
gps_status_callback status_cb;
gps_sv_status_callback sv_status_cb;
} GpsCallbacks;
typedef struct {
int (*init)( GpsCallbacks* callbacks );
int (*start)( void );
int (*stop)( void );
void (*set_fix_frequency)( int frequency );
void (*cleanup)( void );
int (*inject_time)(GpsUtcTime time, int64_t timeReference,
int uncertainty);
void (*delete_aiding_data)(GpsAidingData flags);
int (*set_position_mode)(GpsPositionMode mode, int fix_frequency);
const void* (*get_extension)(const char* name);
} GpsInterface;
typedef struct {
uint16_t flags;
double latitude;
double longitude;
double altitude;
float speed;
float bearing;
float accuracy;
GpsUtcTime timestamp;
} GpsLocation;
在GpsInterface->init()的时候要把上层的GpsCallbacks传进来,然后start后,从驱动那里poll获得gps raw data,并对raw data进行解析并填充GpsLocation数据结构,然后调用location_cb 上报location 数据。
//初始化的时候,得到GpsInterface,调用init,
static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject obj) {
if (!sGpsInterface)
sGpsInterface = gps_get_interface();
return (sGpsInterface && sGpsInterface->init(&sGpsCallbacks) == 0);
}
GpsCallbacks sGpsCallbacks = {
上一篇:刑法学复习题及答案
下一篇:液压钻机的液压系统设计