host: move to Car App Library 1.8

Apps built on 1.8 can now hand Gearslip their newer template pieces (chips,
progress bars, timers); drawing them comes next. Vela, Organic Maps and RF
Sentinel connect as before.
This commit is contained in:
Seb3thehacker committed 2026-10-24 14:31:18 -07:00
1 parent 795963f178
commit 3cea17d178
2 files changed
+11 -1

No files matched your search

@@ -403,6 +403,8 @@ class CarAppConnection(private val context: Context) {
// failure worth surfacing. // failure worth surfacing.
runCatching { runCatching {
app.getManager(CarContext.NAVIGATION_SERVICE, object : IOnDoneCallback.Stub() { app.getManager(CarContext.NAVIGATION_SERVICE, object : IOnDoneCallback.Stub() {
// Car App Library 1.8 versions its host interfaces; each answers with the version it was built from.
override fun getInterfaceVersion(): Int = IOnDoneCallback.VERSION
override fun onSuccess(response: Bundleable?) { override fun onSuccess(response: Bundleable?) {
val value = response?.let { runCatching { it.get() }.getOrNull() } val value = response?.let { runCatching { it.get() }.getOrNull() }
navigationManager = when (value) { navigationManager = when (value) {
@@ -626,6 +628,7 @@ class CarAppConnection(private val context: Context) {
// --- host interfaces the app calls back into ----------------------------------------- // --- host interfaces the app calls back into -----------------------------------------
private fun createAppHost(owner: Any) = object : IAppHost.Stub() { private fun createAppHost(owner: Any) = object : IAppHost.Stub() {
override fun getInterfaceVersion(): Int = IAppHost.VERSION
override fun invalidate() { override fun invalidate() {
GearslipLog.i("host: app invalidated its template") GearslipLog.i("host: app invalidated its template")
main.post { requestTemplate() } main.post { requestTemplate() }
@@ -664,6 +667,7 @@ class CarAppConnection(private val context: Context) {
val trip: StateFlow<androidx.car.app.navigation.model.Trip?> = _trip.asStateFlow() val trip: StateFlow<androidx.car.app.navigation.model.Trip?> = _trip.asStateFlow()
private val navigationHost = object : INavigationHost.Stub() { private val navigationHost = object : INavigationHost.Stub() {
override fun getInterfaceVersion(): Int = INavigationHost.VERSION
override fun navigationStarted() { override fun navigationStarted() {
GearslipLog.i("host: navigation started") GearslipLog.i("host: navigation started")
navigating = true navigating = true
@@ -691,6 +695,7 @@ class CarAppConnection(private val context: Context) {
* IBinder must be a real IOnDoneCallback - the app dispatches the reply through it. * IBinder must be a real IOnDoneCallback - the app dispatches the reply through it.
*/ */
private val hardwareHost = object : ICarHardwareHost.Stub() { private val hardwareHost = object : ICarHardwareHost.Stub() {
override fun getInterfaceVersion(): Int = ICarHardwareHost.VERSION
override fun getCarHardwareResult( override fun getCarHardwareResult(
type: Int, type: Int,
params: Bundleable?, params: Bundleable?,
@@ -721,6 +726,7 @@ class CarAppConnection(private val context: Context) {
* Library documents for a projected head unit; they are about the screen, not about us. * Library documents for a projected head unit; they are about the screen, not about us.
*/ */
private val constraintHost = object : IConstraintHost.Stub() { private val constraintHost = object : IConstraintHost.Stub() {
override fun getInterfaceVersion(): Int = IConstraintHost.VERSION
override fun getContentLimit(type: Int): Int = when (type) { override fun getContentLimit(type: Int): Int = when (type) {
ConstraintManager.CONTENT_LIMIT_TYPE_GRID -> 12 ConstraintManager.CONTENT_LIMIT_TYPE_GRID -> 12
ConstraintManager.CONTENT_LIMIT_TYPE_PANE -> 4 ConstraintManager.CONTENT_LIMIT_TYPE_PANE -> 4
@@ -739,10 +745,12 @@ class CarAppConnection(private val context: Context) {
* that pushes suggestions shouldn't fail because its host doesn't surface them. * that pushes suggestions shouldn't fail because its host doesn't surface them.
*/ */
private val suggestionHost = object : ISuggestionHost.Stub() { private val suggestionHost = object : ISuggestionHost.Stub() {
override fun getInterfaceVersion(): Int = ISuggestionHost.VERSION
override fun updateSuggestions(suggestions: Bundleable?) = Unit override fun updateSuggestions(suggestions: Bundleable?) = Unit
} }
private fun createCarHost(owner: Any) = object : ICarHost.Stub() { private fun createCarHost(owner: Any) = object : ICarHost.Stub() {
override fun getInterfaceVersion(): Int = ICarHost.VERSION
private val appHost = createAppHost(owner) private val appHost = createAppHost(owner)
override fun getHost(type: String?): IBinder? = when (type) { override fun getHost(type: String?): IBinder? = when (type) {
@@ -775,6 +783,7 @@ class CarAppConnection(private val context: Context) {
*/ */
private fun call(name: String, onValue: (Any?) -> Unit, send: (IOnDoneCallback) -> Unit) { private fun call(name: String, onValue: (Any?) -> Unit, send: (IOnDoneCallback) -> Unit) {
val callback = object : IOnDoneCallback.Stub() { val callback = object : IOnDoneCallback.Stub() {
override fun getInterfaceVersion(): Int = IOnDoneCallback.VERSION
override fun onSuccess(response: Bundleable?) { override fun onSuccess(response: Bundleable?) {
val value = response?.let { runCatching { it.get() }.getOrNull() } val value = response?.let { runCatching { it.get() }.getOrNull() }
main.post { onValue(value) } main.post { onValue(value) }
@@ -790,6 +799,7 @@ class CarAppConnection(private val context: Context) {
} }
private fun noop(name: String) = object : IOnDoneCallback.Stub() { private fun noop(name: String) = object : IOnDoneCallback.Stub() {
override fun getInterfaceVersion(): Int = IOnDoneCallback.VERSION
override fun onSuccess(response: Bundleable?) = Unit override fun onSuccess(response: Bundleable?) = Unit
override fun onFailure(response: Bundleable?) = GearslipLog.w("host: $name failed") override fun onFailure(response: Bundleable?) = GearslipLog.w("host: $name failed")
} }
+1 -1
View File
@@ -8,7 +8,7 @@ espressoCore = "3.7.0"
lifecycleRuntimeKtx = "2.10.0" lifecycleRuntimeKtx = "2.10.0"
activityCompose = "1.13.0" activityCompose = "1.13.0"
composeBom = "2026.05.01" composeBom = "2026.05.01"
carApp = "1.7.0" carApp = "1.8.0-rc01"
appcompat = "1.7.1" appcompat = "1.7.1"
material = "1.14.0" material = "1.14.0"
constraintlayout = "2.2.1" constraintlayout = "2.2.1"