Skip to content

Commit 6878da2

Browse files
malysclaude
andcommitted
feat(catalog): tell a phone on board from a phone merely in range
BT_DEVICE_CONNECTED answers "the link is up", which a phone left in the house answers just as well when the car is parked next to it. Two entries that do not: - BT_DEVICE_ONBOARD: only devices still connected once the car has moved. Unknowable before the first metres, so UNAVAILABLE then, never false. - BT_DEVICE_HANDSFREE: the phone the head unit chose for hands-free, which answers from the first second and disambiguates two phones in range. Both are context entries: no snapshot key, no @SupportedOn. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent c14c811 commit 6878da2

10 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎docs/firmware-matrix.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
|---|:--:|:--:|:--:|:--:|:--:|:--:|
77
| BT_DEVICE_CONNECTED | — | — | — | — | — | — |
88
| ANY_BT_CONNECTED | — | — | — | — | — | — |
9+
| BT_DEVICE_ONBOARD | — | — | — | — | — | — |
10+
| BT_DEVICE_HANDSFREE | — | — | — | — | — | — |
911
| TIME_OF_DAY | — | — | — | — | — | — |
1012
| DAY_OF_WEEK | — | — | — | — | — | — |
1113
| DATE | — | — | — | — | — | — |

‎lib/src/main/java/com/mg4/hardware/catalog/ConditionType.kt‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,34 @@ enum class ConditionType(
6161
R.string.cond_bt_any, ConditionGroup.CONTEXT,
6262
ValueSpec.BOOL, snapshotKey = null
6363
),
64+
/**
65+
* A phone that is *in the car*, not merely within radio range of it.
66+
*
67+
* [BT_DEVICE_CONNECTED] answers "the link is up", which a phone left in the house
68+
* answers just as well when the car is parked ten metres away — and it is what made
69+
* arrival rules fire on the driveway. This one is only true of a device still connected
70+
* once the car has actually moved, so a phone that stayed behind drops out of it.
71+
*
72+
* Unknowable until the car has driven: before that the condition is UNAVAILABLE, never
73+
* false, and rules that must act at ignition should gate on [BT_DEVICE_CONNECTED] plus
74+
* a vehicle signal instead.
75+
*/
76+
BT_DEVICE_ONBOARD(
77+
R.string.cond_bt_onboard, ConditionGroup.CONTEXT,
78+
ValueSpec(ValueKind.BT_DEVICE), snapshotKey = null
79+
),
80+
/**
81+
* The phone the head unit has made its hands-free device.
82+
*
83+
* The head unit picks one, whatever the number of phones in range, and that choice is
84+
* available from the first second of the drive — which is what [BT_DEVICE_ONBOARD]
85+
* cannot offer. With two phones both in range it is the head unit's answer, not a
86+
* measurement, so it is a hint about which phone is driving, not proof.
87+
*/
88+
BT_DEVICE_HANDSFREE(
89+
R.string.cond_bt_handsfree, ConditionGroup.CONTEXT,
90+
ValueSpec(ValueKind.BT_DEVICE), snapshotKey = null
91+
),
6492
TIME_OF_DAY(
6593
R.string.cond_time, ConditionGroup.CONTEXT,
6694
ValueSpec(ValueKind.TIME_RANGE), snapshotKey = null

‎lib/src/main/res/values-de/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="ignition_start">Startet</string>
4747
<string name="cond_bt_device">Bluetooth-Telefon verbunden</string>
4848
<string name="cond_bt_any">Beliebiges Bluetooth-Gerät verbunden</string>
49+
<string name="cond_bt_onboard">Telefon an Bord (Bluetooth)</string>
50+
<string name="cond_bt_handsfree">Bluetooth-Freisprechtelefon</string>
4951
<string name="cond_time">Uhrzeit</string>
5052
<string name="cond_day">Wochentag</string>
5153
<string name="cond_date">Genaues Datum</string>

‎lib/src/main/res/values-es/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="ignition_start">Arrancando</string>
4747
<string name="cond_bt_device">Teléfono Bluetooth conectado</string>
4848
<string name="cond_bt_any">Cualquier dispositivo Bluetooth conectado</string>
49+
<string name="cond_bt_onboard">Teléfono a bordo (Bluetooth)</string>
50+
<string name="cond_bt_handsfree">Teléfono manos libres Bluetooth</string>
4951
<string name="cond_time">Hora del día</string>
5052
<string name="cond_day">Día de la semana</string>
5153
<string name="cond_date">Fecha exacta</string>

‎lib/src/main/res/values-fr/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="ignition_start">Démarrage</string>
4747
<string name="cond_bt_device">Téléphone Bluetooth connecté</string>
4848
<string name="cond_bt_any">Un appareil Bluetooth est connecté</string>
49+
<string name="cond_bt_onboard">Téléphone à bord (Bluetooth)</string>
50+
<string name="cond_bt_handsfree">Téléphone mains-libres Bluetooth</string>
4951
<string name="cond_time">Heure</string>
5052
<string name="cond_day">Jour de la semaine</string>
5153
<string name="cond_date">Date précise</string>

‎lib/src/main/res/values-it/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="ignition_start">Avviamento</string>
4747
<string name="cond_bt_device">Telefono Bluetooth connesso</string>
4848
<string name="cond_bt_any">Qualsiasi dispositivo Bluetooth connesso</string>
49+
<string name="cond_bt_onboard">Telefono a bordo (Bluetooth)</string>
50+
<string name="cond_bt_handsfree">Telefono vivavoce Bluetooth</string>
4951
<string name="cond_time">Ora del giorno</string>
5052
<string name="cond_day">Giorno della settimana</string>
5153
<string name="cond_date">Data esatta</string>

‎lib/src/main/res/values-pt/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="ignition_start">A arrancar</string>
4747
<string name="cond_bt_device">Telefone Bluetooth ligado</string>
4848
<string name="cond_bt_any">Qualquer dispositivo Bluetooth ligado</string>
49+
<string name="cond_bt_onboard">Telefone a bordo (Bluetooth)</string>
50+
<string name="cond_bt_handsfree">Telefone mãos-livres Bluetooth</string>
4951
<string name="cond_time">Hora do dia</string>
5052
<string name="cond_day">Dia da semana</string>
5153
<string name="cond_date">Data exata</string>

‎lib/src/main/res/values/strings.xml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<string name="ignition_start">Starting</string>
4747
<string name="cond_bt_device">Bluetooth phone connected</string>
4848
<string name="cond_bt_any">Any Bluetooth device connected</string>
49+
<string name="cond_bt_onboard">Phone on board (Bluetooth)</string>
50+
<string name="cond_bt_handsfree">Bluetooth hands-free phone</string>
4951
<string name="cond_time">Time of day</string>
5052
<string name="cond_day">Day of week</string>
5153
<string name="cond_date">Exact date</string>

‎lib/src/test/java/com/mg4/hardware/FirmwareSupportTest.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class FirmwareSupportTest {
2222
private val firmwareIndependentConditions = setOf(
2323
ConditionType.BT_DEVICE_CONNECTED,
2424
ConditionType.ANY_BT_CONNECTED,
25+
ConditionType.BT_DEVICE_ONBOARD,
26+
ConditionType.BT_DEVICE_HANDSFREE,
2527
ConditionType.TIME_OF_DAY,
2628
ConditionType.DAY_OF_WEEK,
2729
ConditionType.DATE,

‎lib/src/test/java/com/mg4/hardware/catalog/CatalogConsistencyTest.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ class CatalogConsistencyTest {
9595
val localOnly = setOf(
9696
ConditionType.BT_DEVICE_CONNECTED,
9797
ConditionType.ANY_BT_CONNECTED,
98+
ConditionType.BT_DEVICE_ONBOARD,
99+
ConditionType.BT_DEVICE_HANDSFREE,
98100
ConditionType.TIME_OF_DAY,
99101
ConditionType.DAY_OF_WEEK,
100102
ConditionType.DATE,

0 commit comments

Comments
 (0)