Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.appcompat:appcompat:1.4.0"
implementation "androidx.core:core-ktx:1.7.0"
implementation "com.google.android.gms:play-services-location:21.0.1"
implementation "com.google.android.gms:play-services-location:20.0.0"
implementation "androidx.activity:activity:1.2.0"
implementation "androidx.fragment:fragment:1.3.0"
compileOnly "com.huawei.hms:location:6.4.0.300"
Expand Down
28 changes: 6 additions & 22 deletions sdk/src/main/java/io/radar/sdk/RadarGoogleLocationClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,8 @@ internal class RadarGoogleLocationClient(

override fun getCurrentLocation(desiredAccuracy: RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy, block: (location: Location?) -> Unit) {
val priority = priorityForDesiredAccuracy(desiredAccuracy)

var currentLocationRequestBuilder = CurrentLocationRequest.Builder()
.setPriority(priority)
if (desiredAccuracy == RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.HIGH) {
currentLocationRequestBuilder = currentLocationRequestBuilder.setMaxUpdateAgeMillis(0)
}

val timeout = RadarSettings.getSdkConfiguration(context).locationManagerTimeout
if (timeout > 0) {
logger.d("Requesting location with timeout | timeout = $timeout")
currentLocationRequestBuilder = currentLocationRequestBuilder.setDurationMillis(timeout.toLong())
} else {
logger.d("Requesting location with default timeout")
}
val currentLocationRequest = currentLocationRequestBuilder.build()

locationClient.getCurrentLocation(currentLocationRequest, null).addOnSuccessListener { location ->

locationClient.getCurrentLocation(priority, null).addOnSuccessListener { location ->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CurrentLocationRequest not supported in v20. Don't need to worry about desiredAccuracy = HIGH or timeout config in this release

logger.d("Received current location")

block(location)
Expand All @@ -58,12 +43,11 @@ internal class RadarGoogleLocationClient(
) {
val priority = priorityForDesiredAccuracy(desiredAccuracy)

var locationRequestBuilder = LocationRequest.Builder(priority, interval * 1000L)
.setMinUpdateIntervalMillis(fastestInterval * 1000L)
if (desiredAccuracy == RadarTrackingOptions.RadarTrackingOptionsDesiredAccuracy.HIGH) {
locationRequestBuilder = locationRequestBuilder.setMaxUpdateAgeMillis(0)
val locationRequest = LocationRequest().apply {
this.priority = priority
this.interval = interval * 1000L
this.fastestInterval = fastestInterval * 1000L
}
val locationRequest = locationRequestBuilder.build()

locationClient.requestLocationUpdates(locationRequest, pendingIntent)
}
Expand Down