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

Commit 2d2078aa authored by Yusuf T. Mobile's avatar Yusuf T. Mobile Committed by Mike Lockwood
Browse files

LocationManagerService: Take fix accuracy into account in proximity zone logic.

Fixes http://code.google.com/p/android/issues/detail?id=2002



Change-Id: If2b0665c556269279c5813f2254f9624a556bd92
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent 94ef4991
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -1069,13 +1069,13 @@ public class LocationManagerService extends ILocationManager.Stub implements Run
            return mIntent;
            return mIntent;
        }
        }


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


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


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