Skip to content

Commit

Permalink
feat:优化minAccuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
nestor committed Aug 22, 2023
1 parent d9b670a commit 8018227
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
14 changes: 7 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
alias(libs.plugins.firebase.appdistribution)
alias(libs.plugins.google.services)
alias(libs.plugins.hilt)
id("com.google.firebase.crashlytics")
alias(libs.plugins.firebase.crashlytics)
}

android {
Expand Down Expand Up @@ -110,14 +110,14 @@ android {
defaultConfig.buildConfigField("String[]", "APPLICATION_IDS", "{$values}")
}

playConfigs {
// register("minimal") {
// playConfigs {
//// register("minimal") {
//// enabled.set(false)
//// }
// register("full") {
// enabled.set(false)
// }
register("full") {
enabled.set(false)
}
}
// }

testOptions {
unitTests.isReturnDefaultValues = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class LocationSensorManager : LocationSensorManagerBase() {
private var isBackgroundLocationSetup = false
private var isZoneLocationSetup = false

private var lastLocationSend = 0L
private var lastLocationReceived = 0L
private var lastUpdateLocation = ""
private var lastLocationSend = mutableMapOf<Int, Long>()
private var lastLocationReceived = mutableMapOf<Int, Long>()
private var lastUpdateLocation = mutableMapOf<Int, String?>()

private var zones: Array<Entity<ZoneAttributes>> = emptyArray()
private var zonesLastReceived = 0L
Expand Down Expand Up @@ -876,7 +876,10 @@ class LocationSensorManager : LocationSensorManagerBase() {

private fun handleLocationUpdate(intent: Intent) {
Log.d(TAG, "Received location update.")
lastLocationReceived = System.currentTimeMillis()
val serverIds = getEnabledServers(latestContext, backgroundLocation)
serverIds.forEach {
lastLocationReceived[it] = System.currentTimeMillis()
}
if (mLocationClient != null) {
mLocationClient?.startLocation()
} else {
Expand Down Expand Up @@ -950,7 +953,7 @@ class LocationSensorManager : LocationSensorManagerBase() {
// return
// }

if (location.time < lastLocationSend || (now - location.time) > 320000) {
if (location.time < (lastLocationSend[serverId]?:0) || (now - location.time) > 320000) {
Log.d(
TAG,
"Skipping old location update since time is before the last one we sent, received: ${location.time} last sent: $lastLocationSend"
Expand Down Expand Up @@ -984,8 +987,8 @@ class LocationSensorManager : LocationSensorManagerBase() {
// )
// return
// }
lastLocationSend = now
lastUpdateLocation = updateLocationString
lastLocationSend[serverId] = now
lastUpdateLocation[serverId] = updateLocationString
lastTime2 = System.currentTimeMillis()
getGeocodedLocation(location)
checkGps(wifi)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
alias(libs.plugins.hilt).apply(false)
alias(libs.plugins.kotlin.kapt).apply(false)
alias(libs.plugins.kotlin.parcelize).apply(false)
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.6")
alias(libs.plugins.firebase.crashlytics).apply(false)
}

allprojects {
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ wearInput = "1.2.0-alpha02"
webkit = "1.7.0"
wear-remote-interactions = "1.0.0"
workRuntimeKtx = "2.8.1"
firebase="2.9.6"


[plugins]
android-application = { id = "com.android.application", version.ref = "androidPlugin" }
Expand All @@ -73,6 +75,7 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebase" }

[libraries]
accompanist-themeadapter-material = { module = "com.google.accompanist:accompanist-themeadapter-material", version.ref = "accompanist" }
Expand Down
5 changes: 4 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

include(":common", ":app")

rootProject.name = "home-assistant-android"

pluginManagement {
repositories {
// maven { setUrl("https://mirrors.cloud.tencent.com/gradle/") }
//maven { setUrl("https://mirrors.cloud.tencent.com/nexus/repository/maven-public/") }
gradlePluginPortal()
google()
}
Expand All @@ -25,6 +26,8 @@ extensions.configure<org.ajoberstar.reckon.gradle.ReckonExtension> {

dependencyResolutionManagement {
repositories {
//maven { setUrl("https://mirrors.cloud.tencent.com/gradle/") }
//maven { setUrl("https://mirrors.cloud.tencent.com/nexus/repository/maven-public/") }
mavenCentral()
google()
maven("https://jitpack.io")
Expand Down

0 comments on commit 8018227

Please sign in to comment.