From 74c0e28e27386365d7e1a59515faf06edb218978 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 18 Aug 2020 23:55:43 +0200 Subject: [PATCH] Ignore longstanding gps requests with more than 30s request interval --- .../java/org/microg/gms/location/RealLocationProvider.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java b/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java index 0ae75148..0fe9e67b 100644 --- a/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java +++ b/play-services-location-core/src/main/java/org/microg/gms/location/RealLocationProvider.java @@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean; @SuppressWarnings("MissingPermission") public class RealLocationProvider { public static final String TAG = "GmsLocProviderReal"; + private static final int MIN_GPS_TIME = 30000; private final LocationManager locationManager; private final String name; @@ -119,6 +120,12 @@ public class RealLocationProvider { if (sb.length() != 0) sb.append(", "); sb.append(request.packageName).append(":").append(request.locationRequest.getInterval()).append("ms"); } + if (minTime > MIN_GPS_TIME && name.equals("gps")) { + Log.d(TAG, name + ": ignoring request as " + minTime + "ms (" + sb + "), is less than " + MIN_GPS_TIME); + locationManager.removeUpdates(listener); + connected.set(false); + return; + } Log.d(TAG, name + ": requesting location updates with interval " + minTime + "ms (" + sb + "), minDistance=" + minDistance); if (connected.get()) { if (connectedMinTime != minTime || connectedMinDistance != minDistance) {