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

Commit c44c6d03 authored by Bernd Holzhey's avatar Bernd Holzhey
Browse files

fix NullPointerException if location is not set.

parent ff846009
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -181,8 +181,7 @@ class DockObserver extends UEventObserver {

        public void onLocationChanged(Location location) {
            final boolean hasMoved = hasMoved(location);
            final boolean hasBetterAccuracy = location.getAccuracy() < mLocation.getAccuracy();
            if (hasMoved || hasBetterAccuracy) {
            if (hasMoved || hasBetterAccuracy(location)) {
                synchronized (this) {
                    mLocation = location;
                }
@@ -201,6 +200,16 @@ class DockObserver extends UEventObserver {
        public void onStatusChanged(String provider, int status, Bundle extras) {
        }

        private boolean hasBetterAccuracy(Location location) {
            if (location == null) {
                return false;
            }
            if (mLocation == null) {
                return true;
            }
            return location.getAccuracy() < mLocation.getAccuracy();
        }

        /*
         * The user has moved if the accuracy circles of the two locations
         * don't overlap.