Skip to content

Commit

Permalink
Fix Android Auto connected sensor intent crash (#3434)
Browse files Browse the repository at this point in the history
- The CarConnection class registers for intents using the provided context, so switch to application context instead
  • Loading branch information
jpelgrom committed Apr 1, 2023
1 parent 3c0145e commit f89d3c7
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class AndroidAutoSensorManager : SensorManager, Observer<Int> {
private var carConnection: CarConnection? = null

override fun requestSensorUpdate(context: Context) {
this.context = context
this.context = context.applicationContext
if (!isEnabled(context, androidAutoConnected)) {
return
}
CoroutineScope(Dispatchers.Main + Job()).launch {
if (carConnection == null) {
carConnection = CarConnection(context)
carConnection = CarConnection(context.applicationContext)
}
carConnection?.type?.observeForever(this@AndroidAutoSensorManager)
}
Expand Down

0 comments on commit f89d3c7

Please sign in to comment.