mirror of
https://github.com/home-assistant/android
synced 2024-10-15 12:32:54 +00:00
Fix Android Auto connected sensor intent crash (#3434)
- The CarConnection class registers for intents using the provided context, so switch to application context instead
This commit is contained in:
parent
3c0145eed3
commit
f89d3c7c78
|
@ -46,13 +46,13 @@ class AndroidAutoSensorManager : SensorManager, Observer<Int> {
|
||||||
private var carConnection: CarConnection? = null
|
private var carConnection: CarConnection? = null
|
||||||
|
|
||||||
override fun requestSensorUpdate(context: Context) {
|
override fun requestSensorUpdate(context: Context) {
|
||||||
this.context = context
|
this.context = context.applicationContext
|
||||||
if (!isEnabled(context, androidAutoConnected)) {
|
if (!isEnabled(context, androidAutoConnected)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
CoroutineScope(Dispatchers.Main + Job()).launch {
|
CoroutineScope(Dispatchers.Main + Job()).launch {
|
||||||
if (carConnection == null) {
|
if (carConnection == null) {
|
||||||
carConnection = CarConnection(context)
|
carConnection = CarConnection(context.applicationContext)
|
||||||
}
|
}
|
||||||
carConnection?.type?.observeForever(this@AndroidAutoSensorManager)
|
carConnection?.type?.observeForever(this@AndroidAutoSensorManager)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue