Skip to content

Commit

Permalink
Fix high accuracy command after sensor update logic was corrected (#1849
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dshokouhi authored Oct 28, 2021
1 parent 3d4c37e commit b75f730
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,8 @@ class MessagingService : FirebaseMessagingService() {
LocationSensorManager.setHighAccuracyModeSetting(applicationContext, true)
}
val intent = Intent(this, LocationSensorManager::class.java)
intent.action = LocationSensorManager.ACTION_REQUEST_LOCATION_UPDATES
intent.action = LocationSensorManager.ACTION_FORCE_HIGH_ACCURACY
intent.putExtra("command", title)
applicationContext.sendBroadcast(intent)
}
COMMAND_ACTIVITY -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class LocationSensorManager : BroadcastReceiver(), SensorManager {
"io.homeassistant.companion.android.background.PROCESS_UPDATES"
const val ACTION_PROCESS_GEO =
"io.homeassistant.companion.android.background.PROCESS_GEOFENCE"
const val ACTION_FORCE_HIGH_ACCURACY =
"io.homeassistant.companion.android.background.FORCE_HIGH_ACCURACY"

val backgroundLocation = SensorManager.BasicSensor(
"location_background",
Expand Down Expand Up @@ -139,6 +141,13 @@ class LocationSensorManager : BroadcastReceiver(), SensorManager {
ACTION_PROCESS_LOCATION -> handleLocationUpdate(intent)
ACTION_PROCESS_GEO -> handleGeoUpdate(intent)
ACTION_REQUEST_ACCURATE_LOCATION_UPDATE -> requestSingleAccurateLocation()
ACTION_FORCE_HIGH_ACCURACY -> {
val intentData = intent.extras?.get("command")?.toString()
if (intentData == "turn_on")
startHighAccuracyService(getHighAccuracyModeIntervalSetting(latestContext))
else if (intentData == "turn_off")
stopHighAccuracyService()
}
else -> Log.w(TAG, "Unknown intent action: ${intent.action}!")
}
}
Expand Down

0 comments on commit b75f730

Please sign in to comment.