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