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

Commit 5550ef48 authored by Yusuf T. Mobile's avatar Yusuf T. Mobile Committed by Jean-Baptiste Queru
Browse files

Fixed Android issue #2002: "Proximity alert detection logic is broken"

parent 62e73f46
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -1157,13 +1157,13 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
            return mIntent;
        }

        boolean isInProximity(double latitude, double longitude) {
        boolean isInProximity(double latitude, double longitude, float accuracy) {
            Location loc = new Location("");
            loc.setLatitude(latitude);
            loc.setLongitude(longitude);

            double radius = loc.distanceTo(mLocation);
            return radius <= mRadius;
            return radius <= Math.max(mRadius,accuracy);
        }
        
        @Override
@@ -1203,6 +1203,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
            long now = System.currentTimeMillis();
            double latitude = loc.getLatitude();
            double longitude = loc.getLongitude();
            float accuracy = loc.getAccuracy();
            ArrayList<PendingIntent> intentsToRemove = null;

            for (ProximityAlert alert : mProximityAlerts.values()) {
@@ -1212,7 +1213,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
                if ((expiration == -1) || (now <= expiration)) {
                    boolean entered = mProximitiesEntered.contains(alert);
                    boolean inProximity =
                        alert.isInProximity(latitude, longitude);
                        alert.isInProximity(latitude, longitude, accuracy);
                    if (!entered && inProximity) {
                        if (LOCAL_LOGV) {
                            Log.v(TAG, "Entered alert");