Skip to content

Commit

Permalink
Ignore unreliable and low-accuracy compass readings.
Browse files Browse the repository at this point in the history
Note: this may prevent all compass readings, but not having a reading is better than having one that is totally wrong, which is what SYNCHRO Field testers are seeing.
  • Loading branch information
tcobbs-bentley committed Jun 24, 2024
1 parent 926812e commit 904232a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import android.hardware.SensorManager.AXIS_MINUS_X
import android.hardware.SensorManager.AXIS_MINUS_Y
import android.hardware.SensorManager.AXIS_X
import android.hardware.SensorManager.AXIS_Y
import android.hardware.SensorManager.*
import android.location.Location
import android.os.Build
import android.os.Looper
Expand Down Expand Up @@ -242,6 +239,9 @@ class ITMGeolocationManager(private var context: Context) {
}

override fun onSensorChanged(event: SensorEvent?) {
if (event?.accuracy == SENSOR_STATUS_UNRELIABLE || event?.accuracy == SENSOR_STATUS_ACCURACY_LOW) {
return
}
when (event?.sensor?.type) {
Sensor.TYPE_ACCELEROMETER -> {
accelerometerReading = event.values.copyOf()
Expand Down

0 comments on commit 904232a

Please sign in to comment.