Chinaunix首页 | 论坛 | 博客
  • 博客访问: 300825
  • 博文数量: 43
  • 博客积分: 2071
  • 博客等级: 大尉
  • 技术积分: 488
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-25 17:48
文章分类

全部博文(43)

文章存档

2014年(5)

2013年(4)

2011年(9)

2010年(8)

2009年(17)

我的朋友

分类: 嵌入式

2011-07-13 18:24:39

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().

阅读(1455) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~