Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
48 changes: 24 additions & 24 deletions ORLib/src/main/java/io/openremote/orlib/service/GeofenceProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -356,39 +356,39 @@ class GeofenceProvider(val context: Context) {
LOG.info("Enabling geofence provider")

Thread {
val hasPermission =
when {
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q -> {
context.checkSelfPermission(ACCESS_BACKGROUND_LOCATION) ==
PackageManager.PERMISSION_GRANTED
}
else -> {
context.checkSelfPermission(ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
}
val hasPermission =
when {
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q -> {
context.checkSelfPermission(ACCESS_BACKGROUND_LOCATION) ==
PackageManager.PERMISSION_GRANTED
}
else -> {
context.checkSelfPermission(ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
}
}

callback?.accept(
hashMapOf(
"action" to "PROVIDER_ENABLE",
"provider" to "geofence",
"hasPermission" to hasPermission,
"success" to true,
)
callback?.accept(
hashMapOf(
"action" to "PROVIDER_ENABLE",
"provider" to "geofence",
"hasPermission" to hasPermission,
"success" to true,
)
)

if (hasPermission) {
LOG.info("Has permission so fetching geofences")
if (hasPermission) {
LOG.info("Has permission so fetching geofences")

if (getGeofences(context).isEmpty()) {
// Could be first time getting geofences so wait a few seconds for backend to catch up
Timer().schedule(10000) {
refreshGeofences()
}
} else {
if (getGeofences(context).isEmpty()) {
// Could be first time getting geofences so wait a few seconds for backend to catch up
Timer().schedule(10000) {
refreshGeofences()
}
} else {
refreshGeofences()
}
}
}
.start()
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ play-services-location = "21.4.0"
play-services-vision = "20.1.3"
protobuf = "4.36.2"
protobuf-plugin = "0.10.0"
spotless = "8.10.1"
spotless = "8.10.3"

[libraries]
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
Expand Down
Loading