美文网首页
android GPS框架

android GPS框架

作者: 浪里_个郎 | 来源:发表于2020-03-10 19:38 被阅读0次

后续NMEA解析请见: Android解析NMEA

1,GPS整体架构介绍

框架图

1,HAL层从驱动读取数据,JNI层会向HAL层注册回调,HAL层获取数据后将数据传给JNI层

2,JNI层会获取GnssLocationProvider.java中的方法,在获得HAL层数据后,在c++代码中调用java方法,将数据传到framework/service中

3,LocationManagerService作为系统服务,创建了GnssLocationProvider,所以GnssLocationProvider获取的数据也就给到了LocationManagerService。根据回调注册的不同,最终数据会通过LocationManagerService或GnssStatusListenerHelper调用之前注册到LocationManagerService中的回调函数

4,LocationManager作为android SDK,负责连接app和LocationManagerService,通过binder与LocationManagerService通信。但LocationManager本身也是也被发布成了系统服务:

@SystemService(Context.LOCATION_SERVICE)

public class LocationManager {

带有@SystemService注释的类,会调用publishBinderService将自己注册到ServiceManager中,我们可以在app中通过

lm = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);

来获取LocationManager 服务。

2,NMEA协议数据的回调

//GPS状态回调注册

LocationManager .addGpsStatusListener(GpsStatus.Listener listener); 

//导航信息回调注册

LocationManager.requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)


相关文章

网友评论

      本文标题:android GPS框架

      本文链接:https://www.haomeiwen.com/subject/qemgdhtx.html