Skip to content

Commit

Permalink
Set context in every call
Browse files Browse the repository at this point in the history
  • Loading branch information
ivancea committed Jan 6, 2024
1 parent c6c8695 commit 7f6e99a
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ class CarSensorManager :
get() = R.string.sensor_name_car

override suspend fun getAvailableSensors(context: Context): List<SensorManager.BasicSensor> {
this.context = context.applicationContext

return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
sensorsList
} else {
Expand All @@ -189,6 +191,8 @@ class CarSensorManager :
}

override fun hasSensor(context: Context): Boolean {
this.context = context.applicationContext

return Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
}

Expand All @@ -203,6 +207,8 @@ class CarSensorManager :
}

fun isEnabled(context: Context, carSensor: CarSensor): Boolean {
this.context = context.applicationContext

if (isAutomotive && !carSensor.automotiveEnabled || !isAutomotive && !carSensor.autoEnabled) {
return false
}
Expand All @@ -212,6 +218,7 @@ class CarSensorManager :

override fun requestSensorUpdate(context: Context) {
this.context = context.applicationContext

if (allDisabled()) {
return
}
Expand Down

0 comments on commit 7f6e99a

Please sign in to comment.