Breaking Change: Only update geocoded sensor with location if the setting is turned on (#2913)

* Add a setting to control if the geocoded sensor should update with device tracker

* Update strings for settings
This commit is contained in:
Daniel Shokouhi 2022-09-26 07:55:02 -07:00 committed by GitHub
parent 113582ad2d
commit cabd41e6d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 5 deletions

View file

@ -18,6 +18,7 @@ class GeocodeSensorManager : SensorManager {
companion object {
private const val SETTING_ACCURACY = "geocode_minimum_accuracy"
const val SETTINGS_INCLUDE_LOCATION = "geocode_include_location_updates"
private const val DEFAULT_MINIMUM_ACCURACY = 200
private const val TAG = "GeocodeSM"
val geocodedLocation = SensorManager.BasicSensor(

View file

@ -766,16 +766,29 @@ class LocationSensorManager : LocationSensorManagerBase() {
lastLocationSend = now
lastUpdateLocation = updateLocation.gps.contentToString()
val geocodeIncludeLocation = getSetting(
latestContext,
GeocodeSensorManager.geocodedLocation,
GeocodeSensorManager.SETTINGS_INCLUDE_LOCATION,
SensorSettingType.TOGGLE,
"false"
).toBoolean()
ioScope.launch {
try {
integrationUseCase.updateLocation(updateLocation)
Log.d(TAG, "Location update sent successfully")
// Update Geocoded Location Sensor
val intent = Intent(latestContext, SensorReceiver::class.java)
intent.action = SensorReceiverBase.ACTION_UPDATE_SENSOR
intent.putExtra(SensorReceiverBase.EXTRA_SENSOR_ID, GeocodeSensorManager.geocodedLocation.id)
latestContext.sendBroadcast(intent)
if (geocodeIncludeLocation) {
val intent = Intent(latestContext, SensorReceiver::class.java)
intent.action = SensorReceiverBase.ACTION_UPDATE_SENSOR
intent.putExtra(
SensorReceiverBase.EXTRA_SENSOR_ID,
GeocodeSensorManager.geocodedLocation.id
)
latestContext.sendBroadcast(intent)
}
} catch (e: Exception) {
Log.e(TAG, "Could not update location.", e)
}

View file

@ -478,7 +478,7 @@
<string name="sensor_description_dnd_sensor">The current state of Do Not Disturb</string>
<string name="sensor_description_doze">Whether the device is in Doze mode</string>
<string name="sensor_description_external_storage">Information about the total and available storage space externally</string>
<string name="sensor_description_geocoded_location">Calculated address based on GPS data using Googles Location API</string>
<string name="sensor_description_geocoded_location">Calculated address based on GPS data using Googles Location API. The minimum accuracy setting determines if a location update is accurate enough to be updated, the default is 200 meters. A setting also exists to send a sensor update anytime the location sensors update, by default this off.</string>
<string name="sensor_description_headphone">Whether headphones are plugged into the device</string>
<string name="sensor_description_headset_mounted">Whether the headset is currently in use</string>
<string name="sensor_description_high_accuracy_mode">Whether high accuracy mode is active on the device</string>
@ -588,6 +588,7 @@
<string name="sensor_setting_beacon_monitor_filter_iterations_title">Filter Iterations</string>
<string name="sensor_setting_beacon_monitor_filter_rssi_multiplier_title">Filter RSSI Multiplier</string>
<string name="sensor_setting_geocode_minimum_accuracy_title">Minimum Accuracy</string>
<string name="sensor_setting_geocode_include_location_updates_title">Update sensor with location sensors</string>
<string name="sensor_setting_lastreboot_deadband_title">Deadband</string>
<string name="sensor_setting_lastupdate_add_new_intent_title">Add New Intent</string>
<string name="sensor_setting_lastupdate_intent_title" translatable="false">Intent %1$1s</string>