Loading core/java/android/webkit/GeolocationService.java +15 −5 Original line number Diff line number Diff line Loading @@ -62,9 +62,10 @@ final class GeolocationService implements LocationListener { /** * Start listening for location updates. */ public void start() { public boolean start() { registerForLocationUpdates(); mIsRunning = true; return mIsNetworkProviderAvailable || mIsGpsProviderAvailable; } /** Loading @@ -87,6 +88,8 @@ final class GeolocationService implements LocationListener { // only unregister from all, then reregister with all but the GPS. unregisterFromLocationUpdates(); registerForLocationUpdates(); // Check that the providers are still available after we re-register. maybeReportError("The last location provider is no longer available"); } } } Loading Loading @@ -155,12 +158,17 @@ final class GeolocationService implements LocationListener { * Registers this object with the location service. */ private void registerForLocationUpdates() { try { // Registration may fail if providers are not present on the device. try { mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); mIsNetworkProviderAvailable = true; } catch(IllegalArgumentException e) { } if (mIsGpsEnabled) { try { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); mIsGpsProviderAvailable = true; } catch(IllegalArgumentException e) { } } } catch(SecurityException e) { Log.e(TAG, "Caught security exception registering for location updates from system. " + Loading @@ -173,6 +181,8 @@ final class GeolocationService implements LocationListener { */ private void unregisterFromLocationUpdates() { mLocationManager.removeUpdates(this); mIsNetworkProviderAvailable = false; mIsGpsProviderAvailable = false; } /** Loading Loading
core/java/android/webkit/GeolocationService.java +15 −5 Original line number Diff line number Diff line Loading @@ -62,9 +62,10 @@ final class GeolocationService implements LocationListener { /** * Start listening for location updates. */ public void start() { public boolean start() { registerForLocationUpdates(); mIsRunning = true; return mIsNetworkProviderAvailable || mIsGpsProviderAvailable; } /** Loading @@ -87,6 +88,8 @@ final class GeolocationService implements LocationListener { // only unregister from all, then reregister with all but the GPS. unregisterFromLocationUpdates(); registerForLocationUpdates(); // Check that the providers are still available after we re-register. maybeReportError("The last location provider is no longer available"); } } } Loading Loading @@ -155,12 +158,17 @@ final class GeolocationService implements LocationListener { * Registers this object with the location service. */ private void registerForLocationUpdates() { try { // Registration may fail if providers are not present on the device. try { mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); mIsNetworkProviderAvailable = true; } catch(IllegalArgumentException e) { } if (mIsGpsEnabled) { try { mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); mIsGpsProviderAvailable = true; } catch(IllegalArgumentException e) { } } } catch(SecurityException e) { Log.e(TAG, "Caught security exception registering for location updates from system. " + Loading @@ -173,6 +181,8 @@ final class GeolocationService implements LocationListener { */ private void unregisterFromLocationUpdates() { mLocationManager.removeUpdates(this); mIsNetworkProviderAvailable = false; mIsGpsProviderAvailable = false; } /** Loading