mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-11-10 16:02:25 +01:00
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:
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.
|
||||
runCatching {
|
||||
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?) {
|
||||
val value = response?.let { runCatching { it.get() }.getOrNull() }
|
||||
navigationManager = when (value) {
|
||||
@@ -626,6 +628,7 @@ class CarAppConnection(private val context: Context) {
|
||||
// --- host interfaces the app calls back into -----------------------------------------
|
||||
|
||||
private fun createAppHost(owner: Any) = object : IAppHost.Stub() {
|
||||
override fun getInterfaceVersion(): Int = IAppHost.VERSION
|
||||
override fun invalidate() {
|
||||
GearslipLog.i("host: app invalidated its template")
|
||||
main.post { requestTemplate() }
|
||||
@@ -664,6 +667,7 @@ class CarAppConnection(private val context: Context) {
|
||||
val trip: StateFlow<androidx.car.app.navigation.model.Trip?> = _trip.asStateFlow()
|
||||
|
||||
private val navigationHost = object : INavigationHost.Stub() {
|
||||
override fun getInterfaceVersion(): Int = INavigationHost.VERSION
|
||||
override fun navigationStarted() {
|
||||
GearslipLog.i("host: navigation started")
|
||||
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.
|
||||
*/
|
||||
private val hardwareHost = object : ICarHardwareHost.Stub() {
|
||||
override fun getInterfaceVersion(): Int = ICarHardwareHost.VERSION
|
||||
override fun getCarHardwareResult(
|
||||
type: Int,
|
||||
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.
|
||||
*/
|
||||
private val constraintHost = object : IConstraintHost.Stub() {
|
||||
override fun getInterfaceVersion(): Int = IConstraintHost.VERSION
|
||||
override fun getContentLimit(type: Int): Int = when (type) {
|
||||
ConstraintManager.CONTENT_LIMIT_TYPE_GRID -> 12
|
||||
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.
|
||||
*/
|
||||
private val suggestionHost = object : ISuggestionHost.Stub() {
|
||||
override fun getInterfaceVersion(): Int = ISuggestionHost.VERSION
|
||||
override fun updateSuggestions(suggestions: Bundleable?) = Unit
|
||||
}
|
||||
|
||||
private fun createCarHost(owner: Any) = object : ICarHost.Stub() {
|
||||
override fun getInterfaceVersion(): Int = ICarHost.VERSION
|
||||
private val appHost = createAppHost(owner)
|
||||
|
||||
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) {
|
||||
val callback = object : IOnDoneCallback.Stub() {
|
||||
override fun getInterfaceVersion(): Int = IOnDoneCallback.VERSION
|
||||
override fun onSuccess(response: Bundleable?) {
|
||||
val value = response?.let { runCatching { it.get() }.getOrNull() }
|
||||
main.post { onValue(value) }
|
||||
@@ -790,6 +799,7 @@ class CarAppConnection(private val context: Context) {
|
||||
}
|
||||
|
||||
private fun noop(name: String) = object : IOnDoneCallback.Stub() {
|
||||
override fun getInterfaceVersion(): Int = IOnDoneCallback.VERSION
|
||||
override fun onSuccess(response: Bundleable?) = Unit
|
||||
override fun onFailure(response: Bundleable?) = GearslipLog.w("host: $name failed")
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ espressoCore = "3.7.0"
|
||||
lifecycleRuntimeKtx = "2.10.0"
|
||||
activityCompose = "1.13.0"
|
||||
composeBom = "2026.05.01"
|
||||
carApp = "1.7.0"
|
||||
carApp = "1.8.0-rc01"
|
||||
appcompat = "1.7.1"
|
||||
material = "1.14.0"
|
||||
constraintlayout = "2.2.1"
|
||||
|
||||
Reference in new issue
Block a user