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

This commit is contained in:
Seb3thehacker committed 2026-11-29 22:19:46 -08:00
1 parent fb865d98e4
commit 7b08f9892a
3 files changed
+31 -3

No files matched your search

+11 -3
View File
@@ -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 | | [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 | | [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 | | [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 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 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 ### 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 ```xml
<service <service
android:name=".GearslipService" android:name=".GearslipService"
android:exported="true"> android:exported="true"
android:permission="app.seb3thehacker.gearslip.permission.BIND_APP">
<intent-filter> <intent-filter>
<action android:name="app.seb3thehacker.gearslip.APP" /> <action android:name="app.seb3thehacker.gearslip.APP" />
</intent-filter> </intent-filter>
@@ -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 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. 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 Gearslip binds your service when the driver opens your tile and unbinds it when they leave. Keep
no state that a rebind cannot rebuild. no state that a rebind cannot rebuild.
+9
View File
@@ -97,6 +97,15 @@
android:protectionLevel="normal" /> android:protectionLevel="normal" />
<uses-permission android:name="android.car.permission.TEMPLATE_RENDERER" /> <uses-permission android:name="android.car.permission.TEMPLATE_RENDERER" />
<!--
A Gearslip app's service requires this, so only an app signed with Gearslip's own key can
bind it and read what it shows (docs/BUILDING_APPS.md, "Gearslip apps").
-->
<permission
android:name="app.seb3thehacker.gearslip.permission.BIND_APP"
android:protectionLevel="signature" />
<uses-permission android:name="app.seb3thehacker.gearslip.permission.BIND_APP" />
<uses-feature android:name="android.hardware.usb.accessory" android:required="true" /> <uses-feature android:name="android.hardware.usb.accessory" android:required="true" />
<queries> <queries>
@@ -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. */ /** Finds the services that declare the Gearslip app action and a version Gearslip speaks. */
object GearslipAppCatalog { object GearslipAppCatalog {
const val ACTION = "app.seb3thehacker.gearslip.APP" 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_VERSION = "app.seb3thehacker.gearslip.version"
private const val META_LABEL = "app.seb3thehacker.gearslip.label" private const val META_LABEL = "app.seb3thehacker.gearslip.label"
private const val META_ICON = "app.seb3thehacker.gearslip.icon" private const val META_ICON = "app.seb3thehacker.gearslip.icon"
@@ -41,6 +47,11 @@ object GearslipAppCatalog {
return found.mapNotNull { info -> return found.mapNotNull { info ->
val service = info.serviceInfo ?: return@mapNotNull null val service = info.serviceInfo ?: return@mapNotNull null
if (!service.exported || service.packageName == context.packageName) 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 val meta = service.metaData
// android:value="1" arrives as an Int; a string "1" is taken too. // android:value="1" arrives as an Int; a string "1" is taken too.
val version = meta?.get(META_VERSION)?.toString()?.toIntOrNull() ?: return@mapNotNull null val version = meta?.get(META_VERSION)?.toString()?.toIntOrNull() ?: return@mapNotNull null