diff options
| -rw-r--r-- | services/java/com/android/server/DockObserver.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java index 25ebee459589..547a2a1d42f3 100644 --- a/services/java/com/android/server/DockObserver.java +++ b/services/java/com/android/server/DockObserver.java @@ -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 { |