qcom android GPS 启动流程
来源:互联网 发布:中国地质大学北京知乎 编辑:程序博客网 时间:2024/06/08 00:43
1 LocationManagerService启动及初始化过程
(1) 在SystemServer.java的startOtherServices中添加LocationManagerService的代码如下:
try { location = new LocationManagerService(context); ServiceManager.addService(Context.LOCATION_SERVICE, location);} catch (Throwable e) { reportWtf("starting Location Manager", e);}
(2) 在systemReady中调用systemRunning, 启动LocationManagerService的代码如下:
try { if (locationF != null) locationF.systemRunning();} catch (Throwable e) { reportWtf("Notifying Location Service running", e);}
(3) 准备GnssLocationProvider,LocationManagerService的systemRunning函数中会调用 loadProvidersLocked, 其代码如下:
private void loadProvidersLocked() { // create a passive location provider, which is always enabled PassiveProvider passiveProvider = new PassiveProvider(this); addProviderLocked(passiveProvider); mEnabledProviders.add(passiveProvider.getName()); mPassiveProvider = passiveProvider; if (GnssLocationProvider.isSupported()) { // Create a gps location provider GnssLocationProvider gnssProvider = new GnssLocationProvider(mContext, this, mLocationHandler.getLooper()); mGnssSystemInfoProvider = gnssProvider.getGnssSystemInfoProvider(); ...... } ......}
(4) GnssLocationProvider的class_init_native方法。
该方法是一个静态方法,会在isSupported方法之前被调用。最终会调用到native函数中:android_location_GnssLocationProvider_class_init_native。
在这个函数中实现对gps.default.so的加载。
static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env, jclass clazz) { int err; hw_module_t* module; ....... err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module); if (err == 0) { hw_device_t* device; err = module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device); if (err == 0) { gps_device_t* gps_device = (gps_device_t *)device; sGpsInterface = gps_device->get_gps_interface(gps_device); } } if (sGpsInterface) { ...... }}
(5) sGpsInterface 接口:
static const GpsInterface sLocEngInterface ={ sizeof(GpsInterface), loc_init, loc_start, loc_stop, loc_cleanup, loc_inject_time, loc_inject_location, loc_delete_aiding_data, loc_set_position_mode, loc_get_extension};
(6) Others interface:
具体实现请参考:/LINUX/android/hardware/qcom/gps/loc_api/libloc_api_50001/loc.cpp
if (sGpsInterface) { sGpsXtraInterface = (const GpsXtraInterface*)sGpsInterface->get_extension(GPS_XTRA_INTERFACE); sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE); sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE); sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE); sAGpsRilInterface = (const AGpsRilInterface*)sGpsInterface->get_extension(AGPS_RIL_INTERFACE); sGpsGeofencingInterface = (const GpsGeofencingInterface*)sGpsInterface->get_extension(GPS_GEOFENCING_INTERFACE); sGpsMeasurementInterface = (const GpsMeasurementInterface*)sGpsInterface->get_extension(GPS_MEASUREMENT_INTERFACE); sGpsNavigationMessageInterface = (const GpsNavigationMessageInterface*)sGpsInterface->get_extension( GPS_NAVIGATION_MESSAGE_INTERFACE); sGnssConfigurationInterface = (const GnssConfigurationInterface*)sGpsInterface->get_extension( GNSS_CONFIGURATION_INTERFACE);}
(7) GPS framework 回调函数库:
GpsCallbacks sGpsCallbacks = { sizeof(GpsCallbacks), location_callback, status_callback, sv_status_callback, nmea_callback, set_capabilities_callback, acquire_wakelock_callback, release_wakelock_callback, create_thread_callback, request_utc_time_callback, set_system_info_callback, gnss_sv_status_callback,};GpsXtraCallbacks sGpsXtraCallbacks = { xtra_download_request_callback, create_thread_callback,};AGpsCallbacks sAGpsCallbacks = { agps_status_callback, create_thread_callback,};GpsNiCallbacks sGpsNiCallbacks = { gps_ni_notify_callback, create_thread_callback,};AGpsRilCallbacks sAGpsRilCallbacks = { agps_request_set_id, agps_request_ref_location, create_thread_callback,};......
2 GPS启动流程
(1) GnssLocationProvider.java里处理GPS启动,关闭请求
@Override public void handleMessage(Message msg) { int message = msg.what; switch (message) { case ENABLE: if (msg.arg1 == 1) { handleEnable(); } else { handleDisable(); } break; ...... }}
(2) handleEnable里启动native层初始化动作
private void handleEnable() { if (DEBUG) Log.d(TAG, "handleEnable"); synchronized (mLock) { if (mEnabled) return; mEnabled = true; } boolean enabled = native_init(); if (enabled) { mSupportsXtra = true; } else { synchronized (mLock) { mEnabled = false; } Log.w(TAG, "Failed to enable location provider"); }}
(3) GPS native初始化,即GnssLocationProvider初始化过程:
static jboolean android_location_GnssLocationProvider_init(JNIEnv* env, jobject obj){ // this must be set before calling into the HAL library if (!mCallbacksObj) mCallbacksObj = env->NewGlobalRef(obj); // fail if the main interface fails to initialize if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0) return JNI_FALSE; // if XTRA initialization fails we will disable it by sGpsXtraInterface to NULL, // but continue to allow the rest of the GPS interface to work. if (sGpsXtraInterface && sGpsXtraInterface->init(&sGpsXtraCallbacks) != 0) sGpsXtraInterface = NULL; ...... return JNI_TRUE;}
(4) Loc_init, 设置framework层回调函数,初始化loc eng,并通过modem接口上电:
static int loc_init(GpsCallbacks* callbacks){ int retVal = -1; ENTRY_LOG(); LOC_API_ADAPTER_EVENT_MASK_T event; ...... LocCallbacks clientCallbacks = {local_loc_cb, /* location_cb */ callbacks->status_cb, /* status_cb */ local_sv_cb, /* sv_status_cb */ callbacks->nmea_cb, /* nmea_cb */ callbacks->set_capabilities_cb, /* set_capabilities_cb */ callbacks->acquire_wakelock_cb, /* acquire_wakelock_cb */ callbacks->release_wakelock_cb, /* release_wakelock_cb */ callbacks->create_thread_cb, /* create_thread_cb */ NULL, /* location_ext_parser */ NULL, /* sv_ext_parser */ callbacks->request_utc_time_cb, /* request_utc_time_cb */ callbacks->set_system_info_cb, /* set_system_info_cb */ callbacks->gnss_sv_status_cb, /* gnss_sv_status_cb */ }; gps_loc_cb = callbacks->location_cb; gps_sv_cb = callbacks->sv_status_cb; retVal = loc_eng_init(loc_afw_data, &clientCallbacks, event, NULL); ...... if(retVal) { LOC_LOGE("loc_eng_init() fail!"); goto err; } loc_afw_data.adapter->setPowerVoteRight(loc_get_target() == TARGET_QCA1530); loc_afw_data.adapter->setPowerVote(true); LOC_LOGD("loc_eng_init() success!");err: EXIT_LOG(%d, retVal); return retVal;}
(5) LocEngInit及msgTask初始化流程:
阅读全文
0 0
- qcom android GPS 启动流程
- qcom Android Camera 运行流程
- QCOM FFBM 模式启动流程梳理
- QCOM GPS Modem侧定位信息上报流程
- Android gps 初始化流程
- Android GPS 流程笔记
- Linux/Android系统知识之Qcom Platform开机流程概述
- Android启动gps
- Qcom流程8x12
- android 2.3 gps流程分析
- GPS启动流程及数据流向分析
- Qcom spk protect 的流程
- qcom 显示驱动注册流程
- QCOM Android 显示系统
- QCOM 从CPU 启动地址
- Qcom从CPU的启动
- 【Android架构GPS篇】之GPS定位应用层流程
- 【Android架构GPS篇】之GPS定位应用层流程
- 详谈智能指针
- JAVA学习日记---Thinking in Java学习笔记,1-4章总结
- Android NuPlayer播放框架
- 链表-python-leetcode 83 Remove Duplicates from Sorted List
- 对象池与池管理
- qcom android GPS 启动流程
- vue-cli项目导入jquery插件(其他插件类似)
- 通过 Moya+RxSwift+Argo 完成网络请求
- poj2186 Popular Cows(强连通分量)
- 51nod 1297 管理二叉树
- 游戏编程入门(6):开发 Brainiac(记忆对对碰) 游戏
- Maven 进阶---自定义工具类,在本地仓库存储并使用 jar
- 获取本地视频,网络视频的第一帧图片,使之显示出来
- Redis技巧