Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5ccb59e authored by Mike Lockwood's avatar Mike Lockwood Committed by Android (Google) Code Review
Browse files

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

parents 25c374e8 faa7e836
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -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 {