DockObserver: Watch for exceptions in LocationManger.isProviderEnabled().

Change-Id: Ieb9f6b0c20a6ce2223cb4b4956580b8543094c2f
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2010-03-02 20:49:47 -05:00
parent c018f3cfdd
commit faa7e8363e

View File

@ -421,9 +421,19 @@ class DockObserver extends UEventObserver {
}
break;
case MSG_ENABLE_LOCATION_UPDATES:
if (mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
boolean networkLocationEnabled;
try {
networkLocationEnabled =
mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
} catch (Exception e) {
// we may get IllegalArgumentException if network location provider
// does not exist or is not yet installed.
networkLocationEnabled = false;
}
if (networkLocationEnabled) {
mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,
LOCATION_UPDATE_MS, LOCATION_UPDATE_DISTANCE_METER, mLocationListener);
LOCATION_UPDATE_MS, LOCATION_UPDATE_DISTANCE_METER,
mLocationListener);
retrieveLocation();
if (mCarModeEnabled && mLocation != null && mNightMode == MODE_NIGHT_AUTO) {
try {