Skip to content

Commit

Permalink
Catch automotive exception and allow sensors to be enabled via server…
Browse files Browse the repository at this point in the history
… side (#4652)
  • Loading branch information
dshokouhi authored Oct 7, 2024
1 parent b5e7bdd commit dc444e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,7 @@ class CarSensorManager :
override fun hasSensor(context: Context): Boolean {
this.latestContext = context.applicationContext

return if (isAutomotive) {
BuildConfig.FLAVOR == "minimal"
} else {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
BuildConfig.FLAVOR == "full"
}
return isAutomotive || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && BuildConfig.FLAVOR == "full")
}

override fun requiredPermissions(sensorId: String): Array<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ abstract class BaseVehicleScreen(
private var car: Car? = null
private var carRestrictionManager: CarUxRestrictionsManager? = null
protected val isDrivingOptimized
get() = car?.let {
(
it.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE) as CarUxRestrictionsManager
).currentCarUxRestrictions.isRequiresDistractionOptimization
} ?: false
get() = try {
car?.let {
(
it.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE) as CarUxRestrictionsManager
).currentCarUxRestrictions.isRequiresDistractionOptimization
} ?: false
} catch (e: Exception) {
Log.e(TAG, "Error getting UX Restrictions", e)
false
}

init {
lifecycle.addObserver(object : DefaultLifecycleObserver {
Expand Down

0 comments on commit dc444e8

Please sign in to comment.