forked from organicmaps/organicmaps
[android] fix SecurityException
This commit is contained in:
parent
bfa6a5ae8b
commit
5dc2affbc4
1 changed files with 14 additions and 8 deletions
|
@ -109,20 +109,26 @@ class AndroidNativeProvider extends BaseLocationProvider
|
|||
expirationMillis);
|
||||
}
|
||||
|
||||
@SuppressWarnings("MissingPermission")
|
||||
// A permission is checked externally
|
||||
@Nullable
|
||||
private static Location findBestNotExpiredLocation(LocationManager manager, List<String> providers, long expirationMillis)
|
||||
{
|
||||
Location res = null;
|
||||
for (final String pr : providers)
|
||||
try
|
||||
{
|
||||
final Location last = manager.getLastKnownLocation(pr);
|
||||
if (last == null || LocationUtils.isExpired(last, last.getTime(), expirationMillis))
|
||||
continue;
|
||||
for (final String pr : providers)
|
||||
{
|
||||
final Location last = manager.getLastKnownLocation(pr);
|
||||
if (last == null || LocationUtils.isExpired(last, last.getTime(), expirationMillis))
|
||||
continue;
|
||||
|
||||
if (res == null || res.getAccuracy() > last.getAccuracy())
|
||||
res = last;
|
||||
if (res == null || res.getAccuracy() > last.getAccuracy())
|
||||
res = last;
|
||||
}
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
LOGGER.e(TAG, "Dynamic permission ACCESS_COARSE_LOCATION/ACCESS_FINE_LOCATION is not granted",
|
||||
e);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue