From 7b08f9892adee7b2afbc238dad567853349b9957 Mon Sep 17 00:00:00 2001 From: Seb3thehacker Date: Sun, 29 Nov 2026 22:19:46 -0800 Subject: [PATCH] Gearslip apps are locked to Gearslip's key: an app's service must require a permission only Gearslip's signer holds, and Gearslip skips any that doesn't --- docs/BUILDING_APPS.md | 14 +++++++++++--- gearslip/src/main/AndroidManifest.xml | 9 +++++++++ .../seb3thehacker/gearslip/host/GearslipApps.kt | 11 +++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/docs/BUILDING_APPS.md b/docs/BUILDING_APPS.md index ee72dfd..78bec2a 100644 --- a/docs/BUILDING_APPS.md +++ b/docs/BUILDING_APPS.md @@ -7,7 +7,7 @@ Gearslip renders four kinds of app on a car screen. This page specifies all four | [Templated apps](#templated-apps) | An AndroidX Car App Library app. Gearslip hosts it. | Works today | | [Media apps](#media-apps) | A `MediaBrowserService` that opted in to Android Auto. | Works today | | [Messaging apps](#messaging-apps) | An app whose notifications opted in to Android Auto. | Works today | -| [Gearslip apps](#gearslip-apps) | A native Gearslip screen, described over binder. | Specified here; not yet implemented | +| [Gearslip apps](#gearslip-apps) | A native Gearslip screen, described over binder. | Works today | Write a templated app when your app fits the Car App Library's templates, because it runs today and it also runs on Android Auto. Write a media app when you ship audio. Write a Gearslip app @@ -266,12 +266,14 @@ templated app if you need to draw a map, because version 1 lends no surface. ### Discovery -Export a service with the Gearslip action and declare the protocol version it speaks: +Export a service with the Gearslip action, require Gearslip's bind permission, and declare the +protocol version it speaks: ```xml + android:exported="true" + android:permission="app.seb3thehacker.gearslip.permission.BIND_APP"> @@ -288,6 +290,12 @@ launcher, under your application's own label and icon. To override either on the Gearslip binds to any app that declares this service. It asks the driver for nothing, exactly as a head unit asks nothing before running an Android Auto app. +Only apps signed with Gearslip's key hold the bind permission, so no other app on the phone can +bind your service and read your screens. Gearslip skips a service that doesn't require it. The +SDK also checks that the caller is signed with the certificate in +[Letting Gearslip in](#letting-gearslip-in). To test with a Gearslip you signed yourself, add +your key's digest to `trustedHosts`. + Gearslip binds your service when the driver opens your tile and unbinds it when they leave. Keep no state that a rebind cannot rebuild. diff --git a/gearslip/src/main/AndroidManifest.xml b/gearslip/src/main/AndroidManifest.xml index ad96956..88d6c09 100644 --- a/gearslip/src/main/AndroidManifest.xml +++ b/gearslip/src/main/AndroidManifest.xml @@ -97,6 +97,15 @@ android:protectionLevel="normal" /> + + + + diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/host/GearslipApps.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/host/GearslipApps.kt index 1fd27e0..988b0a5 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/host/GearslipApps.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/host/GearslipApps.kt @@ -29,6 +29,12 @@ class GearslipAppInfo(val component: ComponentName, val label: String, val icon: /** Finds the services that declare the Gearslip app action and a version Gearslip speaks. */ object GearslipAppCatalog { const val ACTION = "app.seb3thehacker.gearslip.APP" + + /** + * The permission a Gearslip app's service must require. Only apps signed with Gearslip's key + * hold it, so nothing else on the phone can bind the service and read the app's screens. + */ + const val BIND_PERMISSION = "app.seb3thehacker.gearslip.permission.BIND_APP" private const val META_VERSION = "app.seb3thehacker.gearslip.version" private const val META_LABEL = "app.seb3thehacker.gearslip.label" private const val META_ICON = "app.seb3thehacker.gearslip.icon" @@ -41,6 +47,11 @@ object GearslipAppCatalog { return found.mapNotNull { info -> val service = info.serviceInfo ?: return@mapNotNull null if (!service.exported || service.packageName == context.packageName) return@mapNotNull null + // A service any app could bind isn't offered: the driver's screens would be open to it. + if (service.permission != BIND_PERMISSION) { + Log.w("GearslipApp", "${service.packageName} skipped: its service doesn't require $BIND_PERMISSION") + return@mapNotNull null + } val meta = service.metaData // android:value="1" arrives as an Int; a string "1" is taken too. val version = meta?.get(META_VERSION)?.toString()?.toIntOrNull() ?: return@mapNotNull null