Skip to content

Commit

Permalink
[STAD-513] Set accuracy to fix distance on Samsung Android 10 (#279)
Browse files Browse the repository at this point in the history
* [STAD-513] Set accuracy to fix distance on Samsung Android 10

* Upgrade Robolectric to fix test build on CI
  • Loading branch information
hb0 authored May 15, 2023
1 parent bbaf1a3 commit 4ea0a78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ext {
mockitoVersion = "3.3.3"
hamcrestVersion = "1.3"
rulesVersion = "1.3.0"
robolectricVersion = "4.3.1"
robolectricVersion = "4.10.2"
androidxTestCoreVersion = "1.1.0"

sourceCompatibility = JavaVersion.VERSION_11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Cyface GmbH
* Copyright 2019-2023 Cyface GmbH
*
* This file is part of the Cyface SDK for Android.
*
Expand All @@ -22,6 +22,7 @@
import android.os.Parcel;

import androidx.annotation.NonNull;

import de.cyface.persistence.model.GeoLocation;
import de.cyface.persistence.model.Measurement;

Expand All @@ -30,7 +31,7 @@
* {@link Measurement#getDistance()} using simply {@link Location#distanceTo(Location)}.
*
* @author Armin Schnabel
* @version 2.0.2
* @version 2.0.3
* @since 3.2.0
*/
public class DefaultDistanceCalculationStrategy implements DistanceCalculationStrategy {
Expand Down Expand Up @@ -81,6 +82,9 @@ public double calculateDistance(@NonNull GeoLocation lastLocation, @NonNull GeoL
previousLocation.setLongitude(lastLocation.getLon());
nextLocation.setLatitude(newLocation.getLat());
nextLocation.setLongitude(newLocation.getLon());
// w/o `accuracy`, `distanceTo()` returns `0` on Samsung Galaxy S9 Android 10 [STAD-513]
previousLocation.setAccuracy(lastLocation.getAccuracy());
nextLocation.setAccuracy(newLocation.getAccuracy());

return previousLocation.distanceTo(nextLocation);
}
Expand Down

0 comments on commit 4ea0a78

Please sign in to comment.