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

Commit a9489f88 authored by Mike Lockwood's avatar Mike Lockwood Committed by Android (Google) Code Review
Browse files

Merge "fix NullPointerException if location is not set."

parents 24e09b99 c44c6d03
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.