mirror of
https://github.com/twinksoftware/Gearslip.git
synced 2026-12-01 07:40:31 +01:00
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:
1 parent
fb865d98e4
commit
7b08f9892a
3 files changed
+31
-3
No files matched your search
@@ -97,6 +97,15 @@
|
||||
android:protectionLevel="normal" />
|
||||
<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" />
|
||||
|
||||
<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. */
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user