Skip to content

Commit

Permalink
avoid ranging in background
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpatrick committed Mar 3, 2023
1 parent 0e8686d commit bea45c8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.5.13-beta.7'
radarVersion = '3.5.13-beta.8'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
1 change: 1 addition & 0 deletions sdk/src/main/java/io/radar/sdk/RadarApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ internal class RadarApiClient(
queryParams.append("near=${location.latitude},${location.longitude}")
queryParams.append("&radius=${radius}")
queryParams.append("&limit=${limit}")
queryParams.append("&installId=${RadarSettings.getInstallId(context)}")

val host = RadarSettings.getHost(context)
val uri = Uri.parse(host).buildUpon()
Expand Down
4 changes: 4 additions & 0 deletions sdk/src/main/java/io/radar/sdk/RadarBeaconManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ internal class RadarBeaconManager(
private const val TIMEOUT_TOKEN = "timeout"
}

internal fun getNearbyBeacons(): Array<RadarBeacon>? {
return nearbyBeacons.toTypedArray()
}

private fun addCallback(callback: RadarBeaconCallback?) {
if (callback == null) {
return
Expand Down
34 changes: 32 additions & 2 deletions sdk/src/main/java/io/radar/sdk/RadarLocationManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package io.radar.sdk

import android.annotation.SuppressLint
import android.app.NotificationManager
import android.bluetooth.le.ScanResult
import android.content.Context
import android.content.Intent
import android.location.Location
import android.os.Build
import io.radar.sdk.Radar.RadarLocationCallback
import io.radar.sdk.Radar.RadarLocationServicesProvider.GOOGLE
import io.radar.sdk.Radar.RadarLocationServicesProvider.HUAWEI
import io.radar.sdk.Radar.RadarLocationSource
import io.radar.sdk.Radar.RadarStatus
Expand Down Expand Up @@ -592,6 +590,7 @@ internal class RadarLocationManager(
})
}

/*
if (options.beacons && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& permissionsHelper.bluetoothPermissionsGranted(context)) {
Radar.apiClient.searchBeacons(location, 1000, 10, object : RadarApiClient.RadarSearchBeaconsApiCallback {
Expand Down Expand Up @@ -632,6 +631,37 @@ internal class RadarLocationManager(
} else {
callTrackApi(null)
}
*/

if (options.beacons && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& permissionsHelper.bluetoothPermissionsGranted(context)) {
if (source != RadarLocationSource.BEACON_ENTER && source != RadarLocationSource.BEACON_EXIT && source != RadarLocationSource.MOCK_LOCATION && source != RadarLocationSource.MANUAL_LOCATION) {
Radar.apiClient.searchBeacons(
location,
1000,
10,
object : RadarApiClient.RadarSearchBeaconsApiCallback {
override fun onComplete(
status: RadarStatus,
res: JSONObject?,
beacons: Array<RadarBeacon>?,
uuids: Array<String>?,
uids: Array<String>?
) {
if (!uuids.isNullOrEmpty() || !uids.isNullOrEmpty()) {
Radar.beaconManager.startMonitoringBeaconUUIDs(uuids, uids)
} else if (beacons != null) {
Radar.beaconManager.startMonitoringBeacons(beacons)
}
}
})
}

val beacons = Radar.beaconManager.getNearbyBeacons()
callTrackApi(beacons)
} else {
callTrackApi(null)
}
}

private fun startForegroundService(foregroundService: RadarTrackingOptions.RadarTrackingOptionsForegroundService) {
Expand Down

0 comments on commit bea45c8

Please sign in to comment.