fix NullPointerException if location is not set.
Bug: http://b/issue?id=2490154
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user