diff options
| author | 2010-03-05 14:13:29 +0100 | |
|---|---|---|
| committer | 2010-03-05 14:13:29 +0100 | |
| commit | c44c6d038dae9dbe2e6dbc182372590cef18bcb7 (patch) | |
| tree | 1d337c326fed578de4614ff6b7600e93c3375ebe | |
| parent | ff846009ecb6df669feeb5d5feecf4b304b8b9a5 (diff) | |
fix NullPointerException if location is not set.
Bug: http://b/issue?id=2490154
| -rw-r--r-- | services/java/com/android/server/DockObserver.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/services/java/com/android/server/DockObserver.java b/services/java/com/android/server/DockObserver.java index 73e760e59b98..28236f00b4ab 100644 --- a/services/java/com/android/server/DockObserver.java +++ b/services/java/com/android/server/DockObserver.java @@ -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. |