免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 784 | 回复: 0
打印 上一主题 下一主题

Gingerbread中 GPS 主要流程分析 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-22 08:51 |只看该作者 |倒序浏览
1. GPS enable process
1.1. onPreferenceTreeClick() in SecureSetting.java.
            Settings.Secure.setLocationProviderEnabled(getContentResolver(),
                    LocationManager.GPS_PROVIDER, enabled);

if user selects GPS, configuration value in secure settings database will be updated accordingly.

1.2. initialize() in LocationManagerService.java.
        mSettings = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, mLocationHandler);
        SettingsObserver settingsObserver = new SettingsObserver();
        mSettings.addObserver(settingsObserver);

it will observe the value in secure settings database.
and then call updateProvidersLocked() as below.
    private final class SettingsObserver implements Observer {
        public void update(Observable o, Object arg) {
            synchronized (mLock) {
                updateProvidersLocked();
            }
        }
    }

1.3. do GPS / AGPS initial process.
 
updateProvidersLocked() -> updateProviderListenersLocked() -> enable() in GpsLocationProvider.java -> send message - ENABLE -> handleEnable() -> native_init() / native_supports_xtra() / native_set_agps_server().


2. GPS disable process
2.1. onPreferenceTreeClick() in SecureSetting.java.
            Settings.Secure.setLocationProviderEnabled(getContentResolver(),
                    LocationManager.GPS_PROVIDER, enabled);

if user selects GPS, configuration value in secure settings database will be updated accordingly.

2.2. initialize() in LocationManagerService.java.
        mSettings = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, mLocationHandler);
        SettingsObserver settingsObserver = new SettingsObserver();
        mSettings.addObserver(settingsObserver);

it will observe the value in secure settings database.
and then call updateProvidersLocked() as below.

    private final class SettingsObserver implements Observer {
        public void update(Observable o, Object arg) {
            synchronized (mLock) {
                updateProvidersLocked();
            }
        }
    }

2.3. do GPS / AGPS de-initial process.
updateProvidersLocked() -> updateProviderListenersLocked() -> disable() in GpsLocationProvider.java -> send message - ENABLE -> handleDisable() -> stopNavigating() / native_cleanup().


3. GPS start navigation process
3.1. Application calls requestLocationUpdates() in SDK API layer, requestLocationUpdates() is in LocationManager.java.
_requestLocationUpdates() 
-> requestLocationUpdates() 
-> requestLocationUpdatesLocked() in LocationManagerService.java 
-> enableLocationTracking() in GpsLocationProvider.java 
-> send message - ENABLE_TRACKING 
-> handleEnableLocationTracking() 
-> startNavigating() 
-> native_set_position_mode() / native_start().


4. GPS stop navigation process
4.1. Application calls removeUpdates() in SDK API layer, removeUpdates() is in LocationManager.java.
removeUpdates() 
removeUpdates() in LocationManagerService.java 
-> removeUpdatesLocked()
-> enableLocationTracking() in GpsLocationProvider.java 
-> send message - ENABLE_TRACKING 
-> handleEnableLocationTracking() 
-> stopNavigating() 
-> native_stop().

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP