Catch IllegalArgumentException when calling
LocationManager#requestLocationUpdate - Cannot depend on LocationManager#isProviderEnabled, since it always returns false for FLP. Bug: 80199046 Change-Id: I9c85b8a9468bceca0620c5aff16655ed633ee36b Fixes: 80199046 Test: Manually added a CTS test to trigger the flow in AOSP build on device, and successfully caught the exception when requesting location updates from NLP.
This commit is contained in:
@@ -1015,26 +1015,25 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
|
||||
locationListener = mFusedLocationListener;
|
||||
}
|
||||
|
||||
if (!locationManager.isProviderEnabled(provider)) {
|
||||
Log.w(TAG, "Unable to request location since " + provider
|
||||
+ " provider does not exist or is not enabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.i(TAG,
|
||||
String.format(
|
||||
"GNSS HAL Requesting location updates from %s provider for %d millis.",
|
||||
provider, durationMillis));
|
||||
locationManager.requestLocationUpdates(provider,
|
||||
LOCATION_UPDATE_MIN_TIME_INTERVAL_MILLIS, /*minDistance=*/ 0,
|
||||
locationListener, mHandler.getLooper());
|
||||
locationListener.numLocationUpdateRequest++;
|
||||
mHandler.postDelayed(() -> {
|
||||
if (--locationListener.numLocationUpdateRequest == 0) {
|
||||
Log.i(TAG, String.format("Removing location updates from %s provider.", provider));
|
||||
locationManager.removeUpdates(locationListener);
|
||||
}
|
||||
}, durationMillis);
|
||||
try {
|
||||
locationManager.requestLocationUpdates(provider,
|
||||
LOCATION_UPDATE_MIN_TIME_INTERVAL_MILLIS, /*minDistance=*/ 0,
|
||||
locationListener, mHandler.getLooper());
|
||||
locationListener.numLocationUpdateRequest++;
|
||||
mHandler.postDelayed(() -> {
|
||||
if (--locationListener.numLocationUpdateRequest == 0) {
|
||||
Log.i(TAG,
|
||||
String.format("Removing location updates from %s provider.", provider));
|
||||
locationManager.removeUpdates(locationListener);
|
||||
}
|
||||
}, durationMillis);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.w(TAG, "Unable to request location.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void injectBestLocation(Location location) {
|
||||
|
||||
Reference in New Issue
Block a user