From b4c2f3db79cd2b1a242df4b7df4d8ae5d1bac0b4 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Mon, 30 Nov 2026 18:42:15 +0100 Subject: [PATCH 01/17] =?UTF-8?q?fix(hmiapp):=20Android=20Auto=20ne=20disp?= =?UTF-8?q?ara=C3=AEt=20plus=20apr=C3=A8s=20une=20nuit=20gar=C3=A9e=20(#27?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Une voiture garée réveille l'unité plusieurs fois par nuit, environ une minute à chaque fois (#261, X2 F39 ; #137, MINI F54). Chaque réveil chargeait l'appli et s'arrêtait avant les 2 minutes qui remettent le garde-fou à zéro ; l'heure, figée au début de chaque démarrage, les mettait dans les mêmes 15 minutes. Au troisième, l'appli était coupée et il fallait le SSH pour la ravoir. Chaque ligne du garde-fou garde maintenant le démarrage de l'unité (boot_id) et une marque posée après 30 s de marche (15 s après le démarrage automatique pour sa garde). Un chargement qui a tenu ne compte plus, sauf si l'iDrive redémarre dans le même démarrage de l'unité. Les anciennes lignes comptent comme avant. --- CHANGELOG.en.md | 4 + CHANGELOG.md | 4 + docs/ARCHITECTURE.md | 4 +- docs/MAINTENANCE.md | 14 +-- hmiapp/app_guards.cpp | 64 ++++++++++++-- hmiapp/app_guards.hpp | 16 ++-- hmiapp/entry_aa_app.cpp | 1 + hmiapp/guard_file.hpp | 152 ++++++++++++++++++++++++++------ tests/test_guard_file.cpp | 180 ++++++++++++++++++++++++++++---------- 9 files changed, 343 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 9ebd6a6..e3ba674 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,6 +13,10 @@ QEMU with the car's libraries). ## [Unreleased] +### Fixed + +- iDrive app: Android Auto disappeared from the menu after a night with the car parked, and SSH was needed to get it back ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). The car wakes the unit several times a night, about a minute each time: each wake-up loaded the app and ended before the 2 minutes that reset the crash guard, and the unit's date, standing still early in each start, put them all within the same 15 minutes. At the third, the guard took it for iDrive crashing in a loop and turned the app off. A load followed by 30 seconds of running no longer counts; an iDrive going down right after loading the app, or restarting three times within one start of the unit, still turns it off. Same rule for the automatic start (15 seconds). Tested on PC. + ## [0.13.0-rc.12] - 2026-11-27 · PC Release candidate for wireless: U-APSD power saving also taken away from a phone that joined the car's Wi-Fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 8603a02..0a77d77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +### Corrigé + +- Appli de l'iDrive : Android Auto disparaissait du menu après une nuit voiture garée, et il fallait le SSH pour le ravoir ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39 ; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). La voiture réveille l'unité plusieurs fois par nuit, environ une minute à chaque fois : chaque réveil chargeait l'appli et s'arrêtait avant les 2 minutes qui remettent le garde-fou à zéro, et l'heure de l'unité, figée au début de chaque démarrage, les mettait tous dans les mêmes 15 minutes. Au troisième, le garde-fou croyait à un iDrive qui plante en boucle et coupait l'appli. Un chargement suivi de 30 secondes de marche ne compte plus ; un iDrive qui tombe juste après avoir chargé l'appli, ou qui redémarre trois fois dans un même démarrage de l'unité, la coupe toujours. Même règle pour le démarrage automatique (15 secondes). Testé sur PC. + ## [0.13.0-rc.12] - 2026-11-27 · PC Version candidate pour le sans-fil : l'économie d'énergie U-APSD retirée aussi au téléphone qui a rejoint le diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 59b862b..8e738f8 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -106,7 +106,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `idrive_coding` | Codage de la voiture lu dans l'iDrive au démarrage de l'appli et écrit pour le service : touches du contrôleur, marque (BMW ou MINI) ; réglage de la fenêtre du mode de conduite, lu pour l'appli | | `posted_task.hpp` | Tâches différées de l'appli marquées pendant qu'elles tournent : les lectures de l'iDrive (cache par fil de HmiMain3D) y sont refusées, elles arrêteraient son fil (testé sur PC, `tests/test_idrive_lookups.py` garde ces lectures dans `idrive_coding`) | | `app_guards` | Interrupteur, garde-fou contre les plantages, démarrage automatique, cases du menu | -| `guard_file.hpp` | Fichiers des deux garde-fous : seuls les démarrages des 15 dernières minutes comptent, fichier remplacé d'un coup (testé sur PC) | +| `guard_file.hpp` | Fichiers des deux garde-fous : seuls comptent les évènements des 15 dernières minutes que la marche n'a pas suivis (ou du même démarrage de l'unité), fichier remplacé d'un coup (testé sur PC) | | `app_log`, `log_profile.hpp` | Journal de l'appli, profil maintenance | | `popup_peek.hpp`, `cds_parse.hpp` | Fenêtres de l'iDrive par-dessus Android Auto, lecture des données de l'iDrive | | `mono_clock.hpp` | Temps écoulé depuis le démarrage de l'unité, pour les délais | @@ -136,7 +136,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `tests/test_evo_mic.cpp` | Micro de la voiture sur une fausse libasound (`tests/fake_libasound.c`) : son transmis, arrêt immédiat avec un micro muet ou en panne, réouverture espacée | | `tests/test_wifi_link.cpp` | Qualité du Wi-Fi : messages du noyau, redémarrages de la puce et leur fil de lecture, ligne de journal, connexion rendue en fin de session | | `tests/test_pending_restart.cpp` | Redémarrage d'Android Auto quand la case du câble USB change en marche | -| `tests/test_guard_file.cpp` | Garde-fous : démarrages d'autres jours ignorés, boucle de plantages, date qui recule, ligne coupée, fichier remplacé d'un coup | +| `tests/test_guard_file.cpp` | Garde-fous : démarrages d'autres jours ignorés, boucle de plantages, réveils de nuit d'une voiture garée, iDrive relancé dans un même démarrage, anciennes lignes, date qui recule, ligne coupée, fichier remplacé d'un coup | | `tests/test_hold_machine.cpp` | Page vide de l'iDrive : ouverture, démarrage automatique, fenêtres, modes, appels, touches | | `tests/test_media_recall.cpp` | Double appui sur MEDIA : geste lu par le vrai décodeur, conditions, demande à usage unique | | `tests/test_aa_frame.cpp`, `tests/test_aa_messages.cpp`, `tests/test_tcp_server.cpp` | Trames hostiles, messages construits, écoute TCP | diff --git a/docs/MAINTENANCE.md b/docs/MAINTENANCE.md index 55efb71..4ea1ea3 100644 --- a/docs/MAINTENANCE.md +++ b/docs/MAINTENANCE.md @@ -175,11 +175,15 @@ cd /var/local/data/AA && rm -f maintenance app.log app.old.log service.log servi ## Garde-fou -Si l'iDrive redémarre trois fois en 15 minutes, chaque fois moins de 2 minutes après avoir chargé l'appli, celle-ci ne -se lance plus et l'iDrive repart sans elle : le fichier `/var/local/data/AA/app-guard` compte ces démarrages, et -s'efface tout seul après 2 minutes sans incident. Seuls ceux des 15 dernières minutes comptent : l'appli se relance -d'elle-même à un démarrage de l'iDrive 15 minutes plus tard (et si la cause est toujours là, l'iDrive peut redémarrer -encore trois fois). Le fichier `app.disable`, posé à la main, garde l'appli éteinte. Pour la réactiver tout de suite, +Si l'iDrive tombe trois fois en 15 minutes moins de 30 secondes après avoir chargé l'appli, celle-ci ne se lance +plus et l'iDrive repart sans elle : le fichier `/var/local/data/AA/app-guard` compte ces chargements, et s'efface tout +seul après 2 minutes sans incident. Un chargement suivi de 30 secondes de marche ne compte plus, sauf si l'iDrive +redémarre ensuite sans que l'unité redémarre : une voiture garée réveille l'unité environ une minute plusieurs fois +par nuit, et ces réveils coupaient l'appli au matin ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261)). Chaque ligne du fichier donne la date, le démarrage +de l'unité (`/proc/sys/kernel/random/boot_id`) et 1 si le chargement a tenu. Seuls ceux des 15 dernières minutes +comptent : l'appli se relance d'elle-même à un démarrage de l'iDrive 15 minutes plus tard (et si la cause est +toujours là, l'iDrive peut tomber encore trois fois). Le démarrage automatique a la même garde (`bootguard`), un +démarrage suivi de 15 secondes de marche ne comptant plus. Le fichier `app.disable`, posé à la main, garde l'appli éteinte. Pour la réactiver tout de suite, après avoir trouvé la cause : ```sh diff --git a/hmiapp/app_guards.cpp b/hmiapp/app_guards.cpp index 1a3d5c3..3516a4f 100644 --- a/hmiapp/app_guards.cpp +++ b/hmiapp/app_guards.cpp @@ -29,8 +29,35 @@ const int kCrashGuardMax = 3; // starts without 2 min of uptime before the app // removed the file over SSH (#4). const long kCrashGuardWindowS = 15 * 60; const long kStableAfterS = 120; - -bool g_autostartDone = false, g_stableMarked = false; +// A run that goes on this long after loading the app, or after its automatic start, did not end because of it: the +// load or the start no longer counts (guard_file.hpp). Each wake-up of a parked car (#261) lasted about a minute, the +// automatic start coming 30 s after iDrive's; an iDrive brought down by the app went down within seconds. +const long kLoadLivedAfterS = 30; +const long kAutostartLivedAfterS = 15; + +bool g_autostartDone = false, g_stableMarked = false, g_loadLived = false, g_autostartLived = false; +long g_autostartAt = 0; // monotonic seconds when the automatic start launched the service, 0 before + +// This start of the unit, as the kernel names it ("" when it cannot be read): the guards tell the events of this start +// from those of earlier ones. +const char* bootId() { + static char id[kBootIdMax] = ""; + static bool read = false; + if (!read) { + read = true; + FILE* f = fopen("/proc/sys/kernel/random/boot_id", "re"); + if (f) { + if (fgets(id, sizeof(id), f)) { + id[strcspn(id, "\n")] = '\0'; + } + fclose(f); + } + if (!validBootId(id)) { + id[0] = '\0'; + } + } + return id; +} bool fileExists(const char* p) { struct stat st; @@ -57,10 +84,12 @@ void setSwitch(const char* what, const char* path, bool on, const char* content) } // Both guards count on the date, not on the monotonic clock (mono_clock.hpp): the starts they count can be in -// different runs of the unit, and that clock starts again at each. +// different runs of the unit, and that clock starts again at each. Each line also names the unit's start it was +// written in (bootId), and is marked once its run lasted (markRunLived). bool bootGuardAllows() { int n = 0; - if (!guardTurn(contract::kBootGuard, static_cast(time(nullptr)), kBootGuardWindowS, kBootGuardMax, &n)) { + if (!guardTurn(contract::kBootGuard, static_cast(time(nullptr)), kBootGuardWindowS, kBootGuardMax, bootId(), + &n)) { alog("autostart SKIPPED by the bootloop guard (%d starts within %ld min): use Start in the menu", n, kBootGuardWindowS / 60); return false; @@ -79,12 +108,14 @@ bool appDisabled() { } // ---- crash guard (HMI crash loop protection) ------------------------------------------------------------------------ -// create() adds one line; 2 minutes later the status poll deletes the file. kCrashGuardMax lines of the last -// kCrashGuardWindowS = the HMI went down that many times shortly after loading us: create() then refuses (iDrive starts -// without the app), until those loads are older. +// create() adds one line; 30 s later the status poll marks it lived, 2 minutes later it deletes the file. +// kCrashGuardMax counted lines of the last kCrashGuardWindowS (not lived, or of this start of the unit) = the HMI went +// down that many times shortly after loading us: create() then refuses (iDrive starts without the app), until those +// loads are older. bool crashGuardAllows() { int n = 0; - if (!guardTurn(contract::kAppGuard, static_cast(time(nullptr)), kCrashGuardWindowS, kCrashGuardMax, &n)) { + if (!guardTurn(contract::kAppGuard, static_cast(time(nullptr)), kCrashGuardWindowS, kCrashGuardMax, bootId(), + &n)) { alog( "crash guard: the HMI restarted %d times within %ld min, each time shortly after loading this app: app " "turned off. It loads again at an iDrive start once these are %ld min old; to load it at once, remove %s " @@ -95,6 +126,22 @@ bool crashGuardAllows() { return true; } +void markRunLived(long initTime) { + const long now = monoSeconds(); + if (!g_loadLived && initTime && now - initTime >= kLoadLivedAfterS) { + g_loadLived = true; + if (!markGuardLived(contract::kAppGuard, bootId())) { + alog("crash guard: %s could not be updated (errno %d)", contract::kAppGuard, errno); + } + } + if (!g_autostartLived && g_autostartAt && now - g_autostartAt >= kAutostartLivedAfterS) { + g_autostartLived = true; + if (!markGuardLived(contract::kBootGuard, bootId())) { + alog("autostart guard: %s could not be updated (errno %d)", contract::kBootGuard, errno); + } + } +} + void resetGuardsWhenStable(long initTime) { if (!g_stableMarked && initTime && monoSeconds() - initTime >= kStableAfterS) { g_stableMarked = true; @@ -122,6 +169,7 @@ void serviceAutostart(long initTime) { return; } alog("autostart: launching the service"); + g_autostartAt = monoSeconds(); launchService(); } diff --git a/hmiapp/app_guards.hpp b/hmiapp/app_guards.hpp index 85bc460..c6799ff 100644 --- a/hmiapp/app_guards.hpp +++ b/hmiapp/app_guards.hpp @@ -2,13 +2,16 @@ // SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 // What keeps the app from harming iDrive, and the automatic start they protect. Files in /var/local/data/AA: // app.disable present: the app stays off (iDrive starts without it) -// app-guard crash guard: one line per load of the app; 3 loads within 15 minutes that did not reach 2 minutes of -// uptime (an HMI crash loop) and the app refuses to start until they are 15 minutes old. Removed once -// the HMI has been up 2 minutes with it. +// app-guard crash guard: one line per load of the app; 3 loads within 15 minutes whose run ended within 30 s +// (an HMI crash loop), or that iDrive restarted from within the same start of the unit, and the app +// refuses to start until they are 15 minutes old. A load followed by 30 s of running no longer counts: +// a parked car wakes the unit for about a minute at a time (#261). Removed once the HMI has been up +// 2 minutes with it. // autostart present: Android Auto starts by itself 30 s after iDrive // usb present: Android Auto over a USB cable instead of wireless (docs/USB.md) -// bootguard the automatic starts of the last 15 minutes; at 3, the automatic start is skipped (Start in the menu -// still works). Removed by a manual start and once the HMI has been up 2 minutes. +// bootguard the automatic starts of the last 15 minutes not followed by 15 s of running (or of this start of the +// unit); at 3, the automatic start is skipped (Start in the menu still works). Removed by a manual +// start and once the HMI has been up 2 minutes. #ifndef ENTRY_AAD_HMIAPP_APP_GUARDS_HPP #define ENTRY_AAD_HMIAPP_APP_GUARDS_HPP @@ -17,10 +20,11 @@ namespace app { // When iDrive creates the app; each logs why it keeps the app off. bool appDisabled(); // app.disable is present -bool crashGuardAllows(); // counts this load; false after 3 loads within 15 minutes without 2 minutes of uptime +bool crashGuardAllows(); // counts this load; false after 3 counted loads within 15 minutes (app-guard above) // Once per status poll, initTime being when onInit ran on the monotonic clock (mono_clock.hpp), 0 before: the car's // date can move back hours after iDrive starts, which held these delays back as long (#86). +void markRunLived(long initTime); // 30 s after onInit, 15 s after the automatic start: lines lived void resetGuardsWhenStable(long initTime); // 2 minutes up: not a crash loop void serviceAutostart(long initTime); // the automatic start, once, 30 s after onInit diff --git a/hmiapp/entry_aa_app.cpp b/hmiapp/entry_aa_app.cpp index 82e8a2f..d1cb70c 100644 --- a/hmiapp/entry_aa_app.cpp +++ b/hmiapp/entry_aa_app.cpp @@ -507,6 +507,7 @@ void statusRun(void*) { if (!g_settingsShown) { showSettings(app); } + markRunLived(g_initTime); resetGuardsWhenStable(g_initTime); serviceStop(); if (g_restart.asked()) { diff --git a/hmiapp/guard_file.hpp b/hmiapp/guard_file.hpp index 014a56c..0d02d0e 100644 --- a/hmiapp/guard_file.hpp +++ b/hmiapp/guard_file.hpp @@ -1,7 +1,16 @@ // Copyright (c) 2026 Jiraiya43 // SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 -// The guards' files (app_guards.hpp): one date per line, the app's loads or its automatic starts. Only the recent -// ones count, and a file is replaced whole, never left half written. Pure file logic: tests/test_guard_file.cpp. +// The guards' files (app_guards.hpp): one line per counted event, the app's loads or its automatic starts. Only the +// recent ones count, and a file is replaced whole, never left half written. Pure file logic: tests/test_guard_file.cpp. +// +// A line is " ": the date of the event, the id of the unit's start it happened in +// (/proc/sys/kernel/random/boot_id), and 1 once that run went on for a while after it (markGuardLived), else 0. +// The car wakes the unit several times a night while it is parked (an X2 F39, #261): each wake-up loads the app and +// lasts about a minute, short of the 2 minutes that clear the guards, and the unit's date stands still at the same +// value early in each start. Counted on their dates alone, three wake-ups turned the app off until someone removed the +// file over SSH. So an event counts when its run ended early (not lived: an iDrive that went down right after loading +// the app, the unit restarted since or not), or when it happened earlier in this same start (iDrive itself restarted +// without the unit). A line of an older version, a date alone, counts as before. #ifndef ENTRY_AAD_HMIAPP_GUARD_FILE_HPP #define ENTRY_AAD_HMIAPP_GUARD_FILE_HPP @@ -9,12 +18,20 @@ #include #include #include +#include #include namespace evo { namespace app { -const int kGuardDatesMax = 8; // dates kept in a guard file: more than any guard counts +const int kGuardDatesMax = 8; // lines kept in a guard file: more than any guard counts +const size_t kBootIdMax = 40; // a boot id: 36 characters + +struct GuardEntry { + long date; + char boot[kBootIdMax]; // "" when unknown (a line of an older version, or no boot id on this unit) + bool lived; // its run went on for a while after the event +}; // A date within window seconds of now, on either side. The car's date can step back a little between two starts (a // line just ahead still counts), but a line hours ahead (a date set back since, or never set) would count for ever. @@ -24,41 +41,86 @@ inline bool guardDateRecent(long date, long now, long window) { return d < window && -d < window; } -// The recent dates of path, at most kGuardDatesMax, into dates; how many. A missing file counts nothing, and so does a -// line that is not a date (one cut by a power loss while an older version appended it). -inline int readGuardDates(const char* path, long now, long window, long* dates) { +// A boot id as the kernel gives it: hexadecimal digits and dashes, 36 characters; "" is accepted (unknown). +inline bool validBootId(const char* id) { + const size_t n = strlen(id); + if (n >= kBootIdMax) { + return false; + } + for (size_t i = 0; i < n; ++i) { + const char c = id[i]; + if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || c == '-')) { + return false; + } + } + return true; +} + +// Whether an event counts against the guard, the unit being in its start `boot` ("" when unknown). +inline bool guardEntryCounts(const GuardEntry& e, const char* boot) { + return !e.lived || (boot[0] && !strcmp(e.boot, boot)); +} + +// One line into e; false when it is not one (a line cut by a power loss, text). +inline bool parseGuardLine(const char* line, GuardEntry& e) { + char* end = nullptr; + errno = 0; + const long date = strtol(line, &end, 10); + if (end == line || errno != 0) { + return false; + } + e.date = date; + e.boot[0] = '\0'; + e.lived = false; + if (*end == '\n' || *end == '\0') { + return true; // a date alone: a line of an older version + } + char boot[kBootIdMax + 1]; + int lived = -1; + char rest = 0; + if (*end != ' ' || sscanf(end, " %40s %d%c", boot, &lived, &rest) < 2 || (rest != 0 && rest != '\n') || + (lived != 0 && lived != 1) || !validBootId(boot)) { + return false; + } + if (strcmp(boot, "-") != 0) { // "-": written for an unknown start + memcpy(e.boot, boot, strlen(boot) + 1); + } + e.lived = lived == 1; + return true; +} + +// The lines of path whose date is recent, at most kGuardDatesMax, into entries; how many. A missing file counts +// nothing, and neither does a line that is not one. +inline int readGuardEntries(const char* path, long now, long window, GuardEntry* entries) { FILE* f = fopen(path, "re"); if (!f) { return 0; } int n = 0; - char line[64]; + char line[128]; while (n < kGuardDatesMax && fgets(line, sizeof(line), f)) { - char* end = nullptr; - errno = 0; - const long date = strtol(line, &end, 10); - if (end == line || errno != 0 || (*end != '\n' && *end != '\0')) { - continue; - } - if (guardDateRecent(date, now, window)) { - dates[n++] = date; + GuardEntry e; + if (parseGuardLine(line, e) && guardDateRecent(e.date, now, window)) { + entries[n++] = e; } } fclose(f); return n; } -// Replaces path with dates, one per line: written beside it, synced, then renamed over it, so a power loss leaves +// Replaces path with entries, one per line: written beside it, synced, then renamed over it, so a power loss leaves // either the old file or the new one. False when it could not be written (the old one then stays as it was). -inline bool writeGuardDates(const char* path, const long* dates, int n) { +inline bool writeGuardEntries(const char* path, const GuardEntry* entries, int n) { char tmp[256]; if (snprintf(tmp, sizeof(tmp), "%s.tmp", path) >= static_cast(sizeof(tmp))) { return false; } - char text[kGuardDatesMax * 24]; + char text[kGuardDatesMax * (24 + kBootIdMax + 4)]; int len = 0; for (int i = 0; i < n && i < kGuardDatesMax; ++i) { - len += snprintf(text + len, sizeof(text) - len, "%ld\n", dates[i]); + const GuardEntry& e = entries[i]; + len += + snprintf(text + len, sizeof(text) - len, "%ld %s %d\n", e.date, e.boot[0] ? e.boot : "-", e.lived ? 1 : 0); } const int fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); if (fd < 0) { @@ -84,21 +146,53 @@ inline bool writeGuardDates(const char* path, const long* dates, int n) { return true; } -// One turn of a guard (max: kGuardDatesMax at most): true while fewer than max dates of path are recent, now then -// added to them and the old ones dropped; false at max, the file left as it is. *recent: how many were. A file that -// cannot be written does not stop the start: it only cannot be counted. -inline bool guardTurn(const char* path, long now, long window, int max, int* recent) { - long dates[kGuardDatesMax]; - int n = readGuardDates(path, now, window, dates); - *recent = n; - if (n >= max || n >= kGuardDatesMax) { +// One turn of a guard (max: kGuardDatesMax at most), the unit being in its start `boot` ("" when unknown): true while +// fewer than max recent lines count (guardEntryCounts), this event then added to them and the others dropped; false at +// max, the file left as it is. *counted: how many counted. A file that cannot be written does not stop the start: it +// only cannot be counted. +inline bool guardTurn(const char* path, long now, long window, int max, const char* boot, int* counted) { + GuardEntry entries[kGuardDatesMax]; + const int n = readGuardEntries(path, now, window, entries); + int kept = 0; + for (int i = 0; i < n; ++i) { + if (guardEntryCounts(entries[i], boot)) { + entries[kept++] = entries[i]; + } + } + *counted = kept; + if (kept >= max || kept >= kGuardDatesMax) { return false; } - dates[n++] = now; - writeGuardDates(path, dates, n); + GuardEntry& e = entries[kept++]; + e.date = now; + e.boot[0] = '\0'; + if (validBootId(boot)) { + memcpy(e.boot, boot, strlen(boot) + 1); + } + e.lived = false; + writeGuardEntries(path, entries, kept); return true; } +// The events of this start `boot` lived: their run went on long enough after them. Nothing when the start is unknown +// (its lines could not be told from the others) or the file has none of them. False only when it could not be written. +inline bool markGuardLived(const char* path, const char* boot) { + if (!boot[0] || !validBootId(boot)) { + return true; + } + GuardEntry entries[kGuardDatesMax]; + const long kAnyDate = 0x7fffffffL; // every line, whatever its date: only rewritten, never counted here + const int n = readGuardEntries(path, 0, kAnyDate, entries); + bool changed = false; + for (int i = 0; i < n; ++i) { + if (!entries[i].lived && !strcmp(entries[i].boot, boot)) { + entries[i].lived = true; + changed = true; + } + } + return !changed || writeGuardEntries(path, entries, n); +} + } // namespace app } // namespace evo diff --git a/tests/test_guard_file.cpp b/tests/test_guard_file.cpp index 99e260c..4ed0b5b 100644 --- a/tests/test_guard_file.cpp +++ b/tests/test_guard_file.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2026 Jiraiya43 // SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 -// hmiapp/guard_file.hpp: the guards' files count only recent dates, and are replaced whole. +// hmiapp/guard_file.hpp: the guards' files count only recent events whose run ended early (or of this start of the +// unit), and are replaced whole. #include #include #include @@ -21,13 +22,20 @@ namespace { +using evo::app::GuardEntry; using evo::app::guardTurn; -using evo::app::readGuardDates; -using evo::app::writeGuardDates; +using evo::app::markGuardLived; +using evo::app::readGuardEntries; +using evo::app::writeGuardEntries; const long kWindow = 15 * 60; const int kMax = 3; const long kNow = 1795000000; // a date in 2026 +// Starts of the unit, as /proc/sys/kernel/random/boot_id names them. +const char kBootA[] = "1b4e28ba-2fa1-11d2-883f-0016d3cca427"; +const char kBootB[] = "6fa459ea-ee8a-3ca4-894e-db77e160355e"; +const char kBootC[] = "16fd2706-8baf-433b-82eb-8c7fada847da"; +const char kBootD[] = "886313e1-3b8a-5372-9b90-0c9aee199e5d"; std::string g_dir; @@ -56,7 +64,15 @@ std::string get(const std::string& file) { return text; } -std::string lines(long a, long b = 0, long c = 0) { +// One line as the guard writes it. +std::string line(long date, const char* boot, bool lived) { + char text[96]; + snprintf(text, sizeof(text), "%ld %s %d\n", date, boot[0] ? boot : "-", lived ? 1 : 0); + return text; +} + +// Lines of an older version: a date alone. +std::string dates(long a, long b = 0, long c = 0) { char text[96]; snprintf(text, sizeof(text), "%ld\n", a); std::string all = text; @@ -79,76 +95,144 @@ bool exists(const std::string& file) { void oldLoadsDoNotCount() { const std::string f = path("app-guard"); const long twoDays = 2 * 24 * 3600; - put(f, lines(kNow - twoDays - 600, kNow - twoDays - 300, kNow - twoDays)); - int recent = -1; - CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, &recent)); - CHECK(recent == 0); - CHECK(get(f) == lines(kNow)); // the old ones dropped, this load counted + put(f, dates(kNow - twoDays - 600, kNow - twoDays - 300, kNow - twoDays)); + int counted = -1; + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, kBootA, &counted)); + CHECK(counted == 0); + CHECK(get(f) == line(kNow, kBootA, false)); // the old ones dropped, this load counted CHECK(!exists(f + ".tmp")); puts("PASS loads of other days do not count"); } +// iDrive brought down right after loading the app, start after start of the unit: none of them lived. void crashLoop() { const std::string f = path("loop"); - int recent = -1; + int counted = -1; unlink(f.c_str()); - CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, &recent) && recent == 0); // no file yet - CHECK(guardTurn(f.c_str(), kNow + 70, kWindow, kMax, &recent) && recent == 1); - CHECK(guardTurn(f.c_str(), kNow + 140, kWindow, kMax, &recent) && recent == 2); - CHECK(get(f) == lines(kNow, kNow + 70, kNow + 140)); - CHECK(!guardTurn(f.c_str(), kNow + 210, kWindow, kMax, &recent) && recent == 3); // the third short run: off - CHECK(get(f) == lines(kNow, kNow + 70, kNow + 140)); // left as it is - CHECK(!guardTurn(f.c_str(), kNow + kWindow - 1, kWindow, kMax, &recent) && recent == 3); + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, kBootA, &counted) && counted == 0); // no file yet + CHECK(guardTurn(f.c_str(), kNow + 70, kWindow, kMax, kBootB, &counted) && counted == 1); + CHECK(guardTurn(f.c_str(), kNow + 140, kWindow, kMax, kBootC, &counted) && counted == 2); + const std::string three = + line(kNow, kBootA, false) + line(kNow + 70, kBootB, false) + line(kNow + 140, kBootC, false); + CHECK(get(f) == three); + CHECK(!guardTurn(f.c_str(), kNow + 210, kWindow, kMax, kBootD, &counted) && counted == 3); // the third: off + CHECK(get(f) == three); // left as it is + CHECK(!guardTurn(f.c_str(), kNow + kWindow - 1, kWindow, kMax, kBootD, &counted) && counted == 3); // 15 minutes after the first load: it no longer counts, the app loads again - CHECK(guardTurn(f.c_str(), kNow + kWindow, kWindow, kMax, &recent) && recent == 2); - CHECK(get(f) == lines(kNow + 70, kNow + 140, kNow + kWindow)); - puts("PASS 3 loads within 15 minutes turn the app off, until the first is 15 minutes old"); + CHECK(guardTurn(f.c_str(), kNow + kWindow, kWindow, kMax, kBootD, &counted) && counted == 2); + CHECK(get(f) == + line(kNow + 70, kBootB, false) + line(kNow + 140, kBootC, false) + line(kNow + kWindow, kBootD, false)); + puts("PASS 3 loads that did not last within 15 minutes turn the app off, until the first is 15 minutes old"); +} + +// #261, X2 F39: a parked car woke the unit again and again overnight, each run about a minute long, the unit's date the +// same early in each start. Each load lived 30 s: none of them counts, whatever the dates say. +void nightWakeUps() { + const std::string f = path("night"); + unlink(f.c_str()); + const char* boots[] = {kBootA, kBootB, kBootC, kBootD}; + int counted = -1; + for (int i = 0; i < 4; ++i) { + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, boots[i], &counted) && counted == 0); + CHECK(markGuardLived(f.c_str(), boots[i])); + } + // The morning's start: loaded, the earlier runs that lasted dropped from the file. + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, kBootA, &counted) && counted == 0); + CHECK(get(f) == line(kNow, kBootA, false)); + puts("PASS loads followed by 30 s of running never add up, overnight wake-ups included"); +} + +// iDrive itself restarted (the unit did not): a load that lived still counts within the same start. +void restartWithinOneStart() { + const std::string f = path("same"); + unlink(f.c_str()); + int counted = -1; + for (int i = 0; i < 3; ++i) { + CHECK(guardTurn(f.c_str(), kNow + 60 * i, kWindow, kMax, kBootA, &counted) && counted == i); + CHECK(markGuardLived(f.c_str(), kBootA)); + } + CHECK(!guardTurn(f.c_str(), kNow + 200, kWindow, kMax, kBootA, &counted) && counted == 3); + // In a new start of the unit, those that lived no longer count. + CHECK(guardTurn(f.c_str(), kNow + 260, kWindow, kMax, kBootB, &counted) && counted == 0); + puts("PASS iDrive restarting three times within one start of the unit turns the app off"); +} + +// markGuardLived only touches the lines of its own start, and nothing without a known start. +void livedOnlyForItsStart() { + const std::string f = path("mark"); + put(f, line(kNow, kBootA, false) + line(kNow + 5, kBootB, false)); + CHECK(markGuardLived(f.c_str(), kBootB)); + CHECK(get(f) == line(kNow, kBootA, false) + line(kNow + 5, kBootB, true)); + CHECK(markGuardLived(f.c_str(), "")); // unknown start: nothing written + CHECK(get(f) == line(kNow, kBootA, false) + line(kNow + 5, kBootB, true)); + // A unit without a boot id: its loads are never marked, so they count as before. + unlink(f.c_str()); + int counted = -1; + for (int i = 0; i < 3; ++i) { + CHECK(guardTurn(f.c_str(), kNow + i, kWindow, kMax, "", &counted) && counted == i); + CHECK(markGuardLived(f.c_str(), "")); + } + CHECK(!guardTurn(f.c_str(), kNow + 3, kWindow, kMax, "", &counted) && counted == 3); + puts("PASS only the lines of this start are marked; without a boot id, loads count as before"); +} + +// The lines of the version before: a date alone, counted as a load that did not last. +void olderLines() { + const std::string f = path("older"); + put(f, dates(kNow - 30, kNow - 20, kNow - 10)); + int counted = -1; + CHECK(!guardTurn(f.c_str(), kNow, kWindow, kMax, kBootA, &counted) && counted == 3); + put(f, dates(kNow - 30, kNow - 20)); + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, kBootA, &counted) && counted == 2); + CHECK(get(f) == line(kNow - 30, "", false) + line(kNow - 20, "", false) + line(kNow, kBootA, false)); + puts("PASS a date alone (the version before) counts as before"); } void dateMovedBack() { const std::string f = path("back"); // A line 5 minutes ahead (the date stepped back a little since) still counts; one a day ahead does not. - put(f, lines(kNow + 300, kNow - 60, kNow + 24 * 3600)); - int recent = -1; - CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, &recent) && recent == 2); - CHECK(get(f) == lines(kNow + 300, kNow - 60, kNow)); + put(f, dates(kNow + 300, kNow - 60, kNow + 24 * 3600)); + int counted = -1; + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, kBootA, &counted) && counted == 2); + CHECK(get(f) == line(kNow + 300, "", false) + line(kNow - 60, "", false) + line(kNow, kBootA, false)); // On the car, long is 32 bits: a date far from now must not overflow the difference. put(f, "-2147483647\n2147483647\n"); - CHECK(guardTurn(f.c_str(), 2147483000L, kWindow, kMax, &recent) && recent == 1); + CHECK(guardTurn(f.c_str(), 2147483000L, kWindow, kMax, kBootA, &counted) && counted == 1); puts("PASS a date a little ahead counts, one far ahead or far behind does not"); } -void notADate() { +void notALine() { const std::string f = path("cut"); - char good[32]; - snprintf(good, sizeof(good), "%ld\n", kNow - 10); - // A line cut by a power loss while an older version appended it, an empty line, text: none of them counts. - put(f, std::string("17952") + "x\n\nhello\n" + good + good); - int recent = -1; - CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, &recent) && recent == 2); - CHECK(get(f) == lines(kNow - 10, kNow - 10, kNow)); - long dates[evo::app::kGuardDatesMax]; + const std::string good = line(kNow - 10, kBootA, false); + // A line cut by a power loss, an empty line, text, a bad start, a bad mark: none of them counts. + put(f, std::string("17952") + "x\n\nhello\n" + "1795000000 not-a-boot! 0\n" + "1795000000 " + kBootA + " 7\n" + + "1795000000 " + kBootA + " 1 more\n" + good + good); + int counted = -1; + CHECK(guardTurn(f.c_str(), kNow, kWindow, kMax, kBootB, &counted) && counted == 2); + CHECK(get(f) == good + good + line(kNow, kBootB, false)); + GuardEntry entries[evo::app::kGuardDatesMax]; std::string many; for (int i = 0; i < 12; ++i) { many += good; } put(f, many); - CHECK(readGuardDates(f.c_str(), kNow, kWindow, dates) == evo::app::kGuardDatesMax); // at most 8 read - puts("PASS a line that is not a date is ignored, 8 dates at most"); + CHECK(readGuardEntries(f.c_str(), kNow, kWindow, entries) == evo::app::kGuardDatesMax); // at most 8 read + puts("PASS a line that is not one is ignored, 8 lines at most"); } void replacedWhole() { const std::string f = path("whole"); - const long dates[] = {kNow - 5, kNow}; + GuardEntry two[2] = {{kNow - 5, "", false}, {kNow, "", true}}; + memcpy(two[1].boot, kBootA, sizeof(kBootA)); put(f + ".tmp", "left by a power loss\n"); // a write cut before its rename - put(f, lines(kNow - 900)); - CHECK(writeGuardDates(f.c_str(), dates, 2)); - CHECK(get(f) == lines(kNow - 5, kNow) && !exists(f + ".tmp")); + put(f, dates(kNow - 900)); + CHECK(writeGuardEntries(f.c_str(), two, 2)); + CHECK(get(f) == line(kNow - 5, "", false) + line(kNow, kBootA, true) && !exists(f + ".tmp")); // It cannot be written (no such folder): false, nothing left behind; the guard still lets the start go. const std::string nowhere = path("missing/app-guard"); - CHECK(!writeGuardDates(nowhere.c_str(), dates, 2) && !exists(nowhere)); - int recent = -1; - CHECK(guardTurn(nowhere.c_str(), kNow, kWindow, kMax, &recent) && recent == 0); + CHECK(!writeGuardEntries(nowhere.c_str(), two, 2) && !exists(nowhere)); + int counted = -1; + CHECK(guardTurn(nowhere.c_str(), kNow, kWindow, kMax, kBootA, &counted) && counted == 0); puts("PASS written beside, then renamed over the old file; a file that cannot be written stops nothing"); } @@ -160,14 +244,18 @@ int main() { g_dir = dir; oldLoadsDoNotCount(); crashLoop(); + nightWakeUps(); + restartWithinOneStart(); + livedOnlyForItsStart(); + olderLines(); dateMovedBack(); - notADate(); + notALine(); replacedWhole(); - const char* names[] = {"app-guard", "loop", "back", "cut", "whole"}; + const char* names[] = {"app-guard", "loop", "night", "same", "mark", "older", "back", "cut", "whole"}; for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); ++i) { unlink(path(names[i]).c_str()); } rmdir(dir); - puts("PASS guard file: recent dates only, replaced whole"); + puts("PASS guard file: recent events whose run ended early, or of this start, replaced whole"); return 0; } From e967fee41447f53d5305e00b64a4df6c96c25cf9 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Mon, 30 Nov 2026 22:37:44 +0100 Subject: [PATCH 02/17] =?UTF-8?q?fix(bluetooth):=20redemander=20le=20son?= =?UTF-8?q?=20du=20t=C3=A9l=C3=A9phone=20pendant=20Android=20Auto=20(#271)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Quand le Bluetooth du téléphone tombe de lui-même pendant une séance sans fil (conducteur sorti de la voiture, radio en défaut : raisons 3 et 4 de la pile Alps), Android Auto reste à l'écran par le Wi-Fi sans aucun son, et la voiture ne rebranche pas toujours le téléphone : 145 s sur une MINI F56 (#88), 129 s sur un X1 F48 (#203), téléphone dans la voiture ; pour de bon quand le téléphone revient après les 70 s de reconnexion de la pile. Pendant la séance, le service demande à la pile de rebrancher les appels (fonction 2) et le son (fonction 4) du téléphone qui sont tombés : BtApplDeviceConnectReq(adresse, fonction, 0), arguments lus dans l'outil Alps evo_genivi_converter. 15 s après la coupure, toutes les 30 s, toutes les 2 minutes après 5 minutes, plus tôt quand le téléphone se montre de nouveau. Coupure choisie (raisons 1 et 2) ou hors séance : rien. platform/phone_audio_recall.hpp (pur, tests/test_phone_audio_recall.cpp sur les chronologies des journaux), banc D-Bus de tests/test_alps_spp.cpp. --- CHANGELOG.en.md | 1 + CHANGELOG.md | 1 + Makefile | 4 + docs/ARCHITECTURE.md | 2 + platform/alps_spp.cpp | 61 +++++++- platform/alps_spp.hpp | 14 +- platform/phone_audio_recall.hpp | 154 ++++++++++++++++++++ platform/wireless_loop.cpp | 6 + tests/test_alps_spp.cpp | 88 +++++++++++- tests/test_phone_audio_recall.cpp | 227 ++++++++++++++++++++++++++++++ tests/test_wireless_lifecycle.cpp | 9 +- 11 files changed, 559 insertions(+), 8 deletions(-) create mode 100644 platform/phone_audio_recall.hpp create mode 100644 tests/test_phone_audio_recall.cpp diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index e3ba674..2dd3abd 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -16,6 +16,7 @@ QEMU with the car's libraries). ### Fixed - iDrive app: Android Auto disappeared from the menu after a night with the car parked, and SSH was needed to get it back ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). The car wakes the unit several times a night, about a minute each time: each wake-up loaded the app and ended before the 2 minutes that reset the crash guard, and the unit's date, standing still early in each start, put them all within the same 15 minutes. At the third, the guard took it for iDrive crashing in a loop and turned the app off. A load followed by 30 seconds of running no longer counts; an iDrive going down right after loading the app, or restarting three times within one start of the unit, still turns it off. Same rule for the automatic start (15 seconds). Tested on PC. +- Wireless: when the phone's Bluetooth dropped on its own during Android Auto (the driver out of the car for a moment, or a radio fault), Android Auto stayed on the screen over the Wi-Fi but with no sound at all, neither music nor calls: the car did not always connect the phone again. Seen for 145 s on a MINI F56 ([#88](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/88)) and 129 s on an X1 F48 ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)), the phone in the car, until a stop of the car made the BMW Bluetooth service try again; and for good when the phone comes back after the 70 s during which the Bluetooth stack tries by itself. During a wireless session, the service now asks the Bluetooth stack to connect again the phone's calls and audio that dropped on their own (the request the BMW Bluetooth service and CarPlay also make): 15 s after the drop if the car or the phone have not done it, then every 30 s, every 2 minutes after 5 minutes, and 3 s after the phone shows up on Bluetooth again. A drop that was chosen (Bluetooth turned off on the phone, another phone picked in the iDrive) is left as it is, and nothing changes outside a wireless session. `[PhoneAudio]` lines in the service log. Tested on PC. ## [0.13.0-rc.12] - 2026-11-27 · PC diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a77d77..1fea58e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ QEMU avec les bibliothèques de la voiture). ### Corrigé - Appli de l'iDrive : Android Auto disparaissait du menu après une nuit voiture garée, et il fallait le SSH pour le ravoir ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39 ; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). La voiture réveille l'unité plusieurs fois par nuit, environ une minute à chaque fois : chaque réveil chargeait l'appli et s'arrêtait avant les 2 minutes qui remettent le garde-fou à zéro, et l'heure de l'unité, figée au début de chaque démarrage, les mettait tous dans les mêmes 15 minutes. Au troisième, le garde-fou croyait à un iDrive qui plante en boucle et coupait l'appli. Un chargement suivi de 30 secondes de marche ne compte plus ; un iDrive qui tombe juste après avoir chargé l'appli, ou qui redémarre trois fois dans un même démarrage de l'unité, la coupe toujours. Même règle pour le démarrage automatique (15 secondes). Testé sur PC. +- Sans-fil : quand le Bluetooth du téléphone tombait de lui-même pendant Android Auto (conducteur sorti de la voiture un moment, ou radio en défaut), Android Auto restait à l'écran par le Wi-Fi mais sans aucun son, ni musique ni appels : la voiture ne rebranchait pas toujours le téléphone. Vu pendant 145 s sur une MINI F56 ([#88](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/88)) et 129 s sur un X1 F48 ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)), téléphone dans la voiture, jusqu'à ce qu'un arrêt de la voiture fasse réessayer le service Bluetooth BMW ; et pour de bon quand le téléphone revient après les 70 s pendant lesquelles la pile Bluetooth réessaie d'elle-même. Pendant une séance sans fil, le service demande maintenant à la pile Bluetooth de rebrancher les appels et le son du téléphone qui sont tombés d'eux-mêmes (la demande que font aussi le service Bluetooth BMW et CarPlay) : 15 s après la coupure si la voiture ou le téléphone ne l'ont pas fait, puis toutes les 30 s, toutes les 2 minutes après 5 minutes, et 3 s après que le téléphone se montre de nouveau en Bluetooth. Une coupure choisie (Bluetooth coupé sur le téléphone, autre téléphone choisi dans l'iDrive) est laissée telle quelle, et rien ne change hors d'une séance sans fil. Lignes `[PhoneAudio]` du journal du service. Testé sur PC. ## [0.13.0-rc.12] - 2026-11-27 · PC diff --git a/Makefile b/Makefile index 1b08500..ad297bc 100644 --- a/Makefile +++ b/Makefile @@ -201,6 +201,8 @@ test-host: test-parsers test-spp-host test-kombi-host test-gps-host test-capture ./tests/test-pending-restart $(HOST_CXX) $(HOST_FLAGS) tests/test_guard_file.cpp -o tests/test-guard-file ./tests/test-guard-file + $(HOST_CXX) $(HOST_FLAGS) tests/test_phone_audio_recall.cpp -o tests/test-phone-audio-recall + ./tests/test-phone-audio-recall $(HOST_CXX) $(HOST_FLAGS) tests/test_log_profile.cpp -o tests/test-log-profile ./tests/test-log-profile $(HOST_CXX) $(HOST_FLAGS) tests/test_kept_log.cpp -o tests/test-kept-log @@ -284,6 +286,8 @@ test-unit-sanitizers: ./tests/test-pending-restart $(HOST_CXX) $(HOST_FLAGS) tests/test_guard_file.cpp -o tests/test-guard-file ./tests/test-guard-file + $(HOST_CXX) $(HOST_FLAGS) tests/test_phone_audio_recall.cpp -o tests/test-phone-audio-recall + ./tests/test-phone-audio-recall $(HOST_CXX) $(HOST_FLAGS) tests/test_log_profile.cpp -o tests/test-log-profile ./tests/test-log-profile $(HOST_CXX) $(HOST_FLAGS) tests/test_kept_log.cpp -o tests/test-kept-log diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 8e738f8..2596629 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -79,6 +79,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `ap_uapsd.hpp` | Point d'accès de la voiture sans U-APSD pour le téléphone qui le rejoint (réglage en mémoire de hostapd, balise reconstruite une fois par démarrage du point d'accès, appareils déjà connectés compris) | | `wifi_link` | Qualité de la liaison Wi-Fi avec le téléphone, lue dans le noyau pour les journaux : entrée du téléphone (nl80211), redémarrages de la puce WL18xx comptés par son pilote (debugfs, lus sur un fil à part, jamais `fw_stats`), TCP, et l'état du lien Bluetooth des BMW Apps (testé sur PC) | | `alps_spp`, `evo_spp_snapshot` | Pile Bluetooth de la voiture : commandes, et lecture de son état en mémoire | +| `phone_audio_recall.hpp` | Appels et son du téléphone en Bluetooth redemandés à la pile pendant une séance sans fil quand ils sont tombés d'eux-mêmes (15 s après, toutes les 30 s, toutes les 2 minutes après 5 minutes) ; rien hors séance, ni quand la voiture ou le téléphone les ont coupés (testé sur PC) | | `evo_elf.hpp` | Symboles exportés par une bibliothèque de la voiture, lus dans son fichier | | `evo_control`, `control_address.hpp` | Commandes de l'appli vers le service, par un socket Unix au nom abstrait (ni fichier ni port réseau) | | `kombi_nav` | Service de guidage vers le compteur et la tête haute : fils, réglage `kombi-off`, annulation d'urgence | @@ -137,6 +138,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `tests/test_wifi_link.cpp` | Qualité du Wi-Fi : messages du noyau, redémarrages de la puce et leur fil de lecture, ligne de journal, connexion rendue en fin de session | | `tests/test_pending_restart.cpp` | Redémarrage d'Android Auto quand la case du câble USB change en marche | | `tests/test_guard_file.cpp` | Garde-fous : démarrages d'autres jours ignorés, boucle de plantages, réveils de nuit d'une voiture garée, iDrive relancé dans un même démarrage, anciennes lignes, date qui recule, ligne coupée, fichier remplacé d'un coup | +| `tests/test_phone_audio_recall.cpp` | Appels et son du téléphone redemandés, sur les chronologies de vrais journaux : téléphone dans la voiture, conducteur sorti 3 minutes, voiture qui les rebranche seule, coupure choisie, hors séance, téléphone revenu à portée, horloge qui reboucle | | `tests/test_hold_machine.cpp` | Page vide de l'iDrive : ouverture, démarrage automatique, fenêtres, modes, appels, touches | | `tests/test_media_recall.cpp` | Double appui sur MEDIA : geste lu par le vrai décodeur, conditions, demande à usage unique | | `tests/test_aa_frame.cpp`, `tests/test_aa_messages.cpp`, `tests/test_tcp_server.cpp` | Trames hostiles, messages construits, écoute TCP | diff --git a/platform/alps_spp.cpp b/platform/alps_spp.cpp index e04a95b..267cc41 100644 --- a/platform/alps_spp.cpp +++ b/platform/alps_spp.cpp @@ -14,6 +14,7 @@ #include #include "evo_log.hpp" +#include "phone_audio_recall.hpp" namespace evo { namespace { @@ -107,6 +108,9 @@ struct AlpsSppLink::Impl { size_t rxOffset; uint8_t phone[6]; // the device whose Android Auto link last opened, to tell it from the others in the log bool phoneKnown; + PhoneAudioRecall recall; // its calls and audio, asked for again while a wireless session runs + uint32_t connectAskedAt; + bool connectAsked; // a connection request of ours waits for its confirmation (logged, nothing else) Impl() : conn(nullptr), @@ -134,7 +138,9 @@ struct AlpsSppLink::Impl { cfgId(0), txSince(0), rxOffset(0), - phoneKnown(false) { + phoneKnown(false), + connectAskedAt(0), + connectAsked(false) { memset(phone, 0, sizeof(phone)); pair[0] = pair[1] = -1; pthread_mutex_init(&mu, nullptr); @@ -299,6 +305,16 @@ struct AlpsSppLink::Impl { pthread_cond_broadcast(&cv); return; } + if (!strcmp(member, "BtApplDeviceConnectCfm")) { + // Also sent for btmbt's own requests: only the first one within 2 s of ours is taken for its answer. + uint8_t status; + if (connectAsked && monoMs() - connectAskedAt <= 2000 && dbus_message_has_signature(m, "y") && + dbus_message_get_args(m, nullptr, DBUS_TYPE_BYTE, &status, DBUS_TYPE_INVALID)) { + ELOG("PhoneAudio", "connection request %s (status %u)", status ? "refused" : "taken", status); + } + connectAsked = false; + return; + } const bool connecting = !strcmp(member, "BtApplDeviceConnectInd"); if (!connecting && strcmp(member, "BtApplDeviceDisconnectInd")) { return; @@ -344,6 +360,18 @@ struct AlpsSppLink::Impl { ELOG("SPP", "%s instance=%u function=%llu status=%u reason=%u%s", member, instance, (unsigned long long)function, status, reason, who); } + if (!monitor && phoneKnown && !memcmp(phone, addr, sizeof(phone))) { + const uint32_t now = monoMs(); + if (!connecting && recall.disconnected(function, reason, now)) { + ELOG("PhoneAudio", + "phone's %s: dropped on its own (reason %u) while Android Auto runs; asked for again in %u s " + "unless the car or the phone connect it first", + PhoneAudioRecall::name(function), reason, PhoneAudioRecall::kFirstMs / 1000); + } else if (connecting && recall.connected(function, (status & 0x7f) == 0, now)) { + ELOG("PhoneAudio", "phone's %s: connected again, %u s after the drop", + PhoneAudioRecall::name(function), recall.sinceDrop(now) / 1000); + } + } if (!ours) { return; } @@ -876,6 +904,37 @@ bool AlpsSppLink::requestSppDisconnect() { m && dbus_message_append_args(m, DBUS_TYPE_UINT64, &function, DBUS_TYPE_BYTE, &p_->inst, DBUS_TYPE_INVALID); return sendRequest(p_->conn, m, valid); } +void AlpsSppLink::keepPhoneAudio(bool sessionRunning, uint32_t nowMs) { + Lock request(p_->requestMu); + Lock lock(p_->mu); + if (!p_->active || p_->monitor) { + return; + } + const uint64_t missing = p_->recall.missing(); + p_->recall.session(sessionRunning); + if (missing && !p_->recall.missing()) { + ELOG("PhoneAudio", "session over with the phone's %s still missing: left to the car", + PhoneAudioRecall::name(missing)); + } + const uint64_t function = p_->phoneKnown ? p_->recall.due(nowMs) : 0; + if (!function) { + return; + } + DBusMessage* m = dbus_message_new_method_call(p_->owner.c_str(), path, dm, "BtApplDeviceConnectReq"); + const uint8_t* address = p_->phone; + dbus_uint64_t asked = function; + uint8_t instance = 0; + const bool valid = m && dbus_message_append_args(m, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &address, 6, DBUS_TYPE_UINT64, + &asked, DBUS_TYPE_BYTE, &instance, DBUS_TYPE_INVALID); + const bool sent = sendRequest(p_->conn, m, valid); + if (sent) { + p_->connectAsked = true; + p_->connectAskedAt = monoMs(); + } + ELOG("PhoneAudio", "phone's %s: still missing %u s after the drop; %s (request %u)", + PhoneAudioRecall::name(function), p_->recall.sinceDrop(nowMs) / 1000, + sent ? "the Bluetooth stack is asked to connect it" : "request not sent", p_->recall.requests()); +} std::string AlpsSppLink::introspect(const char* objectPath) { Lock request(p_->requestMu); { diff --git a/platform/alps_spp.hpp b/platform/alps_spp.hpp index df959bf..a59b1f9 100644 --- a/platform/alps_spp.hpp +++ b/platform/alps_spp.hpp @@ -9,8 +9,15 @@ // signals BtApplSppSetUuidCfm(y instance, y status), BtApplSppDataInd(y instance, q length, ay // data), BtApplSppDataCfm(y instance, y status), BtApplSppSendInd(y instance), // BtApplSppDataSendFcInd(y, y) -// org.alps.evo.DM: signals BtApplDeviceConnectInd(y status, ay address, t function, y instance) +// org.alps.evo.DM: BtApplDeviceConnectReq(ay address, t function, y instance) +// BtApplDeviceDisconnectReq(t function, y instance) +// signals BtApplDeviceConnectInd(y status, ay address, t function, y instance) // BtApplDeviceDisconnectInd(y status, ay address, y reason, t function, y instance) +// BtApplDeviceConnectCfm(y status): the request taken or refused; its result comes in ConnectInd +// Functions: 1 SPP (on its instance), 2 calls (hands-free), 4 audio (streaming), 32 phonebook, 1024 messages; the +// last four on instance 0. Disconnection reasons (btmbt): 1 the car, 2 the other side, 3 exception, 4 link loss. +// ConnectReq's argument types are those the Alps tool evo_genivi_converter (built with its debug information) sends +// it with: 6-byte array, uint64, byte, as the ConnectInd it registers. // SetUuid data (as btmbt's CDBUSBluetoothSender::sendSPPBtApplSppSetUuidReq builds it): // [type][initiator UUID][type][UUID of the local SDP record], type 1/2/3 = 16/32/128-bit UUID // No virtual serial port: the kernel has no evo_bvd (bvd_tty), so the data goes through D-Bus. @@ -68,6 +75,11 @@ class AlpsSppLink { bool setDataInterface(uint8_t value, int timeoutMs); // Only this SPP instance (function=1); never disconnect all BMW profiles. bool requestSppDisconnect(); + // While a wireless session runs, asks the stack to connect again the calls or audio of the phone (the device whose + // Android Auto link opened) that dropped on their own: BtApplDeviceConnectReq(its address, function, 0), when + // PhoneAudioRecall says (phone_audio_recall.hpp). Called on every turn of the wireless loop, with whether a session + // runs and the monotonic time in ms. Nothing in monitor mode. + void keepPhoneAudio(bool sessionRunning, uint32_t nowMs); // Waits for the phone to open the link (DeviceConnectInd or first DataInd on our instance). // Returns a fd (read/write of a transparent byte stream), or -1 after timeoutMs. diff --git a/platform/phone_audio_recall.hpp b/platform/phone_audio_recall.hpp new file mode 100644 index 0000000..8cd3352 --- /dev/null +++ b/platform/phone_audio_recall.hpp @@ -0,0 +1,154 @@ +// Copyright (c) 2026 Jiraiya43 +// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 +// The phone's calls and audio over Bluetooth, asked for again while wireless Android Auto runs. +// +// A wireless session needs Bluetooth only to start: the picture and the touches then go over Wi-Fi. Calls (function 2 +// of the Alps stack, hands-free) and audio (function 4, streaming) still reach the car's speakers over Bluetooth. When +// that connection drops on its own (reason 3 "Exception" or 4 "Linkloss", as the BMW Bluetooth service btmbt names +// them: the phone left Bluetooth range, or the radio failed), Android Auto stays on the screen over the Wi-Fi with no +// sound, and the car does not always connect the phone again. Seen for 145 s on a MINI F56 (#88) and 129 s on an X1 F48 +// (#203), the phone in the car: no Bluetooth activity at all, until a stop of the car made btmbt try again, and the +// phone connected at once. And for good when the phone comes back after the 70 s the stack tries by itself +// (evo_config.xml, auto_reconnect_timeout_hfp and _avp = 0x46): the driver who left the car a moment finds Android Auto +// on the screen and no sound. +// +// So while the session runs, the stack is asked to connect what dropped (BtApplDeviceConnectReq, the request btmbt and +// the car's CarPlay make): 15 s after the drop if the car or the phone have not done it (they usually do within 10 s), +// then every 30 s for 5 minutes, every 2 minutes after that. Calls and audio in turn while both are missing; once one +// is back, the other gets 15 s to follow by itself. The phone showing up on Bluetooth after 30 s without a sign of it +// (a connection of anything else, its Android Auto link for instance) brings the next request forward to 3 s, 10 s +// after the previous one at the soonest. A request that fails is no sign of the phone. A drop the car or the phone +// chose (reason 1 or 2: Bluetooth turned off on the phone, another phone picked in the iDrive) is left alone, as is +// everything outside a wireless session: what the car does then is unchanged. +// +// Pure: the requests are sent by the caller (platform/alps_spp.cpp). tests/test_phone_audio_recall.cpp. +#ifndef ENTRY_AAD_PLATFORM_PHONE_AUDIO_RECALL_HPP +#define ENTRY_AAD_PLATFORM_PHONE_AUDIO_RECALL_HPP + +#include + +namespace evo { + +class PhoneAudioRecall { +public: + static const uint64_t kCalls = 2; // hands-free + static const uint64_t kAudio = 4; // streaming + // BtApplDeviceDisconnectInd's reason, as btmbt names it: 1 Local Device, 2 Remote Device, 3 Exception, 4 Linkloss. + static const uint8_t kByCar = 1, kByPhone = 2, kException = 3, kLinkLoss = 4; + static const uint32_t kFirstMs = 15000; // after a drop, or after the other function came back + static const uint32_t kEveryMs = 30000; // for the first kSlowAfter requests + static const unsigned kSlowAfter = 10; + static const uint32_t kSlowMs = 120000; + static const uint32_t kQuietMs = 30000; // no sign of the phone for that long, then one: it is back + static const uint32_t kSoonMs = 3000; + static const uint32_t kGapMs = 10000; // between two requests, at the least + + PhoneAudioRecall() + : running_(false), lost_(0), last_(0), lostAt_(0), next_(0), askedAt_(0), seenAt_(0), asked_(0) {} + + // Whether a wireless session runs, told on every turn of the wireless loop. One that ends forgets what dropped. + void session(bool running) { + running_ = running; + if (!running) { + lost_ = 0; + } + } + + // The stack reports a disconnection of the phone. True when it is one to ask for again. + bool disconnected(uint64_t function, uint8_t reason, uint32_t now) { + const uint64_t audio = function & (kCalls | kAudio); + if (!running_) { + return false; + } + if (!audio) { + seen(now); + return false; + } + if (reason != kException && reason != kLinkLoss) { + lost_ &= ~audio; // the car or the phone chose it + return false; + } + if (!lost_) { + lostAt_ = now; + next_ = now + kFirstMs; + asked_ = 0; + } + lost_ |= audio; + seenAt_ = now; + return true; + } + + // The stack reports a connection of the phone (ok: connected, otherwise an attempt that failed). True when it + // brings back a function that had dropped. + bool connected(uint64_t function, bool ok, uint32_t now) { + if (!lost_) { + return false; + } + if (function & lost_) { + if (!ok) { + return false; // a request that failed, ours or the car's + } + lost_ &= ~function; + seenAt_ = now; + if (lost_) { + next_ = now + kFirstMs; // the other one often follows by itself + } + return true; + } + seen(now); + return false; + } + + // The function to ask the stack to connect now, 0 for none. Counted as asked. + uint64_t due(uint32_t now) { + if (!running_ || !lost_ || !reached(now, next_)) { + return 0; + } + const uint64_t pick = (lost_ & ~last_) ? (lost_ & ~last_) : lost_; + const uint64_t function = (pick & kCalls) ? kCalls : kAudio; + last_ = function; + ++asked_; + askedAt_ = now; + next_ = now + (asked_ < kSlowAfter ? kEveryMs : kSlowMs); + return function; + } + + uint64_t missing() const { return lost_; } + unsigned requests() const { return asked_; } + uint32_t sinceDrop(uint32_t now) const { return now - lostAt_; } + + static const char* name(uint64_t function) { + return function == kCalls ? "calls (hands-free)" : function == kAudio ? "audio (streaming)" : "calls and audio"; + } + +private: + static bool reached(uint32_t now, uint32_t at) { return static_cast(now - at) >= 0; } + + // Something of the phone on Bluetooth while a function is missing: after a quiet spell, it is back within reach. + void seen(uint32_t now) { + if (!lost_) { + return; + } + const bool back = reached(now, seenAt_ + kQuietMs); + seenAt_ = now; + if (!back) { + return; + } + uint32_t soon = now + kSoonMs; + if (asked_ && !reached(soon, askedAt_ + kGapMs)) { + soon = askedAt_ + kGapMs; + } + if (reached(next_, soon)) { + next_ = soon; + } + } + + bool running_; + uint64_t lost_, last_; + uint32_t lostAt_, next_, askedAt_, seenAt_; + unsigned asked_; +}; + +} // namespace evo + +#endif diff --git a/platform/wireless_loop.cpp b/platform/wireless_loop.cpp index 42c7b6f..f7c7732 100644 --- a/platform/wireless_loop.cpp +++ b/platform/wireless_loop.cpp @@ -12,8 +12,12 @@ namespace evo { void runWirelessLoop(AlpsSppLink& bt, const aa::ApInfo& ap, uint16_t port, WirelessHost& host) { const int kPeekMs = 300; // a MyBMW link speaks first: nothing is written into it + // The phone's calls and audio over Bluetooth that drop on their own during a session are asked for again + // (phone_audio_recall.hpp): on every turn, whatever the loop is waiting for. + const auto keepPhoneAudio = [&bt, &host]() { bt.keepPhoneAudio(host.projectionBusy(), monoMs()); }; while (!host.stopRequested() && bt.running()) { int fd = bt.waitLink(250); + keepPhoneAudio(); if (fd < 0) { continue; } @@ -29,6 +33,7 @@ void runWirelessLoop(AlpsSppLink& bt, const aa::ApInfo& ap, uint16_t port, Wirel const uint32_t sinceMs = monoMs(); while (open && host.projectionBusy() && !host.stopRequested() && bt.linkUp()) { open = setup.listen(100); + keepPhoneAudio(); } ELOG("WirelessLoop", "Bluetooth link back while Android Auto runs: %u message(s) from the phone in %u ms%s", setup.heard(), monoMs() - sinceMs, open ? "" : "; closed, or not Android Auto's: nothing written"); @@ -56,6 +61,7 @@ void runWirelessLoop(AlpsSppLink& bt, const aa::ApInfo& ap, uint16_t port, Wirel // 0.13.0-rc.7). unsigned lost = host.lostSessions(); while (!host.stopRequested() && bt.linkUp() && setup.serve(1000)) { + keepPhoneAudio(); const unsigned now = host.lostSessions(); if (now == lost) { continue; diff --git a/tests/test_alps_spp.cpp b/tests/test_alps_spp.cpp index aefb460..1e4782c 100644 --- a/tests/test_alps_spp.cpp +++ b/tests/test_alps_spp.cpp @@ -16,6 +16,7 @@ #include #include "alps_spp.hpp" +#include "evo_log.hpp" #include "evo_process.hpp" #define CHECK(x) \ do { \ @@ -28,6 +29,7 @@ namespace { const char* const path = "/org/alps/evolution/hli"; const char* const spp = "org.alps.evo.SPP"; const char* const dm = "org.alps.evo.DM"; +const uint8_t phone[] = {1, 2, 3, 4, 5, 6}; void sleepMs(int ms) { std::this_thread::sleep_for(std::chrono::milliseconds(ms)); } @@ -35,10 +37,11 @@ class FakeAlps { public: DBusConnection* conn; std::atomic active, suppressUuid, suppressConfig; - std::atomic uuidRequests, dataRequests, writes, reads; + std::atomic uuidRequests, dataRequests, writes, reads, connectRequests; uint8_t config; std::mutex mu; std::vector sent, lastUuid; + std::vector connected; // the functions of the connection requests, in order std::thread worker; FakeAlps() : conn(0), @@ -49,6 +52,7 @@ class FakeAlps { dataRequests(0), writes(0), reads(0), + connectRequests(0), config(0) { DBusError e; dbus_error_init(&e); @@ -81,11 +85,11 @@ class FakeAlps { CHECK(dbus_message_append_args(m, DBUS_TYPE_BYTE, &instance, DBUS_TYPE_INVALID)); send(m); } - void device(bool connecting, uint8_t instance, dbus_uint64_t function = 1, uint8_t statusCode = 0) { + void device(bool connecting, uint8_t instance, dbus_uint64_t function = 1, uint8_t statusCode = 0, + uint8_t reason = 0, const uint8_t* address = phone) { DBusMessage* m = dbus_message_new_signal(path, dm, connecting ? "BtApplDeviceConnectInd" : "BtApplDeviceDisconnectInd"); CHECK(m); - uint8_t address[] = {1, 2, 3, 4, 5, 6}, reason = 0; const uint8_t* a = address; CHECK(dbus_message_append_args(m, DBUS_TYPE_BYTE, &statusCode, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &a, 6, DBUS_TYPE_INVALID)); @@ -167,6 +171,21 @@ class FakeAlps { CHECK(dbus_message_append_args(r, DBUS_TYPE_BYTE, &statusCode, DBUS_TYPE_BYTE, &instance, DBUS_TYPE_UINT16, &id, DBUS_TYPE_INVALID)); send(r); + } else if (!strcmp(member, "BtApplDeviceConnectReq")) { + dbus_uint64_t function; + CHECK(dbus_message_has_signature(m, "ayty")); + CHECK(dbus_message_get_args(m, 0, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &bytes, &n, DBUS_TYPE_UINT64, &function, + DBUS_TYPE_BYTE, &instance, DBUS_TYPE_INVALID)); + CHECK(n == 6 && !memcmp(bytes, phone, 6) && instance == 0); + { + std::lock_guard lock(mu); + connected.push_back(function); + } + ++connectRequests; + uint8_t statusCode = 0; + DBusMessage* r = dbus_message_new_signal(path, dm, "BtApplDeviceConnectCfm"); + CHECK(dbus_message_append_args(r, DBUS_TYPE_BYTE, &statusCode, DBUS_TYPE_INVALID)); + send(r); } else if (!strcmp(member, "BtApplDeviceDisconnectReq")) { dbus_uint64_t function; CHECK( @@ -273,7 +292,12 @@ int main() { fake.device(true, 2); fake.data(2, bytes); CHECK(monitor.waitLink(50) == -1); - CHECK(fake.uuidRequests == 0 && fake.dataRequests == 0 && fake.writes == 0); + monitor.keepPhoneAudio(true, evo::monoMs()); + fake.device(false, 0, 2, 0, 4); + sleepMs(30); + monitor.keepPhoneAudio(true, evo::monoMs() + 60000); + sleepMs(30); + CHECK(fake.uuidRequests == 0 && fake.dataRequests == 0 && fake.writes == 0 && fake.connectRequests == 0); } { evo::AlpsSppLink link; @@ -512,6 +536,60 @@ int main() { CHECK(receive(fourth, first.size()) == first); link.closeLink(); } + { + // The phone's calls and audio dropped on their own while Android Auto runs (phone_audio_recall.hpp): the stack + // is asked to connect them again, the phone's address on instance 0, 15 s after the drop and only while a + // session runs. A drop the phone chose, or another device's, is left alone. + evo::AlpsSppLink link; + CHECK(link.start(5)); + fake.device(true, 5); // the phone opens its Android Auto link: its address is the phone's + int fd = link.waitLink(1000); + CHECK(fd >= 0); + const uint8_t other[] = {9, 8, 7, 6, 5, 4}; + uint32_t t0 = evo::monoMs(); + link.keepPhoneAudio(true, t0); + fake.device(false, 0, 2, 0, 3); // calls: exception, the phone left + fake.device(false, 0, 4, 0, 4, other); // another device's audio + fake.device(false, 0, 4, 0, 2); // the phone's audio, turned off on the phone + sleepMs(50); + link.keepPhoneAudio(true, t0 + 14000); + sleepMs(30); + CHECK(fake.connectRequests == 0); + link.keepPhoneAudio(true, t0 + 16000); + CHECK(fake.awaitCount(fake.connectRequests, 1)); + link.keepPhoneAudio(true, t0 + 20000); // the next one is 30 s later + fake.device(true, 0, 2, 4); // that request failed (the phone out of reach): no sign of the phone + sleepMs(50); + link.keepPhoneAudio(true, t0 + 45000); + CHECK(fake.awaitCount(fake.connectRequests, 1)); + link.keepPhoneAudio(true, t0 + 46100); + CHECK(fake.awaitCount(fake.connectRequests, 2)); + fake.device(true, 0, 2); // back + sleepMs(50); + link.keepPhoneAudio(true, t0 + 200000); + sleepMs(30); + CHECK(fake.connectRequests == 2); + { + std::lock_guard lock(fake.mu); + CHECK(fake.connected.size() == 2 && fake.connected[0] == 2 && fake.connected[1] == 2); + } + // Dropped again, then the session ends before the request: nothing is asked for, not even in a new session. + t0 = evo::monoMs(); + fake.device(false, 0, 4, 0, 4); + sleepMs(50); + link.keepPhoneAudio(false, t0 + 1000); + link.keepPhoneAudio(true, t0 + 60000); + sleepMs(30); + CHECK(fake.connectRequests == 2); + // Outside a session, a drop is not even noted. + link.keepPhoneAudio(false, t0 + 61000); + fake.device(false, 0, 2, 0, 4); + sleepMs(50); + link.keepPhoneAudio(true, t0 + 90000); + sleepMs(30); + CHECK(fake.connectRequests == 2); + link.closeLink(); + } { CHECK(evo::queryAlpsServiceUid() == static_cast(getuid())); evo::AlpsSppLink link; @@ -531,6 +609,6 @@ int main() { } puts( "PASS D-Bus SPP: observation, signatures, instance/profil, HLI, flux, ACK, EOF, reconnexion pendant l'emprunt, " - "delais et arret"); + "appels et son du telephone redemandes, delais et arret"); return 0; } diff --git a/tests/test_phone_audio_recall.cpp b/tests/test_phone_audio_recall.cpp new file mode 100644 index 0000000..858e8d3 --- /dev/null +++ b/tests/test_phone_audio_recall.cpp @@ -0,0 +1,227 @@ +// Copyright (c) 2026 Jiraiya43 +// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 +// platform/phone_audio_recall.hpp: the phone's calls and audio asked for again while wireless Android Auto runs, on +// the timelines of real service logs. +#include +#include + +#include "../platform/phone_audio_recall.hpp" + +#define CHECK(x) \ + do { \ + if (!(x)) { \ + printf("FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); \ + exit(1); \ + } \ + } while (0) + +namespace { + +using evo::PhoneAudioRecall; + +const uint64_t kCalls = PhoneAudioRecall::kCalls, kAudio = PhoneAudioRecall::kAudio, kSpp = 1, kPhonebook = 32; +const uint8_t kException = PhoneAudioRecall::kException, kLinkLoss = PhoneAudioRecall::kLinkLoss; + +uint32_t ms(double seconds) { + return static_cast(seconds * 1000 + 0.5); +} + +// The first moment from..to (ms, inclusive) at which a request is due, or 0; due() is asked every 250 ms, as the +// wireless loop does. +uint64_t firstDue(PhoneAudioRecall& r, uint32_t from, uint32_t to, uint32_t* at) { + for (uint32_t t = from; static_cast(to - t) >= 0; t += 250) { + const uint64_t f = r.due(t); + if (f) { + *at = t; + return f; + } + } + return 0; +} + +// Calls, audio and the Android Auto link dropped together (reason 3), the session went on over the Wi-Fi, and nothing +// came back for 145 s, the phone in the car (MINI F56, #88, service log of 26/11, 198.395 to 343.152 s). Asked for 15 s +// later, the calls come back; the audio gets 15 s to follow by itself, then is asked for. +void phoneInTheCar() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kAudio, kException, ms(198.395))); + CHECK(r.disconnected(kCalls, kException, ms(198.412))); + CHECK(!r.disconnected(kSpp, kException, ms(198.415))); // the Android Auto link is not ours to ask for + CHECK(r.missing() == (kCalls | kAudio)); + uint32_t at = 0; + CHECK(firstDue(r, ms(198.5), ms(213.25), &at) == 0); + CHECK(firstDue(r, ms(213.25), ms(214), &at) == kCalls && at == ms(213.5)); + CHECK(r.connected(kCalls, true, ms(214.1))); + CHECK(r.missing() == kAudio); + CHECK(firstDue(r, ms(214.25), ms(229.0), &at) == 0); + CHECK(firstDue(r, ms(229.0), ms(230), &at) == kAudio && at == ms(229.25)); + CHECK(r.connected(kAudio, true, ms(230.0))); + CHECK(r.missing() == 0 && firstDue(r, ms(230), ms(400), &at) == 0); + puts("PASS calls and audio dropped with the phone in the car: asked for 15 s later instead of 145 s"); +} + +// The driver leaves the car with the phone, Android Auto stays on over the Wi-Fi, and comes back 3 minutes later: +// asked for every 30 s meanwhile, calls and audio in turn; the request after the return connects. +void driverLeftTheCar() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kCalls, kLinkLoss, ms(1000))); + CHECK(r.disconnected(kAudio, kLinkLoss, ms(1000.01))); + uint32_t at = 0; + uint64_t expected = kCalls; + for (double t = 1015; t < 1180; t += 30) { // 1015, 1045, ... 1165: the phone is away, nothing answers + CHECK(firstDue(r, ms(t - 14), ms(t + 1), &at) == expected && at == ms(t)); + CHECK(!r.connected(expected, false, ms(t + 5.12))); // page timeout: no sign of the phone + expected = expected == kCalls ? kAudio : kCalls; + } + CHECK(r.requests() == 6 && r.missing() == (kCalls | kAudio)); + CHECK(firstDue(r, ms(1166), ms(1194.75), &at) == 0); // back in the car at 1180 s + CHECK(firstDue(r, ms(1195), ms(1196), &at) == kCalls); + CHECK(r.connected(kCalls, true, ms(1195.6))); + CHECK(firstDue(r, ms(1196), ms(1210.5), &at) == 0); + CHECK(firstDue(r, ms(1210.75), ms(1211), &at) == kAudio); + CHECK(r.connected(kAudio, true, ms(1211.2)) && r.missing() == 0); + puts("PASS phone away 3 minutes: asked for every 30 s, both back within 31 s of the return"); +} + +// The car or the phone connects them again on their own within a few seconds (F45 of skha-max, 424.998 s: calls back +// at 428.756 s, audio at 454.720 s): no request for the calls; the audio, still missing 15 s after the calls came +// back, is asked for once. +void carReconnectsByItself() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kCalls, kException, ms(424.998))); + CHECK(r.disconnected(kAudio, kException, ms(425.010))); + uint32_t at = 0; + CHECK(firstDue(r, ms(425), ms(428.75), &at) == 0); + CHECK(r.connected(kCalls, true, ms(428.756))); + CHECK(firstDue(r, ms(429), ms(443.5), &at) == 0); + CHECK(firstDue(r, ms(443.75), ms(444), &at) == kAudio); + CHECK(r.requests() == 1); + CHECK(r.connected(kAudio, true, ms(454.720)) && r.missing() == 0); + puts("PASS what the car connects again by itself is not asked for"); +} + +// A drop the car or the phone chose: Bluetooth turned off on the phone (reason 2), another phone picked (reason 1). +void chosenDrops() { + PhoneAudioRecall r; + r.session(true); + CHECK(!r.disconnected(kCalls, PhoneAudioRecall::kByPhone, ms(10))); + CHECK(!r.disconnected(kAudio, PhoneAudioRecall::kByCar, ms(10))); + CHECK(!r.disconnected(kAudio, 0, ms(10)) && !r.disconnected(kAudio, 5, ms(10))); // unknown reasons + uint32_t at = 0; + CHECK(r.missing() == 0 && firstDue(r, ms(10), ms(600), &at) == 0); + // Lost first, then turned off on the phone while asked for: left alone from then on. + CHECK(r.disconnected(kCalls, kLinkLoss, ms(1000))); + CHECK(firstDue(r, ms(1000), ms(1015), &at) == kCalls); + CHECK(!r.disconnected(kCalls, PhoneAudioRecall::kByPhone, ms(1020))); + CHECK(r.missing() == 0 && firstDue(r, ms(1020), ms(1600), &at) == 0); + puts("PASS a drop the car or the phone chose is left alone"); +} + +// Outside a wireless session nothing changes; a session that ends forgets what dropped. +void outsideSession() { + PhoneAudioRecall r; + CHECK(!r.disconnected(kCalls, kLinkLoss, ms(5))); + uint32_t at = 0; + CHECK(firstDue(r, ms(5), ms(100), &at) == 0); + r.session(true); + CHECK(r.disconnected(kCalls, kLinkLoss, ms(100))); + r.session(false); // the session was lost: the car is being left, or it goes on over USB + CHECK(r.missing() == 0 && firstDue(r, ms(100), ms(300), &at) == 0); + r.session(true); // a new session: what dropped before it is not asked for + CHECK(firstDue(r, ms(300), ms(500), &at) == 0); + CHECK(!r.connected(kCalls, true, ms(310))); + puts("PASS outside a wireless session, nothing is asked for"); +} + +// The phone back within reach after a quiet spell (it opens its Android Auto link): the next request comes 3 s later, +// 10 s after the previous one at the soonest. Activity of a phone in reach brings nothing forward. +void phoneShowsUp() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kCalls, kException, ms(0))); + uint32_t at = 0; + CHECK(firstDue(r, ms(0), ms(15), &at) == kCalls); + CHECK(firstDue(r, ms(15.25), ms(45), &at) == kCalls && at == ms(45)); + CHECK(!r.connected(kSpp, true, ms(50))); // nothing of the phone for 50 s: it is back + CHECK(firstDue(r, ms(50.25), ms(54.75), &at) == 0); + CHECK(firstDue(r, ms(55), ms(56), &at) == kCalls && at == ms(55)); + for (double t = 56; t < 84; t += 2) { // the phonebook in and out, every 2 s: a phone in reach + CHECK(!r.connected(kPhonebook, true, ms(t))); + CHECK(!r.disconnected(kPhonebook, PhoneAudioRecall::kByCar, ms(t + 0.5))); + } + CHECK(firstDue(r, ms(55.25), ms(84.75), &at) == 0); + CHECK(firstDue(r, ms(85), ms(86), &at) == kCalls); + CHECK(firstDue(r, ms(85.25), ms(115), &at) == kCalls && at == ms(115)); + // Quiet again for 30 s, then seen 1 s after a request (its Android Auto link, failing: still a sign of the phone): + // the next request waits for the 10 s between two. + CHECK(!r.connected(kSpp, false, ms(116))); + CHECK(firstDue(r, ms(115.25), ms(124.75), &at) == 0); + CHECK(firstDue(r, ms(125), ms(126), &at) == kCalls && at == ms(125)); + puts("PASS the phone back within reach is asked for 3 s later, never twice within 10 s"); +} + +// After 10 requests every 30 s, one every 2 minutes, for as long as the session runs. +void slowsDown() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kAudio, kLinkLoss, ms(0))); + uint32_t at = 0, previous = 0; + for (unsigned i = 1; i <= 14; ++i) { + CHECK(firstDue(r, previous + 250, previous + ms(200), &at) == kAudio); + if (i == 1) { + CHECK(at == ms(15)); + } else { + CHECK(at - previous == (i <= 10 ? ms(30) : ms(120))); + } + previous = at; + } + CHECK(r.requests() == 14); + puts("PASS every 30 s for 5 minutes, then every 2 minutes"); +} + +// The monotonic clock in ms wraps after 49 days: the waits still hold across it. +void clockWraps() { + PhoneAudioRecall r; + r.session(true); + const uint32_t start = 0xFFFFFFFFu - 5000; + CHECK(r.disconnected(kCalls, kLinkLoss, start)); + uint32_t at = 0; + CHECK(firstDue(r, start, start + 14750, &at) == 0); + CHECK(firstDue(r, start + 15000, start + 15250, &at) == kCalls && at == start + 15000); + CHECK(r.sinceDrop(at) == 15000); + puts("PASS the waits hold across the wrap of the clock"); +} + +// A second function that drops later joins the requests already planned; the turn goes to the one not asked last. +void secondDropJoins() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kAudio, kLinkLoss, ms(0))); + uint32_t at = 0; + CHECK(firstDue(r, ms(0), ms(15), &at) == kAudio); + CHECK(r.disconnected(kCalls, kException, ms(20))); + CHECK(firstDue(r, ms(15.25), ms(44.75), &at) == 0); + CHECK(firstDue(r, ms(45), ms(45), &at) == kCalls); + CHECK(firstDue(r, ms(45.25), ms(75), &at) == kAudio); + CHECK(!r.connected(kCalls | kAudio, false, ms(76))); + puts("PASS a later drop joins the planned requests, in turn"); +} + +} // namespace + +int main() { + phoneInTheCar(); + driverLeftTheCar(); + carReconnectsByItself(); + chosenDrops(); + outsideSession(); + phoneShowsUp(); + slowsDown(); + clockWraps(); + secondDropJoins(); + puts("PASS phone audio recall: calls and audio asked for again while wireless Android Auto runs"); + return 0; +} diff --git a/tests/test_wireless_lifecycle.cpp b/tests/test_wireless_lifecycle.cpp index abd5237..0098cc7 100644 --- a/tests/test_wireless_lifecycle.cpp +++ b/tests/test_wireless_lifecycle.cpp @@ -19,6 +19,8 @@ #include "wireless_setup.hpp" static std::atomic starts(0), waits(0), listens(0), serves(0), prepared(0), sppDrops(0); +// The phone's calls and audio are looked after on every turn of the loop, told whether a projection runs. +static std::atomic audioKeptBusy(0), audioKeptIdle(0); static std::atomic fixtureLink(true), borrowed(false); static std::atomic phoneKeepsLink(false); // the phone keeps its Bluetooth link after accepting the Wi-Fi static std::atomic bmwAppsLink(false); // the link listened to is the BMW app's: BCL seen, link still up @@ -54,6 +56,9 @@ bool AlpsSppLink::requestSppDisconnect() { ++sppDrops; return true; } +void AlpsSppLink::keepPhoneAudio(bool sessionRunning, uint32_t) { + ++(sessionRunning ? audioKeptBusy : audioKeptIdle); +} // The access point is made ready (no U-APSD) once before every handshake, never during one, told how to see the // service's stop (each hostapd command may take 5 s). UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user) { @@ -313,9 +318,10 @@ int main() { mediaRecall(app); preparing(false); fixtureLink = true; // phone reopens SPP while TCP projection is active - const int listened = listens; + const int listened = listens, keptBusy = audioKeptBusy; usleep(350000); assert(starts == 1 && app.session.isActive() && listens > listened); + assert(audioKeptBusy > keptBusy + 1); // looked after while the link is listened to, the session running app.session.stop(); app.ready = app.videoEnabled = true; app.focus = false; @@ -356,6 +362,7 @@ int main() { pthread_mutex_lock(&app.mu); assert(app.wirelessDone && app.sppLinks == 4 && app.wppReply && app.wppAccepted); pthread_mutex_unlock(&app.mu); + assert(audioKeptIdle > 0); // and told when nothing runs puts( "PASS actual wireless loop: no handshake during TCP preparation or active session, nor into the BMW app's link " "found then, rearmed after session stop, Bluetooth link closed after a lost wireless session; app commands and " From b7dfe91f1c8c2395d57ecc1f3f421e6be80e55d9 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Mon, 30 Nov 2026 23:29:51 +0100 Subject: [PATCH 03/17] chore: rc.12 avec le garde-fou et le son Bluetooth (#272) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La 0.13.0-rc.12 n'est pas encore publiée : les deux correctifs de [Non publié] (Android Auto qui disparaissait après une nuit garée, #261 ; appels et son du téléphone redemandés pendant Android Auto sans fil) entrent dans sa section, datée du jour de sa publication. CHANGELOG.md et CHANGELOG.en.md. --- CHANGELOG.en.md | 19 +++++++++---------- CHANGELOG.md | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 2dd3abd..17112a7 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,20 +13,19 @@ QEMU with the car's libraries). ## [Unreleased] -### Fixed - -- iDrive app: Android Auto disappeared from the menu after a night with the car parked, and SSH was needed to get it back ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). The car wakes the unit several times a night, about a minute each time: each wake-up loaded the app and ended before the 2 minutes that reset the crash guard, and the unit's date, standing still early in each start, put them all within the same 15 minutes. At the third, the guard took it for iDrive crashing in a loop and turned the app off. A load followed by 30 seconds of running no longer counts; an iDrive going down right after loading the app, or restarting three times within one start of the unit, still turns it off. Same rule for the automatic start (15 seconds). Tested on PC. -- Wireless: when the phone's Bluetooth dropped on its own during Android Auto (the driver out of the car for a moment, or a radio fault), Android Auto stayed on the screen over the Wi-Fi but with no sound at all, neither music nor calls: the car did not always connect the phone again. Seen for 145 s on a MINI F56 ([#88](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/88)) and 129 s on an X1 F48 ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)), the phone in the car, until a stop of the car made the BMW Bluetooth service try again; and for good when the phone comes back after the 70 s during which the Bluetooth stack tries by itself. During a wireless session, the service now asks the Bluetooth stack to connect again the phone's calls and audio that dropped on their own (the request the BMW Bluetooth service and CarPlay also make): 15 s after the drop if the car or the phone have not done it, then every 30 s, every 2 minutes after 5 minutes, and 3 s after the phone shows up on Bluetooth again. A drop that was chosen (Bluetooth turned off on the phone, another phone picked in the iDrive) is left as it is, and nothing changes outside a wireless session. `[PhoneAudio]` lines in the service log. Tested on PC. +## [0.13.0-rc.12] - 2026-11-30 · PC -## [0.13.0-rc.12] - 2026-11-27 · PC - -Release candidate for wireless: U-APSD power saving also taken away from a phone that joined the car's Wi-Fi -by itself, the thread that reads the phone no longer waiting for the spacing of the pictures, and a -`[WifiLink]` line without a misleading figure, which says when the Wi-Fi chip restarts. Installs from a USB -stick since 0.13.0-rc.10. Tested on PC and under QEMU, **not tried in a car yet**. +Release candidate: Android Auto no longer gone from the menu after a night with the car parked, the phone's +calls and audio asked for again when its Bluetooth drops during wireless Android Auto, U-APSD power saving also +taken away from a phone that joined the car's Wi-Fi by itself, the thread that reads the phone no longer waiting +for the spacing of the pictures, and a `[WifiLink]` line without a misleading figure, which says when the Wi-Fi +chip restarts. Installs from a USB stick since 0.13.0-rc.10. Tested on PC and under QEMU, **not tried in a car +yet**. ### Fixed +- iDrive app: Android Auto disappeared from the menu after a night with the car parked, and SSH was needed to get it back ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). The car wakes the unit several times a night, about a minute each time: each wake-up loaded the app and ended before the 2 minutes that reset the crash guard, and the unit's date, standing still early in each start, put them all within the same 15 minutes. At the third, the guard took it for iDrive crashing in a loop and turned the app off. A load followed by 30 seconds of running no longer counts; an iDrive going down right after loading the app, or restarting three times within one start of the unit, still turns it off. Same rule for the automatic start (15 seconds). Tested on PC. +- Wireless: when the phone's Bluetooth dropped on its own during Android Auto (the driver out of the car for a moment, or a radio fault), Android Auto stayed on the screen over the Wi-Fi but with no sound at all, neither music nor calls: the car did not always connect the phone again. Seen for 145 s on a MINI F56 ([#88](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/88)) and 129 s on an X1 F48 ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)), the phone in the car, until a stop of the car made the BMW Bluetooth service try again; and for good when the phone comes back after the 70 s during which the Bluetooth stack tries by itself. During a wireless session, the service now asks the Bluetooth stack to connect again the phone's calls and audio that dropped on their own (the request the BMW Bluetooth service and CarPlay also make): 15 s after the drop if the car or the phone have not done it, then every 30 s, every 2 minutes after 5 minutes, and 3 s after the phone shows up on Bluetooth again. A drop that was chosen (Bluetooth turned off on the phone, another phone picked in the iDrive) is left as it is, and nothing changes outside a wireless session. `[PhoneAudio]` lines in the service log. Tested on PC. - Wireless: a phone already on the car's Wi-Fi when Android Auto started (a known network it joined by itself, a phone back after a lost session) kept U-APSD power saving for the whole session: the access point only rebuilt its beacon without U-APSD when nobody was connected. On an F52, that was the case of four sessions out of four ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). The beacon is now rebuilt once per start of the access point, even with a device connected: it is disconnected once and joins the Wi-Fi again at once without U-APSD, just before the phone gets its start request. Another device on that Wi-Fi (a laptop, an iPhone on CarPlay) is disconnected once too. Removing U-APSD made the stutter go on an X1 F48 ([#138](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/138)); it is not the only cause of wireless lag. Tested on PC. - Logs: the `[WifiLink]` line wrote `0 retried` on every car, which suggested the Wi-Fi chip never had to send a frame again. Its driver does not give that number (one try per frame, "no data about retries" in its source): it is no longer written. Instead the line says when the driver restarted the chip's firmware (`chip firmware restarted`), read from the driver's state without asking the chip anything, on a thread of its own: the main loop never waits for the driver longer than 200 ms. The chip's own statistics (frames sent again, the phone's power saving) are not read: the driver asks the chip for them, and on an X1 F48 two reads 5 s apart were followed by two restarts of its firmware ([#256](https://github.com/Jiraiya43/EntryNav2-Android-Auto/pull/256), [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Tested on PC. - Wireless: pictures that arrive in pairs are still spread before going to the decoder, but the thread that reads the diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fea58e..07c7020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,20 +8,19 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] -### Corrigé - -- Appli de l'iDrive : Android Auto disparaissait du menu après une nuit voiture garée, et il fallait le SSH pour le ravoir ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39 ; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). La voiture réveille l'unité plusieurs fois par nuit, environ une minute à chaque fois : chaque réveil chargeait l'appli et s'arrêtait avant les 2 minutes qui remettent le garde-fou à zéro, et l'heure de l'unité, figée au début de chaque démarrage, les mettait tous dans les mêmes 15 minutes. Au troisième, le garde-fou croyait à un iDrive qui plante en boucle et coupait l'appli. Un chargement suivi de 30 secondes de marche ne compte plus ; un iDrive qui tombe juste après avoir chargé l'appli, ou qui redémarre trois fois dans un même démarrage de l'unité, la coupe toujours. Même règle pour le démarrage automatique (15 secondes). Testé sur PC. -- Sans-fil : quand le Bluetooth du téléphone tombait de lui-même pendant Android Auto (conducteur sorti de la voiture un moment, ou radio en défaut), Android Auto restait à l'écran par le Wi-Fi mais sans aucun son, ni musique ni appels : la voiture ne rebranchait pas toujours le téléphone. Vu pendant 145 s sur une MINI F56 ([#88](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/88)) et 129 s sur un X1 F48 ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)), téléphone dans la voiture, jusqu'à ce qu'un arrêt de la voiture fasse réessayer le service Bluetooth BMW ; et pour de bon quand le téléphone revient après les 70 s pendant lesquelles la pile Bluetooth réessaie d'elle-même. Pendant une séance sans fil, le service demande maintenant à la pile Bluetooth de rebrancher les appels et le son du téléphone qui sont tombés d'eux-mêmes (la demande que font aussi le service Bluetooth BMW et CarPlay) : 15 s après la coupure si la voiture ou le téléphone ne l'ont pas fait, puis toutes les 30 s, toutes les 2 minutes après 5 minutes, et 3 s après que le téléphone se montre de nouveau en Bluetooth. Une coupure choisie (Bluetooth coupé sur le téléphone, autre téléphone choisi dans l'iDrive) est laissée telle quelle, et rien ne change hors d'une séance sans fil. Lignes `[PhoneAudio]` du journal du service. Testé sur PC. +## [0.13.0-rc.12] - 2026-11-30 · PC -## [0.13.0-rc.12] - 2026-11-27 · PC - -Version candidate pour le sans-fil : l'économie d'énergie U-APSD retirée aussi au téléphone qui a rejoint le -Wi-Fi de la voiture tout seul, le fil qui lit le téléphone qui n'attend plus l'espacement des images, et une -ligne `[WifiLink]` sans chiffre trompeur, qui dit quand la puce Wi-Fi redémarre. S'installe par clé USB depuis la -0.13.0-rc.10. Testée sur PC et sous QEMU, **pas encore essayée en voiture**. +Version candidate : Android Auto qui ne disparaît plus du menu après une nuit voiture garée, les appels et le son +du téléphone redemandés quand son Bluetooth tombe pendant Android Auto sans fil, l'économie d'énergie U-APSD +retirée aussi au téléphone qui a rejoint le Wi-Fi de la voiture tout seul, le fil qui lit le téléphone qui +n'attend plus l'espacement des images, et une ligne `[WifiLink]` sans chiffre trompeur, qui dit quand la puce +Wi-Fi redémarre. S'installe par clé USB depuis la 0.13.0-rc.10. Testée sur PC et sous QEMU, **pas encore +essayée en voiture**. ### Corrigé +- Appli de l'iDrive : Android Auto disparaissait du menu après une nuit voiture garée, et il fallait le SSH pour le ravoir ([#261](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/261), X2 F39 ; [#137](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/137), MINI F54). La voiture réveille l'unité plusieurs fois par nuit, environ une minute à chaque fois : chaque réveil chargeait l'appli et s'arrêtait avant les 2 minutes qui remettent le garde-fou à zéro, et l'heure de l'unité, figée au début de chaque démarrage, les mettait tous dans les mêmes 15 minutes. Au troisième, le garde-fou croyait à un iDrive qui plante en boucle et coupait l'appli. Un chargement suivi de 30 secondes de marche ne compte plus ; un iDrive qui tombe juste après avoir chargé l'appli, ou qui redémarre trois fois dans un même démarrage de l'unité, la coupe toujours. Même règle pour le démarrage automatique (15 secondes). Testé sur PC. +- Sans-fil : quand le Bluetooth du téléphone tombait de lui-même pendant Android Auto (conducteur sorti de la voiture un moment, ou radio en défaut), Android Auto restait à l'écran par le Wi-Fi mais sans aucun son, ni musique ni appels : la voiture ne rebranchait pas toujours le téléphone. Vu pendant 145 s sur une MINI F56 ([#88](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/88)) et 129 s sur un X1 F48 ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)), téléphone dans la voiture, jusqu'à ce qu'un arrêt de la voiture fasse réessayer le service Bluetooth BMW ; et pour de bon quand le téléphone revient après les 70 s pendant lesquelles la pile Bluetooth réessaie d'elle-même. Pendant une séance sans fil, le service demande maintenant à la pile Bluetooth de rebrancher les appels et le son du téléphone qui sont tombés d'eux-mêmes (la demande que font aussi le service Bluetooth BMW et CarPlay) : 15 s après la coupure si la voiture ou le téléphone ne l'ont pas fait, puis toutes les 30 s, toutes les 2 minutes après 5 minutes, et 3 s après que le téléphone se montre de nouveau en Bluetooth. Une coupure choisie (Bluetooth coupé sur le téléphone, autre téléphone choisi dans l'iDrive) est laissée telle quelle, et rien ne change hors d'une séance sans fil. Lignes `[PhoneAudio]` du journal du service. Testé sur PC. - Sans-fil : un téléphone déjà sur le Wi-Fi de la voiture quand Android Auto démarre (réseau connu rejoint tout seul, téléphone revenu après une séance perdue) gardait l'économie d'énergie U-APSD toute la séance : le point d'accès ne reconstruisait sa balise sans U-APSD que si personne n'y était connecté. Sur une F52, c'était le cas des quatre séances sur quatre ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). La balise est maintenant reconstruite une fois par démarrage du point d'accès, même avec un appareil connecté : il est déconnecté une fois et rejoint aussitôt le Wi-Fi sans U-APSD, juste avant que le téléphone reçoive sa demande de démarrage. Un autre appareil sur ce Wi-Fi (ordinateur, iPhone en CarPlay) est déconnecté une fois aussi. U-APSD retiré a fait disparaître les à-coups sur une X1 F48 ([#138](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/138)) ; il n'est pas la seule cause de lenteur sans fil. Testé sur PC. - Journaux : la ligne `[WifiLink]` écrivait `0 retried` sur toutes les voitures, ce qui laissait croire que la puce Wi-Fi n'avait jamais à réémettre. Son pilote ne donne pas ce nombre (une seule tentative par trame, « no data about retries » dans son code) : il n'est plus écrit. La ligne dit à la place quand le pilote a redémarré le micrologiciel de la puce (`chip firmware restarted`), lu dans son état, sans rien demander à la puce, sur un fil à part : la boucle principale n'attend jamais le pilote plus de 200 ms. Les statistiques de la puce elle-même (réémissions, économie d'énergie du téléphone) ne sont pas lues : le pilote les demande à la puce, et sur une X1 F48 deux lectures à 5 s d'écart ont été suivies de deux redémarrages de son micrologiciel ([#256](https://github.com/Jiraiya43/EntryNav2-Android-Auto/pull/256), [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Testé sur PC. - Sans-fil : les images qui arrivent par paires sont toujours espacées avant d'aller au décodeur, mais le fil qui lit From e1d2a0ee18829cbc28e0ebd35961f21a19f6c0aa Mon Sep 17 00:00:00 2001 From: peppearci <32198710+peppearci@users.noreply.github.com> Date: Tue, 1 Dec 2026 05:00:50 +0100 Subject: [PATCH 04/17] =?UTF-8?q?fix(wifi):=20contr=C3=B4ler=20le=20802.11?= =?UTF-8?q?n=20du=20t=C3=A9l=C3=A9phone=20(#264)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(wifi): ne plus offrir le 802.11n sur le point d'accès de la voiture Sur une X1 F48, pendant des saccades sans fil, la voiture acquittait les trames du téléphone puis en perdait environ un quart avant son TCP. ieee80211n=0 est réglé dans la mémoire de hostapd avec U-APSD, avant la même reconstruction de la balise (#203). * fix(wifi): contrôler le 802.11n du téléphone Le point d'accès de la voiture peut accepter le 802.11n si le téléphone le demande. Au démarrage du service et à chaque connexion, si une station utilise le 802.11n (debugfs ht_capa), le réseau est régénéré et la connexion refusée, au maximum deux fois de suite. * fix(wifi): préciser le refus de connexion et le cas des autres appareils en 802.11n Commentaire sur lostWireless, qui compte aussi les connexions refusées pour le 802.11n. Le CHANGELOG dit qu'un autre appareil en 802.11n provoque deux reconstructions puis laisse démarrer la séance, et l'entrée anglaise en double est retirée. --------- Co-authored-by: Giuseppe --- CHANGELOG.en.md | 5 ++ CHANGELOG.md | 5 ++ docs/ARCHITECTURE.md | 2 +- docs/MAINTENANCE.md | 19 +++++-- platform/ap_uapsd.hpp | 74 +++++++++++++++++++++---- platform/evo_ap.cpp | 15 ++++-- platform/evo_ap.hpp | 7 ++- platform/service_app.cpp | 38 +++++++++++++ platform/service_app.hpp | 5 +- platform/wireless_loop.cpp | 4 ++ platform/wireless_loop.hpp | 5 +- tests/test_parsers.cpp | 89 +++++++++++++++++++++++-------- tests/test_wireless_lifecycle.cpp | 45 +++++++++++++--- 13 files changed, 262 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 17112a7..baed2e0 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,6 +13,11 @@ QEMU with the car's libraries). ## [Unreleased] +### Fixed + +- Wireless: the car's access point no longer offers 802.11n (`ieee80211n=0`, set in hostapd's memory with U-APSD, before the same beacon rebuild). On an X1 F48, a decrypted capture taken during stalls showed phone frames acknowledged by the car and then lost inside it (26 % of the data segments), against 0.09 % without 802.11n ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). The setting holds for everything on the car's Wi-Fi and caps it at 54 Mbit/s. Tried in a car (X1 F48) in a personal build that contains this change: clear improvement in the first tests, no extended testing. +- Wireless: `ieee80211n=0` was not enough. The car's `hostapd` still grants 802.11n to a phone that asks for it, most likely one with the old beacon (associated about a second after the `RELOAD`): 2 starts of 7 on an X1 F48. The beacon is now also rebuilt when the wireless loop starts, and at the phone's connection, if a device is on 802.11n, it is rebuilt again and the connection refused so that the phone comes back (twice in a row at most). Any device on 802.11n counts, not only the phone: a laptop on 802.11n on the car's Wi-Fi causes two rebuilds, then the session starts anyway. Tried in a car (X1 F48) in a personal build that contains this change: 3 starts of 3 without 802.11n; the refusal of a connection never triggered in the car ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). + ## [0.13.0-rc.12] - 2026-11-30 · PC Release candidate: Android Auto no longer gone from the menu after a night with the car parked, the phone's diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c7020..4276bdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +### Corrigé + +- Sans-fil : le point d'accès de la voiture n'offre plus le 802.11n (`ieee80211n=0`, réglé en mémoire de hostapd avec U-APSD, avant la même reconstruction de la balise). Sur une X1 F48, une capture déchiffrée pendant des saccades montrait des trames du téléphone acquittées par la voiture puis perdues à l'intérieur (26 % des segments de données), contre 0,09 % sans 802.11n ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Le réglage vaut pour tout le Wi-Fi de la voiture et limite son débit à 54 Mbit/s. Essayé en voiture (X1 F48) dans une version personnelle qui contient ce changement : amélioration nette aux premiers essais, pas d'essais prolongés. +- Sans-fil : `ieee80211n=0` ne suffisait pas. Le `hostapd` de la voiture accorde encore le 802.11n à un téléphone qui le demande, sans doute avec l'ancienne balise (associé environ une seconde après le `RELOAD`) : 2 démarrages sur 7 sur une X1 F48. La balise est maintenant aussi reconstruite au démarrage de la boucle sans fil, et à la connexion du téléphone, si un appareil est en 802.11n, elle est reconstruite de nouveau et la connexion refusée pour qu'il revienne (deux fois de suite au plus). Tout appareil en 802.11n compte, pas seulement le téléphone : un ordinateur portable en 802.11n sur le Wi-Fi de la voiture provoque deux reconstructions, puis la séance démarre quand même. Essayé en voiture (X1 F48) dans une version personnelle qui contient ce changement : 3 démarrages sur 3 sans 802.11n ; le refus de connexion ne s'est jamais déclenché en voiture ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). + ## [0.13.0-rc.12] - 2026-11-30 · PC Version candidate : Android Auto qui ne disparaît plus du menu après une nuit voiture garée, les appels et le son diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 2596629..0138e64 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -76,7 +76,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `update_install` | Mise à jour par clé USB (`aa-supervisor --update-check`, `--update-install`) : vérification sans rien écrire, fichiers `.new` relus puis renommés un à un, journal qui termine une mise à jour coupée, rapport ; sur une fausse voiture dans les tests | | `update_car.cpp` | La même sur la voiture : `/proc/mounts`, remontage du système comme à l'installation, chargeur de l'unité, redémarrage, verrous ; `aa-supervisor --reboot`. Seul fichier qui lance `/sbin/reboot`, jamais dans un test | | `evo_reboot` | Redémarrage de l'unité : demandé proprement au processeur de l'unité (Cortex-M4) par vMOST, comme un outil de diagnostic BMW, sinon le redémarrage d'avant (`/sbin/reboot`) ; décisions sur une fausse voiture dans les tests | -| `ap_uapsd.hpp` | Point d'accès de la voiture sans U-APSD pour le téléphone qui le rejoint (réglage en mémoire de hostapd, balise reconstruite une fois par démarrage du point d'accès, appareils déjà connectés compris) | +| `ap_uapsd.hpp` | Point d'accès de la voiture sans U-APSD ni 802.11n pour le téléphone qui le rejoint (réglage en mémoire de hostapd, balise reconstruite une fois par démarrage du point d'accès, appareils déjà connectés compris, et de nouveau si un appareil est en 802.11n quand le téléphone se connecte) | | `wifi_link` | Qualité de la liaison Wi-Fi avec le téléphone, lue dans le noyau pour les journaux : entrée du téléphone (nl80211), redémarrages de la puce WL18xx comptés par son pilote (debugfs, lus sur un fil à part, jamais `fw_stats`), TCP, et l'état du lien Bluetooth des BMW Apps (testé sur PC) | | `alps_spp`, `evo_spp_snapshot` | Pile Bluetooth de la voiture : commandes, et lecture de son état en mémoire | | `phone_audio_recall.hpp` | Appels et son du téléphone en Bluetooth redemandés à la pile pendant une séance sans fil quand ils sont tombés d'eux-mêmes (15 s après, toutes les 30 s, toutes les 2 minutes après 5 minutes) ; rien hors séance, ni quand la voiture ou le téléphone les ont coupés (testé sur PC) | diff --git a/docs/MAINTENANCE.md b/docs/MAINTENANCE.md index 4ea1ea3..2d49849 100644 --- a/docs/MAINTENANCE.md +++ b/docs/MAINTENANCE.md @@ -134,21 +134,34 @@ Auto occupe lui-même l'emplacement des BMW Apps (`takes SPP 0` dans le journal pas de ligne `[WifiLink]`. Avant chaque échange Wi-Fi avec le téléphone, le service demande au point d'accès de la voiture de ne plus proposer -U-APSD, une économie d'énergie du téléphone, et écrit une ligne `car access point:` (journal du service, toujours) : +U-APSD, une économie d'énergie du téléphone, ni le 802.11n (sur une X1 F48, des trames acquittées par la voiture se +perdaient à l'intérieur pendant les saccades, [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203) ; +le réglage vaut pour tout le Wi-Fi de la voiture et limite son débit à 54 Mbit/s), et écrit une ligne +`car access point:` (journal du service, toujours) : | Fin de la ligne | Sens | |---|---| -| `beacon rebuilt: the phone joins without it` | Fait : le téléphone rejoint le Wi-Fi sans U-APSD | +| `beacon rebuilt: the phone joins without them` | Fait : le téléphone rejoint le Wi-Fi sans U-APSD ni 802.11n | | `disconnected once and joins again without it` | Fait : un appareil était déjà sur le Wi-Fi de la voiture (téléphone qui l'a rejoint tout seul, téléphone revenu, ordinateur, iPhone en CarPlay) ; il est déconnecté une fois et le rejoint aussitôt sans U-APSD | | `beacon already rebuilt for this hostapd start` | Déjà fait depuis le dernier démarrage du point d'accès, même par un service arrêté puis relancé depuis : le réglage seul, sans reconstruire la balise une seconde fois | | `beacon left, nobody disconnected` | Un appareil était déjà sur le Wi-Fi, mais le démarrage du point d'accès n'a pas pu être reconnu : personne n'est déconnecté (sinon ce serait à chaque échange), et cet appareil garde U-APSD jusqu'à sa prochaine connexion | | `RELOAD refused` | hostapd a pris le réglage mais refusé de reconstruire sa balise, sans déconnecter personne : le téléphone peut encore demander U-APSD ; redemandé au prochain échange | | `RELOAD not answered` | hostapd n'a pas répondu à temps : la balise a pu être reconstruite ; pas redemandé avant le prochain démarrage du point d'accès, pour ne pas déconnecter le téléphone à chaque échange | -| `left on` | hostapd a refusé le réglage ou n'a pas répondu : rien n'a changé | +| `left on` | hostapd a refusé un des deux réglages ou n'a pas répondu : la balise n'est pas reconstruite | +| `no station on 802.11n` | Vérifié à la connexion du téléphone : personne sur le Wi-Fi de la voiture n'est en 802.11n | +| `a station on 802.11n (rebuild …)` | Un appareil est en 802.11n à la connexion du téléphone : la balise est reconstruite, la connexion refusée, le téléphone revient (deux fois de suite au plus) | +| `still on 802.11n after 2 rebuilds` | Toujours en 802.11n après deux reconstructions : la session démarre ainsi | +| `802.11n not checked` | La liste des stations (debugfs) est illisible : rien n'est vérifié | + +La ligne est écrite au démarrage du service, avant chaque échange Wi-Fi avec un téléphone et, pour la vérification, à +chaque connexion sans fil du téléphone. Le réglage est fait dans la mémoire de hostapd, jamais dans un fichier de la voiture : un redémarrage de l'unité, ou de hostapd par le système, remet celui de BMW. +Ce réglage ne suffit pas toujours : ce hostapd accorde encore le 802.11n à un appareil qui le demande (téléphone qui a +gardé l'ancienne balise), d'où la vérification à la connexion du téléphone. + ### Silences du téléphone et espacement des images Journaux activés, le service écrit aussi une ligne `[Session]` toutes les 10 secondes d'une session, sans fil ou USB : diff --git a/platform/ap_uapsd.hpp b/platform/ap_uapsd.hpp index 231d3df..fd43ed1 100644 --- a/platform/ap_uapsd.hpp +++ b/platform/ap_uapsd.hpp @@ -6,6 +6,11 @@ // frames back for seconds while it saved power (firmware counter ps_poll_upsd_timeouts: 1700 in 12 minutes), and the // picture and the sound stalled; with U-APSD off, the stalls were gone. // +// 802.11n is turned off the same way (#203). During stalls on an X1 F48, a decrypted capture showed the car +// acknowledging the phone's frames on air and about a quarter of them never reaching its TCP; without 802.11n, +// 0.09 % in one run of 6 re-joins. Not told apart: chip firmware, driver, or mac80211's A-MPDU reordering. It holds +// for everything on the car's Wi-Fi and caps it at 54 Mbit/s. +// // hostapd on the car is v2.1-devel. SET changes the setting in memory only (hostapd_set_iface): association responses // follow it at once, but the beacon and the probe responses, which the chip sends from a template, go on offering // U-APSD until hostapd rebuilds them. A phone asks for U-APSD from them in its association request, and hostapd keeps @@ -27,13 +32,22 @@ // then sent only with no station associated, as before. wland can start hostapd again from its own file: the setting // is made before each Wi-Fi exchange with a phone, not once. // +// ieee80211n=0 does not refuse 802.11n: this hostapd still grants HT to a station that asks for it, and refuses it only +// with disable_11n (copy_sta_ht_capab, read in the car's binary, disassembled, and in Android's android-4.4_r1 +// sources). Most likely a phone with the old beacon, joining about a second after RELOAD, asks for HT and +// gets it: on the same X1 F48, 2 starts of 7 had the phone on 802.11n (#203). So the RELOAD is also made when the +// wireless loop starts, ahead of the phone's handshake, and a phone's TCP connection is checked (htStations): a +// station on 802.11n, the beacon is rebuilt again and the phone comes back. +// // Pure: the hostapd_cli calls are made by the caller (platform/evo_ap.cpp). The station list is only counted, never // logged (MAC addresses). tests/test_parsers.cpp. #ifndef ENTRY_AAD_PLATFORM_AP_UAPSD_HPP #define ENTRY_AAD_PLATFORM_AP_UAPSD_HPP +#include #include +#include #include #include @@ -53,7 +67,7 @@ enum class UapsdOffer { inline const char* describeUapsdOffer(UapsdOffer offer) { switch (offer) { case UapsdOffer::kWithdrawn: - return "U-APSD off, beacon rebuilt: the phone joins without it"; + return "U-APSD and 802.11n off, beacon rebuilt: the phone joins without them"; case UapsdOffer::kRejoined: return "U-APSD off, beacon rebuilt: what was already on the car's Wi-Fi was disconnected once and joins " "again without it"; @@ -72,7 +86,7 @@ inline const char* describeUapsdOffer(UapsdOffer offer) { case UapsdOffer::kSetRefused: break; } - return "hostapd refused the setting: U-APSD left on"; + return "hostapd refused a setting: U-APSD or 802.11n left on"; } namespace uapsd { @@ -122,6 +136,43 @@ inline int stations(const std::string& reply) { } } // namespace uapsd +// The stations of the car's access point that joined over 802.11n, from mac80211's debugfs: one folder per station in +// //netdev:wlan0/stations, its ht_capa starting "ht supported" or "ht not supported" (the kernel's +// memory: nothing is asked of the chip). -1 when there is no station list to read. +inline int htStations(const std::string& ieee80211) { + DIR* phys = opendir(ieee80211.c_str()); + if (!phys) { + return -1; + } + int count = -1; + while (const dirent* phy = readdir(phys)) { + if (phy->d_name[0] == '.') { + continue; + } + const std::string list = ieee80211 + "/" + phy->d_name + "/netdev:wlan0/stations"; + DIR* stations = opendir(list.c_str()); + if (!stations) { + continue; + } + if (count < 0) { + count = 0; + } + while (const dirent* station = readdir(stations)) { + if (station->d_name[0] == '.') { + continue; + } + std::ifstream capability((list + "/" + station->d_name + "/ht_capa").c_str()); + std::string line; + if (std::getline(capability, line) && line == "ht supported") { + ++count; + } + } + closedir(stations); + } + closedir(phys); + return count; +} + // Which hostapd start this is: its control socket, created anew each time hostapd starts (unlinked, then bound). struct HostapdStart { unsigned long long device, inode; @@ -158,19 +209,22 @@ inline bool parseHostapdStart(const std::string& text, HostapdStart& out) { } // call(command, reply): runs one hostapd_cli command on wlan0 ({"set", ...}) and gives its reply; false when it could -// not run. At most three calls: the setting, the station list, RELOAD. beaconDone: the beacon was rebuilt for this +// not run. At most four calls: the two settings, the station list, RELOAD. beaconDone: the beacon was rebuilt for this // hostapd start already (the caller knows it from HostapdStart): the setting only. startKnown: the hostapd start could // be told, so a RELOAD stays once per start and may disconnect who is there. stopping(): true once the service is -// asked to stop, checked before each call: a stop waits for the call under way only, never for three of up to 5 s each -// (the supervisor kills the service 10 s after asking it to stop). +// asked to stop, checked before each call: a stop waits for the call under way only, never for several of up to 5 s +// each (the supervisor kills the service 10 s after asking it to stop). template UapsdOffer withdrawUapsd(Call call, Stopping stopping, bool beaconDone = false, bool startKnown = true) { std::string reply; - if (stopping()) { - return UapsdOffer::kStopped; - } - if (!call(std::vector{"set", "uapsd_advertisement_enabled", "0"}, reply) || !uapsd::ok(reply)) { - return UapsdOffer::kSetRefused; + // Both settings first, then one RELOAD for the two. + for (const char* setting : {"uapsd_advertisement_enabled", "ieee80211n"}) { + if (stopping()) { + return UapsdOffer::kStopped; + } + if (!call(std::vector{"set", setting, "0"}, reply) || !uapsd::ok(reply)) { + return UapsdOffer::kSetRefused; + } } if (beaconDone) { return UapsdOffer::kAlreadyDone; diff --git a/platform/evo_ap.cpp b/platform/evo_ap.cpp index 95869c2..4df127e 100644 --- a/platform/evo_ap.cpp +++ b/platform/evo_ap.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -52,13 +53,18 @@ static HostapdStart rebuiltStart() { } return start; } -// The wireless loop's thread only. -UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user) { +// One caller at a time: the wireless loop and a phone's connection both come here. +static pthread_mutex_t gApMutex = PTHREAD_MUTEX_INITIALIZER; +UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user, bool again) { + struct Lock { + Lock() { pthread_mutex_lock(&gApMutex); } + ~Lock() { pthread_mutex_unlock(&gApMutex); } + } lock; const HostapdStart now = currentHostapdStart(); const UapsdOffer offer = withdrawUapsd([](const std::vector& command, std::string& reply) { return callHostapd(command, reply, kChangeTimeoutMs); }, - [stopping, user]() { return stopping(user); }, now.same(rebuiltStart()), now.known); + [stopping, user]() { return stopping(user); }, !again && now.same(rebuiltStart()), now.known); if (now.known && (offer == UapsdOffer::kWithdrawn || offer == UapsdOffer::kRejoined || offer == UapsdOffer::kReloadUnanswered)) { const std::string text = formatHostapdStart(now); @@ -69,6 +75,9 @@ UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user) { } return offer; } +int accessPointHtStations() { + return htStations("/sys/kernel/debug/ieee80211"); +} static bool macAddress(const std::string& value) { if (value.size() != 17) { return false; diff --git a/platform/evo_ap.hpp b/platform/evo_ap.hpp index 2154a5b..08d3b72 100644 --- a/platform/evo_ap.hpp +++ b/platform/evo_ap.hpp @@ -13,7 +13,10 @@ bool parseHostapdConfig(const std::string& text, aa::ApInfo& out); // Read-only hostapd query (bounded child), then ap.conf; IP/MAC from wlan0 ioctls. bool loadAccessPoint(aa::ApInfo& out, std::string& source); // No U-APSD offered to the next phone that joins (ap_uapsd.hpp): hostapd_cli, bounded children. Not logged here. -// stopping(user): true once the service is asked to stop; no hostapd_cli command starts after that. -UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user); +// stopping(user): true once the service is asked to stop; no hostapd_cli command starts after that. again: the beacon +// is rebuilt even if it was for this hostapd start (a station came in over 802.11n all the same). +UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user, bool again = false); +// htStations (ap_uapsd.hpp) of the car's access point. +int accessPointHtStations(); } // namespace evo #endif diff --git a/platform/service_app.cpp b/platform/service_app.cpp index 7b5c857..6c61760 100644 --- a/platform/service_app.cpp +++ b/platform/service_app.cpp @@ -42,6 +42,7 @@ ServiceApp::ServiceApp(uint16_t p, bool v, std::atomic* quit) wppAccepted(false), projectionOverUsb(false), lostWireless(0), + htRebuilds(0), quit_(quit) { pthread_mutex_init(&mu, nullptr); pthread_mutex_init(&connectMu, nullptr); @@ -104,6 +105,31 @@ void ServiceApp::prepareAccessPoint() { ELOG("ServiceApp", "car access point: %s", describeUapsdOffer(withdrawAccessPointUapsd(stopAsked, this))); } +// A phone on 802.11n although it was taken off the beacon (#203): the beacon is rebuilt again, which disconnects it, so +// that it joins and connects again. Twice in a row at most: then the session starts as it is. +bool ServiceApp::phoneMustRejoin() { + const unsigned kMaxRebuilds = 2; + const int onHt = accessPointHtStations(); + if (onHt <= 0) { + if (onHt == 0) { + htRebuilds = 0; + } + ELOG("ServiceApp", "car access point: %s", + onHt == 0 ? "no station on 802.11n" : "stations unreadable, 802.11n not checked"); + return false; + } + if (htRebuilds >= kMaxRebuilds) { + ELOG("ServiceApp", "car access point: a station still on 802.11n after %u rebuilds, the session starts on it", + htRebuilds); + return false; + } + ++htRebuilds; + const UapsdOffer offer = withdrawAccessPointUapsd(stopAsked, this, true); + ELOG("ServiceApp", "car access point: a station on 802.11n (rebuild %u of %u): %s", htRebuilds, kMaxRebuilds, + describeUapsdOffer(offer)); + return offer == UapsdOffer::kWithdrawn || offer == UapsdOffer::kRejoined || offer == UapsdOffer::kReloadUnanswered; +} + void ServiceApp::handshakeEnded(bool spoke, bool accepted) { pthread_mutex_lock(&mu); wppReply = wppReply || spoke; @@ -495,6 +521,18 @@ void ServiceApp::startProjection(int fd, bool overUsb) { pthread_mutex_unlock(&a->mu); ELOG("ServiceApp", "phone %s connection received; preparing the video and the AA session", overUsb ? "USB" : "TCP"); a->session.stop(); // join callbacks before destroying/reinitializing video buffers + if (!overUsb && a->phoneMustRejoin()) { + close(fd); + a->server.notifySessionEnded(); + pthread_mutex_lock(&a->mu); + a->tcpPreparing = false; + // Not a session lost without ByeBye, but counted with them on purpose: the wireless loop then drops the + // Bluetooth link the phone kept, and the phone starts again with the rebuilt beacon. + ++a->lostWireless; + pthread_mutex_unlock(&a->mu); + pthread_mutex_unlock(&a->connectMu); + return; + } bool videoOk = true; if (a->videoEnabled) { pthread_mutex_lock(&a->videoMu); diff --git a/platform/service_app.hpp b/platform/service_app.hpp index 95d8c5a..1db132e 100644 --- a/platform/service_app.hpp +++ b/platform/service_app.hpp @@ -138,11 +138,14 @@ class ServiceApp : public WirelessHost, public UsbHost { std::atomic videoFrames; // counted on the session thread without mu bool wppReply, wppAccepted; bool projectionOverUsb; // the last session came over USB (its loss is not the wireless loop's business) - unsigned lostWireless; // wireless sessions ended without ByeBye + unsigned lostWireless; // wireless sessions ended without ByeBye, and connections refused for 802.11n (#203) + unsigned htRebuilds; // beacon rebuilds in a row for a phone on 802.11n; under connectMu private: // A phone connection, from the TCP listener or the USB loop: the video is made ready and the session starts. void startProjection(int fd, bool overUsb); + // True when the access point's beacon was just rebuilt because a station is on 802.11n: this connection is refused. + bool phoneMustRejoin(); std::atomic* quit_; }; diff --git a/platform/wireless_loop.cpp b/platform/wireless_loop.cpp index f7c7732..ede2d01 100644 --- a/platform/wireless_loop.cpp +++ b/platform/wireless_loop.cpp @@ -15,6 +15,10 @@ void runWirelessLoop(AlpsSppLink& bt, const aa::ApInfo& ap, uint16_t port, Wirel // The phone's calls and audio over Bluetooth that drop on their own during a session are asked for again // (phone_audio_recall.hpp): on every turn, whatever the loop is waiting for. const auto keepPhoneAudio = [&bt, &host]() { bt.keepPhoneAudio(host.projectionBusy(), monoMs()); }; + // A phone that knows the car's Wi-Fi joins by itself once its Bluetooth is up: the beacon is rebuilt ahead of it. + if (!host.stopRequested()) { + host.prepareAccessPoint(); + } while (!host.stopRequested() && bt.running()) { int fd = bt.waitLink(250); keepPhoneAudio(); diff --git a/platform/wireless_loop.hpp b/platform/wireless_loop.hpp index 16c3bb4..d10df77 100644 --- a/platform/wireless_loop.hpp +++ b/platform/wireless_loop.hpp @@ -19,8 +19,9 @@ class WirelessHost { // A phone connection is being prepared or its Android Auto session runs: no new handshake meanwhile. virtual bool projectionBusy() = 0; virtual void sppLinkOpened() = 0; - // Just before the phone is told the access point: the next phone that joins it must be offered no U-APSD - // (ap_uapsd.hpp). Made each time, as wland can start hostapd again from its own file. + // When the loop starts, ahead of any phone, and just before a phone is told the access point: the next phone that + // joins it must be offered no U-APSD and no 802.11n (ap_uapsd.hpp). Made each time, as wland can start hostapd + // again from its own file. virtual void prepareAccessPoint() = 0; // A handshake ended: the phone spoke the wireless protocol, it accepted the Wi-Fi. virtual void handshakeEnded(bool spoke, bool accepted) = 0; diff --git a/tests/test_parsers.cpp b/tests/test_parsers.cpp index 8f0d6e6..d2a69e8 100644 --- a/tests/test_parsers.cpp +++ b/tests/test_parsers.cpp @@ -5,7 +5,10 @@ #include #include #include +#include +#include +#include #include #include #include @@ -58,59 +61,98 @@ evo::UapsdOffer withdrawStartUnknown(FakeHostapd& hostapd, std::initializer_list return withdraw(hostapd, replies, never, false); } +// A debugfs station list on the PC: ///stations//ht_capa. +void htStationCases() { + char root[] = "/tmp/entry-aad-ht-XXXXXX"; + CHECK(mkdtemp(root)); + const std::string dir = root; + CHECK(evo::htStations(dir + "/absent") == -1 && evo::htStations(dir) == -1); + std::vector made; + const auto folder = [&made](const std::string& path) { + CHECK(mkdir(path.c_str(), 0700) == 0); + made.push_back(path); + }; + const auto station = [&](const std::string& netdev, const char* name, const char* capability) { + const std::string path = dir + "/phy0/" + netdev + "/stations/" + name; + folder(path); + std::ofstream(path + "/ht_capa") << capability; + made.push_back(path + "/ht_capa"); + }; + folder(dir + "/phy0"); + CHECK(evo::htStations(dir) == -1); // no access point on that radio + for (const char* netdev : {"netdev:wlan0", "netdev:wlan1"}) { + folder(dir + "/phy0/" + netdev); + folder(dir + "/phy0/" + netdev + "/stations"); + } + CHECK(evo::htStations(dir) == 0); + station("netdev:wlan1", "other", "ht supported\n"); // not the access point + station("netdev:wlan0", "legacy", "ht not supported\n"); + CHECK(evo::htStations(dir) == 0); + station("netdev:wlan0", "fast", "ht supported\ncap: 0x016e\n"); + CHECK(evo::htStations(dir) == 1); + for (size_t i = made.size(); i > 0; --i) { + CHECK(remove(made[i - 1].c_str()) == 0); + } + CHECK(remove(root) == 0); +} + void uapsdCases() { FakeHostapd hostapd; // No station: the setting, then RELOAD to rebuild the beacon and the chip's probe response. - CHECK(withdraw(hostapd, {"OK\n", "", "OK\n"}) == evo::UapsdOffer::kWithdrawn); - CHECK(hostapd.sent.size() == 3 && hostapd.sent[0] == "set uapsd_advertisement_enabled 0" && - hostapd.sent[1] == "all_sta" && hostapd.sent[2] == "raw RELOAD"); - CHECK(withdraw(hostapd, {"OK", " \n", "OK\r\n"}) == evo::UapsdOffer::kWithdrawn); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "OK\n"}) == evo::UapsdOffer::kWithdrawn); + CHECK(hostapd.sent.size() == 4 && hostapd.sent[0] == "set uapsd_advertisement_enabled 0" && + hostapd.sent[1] == "set ieee80211n 0" && hostapd.sent[2] == "all_sta" && hostapd.sent[3] == "raw RELOAD"); + CHECK(withdraw(hostapd, {"OK", "OK", " \n", "OK\r\n"}) == evo::UapsdOffer::kWithdrawn); // A station on the access point (its MIB lines), a phone that joined by itself: RELOAD all the same. It keeps // U-APSD for as long as it stays associated, so it is disconnected once and joins again without it (#203). - CHECK(withdraw(hostapd, {"OK\n", "02:00:00:00:00:01\nflags=[AUTH][ASSOC]\naid=1\n", "OK\n"}) == + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "02:00:00:00:00:01\nflags=[AUTH][ASSOC]\naid=1\n", "OK\n"}) == evo::UapsdOffer::kRejoined); - CHECK(hostapd.sent.size() == 3 && hostapd.sent[2] == "raw RELOAD"); - CHECK(withdraw(hostapd, {"OK\n", "02:00:00:00:00:01\n", "FAIL\n"}) == evo::UapsdOffer::kReloadRefused); + CHECK(hostapd.sent.size() == 4 && hostapd.sent[3] == "raw RELOAD"); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "02:00:00:00:00:01\n", "FAIL\n"}) == evo::UapsdOffer::kReloadRefused); // RELOAD not answered (hostapd_cli timed out or failed): it may have run, told apart from a refusal. - CHECK(withdraw(hostapd, {"OK\n", "02:00:00:00:00:01\n", "!"}) == evo::UapsdOffer::kReloadUnanswered); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "02:00:00:00:00:01\n", "!"}) == evo::UapsdOffer::kReloadUnanswered); // A station list that cannot be read is no proof of an empty one: RELOAD all the same, but no disconnection is // claimed, since maybe nobody was there. - CHECK(withdraw(hostapd, {"OK\n", "!", "OK\n"}) == evo::UapsdOffer::kWithdrawn && hostapd.sent.size() == 3); - CHECK(withdraw(hostapd, {"OK\n", "'STA-FIRST' command failed.\n", "OK\n"}) == evo::UapsdOffer::kWithdrawn); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "!", "OK\n"}) == evo::UapsdOffer::kWithdrawn && hostapd.sent.size() == 4); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "'STA-FIRST' command failed.\n", "OK\n"}) == evo::UapsdOffer::kWithdrawn); // The hostapd start unknown: a RELOAD could not be kept to once per start, so nobody is disconnected, as before. - CHECK(withdrawStartUnknown(hostapd, {"OK\n", "02:00:00:00:00:01\nflags=[AUTH][ASSOC]\n"}) == + CHECK(withdrawStartUnknown(hostapd, {"OK\n", "OK\n", "02:00:00:00:00:01\nflags=[AUTH][ASSOC]\n"}) == evo::UapsdOffer::kBeaconLeft); - CHECK(hostapd.sent.size() == 2); - CHECK(withdrawStartUnknown(hostapd, {"OK\n", "!"}) == evo::UapsdOffer::kBeaconLeft && hostapd.sent.size() == 2); - CHECK(withdrawStartUnknown(hostapd, {"OK\n", "", "OK\n"}) == evo::UapsdOffer::kWithdrawn); + CHECK(hostapd.sent.size() == 3); + CHECK(withdrawStartUnknown(hostapd, {"OK\n", "OK\n", "!"}) == evo::UapsdOffer::kBeaconLeft && + hostapd.sent.size() == 3); + CHECK(withdrawStartUnknown(hostapd, {"OK\n", "OK\n", "", "OK\n"}) == evo::UapsdOffer::kWithdrawn); // The station count of an all_sta reply, MIB lines skipped; -1 for anything that is no station list. CHECK(evo::uapsd::stations("") == 0 && evo::uapsd::stations(" \r\n") == 0); CHECK(evo::uapsd::stations("02:00:00:00:00:01\nflags=[AUTH]\n0A:0b:00:00:00:02\r\naid=2\r\n") == 2); CHECK(evo::uapsd::stations("'STA-FIRST' command failed.\n") == -1); CHECK(evo::uapsd::stations("02:00:00:00:00:0Z\n") == -1 && evo::uapsd::stations("02-00-00-00-00-01\n") == -1); CHECK(strstr(evo::describeUapsdOffer(evo::UapsdOffer::kRejoined), "disconnected once")); - // The setting refused or not answered: nothing else is sent. + // A setting refused or not answered: nothing else is sent. + CHECK(withdraw(hostapd, {"OK\n", "FAIL\n"}) == evo::UapsdOffer::kSetRefused && hostapd.sent.size() == 2); CHECK(withdraw(hostapd, {"FAIL\n"}) == evo::UapsdOffer::kSetRefused && hostapd.sent.size() == 1); CHECK(withdraw(hostapd, {"!"}) == evo::UapsdOffer::kSetRefused && hostapd.sent.size() == 1); CHECK(withdraw(hostapd, {"OKAY\n"}) == evo::UapsdOffer::kSetRefused); - CHECK(withdraw(hostapd, {"OK\n", "", "FAIL\n"}) == evo::UapsdOffer::kReloadRefused); - CHECK(withdraw(hostapd, {"OK\n", "", "!"}) == evo::UapsdOffer::kReloadUnanswered); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "FAIL\n"}) == evo::UapsdOffer::kReloadRefused); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "!"}) == evo::UapsdOffer::kReloadUnanswered); // The beacon already rebuilt for this hostapd start: the setting again, never a second RELOAD (a phone that comes // back reopens its Bluetooth link every 400 ms or so while it joins). const StopAfter running = {&hostapd, never}; - hostapd.replies.assign({"OK\n", "", "OK\n"}); + hostapd.replies.assign({"OK\n", "OK\n", "", "OK\n"}); hostapd.sent.clear(); CHECK(evo::withdrawUapsd(std::ref(hostapd), running, true) == evo::UapsdOffer::kAlreadyDone); - CHECK(hostapd.sent.size() == 1 && hostapd.sent[0] == "set uapsd_advertisement_enabled 0"); + CHECK(hostapd.sent.size() == 2 && hostapd.sent[1] == "set ieee80211n 0"); hostapd.replies.assign({"FAIL\n"}); hostapd.sent.clear(); CHECK(evo::withdrawUapsd(std::ref(hostapd), running, true) == evo::UapsdOffer::kSetRefused); // The service asked to stop: no further hostapd command, whose 5 s each kept the stop waiting (15 s in all, past // the supervisor's 10 s before it kills the service). - CHECK(withdraw(hostapd, {"OK\n", "", "OK\n"}, 0) == evo::UapsdOffer::kStopped && hostapd.sent.empty()); - CHECK(withdraw(hostapd, {"OK\n", "", "OK\n"}, 1) == evo::UapsdOffer::kStopped && hostapd.sent.size() == 1); - CHECK(withdraw(hostapd, {"OK\n", "", "OK\n"}, 2) == evo::UapsdOffer::kStopped && hostapd.sent.size() == 2); - CHECK(withdraw(hostapd, {"OK\n", "", "OK\n"}, 3) == evo::UapsdOffer::kWithdrawn && hostapd.sent.size() == 3); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "OK\n"}, 0) == evo::UapsdOffer::kStopped && hostapd.sent.empty()); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "OK\n"}, 1) == evo::UapsdOffer::kStopped && hostapd.sent.size() == 1); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "OK\n"}, 2) == evo::UapsdOffer::kStopped && hostapd.sent.size() == 2); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "OK\n"}, 3) == evo::UapsdOffer::kStopped && hostapd.sent.size() == 3); + CHECK(withdraw(hostapd, {"OK\n", "OK\n", "", "OK\n"}, 4) == evo::UapsdOffer::kWithdrawn && + hostapd.sent.size() == 4); CHECK(withdraw(hostapd, {"FAIL\n"}, 1) == evo::UapsdOffer::kSetRefused); // a refusal stays a refusal CHECK(strstr(evo::describeUapsdOffer(evo::UapsdOffer::kStopped), "stopping")); // Which hostapd start: its control socket's identity; unknown is never the same start. @@ -175,6 +217,7 @@ int main() { CHECK(!evo::parseHostapdConfig("ssid=ok\npassphrase=demo1234" + std::string(1, '\0'), ap)); CHECK(!evo::parseHostapdConfig(std::string(65537, 'x'), ap)); uapsdCases(); + htStationCases(); puts("PASS UUID/payload Alps et configuration hostapd (aucun secret reel), U-APSD du point d'acces"); return 0; } diff --git a/tests/test_wireless_lifecycle.cpp b/tests/test_wireless_lifecycle.cpp index 0098cc7..6cfb556 100644 --- a/tests/test_wireless_lifecycle.cpp +++ b/tests/test_wireless_lifecycle.cpp @@ -18,7 +18,8 @@ #include "service_contract.hpp" #include "wireless_setup.hpp" -static std::atomic starts(0), waits(0), listens(0), serves(0), prepared(0), sppDrops(0); +static std::atomic starts(0), waits(0), listens(0), serves(0), prepared(0), sppDrops(0), rebuilt(0); +static std::atomic onHt(0); // stations on 802.11n the fake access point reports // The phone's calls and audio are looked after on every turn of the loop, told whether a projection runs. static std::atomic audioKeptBusy(0), audioKeptIdle(0); static std::atomic fixtureLink(true), borrowed(false); @@ -59,22 +60,29 @@ bool AlpsSppLink::requestSppDisconnect() { void AlpsSppLink::keepPhoneAudio(bool sessionRunning, uint32_t) { ++(sessionRunning ? audioKeptBusy : audioKeptIdle); } -// The access point is made ready (no U-APSD) once before every handshake, never during one, told how to see the -// service's stop (each hostapd command may take 5 s). -UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user) { +// The access point is made ready (no U-APSD, no 802.11n) when the loop starts and once before every handshake, never +// during one, told how to see the service's stop (each hostapd command may take 5 s). again: for a station on 802.11n. +UapsdOffer withdrawAccessPointUapsd(bool (*stopping)(void*), void* user, bool again) { assert(stopping && !stopping(user)); apStopping = stopping; apUser = user; + if (again) { + ++rebuilt; + return UapsdOffer::kRejoined; + } ++prepared; return UapsdOffer::kWithdrawn; } +int accessPointHtStations() { + return onHt; +} } // namespace evo namespace aa { WirelessSetup::WirelessSetup(int fd, const ApInfo& ap, uint16_t port, int peekMs) : fd_(fd), ap_(ap), port_(port), peekMs_(peekMs), foreign_(false), spoke_(true), heard_(0) {} bool WirelessSetup::handshake(int) { assert(fd_ == 42 && peekMs_ == 300 && port_ == 50000); - assert(prepared == starts + 1); + assert(prepared == starts + 2); // the loop's start, then each handshake pthread_mutex_lock(&instance->mu); instance->tcpPreparing = true; pthread_mutex_unlock(&instance->mu); @@ -292,6 +300,31 @@ int main() { evo::ServiceApp::command(quit, &app); assert(quitFlag == 1); } + { // A phone that connects while a station is on 802.11n: the beacon is rebuilt and the connection refused, so the + // phone comes back; twice in a row at most. A clean check starts the count again; unreadable stations refuse + // none. + app.ready = true; + const int cases[][4] = {// stations on 802.11n, session starts, rebuilds so far, sessions lost so far + {1, 0, 1, 1}, {1, 0, 2, 2}, {1, 1, 2, 2}, {0, 1, 2, 2}, {1, 0, 3, 3}, {-1, 1, 3, 3}}; + for (const auto& c : cases) { + onHt = c[0]; + int pair[2]; + assert(socketpair(AF_UNIX, SOCK_STREAM, 0, pair) == 0); + evo::ServiceApp::connected(pair[0], &app); + assert(app.session.isActive() == (c[1] != 0) && rebuilt == c[2]); + assert(static_cast(app.lostSessions()) == c[3]); + assert(!app.tcpPreparing); + if (!c[1]) { + char byte; + assert(read(pair[1], &byte, 1) == 0); // the phone's connection was closed, nothing sent into it + } + app.session.stop(); + close(pair[1]); + } + onHt = 0; + app.ready = false; + app.lostWireless = 0; + } preparing(true); pthread_t thread; assert(pthread_create(&thread, 0, evo::ServiceApp::wireless, &app) == 0); @@ -302,7 +335,7 @@ int main() { assert(linkClosedWithin(2000)); usleep(50000); pthread_mutex_lock(&app.mu); - assert(starts == 0 && app.sppLinks == 0 && prepared == 0); + assert(starts == 0 && app.sppLinks == 0 && prepared == 1); pthread_mutex_unlock(&app.mu); bmwAppsLink = false; fixtureLink = true; // the phone's own link comes next, listened to while the connection is prepared From b1a9176c89adc0aa57f2e359baa4faee75d8ac0f Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Tue, 1 Dec 2026 04:38:58 +0100 Subject: [PATCH 05/17] =?UTF-8?q?fix(mise-a-jour):=20tout=20=C3=A9crire=20?= =?UTF-8?q?sur=20la=20flash=20avant=20le=20red=C3=A9marrage=20(#273)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Essayé sur la G20 avec aa-supervisor --reboot : la demande ECUReset au processeur de l'unité la remet à zéro environ une seconde après, avant toute réponse, comme après un codage par un outil BMW, et non par un arrêt propre comme supposé. Les services ne s'arrêtent pas : ce qui n'est pas encore sur la flash est perdu. sync() juste avant la demande ; chaque ligne [Reboot] est écrite sur la flash à mesure, et ajoutée au rapport de la mise à jour (update-report.txt, « restart: ») quel que soit le profil : elles n'allaient qu'au journal du service, profil maintenance, et se perdaient dans la remise à zéro. Le redémarrage lent du 01/12 (2 min 30) venait de la rc.10, qui faisait la mise à jour : c'est la version installée qui redémarre l'unité. --- CHANGELOG.en.md | 1 + CHANGELOG.md | 1 + docs/MAINTENANCE.md | 9 +++++--- platform/evo_reboot.cpp | 43 +++++++++++++++++++++++++++++++++++---- platform/evo_reboot.hpp | 32 +++++++++++++++++------------ platform/update_car.cpp | 24 ++++++++++++++-------- tests/test_evo_reboot.cpp | 37 ++++++++++++++++++++++++++++++--- 7 files changed, 115 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index baed2e0..0121745 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -17,6 +17,7 @@ QEMU with the car's libraries). - Wireless: the car's access point no longer offers 802.11n (`ieee80211n=0`, set in hostapd's memory with U-APSD, before the same beacon rebuild). On an X1 F48, a decrypted capture taken during stalls showed phone frames acknowledged by the car and then lost inside it (26 % of the data segments), against 0.09 % without 802.11n ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). The setting holds for everything on the car's Wi-Fi and caps it at 54 Mbit/s. Tried in a car (X1 F48) in a personal build that contains this change: clear improvement in the first tests, no extended testing. - Wireless: `ieee80211n=0` was not enough. The car's `hostapd` still grants 802.11n to a phone that asks for it, most likely one with the old beacon (associated about a second after the `RELOAD`): 2 starts of 7 on an X1 F48. The beacon is now also rebuilt when the wireless loop starts, and at the phone's connection, if a device is on 802.11n, it is rebuilt again and the connection refused so that the phone comes back (twice in a row at most). Any device on 802.11n counts, not only the phone: a laptop on 802.11n on the car's Wi-Fi causes two rebuilds, then the session starts anyway. Tried in a car (X1 F48) in a personal build that contains this change: 3 starts of 3 without 802.11n; the refusal of a connection never triggered in the car ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). +- Restart after an update from a USB stick: the request to the unit's processor resets the unit about a second later, without stopping the services (seen on a G20 with `aa-supervisor --reboot`), not a clean shutdown as assumed. Everything is now written to the flash just before the request, and the restart's lines are added to the update's report (`update-report.txt`), written to the flash one by one: until now they went only to the service log, maintenance profile, and were lost in the reset. An update made from 0.13.0-rc.10 still restarts the old way (about 2 minutes 30): the installed version restarts the unit. Tested on PC. ## [0.13.0-rc.12] - 2026-11-30 · PC diff --git a/CHANGELOG.md b/CHANGELOG.md index 4276bdd..f7fce52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ QEMU avec les bibliothèques de la voiture). - Sans-fil : le point d'accès de la voiture n'offre plus le 802.11n (`ieee80211n=0`, réglé en mémoire de hostapd avec U-APSD, avant la même reconstruction de la balise). Sur une X1 F48, une capture déchiffrée pendant des saccades montrait des trames du téléphone acquittées par la voiture puis perdues à l'intérieur (26 % des segments de données), contre 0,09 % sans 802.11n ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Le réglage vaut pour tout le Wi-Fi de la voiture et limite son débit à 54 Mbit/s. Essayé en voiture (X1 F48) dans une version personnelle qui contient ce changement : amélioration nette aux premiers essais, pas d'essais prolongés. - Sans-fil : `ieee80211n=0` ne suffisait pas. Le `hostapd` de la voiture accorde encore le 802.11n à un téléphone qui le demande, sans doute avec l'ancienne balise (associé environ une seconde après le `RELOAD`) : 2 démarrages sur 7 sur une X1 F48. La balise est maintenant aussi reconstruite au démarrage de la boucle sans fil, et à la connexion du téléphone, si un appareil est en 802.11n, elle est reconstruite de nouveau et la connexion refusée pour qu'il revienne (deux fois de suite au plus). Tout appareil en 802.11n compte, pas seulement le téléphone : un ordinateur portable en 802.11n sur le Wi-Fi de la voiture provoque deux reconstructions, puis la séance démarre quand même. Essayé en voiture (X1 F48) dans une version personnelle qui contient ce changement : 3 démarrages sur 3 sans 802.11n ; le refus de connexion ne s'est jamais déclenché en voiture ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). +- Redémarrage après une mise à jour par clé USB : la demande au processeur de l'unité remet l'unité à zéro environ une seconde après, sans arrêter les services (vu sur une G20 avec `aa-supervisor --reboot`), et non un arrêt propre comme supposé. Tout est maintenant écrit sur la flash juste avant la demande, et les lignes du redémarrage s'ajoutent au rapport de la mise à jour (`update-report.txt`), écrites sur la flash une à une : jusqu'ici elles n'allaient qu'au journal du service, profil maintenance, et se perdaient dans la remise à zéro. Une mise à jour faite depuis la 0.13.0-rc.10 redémarre encore à l'ancienne (environ 2 minutes 30) : c'est la version installée qui redémarre l'unité. Testé sur PC. ## [0.13.0-rc.12] - 2026-11-30 · PC diff --git a/docs/MAINTENANCE.md b/docs/MAINTENANCE.md index 2d49849..abf7e07 100644 --- a/docs/MAINTENANCE.md +++ b/docs/MAINTENANCE.md @@ -206,10 +206,13 @@ reboot ## Redémarrer l'unité (essai) -Voiture à l'arrêt, `aa-supervisor --reboot` redémarre l'unité comme après une mise à jour par clé USB : redémarrage -propre demandé au processeur de l'unité (Cortex-M4), comme un outil de diagnostic BMW, sinon le redémarrage d'avant +Voiture à l'arrêt, `aa-supervisor --reboot` redémarre l'unité comme après une mise à jour par clé USB : remise à +zéro demandée au processeur de l'unité (Cortex-M4), comme un outil de diagnostic BMW, sinon le redémarrage d'avant (`/sbin/reboot`, environ 3 minutes d'écran noir) ; refusé pendant une mise à jour ou après une mise à jour coupée -(`update-pending`). C'est un essai, jamais fait en voiture : ce qu'il fait s'affiche à chaque étape. +(`update-pending`). Essayé sur la G20 de référence : l'unité repart environ une seconde après la demande, sans arrêt +des services, comme après un codage par un outil BMW ; tout est écrit sur la flash juste avant. Ce qu'il fait +s'affiche à chaque étape. Après une mise à jour par clé USB, ces lignes s'ajoutent aussi à +`/var/local/data/AA/update-report.txt` (« restart: »). ```sh LD_LIBRARY_PATH=/usr/local/lib:/opt/hmi/lib:/usr/lib:/lib /opt/aa/aa-supervisor --reboot diff --git a/platform/evo_reboot.cpp b/platform/evo_reboot.cpp index 4e4bb89..634dfe9 100644 --- a/platform/evo_reboot.cpp +++ b/platform/evo_reboot.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2026 Jiraiya43 // SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 -// The unit's restart: the M4's clean restart asked over vMOST, today's restart otherwise (evo_reboot.hpp). +// The unit's restart: the M4's restart asked over vMOST, today's restart otherwise (evo_reboot.hpp). #include "evo_reboot.hpp" #include @@ -107,7 +107,7 @@ void __attribute__((format(printf, 2, 3))) say(RestartHost& host, const char* fm RestartWay restartHeadUnit(RestartHost& host, unsigned delayMs) { host.sleepMs(delayMs); say(host, - "asking the unit's processor (Cortex-M4) for a clean restart: ECUReset hardReset %02x %02x %02x %02x on " + "asking the unit's processor (Cortex-M4) to restart the unit: ECUReset hardReset %02x %02x %02x %02x on " "%04x.%02x.%02x.%03x, as DiagProxyIC forwards a BMW tester's request", kDiagTester, kDiagUnit, kUdsEcuReset, kUdsHardReset, kM4Address, kDiagFblock, kDiagInstance, kDiagFunction); if (!host.sendEcuReset()) { @@ -332,8 +332,15 @@ void EcuResetSession::end() { // ---- the log ------------------------------------------------------------------------------------------------------ -RebootLog::RebootLog(const char* maintenanceMarker, const char* logFile) - : marker_(maintenanceMarker), file_(logFile), tried_(false), redirected_(false), closed_(false) {} +RebootLog::RebootLog(const char* maintenanceMarker, const char* logFile, const char* report) + : marker_(maintenanceMarker), + file_(logFile), + report_(report), + reportFd_(-1), + tried_(false), + redirected_(false), + reportTried_(false), + closed_(false) {} void RebootLog::line(const char* text) { if (closed_) { @@ -358,6 +365,29 @@ void RebootLog::line(const char* text) { } } ELOG("Reboot", "%s", text); + if (redirected_) { + fsync(STDOUT_FILENO); + } + if (!reportTried_ && report_) { + reportTried_ = true; + const int fd = open(report_, O_WRONLY | O_CREAT | O_APPEND | O_NOFOLLOW | O_CLOEXEC, 0644); + struct stat st; + if (fd >= 0 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode) && st.st_uid == geteuid()) { + reportFd_ = fd; + } else if (fd >= 0) { + ::close(fd); + } + } + if (reportFd_ >= 0) { + char out[1100]; + const int n = snprintf(out, sizeof(out), "[%9.3f] restart: %s\n", upSec(), text); + if (n > 0) { + const size_t len = n < static_cast(sizeof(out)) ? static_cast(n) : sizeof(out) - 1; + if (write(reportFd_, out, len) == static_cast(len)) { + fsync(reportFd_); + } + } + } } void RebootLog::close() { @@ -367,6 +397,11 @@ void RebootLog::close() { closed_ = true; fflush(stdout); fflush(stderr); + if (reportFd_ >= 0) { + fsync(reportFd_); + ::close(reportFd_); + reportFd_ = -1; + } if (!redirected_) { return; } diff --git a/platform/evo_reboot.hpp b/platform/evo_reboot.hpp index a20df83..e44c7e2 100644 --- a/platform/evo_reboot.hpp +++ b/platform/evo_reboot.hpp @@ -1,7 +1,7 @@ // Copyright (c) 2026 Jiraiya43 // SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 -// The unit's restart after an update from a USB stick, and aa-supervisor --reboot: a clean restart asked of the -// unit's own processor (Cortex-M4) as a BMW diagnostic tool asks it, else today's restart. +// The unit's restart after an update from a USB stick, and aa-supervisor --reboot: a restart asked of the unit's own +// processor (Cortex-M4) as a BMW diagnostic tool asks it, else today's restart. // // Today's restart is /sbin/reboot, a link to systemctl, without -f: systemd stops the services, so the BMW // persistence is written, but the iDrive stays black about 3 minutes while systemd waits for the BMW services (after @@ -20,13 +20,15 @@ // to ECUReset) as "ECUReset", and closes the tester's connection 100 ms later. // - SystemManager.service gives SystemManager 5 s for the applications and 20 s for the persistence when the unit // shuts down (SYSM_T_USER_APP_SHUTDOWN, SYSM_T_WRITE_PERSISTENCE). -// Not proven: what the M4 does after a positive answer (a clean shutdown by SystemManager, then the whole unit reset, -// is what is expected), which operation and address its answer carries, whether vmostd hands that answer to a second -// client like us, and why it would refuse (UDS 0x22 says "conditions not correct": whether that means a moving car -// is the M4's business, not read anywhere). Nothing of this has run in a car yet. +// Seen on a G20 (01/12, aa-supervisor --reboot over SSH, the car parked): the unit started again about one second +// after the request, before any answer reached us. So it is a hard reset, as after a BMW tester's coding, not a clean +// shutdown: the services are not stopped and the BMW persistence is not written then (the unit is made for it, a +// tester does it after every coding). Everything is synced to the flash just before the request, and each [Reboot] +// line as it is written: nothing left in the page cache survives the reset. Not seen yet: an answer of the M4, a +// refusal and why (UDS 0x22 says "conditions not correct": whether that means a moving car is the M4's business). // // So, after the request (restartHeadUnit): -// - accepted (51 01), or "response pending" (7F 11 78) without a final answer: the clean shutdown is left to run; +// - accepted (51 01), or "response pending" (7F 11 78) without a final answer: the M4's restart is left to come; // today's restart only if the unit still runs kCleanRestartWaitMs later; // - no answer within kEcuResetAnswerMs: ours may have been lost on the way while the M4 does restart; today's // restart kSilentM4WaitMs later; @@ -130,13 +132,13 @@ class RestartHost { // The way restartHeadUnit took. The host's legacyReboot ends it each time; on the car it returns only if that failed. enum class RestartWay { - kLegacyNow, // no clean restart to wait for: today's restart at once + kLegacyNow, // no restart of the M4 to wait for: today's restart at once kLegacyAfterSilence, // no answer: today's restart kSilentM4WaitMs later kLegacyAfterClean, // accepted or pending: today's restart only if the unit still runs kCleanRestartWaitMs later }; -// Waits delayMs (the iDrive menu says "restarting" meanwhile), asks the M4 for its clean restart, and then (top of -// this file) leaves it to the M4 or goes for today's restart. +// Waits delayMs (the iDrive menu says "restarting" meanwhile), asks the M4 for its restart, and then (top of this +// file) leaves it to the M4 or goes for today's restart. RestartWay restartHeadUnit(RestartHost& host, unsigned delayMs); // aa-supervisor --reboot, by hand over SSH (docs/MAINTENANCE.md), in update_car.cpp (the car only). Refused while an @@ -172,17 +174,21 @@ class EcuResetSession { // The [Reboot] lines of a restart. With a marker and a file: into that file (O_NOFOLLOW, ours, regular), as stdout // and stderr, only while the marker exists (the maintenance profile), opened at the first line; else on stdout as it -// is. close() flushes, fsyncs and puts /dev/null in its place: the file is never opened again. +// is. With a report too (the update's, update_install.hpp), each line is also added to it, whatever the profile: the +// update's report says how its restart went. Both are synced at each line (the M4's reset comes about a second after +// the request). close() flushes, fsyncs and puts /dev/null in its place: neither file is opened again. class RebootLog { public: - RebootLog(const char* maintenanceMarker, const char* logFile); + RebootLog(const char* maintenanceMarker, const char* logFile, const char* report = nullptr); void line(const char* text); void close(); private: const char* marker_; const char* file_; - bool tried_, redirected_, closed_; + const char* report_; + int reportFd_; + bool tried_, redirected_, reportTried_, closed_; }; } // namespace evo diff --git a/platform/update_car.cpp b/platform/update_car.cpp index 5bfd2b0..23baec0 100644 --- a/platform/update_car.cpp +++ b/platform/update_car.cpp @@ -49,7 +49,8 @@ std::string procMounts() { // The restart on the car (evo_reboot.hpp): the vMOST session, the [Reboot] lines, the clock, today's restart. class CarRestartHost : public RestartHost { public: - CarRestartHost(const char* maintenanceMarker, const char* logFile) : log_(maintenanceMarker, logFile) {} + CarRestartHost(const char* maintenanceMarker, const char* logFile, const char* report = nullptr) + : log_(maintenanceMarker, logFile, report) {} uint32_t nowMs() override { return monoMs(); } void sleepMs(unsigned ms) override { const uint32_t end = monoMs() + ms; @@ -65,7 +66,12 @@ class CarRestartHost : public RestartHost { nanosleep(&req, nullptr); } } - bool sendEcuReset() override { return session_.send(); } + // The M4 resets the unit about a second after the request (evo_reboot.hpp): what is written must be on the + // flash first. + bool sendEcuReset() override { + sync(); + return session_.send(); + } bool pump(unsigned ms, EcuResetWatch& watch) override { return session_.pump(ms, watch); } void endSession() override { session_.end(); } void log(const char* line) override { log_.line(line); } @@ -118,9 +124,9 @@ class CarUpdateHost : public UpdateHost { return static_cast(fs.f_bavail) * static_cast(fs.f_frsize); } // The unit restarts a few seconds later, from a child of its own: the iDrive app reads this program's result - // meanwhile. The child keeps this program's locks until the restart. It asks the M4 for its clean restart, and - // falls back on today's /sbin/reboot (evo_reboot.hpp); its [Reboot] lines go to the service's kept log in the - // maintenance profile only. + // meanwhile. The child keeps this program's locks until the restart. It asks the M4 for its restart, and falls + // back on today's /sbin/reboot (evo_reboot.hpp); its [Reboot] lines go to the update's report, and to the + // service's kept log in the maintenance profile. void restartUnit() override { const pid_t pid = fork(); if (pid == 0) { @@ -138,7 +144,7 @@ class CarUpdateHost : public UpdateHost { sigemptyset(&none); sigprocmask(SIG_SETMASK, &none, nullptr); signal(SIGPIPE, SIG_IGN); - CarRestartHost host(contract::kMaintenance, contract::kServiceLogKept); + CarRestartHost host(contract::kMaintenance, contract::kServiceLogKept, contract::kUpdateReport); restartHeadUnit(host, kRestartDelayS * 1000); _exit(127); // not even today's restart could start } @@ -218,9 +224,9 @@ int rebootByHand() { return 1; } printf( - "aa-supervisor --reboot: asking the unit's processor (Cortex-M4) for a clean restart, as a BMW diagnostic " - "tool does. Accepted: the unit shuts down by itself (the usual restart after %u s if it does not). No " - "answer: the usual restart (/sbin/reboot) after %u s. Refused or impossible: the usual restart now.\n", + "aa-supervisor --reboot: asking the unit's processor (Cortex-M4) to restart the unit, as a BMW diagnostic " + "tool does: the unit starts again about a second later. If it does not: the usual restart (/sbin/reboot) " + "after %u s once accepted, after %u s without an answer, now when refused or impossible.\n", kCleanRestartWaitMs / 1000, kSilentM4WaitMs / 1000); fflush(stdout); CarRestartHost host(nullptr, nullptr); // the lines on this terminal diff --git a/tests/test_evo_reboot.cpp b/tests/test_evo_reboot.cpp index e53d4b4..645d3e3 100644 --- a/tests/test_evo_reboot.cpp +++ b/tests/test_evo_reboot.cpp @@ -600,6 +600,36 @@ int main(int argc, char** argv) { CHECK(restoreStdio(savedOut, savedErr)); CHECK(access(target.c_str(), F_OK) != 0); } + { + // The update's report gets the restart's lines too, whatever the profile, after what the update wrote; never + // through a link, nothing after the close. + const std::string report = std::string(dir) + "/update-report.txt"; + const int rfd = open(report.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); + CHECK(rfd >= 0 && write(rfd, "result: installed\n", 18) == 18 && close(rfd) == 0); + unlink(marker.c_str()); // the production profile + { + evo::RebootLog log(marker.c_str(), kept.c_str(), report.c_str()); + log.line("asking the unit's processor"); + log.line("sent (0)"); + log.close(); + log.line("after the close"); + CHECK(restoreStdio(savedOut, savedErr)); + } + const std::string text = readAll(report); + CHECK(text.compare(0, 18, "result: installed\n") == 0); + CHECK(has(text, "] restart: asking the unit's processor\n") && has(text, "] restart: sent (0)\n")); + CHECK(!has(text, "after the close")); + unlink(link.c_str()); + CHECK(symlink(target.c_str(), link.c_str()) == 0); + { + evo::RebootLog log(marker.c_str(), kept.c_str(), link.c_str()); + log.line("into a link"); + log.close(); + CHECK(restoreStdio(savedOut, savedErr)); + } + CHECK(access(target.c_str(), F_OK) != 0); + unlink(report.c_str()); + } close(savedOut); close(savedErr); @@ -613,9 +643,10 @@ int main(int argc, char** argv) { rmdir(dir); puts( - "PASS reboot: request F4 63 11 01 on 0100.FD.04.C00; accepted or pending = clean restart waited 120 s, silent " + "PASS reboot: request F4 63 11 01 on 0100.FD.04.C00; accepted or pending = the M4's restart waited 120 s, " + "silent " "= 30 s, refused / vMOST error / not sent = usual restart at once; copies of FD.04 and FD.41; log in " - "maintenance only, closed before the wait; vmostd gone or a failed write: the connection let go once, nothing " - "deregistered"); + "maintenance only, the update's report always, closed before the wait; vmostd gone or a failed write: the " + "connection let go once, nothing deregistered"); return 0; } From 2bf86ada7a51491bffc7f8c05aa2ebb328f32478 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Tue, 1 Dec 2026 05:01:45 +0100 Subject: [PATCH 06/17] chore: version 0.13.0-rc.13 (#274) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Version candidate : 802.11n coupé sur le point d'accès de la voiture (#264), et redémarrage après une mise à jour par clé USB qui écrit tout sur la flash avant la remise à zéro de l'unité. VERSION, journal des versions fr/en, commandes d'installation, modèle de ticket. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- CHANGELOG.en.md | 10 +++++++++- CHANGELOG.md | 9 +++++++++ VERSION | 2 +- docs/INSTALLATION.en.md | 4 ++-- docs/INSTALLATION.md | 4 ++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e8e6206..60b7c63 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: label: Project version description: The release you installed, or the commit you built. From 0.13.0-rc.10, the title of the Help page in the Android Auto menu shows it. - placeholder: 0.13.0-rc.12 + placeholder: 0.13.0-rc.13 validations: required: true - type: input diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 0121745..2583e33 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -2,7 +2,7 @@ > [!IMPORTANT] > This is a translation of the authoritative [French changelog](CHANGELOG.md), based on -> [`v0.13.0-rc.12`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.12/CHANGELOG.md). +> [`v0.13.0-rc.13`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.13/CHANGELOG.md). > It may become outdated; consult the French changelog for the source of truth. All notable changes to this project. Format inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), @@ -13,6 +13,14 @@ QEMU with the car's libraries). ## [Unreleased] +## [0.13.0-rc.13] - 2026-12-01 · PC + +Release candidate: the car's access point no longer offers 802.11n, against the wireless stutter, and the +restart after an update from a USB stick writes everything to the flash before the unit's reset, which takes +about a second. Installs from a USB stick since 0.13.0-rc.10; the fast restart comes from the installed +version, so since 0.13.0-rc.11. Tested on PC and under QEMU; 802.11n off tried on an X1 F48 and on the +reference G20, the reset by `aa-supervisor --reboot` and after an update on the G20. + ### Fixed - Wireless: the car's access point no longer offers 802.11n (`ieee80211n=0`, set in hostapd's memory with U-APSD, before the same beacon rebuild). On an X1 F48, a decrypted capture taken during stalls showed phone frames acknowledged by the car and then lost inside it (26 % of the data segments), against 0.09 % without 802.11n ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). The setting holds for everything on the car's Wi-Fi and caps it at 54 Mbit/s. Tried in a car (X1 F48) in a personal build that contains this change: clear improvement in the first tests, no extended testing. diff --git a/CHANGELOG.md b/CHANGELOG.md index f7fce52..f69fd49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,15 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +## [0.13.0-rc.13] - 2026-12-01 · PC + +Version candidate : le point d'accès de la voiture n'offre plus le 802.11n, contre les saccades sans fil, et +le redémarrage après une mise à jour par clé USB écrit tout sur la flash avant la remise à zéro de l'unité, +qui prend environ une seconde. S'installe par clé USB depuis la 0.13.0-rc.10 ; le redémarrage rapide vient +de la version installée, donc depuis la 0.13.0-rc.11. Testée sur PC et sous QEMU ; le 802.11n coupé essayé +sur un X1 F48 et sur la G20 de référence, la remise à zéro par `aa-supervisor --reboot` et après une mise à +jour sur la G20. + ### Corrigé - Sans-fil : le point d'accès de la voiture n'offre plus le 802.11n (`ieee80211n=0`, réglé en mémoire de hostapd avec U-APSD, avant la même reconstruction de la balise). Sur une X1 F48, une capture déchiffrée pendant des saccades montrait des trames du téléphone acquittées par la voiture puis perdues à l'intérieur (26 % des segments de données), contre 0,09 % sans 802.11n ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Le réglage vaut pour tout le Wi-Fi de la voiture et limite son débit à 54 Mbit/s. Essayé en voiture (X1 F48) dans une version personnelle qui contient ce changement : amélioration nette aux premiers essais, pas d'essais prolongés. diff --git a/VERSION b/VERSION index 8166ccf..764f92a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.13.0-rc.12 +0.13.0-rc.13 diff --git a/docs/INSTALLATION.en.md b/docs/INSTALLATION.en.md index d6a4e5d..c160f6e 100644 --- a/docs/INSTALLATION.en.md +++ b/docs/INSTALLATION.en.md @@ -38,7 +38,7 @@ the one in its archive (in 0.10.0, the supervisor is called `evo-trial`, not `aa From the PC, in the archive's folder: ```sh -scp entrynav2-android-auto-0.13.0-rc.12-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.13-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -50,7 +50,7 @@ flash memory yet. Nothing is changed during this step. ```sh -V=0.13.0-rc.12 +V=0.13.0-rc.13 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index f613b31..89cda47 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -33,7 +33,7 @@ ancienne, suivre celle de l'archive (dans la 0.10.0, le superviseur s'appelle `e Depuis le PC, dans le dossier de l'archive : ```sh -scp entrynav2-android-auto-0.13.0-rc.12-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.13-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -45,7 +45,7 @@ encore écrit sur la mémoire flash. Rien n'est modifié pendant cette étape. ```sh -V=0.13.0-rc.12 +V=0.13.0-rc.13 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version From c18a72c5291058a87cbbc3f31aa22b30f1372aea Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:11:58 +0100 Subject: [PATCH 07/17] =?UTF-8?q?fix(bluetooth):=20reprendre=20l'emplaceme?= =?UTF-8?q?nt=205=20tenu=20par=20le=20t=C3=A9l=C3=A9phone=20(#277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sur une F45 (#203), le téléphone s'est connecté à l'emplacement Bluetooth 5 dans les 4 s qui ont suivi Arrêter, sur l'identifiant générique remis par la restauration. Le superviseur refusait alors chaque démarrage toutes les 5 s, jusqu'à l'abandon au bout de 2 minutes. BMW ne règle pas cet emplacement (evo_config.xml : 0 et 1). Un appareil connecté au 5 sur l'identifiant générique est maintenant coupé par la pile (BtApplDeviceDisconnectReq, comme la restauration le fait pour notre lien), et le démarrage prend l'emplacement dès qu'il est libre : le service y inscrit Android Auto environ 0,3 s plus tard, alors qu'un téléphone est revenu environ 1,7 s après une coupure demandée par la voiture (#275). Un lien sur un autre identifiant, ou un emplacement qui porte encore Android Auto, attend comme avant. Le contrôle de compatibilité le signale. --- CHANGELOG.en.md | 4 ++++ CHANGELOG.md | 4 ++++ docs/COMPATIBILITE.md | 7 ++++-- platform/spp_baseline.hpp | 15 ++++++++----- tests/test_supervisor.cpp | 46 +++++++++++++++++++++++++++++++++++---- tools/aa_supervisor.cpp | 39 ++++++++++++++++++++++++++++----- 6 files changed, 99 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 2583e33..0f956e6 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,6 +13,10 @@ QEMU with the car's libraries). ## [Unreleased] +### Fixed + +- Wireless: Start was refused every 5 seconds, until it gave up after 2 minutes, when a device stayed connected to Bluetooth slot 5 after a stop. On an F45 the phone connected to it within 4 seconds of Stop, and every start was refused ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). BMW does not use slot 5: when a device is connected to it on the generic UUID, the start now asks the Bluetooth stack to drop that link, as the stop does for ours, then takes the slot as soon as it is free. A link on another UUID, or a slot still carrying Android Auto, waits as before. The compatibility check reports it (`@warn|alps|SPP 5 held by a device on its generic pair`). Tested on PC. + ## [0.13.0-rc.13] - 2026-12-01 · PC Release candidate: the car's access point no longer offers 802.11n, against the wireless stutter, and the diff --git a/CHANGELOG.md b/CHANGELOG.md index f69fd49..10bf553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +### Corrigé + +- Sans-fil : Démarrer était refusé toutes les 5 secondes, jusqu'à l'abandon au bout de 2 minutes, quand un appareil restait connecté à l'emplacement Bluetooth 5 après un arrêt. Sur une F45, le téléphone s'y est connecté dans les 4 secondes qui ont suivi Arrêter, et chaque démarrage a été refusé ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). BMW ne se sert pas de l'emplacement 5 : quand un appareil y est connecté sur l'identifiant générique, le démarrage demande maintenant à la pile Bluetooth de couper ce lien, comme l'arrêt le fait pour le nôtre, puis prend l'emplacement dès qu'il est libre. Un lien sur un autre identifiant, ou un emplacement qui porte encore Android Auto, attend comme avant. Le contrôle de compatibilité le signale (`@warn|alps|SPP 5 held by a device on its generic pair`). Testé sur PC. + ## [0.13.0-rc.13] - 2026-12-01 · PC Version candidate : le point d'accès de la voiture n'offre plus le 802.11n, contre les saccades sans fil, et diff --git a/docs/COMPATIBILITE.md b/docs/COMPATIBILITE.md index 5284abd..9c09fe3 100644 --- a/docs/COMPATIBILITE.md +++ b/docs/COMPATIBILITE.md @@ -133,8 +133,11 @@ règle que deux : le 0, celui des BMW Apps, où se connecte l'appli My BMW, et l avant : My BMW ne trouve alors plus la voiture tant qu'Android Auto tourne. Le journal du superviseur dit lequel il a pris (`Android Auto takes SPP 5` ou `takes SPP 0`). Le contrôle regarde le même emplacement, choisi de la même façon (`@ok|alps|SPP 5` ou `SPP 0`) : My BMW connecté sur le 0 ne le rend plus douteux quand Android Auto prend le 5. Un -emplacement 5 encore connecté, ou qui porte encore Android Auto, sort en `@warn|alps|` : un démarrage attend qu'il se -libère. +emplacement 5 qui porte encore Android Auto, ou connecté sur un autre identifiant, sort en `@warn|alps|` : un +démarrage attend qu'il se libère. Un appareil connecté au 5 sur son identifiant générique (un téléphone qui s'y est +reconnecté juste après un arrêt, [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)) sort en +`@warn|alps|SPP 5 held by a device on its generic pair` : un démarrage demande à la pile Bluetooth de couper ce lien, +puis prend l'emplacement. Pour vérifier cet emplacement, Android Auto lit les tables de la pile en mémoire. Sur une autre voiture : diff --git a/platform/spp_baseline.hpp b/platform/spp_baseline.hpp index df5dd17..315fd2b 100644 --- a/platform/spp_baseline.hpp +++ b/platform/spp_baseline.hpp @@ -38,17 +38,22 @@ inline bool genericPair(const std::vector& payload) { return uuidPairHex(payload) == "011101011101"; } // What slot 5 offers, read before anything is changed. kSlotFree: started and idle like slot 0 is, still the generic -// pair. kSlotBusy: connected, or already carrying the Android Auto pair: this start is refused and tried again later, -// never moved to slot 0, which would advertise Android Auto twice. kSlotAbsent: unreadable, not started on this car, -// in another state, or holding another UUID: Android Auto stays on slot 0, as before. -enum SlotOffer { kSlotFree, kSlotBusy, kSlotAbsent }; +// pair. kSlotHeld: a device connected to its generic pair: a start asks the stack to drop that link, then takes the +// slot once it is idle (aa_supervisor.cpp, dropHeldLink). kSlotBusy: connected to another pair, or already carrying the +// Android Auto pair: this start is refused and tried again later, never moved to slot 0, which would advertise Android +// Auto twice. kSlotAbsent: unreadable, not started on this car, in another state, or holding another UUID: Android +// Auto stays on slot 0, as before. +enum SlotOffer { kSlotFree, kSlotHeld, kSlotBusy, kSlotAbsent }; inline SlotOffer spareSlotOffer(bool readable, const SppSlotSnapshot& slot, const std::vector& aaPair) { if (!readable || slot.state == 0) { return kSlotAbsent; } - if (slot.uuidPayload == aaPair || slot.transportUuidPayload == aaPair || slot.connected || slot.state == 2) { + if (slot.uuidPayload == aaPair || slot.transportUuidPayload == aaPair) { return kSlotBusy; } + if (slot.connected || slot.state == 2) { + return slot.uuidPayload == slot.transportUuidPayload && genericPair(slot.uuidPayload) ? kSlotHeld : kSlotBusy; + } if (!slot.idle() || slot.uuidPayload != slot.transportUuidPayload || !genericPair(slot.uuidPayload)) { return kSlotAbsent; } diff --git a/tests/test_supervisor.cpp b/tests/test_supervisor.cpp index ed9d995..cb3b7ab 100644 --- a/tests/test_supervisor.cpp +++ b/tests/test_supervisor.cpp @@ -20,7 +20,8 @@ int dbusAlpsUid = 1011; // the user D-Bus gives for org.alps.evolution (-1: n bool alpsUnderUid = true; // the Alps library is found among that user's processes std::vector openedUids; bool failUuid = false, failConfig = false, videoGone = true, liveLink = false, failRead = false; -int uuidStatus = 0; // non-zero: the stack's answer to the next UUID writes (4: not ready yet, #97) +bool refuseDisconnect = false; // the disconnection request cannot be sent +int uuidStatus = 0; // non-zero: the stack's answer to the next UUID writes (4: not ready yet, #97) bool flipKnown = true; // The phone of a lost session, as on the car: while our Android Auto UUID is on the slot, it reconnects kPhoneBackMs // after a disconnection, phoneReturns more times. lateWrites: results of the next UUID writes, which reach the stack @@ -158,6 +159,9 @@ int AlpsSppLink::registerUuidPayload(const std::vector& payload, int) { } bool AlpsSppLink::requestSppDisconnect() { assert(started == testSlot); + if (refuseDisconnect) { + return false; // the request could not be sent + } ++disconnects; simulated.state = 1; simulated.transportState = 0; @@ -467,7 +471,8 @@ static void phoneBackCases(const std::vector& generic) { liveLink = false; assert(chdir(cwd) == 0 && rmdir(dir) == 0); } -// Which slot a start takes: 5 while it is free, 0 where 5 is not available, none while 5 is in use. +// Which slot a start takes: 5 while it is free or only held on its generic pair, 0 where 5 is not available, none while +// 5 is in use. static void slotCases(const std::vector& bmw, const std::vector& generic) { const std::vector aa = aaPayload(); evo::SppSlotSnapshot s; @@ -479,11 +484,18 @@ static void slotCases(const std::vector& bmw, const std::vector& bmw, const std::vector(evo::kAaSlot)) && bt.requestSppDisconnect(); + if (asked && waitIdle(reader, evo::kAaSlot, slot, kIdleWaitMs) && + evo::spareSlotOffer(true, slot, aaPayload()) == evo::kSlotFree) { + ELOG("Supervisor", "preflight: SPP %u held by a device on its generic pair: dropped, idle after %u ms", + evo::kAaSlot, evo::monoMs() - begin); + return true; + } + ELOG("Supervisor", "preflight: SPP %u held by a device on its generic pair: %s; start refused for now", + evo::kAaSlot, asked ? "not idle after the drop" : "drop request not sent"); + return false; +} +// Slot 5 when BMW started it and nobody uses it (spp_baseline.hpp), slot 0 as before otherwise. Only reads, except +// for a link held on slot 5's generic pair, which is dropped (dropHeldLink). bool chooseSlot(evo::SppSnapshotReader& reader, unsigned& slotId, evo::SppSlotSnapshot& slot, std::vector& cfg) { evo::SppSlotSnapshot spare; @@ -379,7 +400,10 @@ bool chooseSlot(evo::SppSnapshotReader& reader, unsigned& slotId, evo::SppSlotSn evo::kAaSlot); return false; } - if (offer == evo::kSlotFree) { + if (offer == evo::kSlotHeld && !dropHeldLink(reader, spare)) { + return false; + } + if (offer == evo::kSlotFree || offer == evo::kSlotHeld) { // Its 0x6203 cannot be read through the stack (slotConfigurationReadable): BMW never sets it // (stack/etc/evo_config.xml sets slots 0 and 1), so its start value, 0, is saved and written back at the end. slotId = evo::kAaSlot; @@ -500,14 +524,19 @@ void compatBluetooth(evo::SppSnapshotReader& reader, bool usb) { "checked)"); return; } - const unsigned slotId = offer == evo::kSlotFree ? evo::kAaSlot : evo::kAaFallbackSlot; - if (offer != evo::kSlotFree && !reader.read(slotId, slot)) { + const bool onSpare = offer == evo::kSlotFree || offer == evo::kSlotHeld; + const unsigned slotId = onSpare ? evo::kAaSlot : evo::kAaFallbackSlot; + if (!onSpare && !reader.read(slotId, slot)) { bluetoothLine(usb, "block", "alps", reader.error()); return; } char where[16]; snprintf(where, sizeof(where), "SPP %u", slotId); - bluetoothLine(usb, slot.idle() ? "ok" : "warn", "alps", where); + std::string detail = where; + if (offer == evo::kSlotHeld) { + detail += " held by a device on its generic pair: a start asks Bluetooth to drop it"; + } + bluetoothLine(usb, slot.idle() ? "ok" : "warn", "alps", detail); bluetoothLine(usb, evo::baselineSupported(slot.uuidPayload) ? "ok" : "block", "uuid", hex(slot.uuidPayload)); // On slot 5 the stack answers slot 0's value (slotConfigurationReadable): the read shows that it answers. std::vector cfg; From 45fc8d4bf7d5b9015fa0bc863ea05f672d73c60f Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Tue, 1 Dec 2026 18:13:35 +0100 Subject: [PATCH 08/17] fix(journaux): trames brutes du toucher qui portent un doigt (#278) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le service écrit 12 trames brutes de l'écran tactile par séance. C'étaient les 12 premières reçues : sur une F45 (#266), toutes vides, avant le premier toucher, et le journal ne pouvait pas montrer pourquoi un glissement arrivait au téléphone comme un appui. En transfert vers Android Auto, ce sont maintenant les premières qui posent, bougent ou lèvent un doigt, ou qui ne sont pas comprises. En observation, rien ne change. Même nombre de lignes. --- CHANGELOG.en.md | 4 ++++ CHANGELOG.md | 4 ++++ platform/evo_touch.cpp | 15 ++++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 0f956e6..e1a2951 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,6 +13,10 @@ QEMU with the car's libraries). ## [Unreleased] +### Changed + +- Service log: the 12 raw touchscreen frames written each session are now the first ones that press, move or lift a finger, instead of the very first received. On an F45 those were all empty, and the log could not show why a swipe reached the phone as a tap ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Same number of lines. Tested on PC. + ### Fixed - Wireless: Start was refused every 5 seconds, until it gave up after 2 minutes, when a device stayed connected to Bluetooth slot 5 after a stop. On an F45 the phone connected to it within 4 seconds of Stop, and every start was refused ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). BMW does not use slot 5: when a device is connected to it on the generic UUID, the start now asks the Bluetooth stack to drop that link, as the stop does for ours, then takes the slot as soon as it is free. A link on another UUID, or a slot still carrying Android Auto, waits as before. The compatibility check reports it (`@warn|alps|SPP 5 held by a device on its generic pair`). Tested on PC. diff --git a/CHANGELOG.md b/CHANGELOG.md index 10bf553..687bfa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +### Modifié + +- Journal du service : les 12 trames brutes de l'écran tactile écrites à chaque séance sont maintenant les premières qui posent, bougent ou lèvent un doigt, au lieu des toutes premières reçues. Sur une F45, ces dernières étaient toutes vides et le journal ne montrait pas pourquoi un glissement arrivait au téléphone comme un appui ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Même nombre de lignes. Testé sur PC. + ### Corrigé - Sans-fil : Démarrer était refusé toutes les 5 secondes, jusqu'à l'abandon au bout de 2 minutes, quand un appareil restait connecté à l'emplacement Bluetooth 5 après un arrêt. Sur une F45, le téléphone s'y est connecté dans les 4 secondes qui ont suivi Arrêter, et chaque démarrage a été refusé ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). BMW ne se sert pas de l'emplacement 5 : quand un appareil y est connecté sur l'identifiant générique, le démarrage demande maintenant à la pile Bluetooth de couper ce lien, comme l'arrêt le fait pour le nôtre, puis prend l'emplacement dès qu'il est libre. Un lien sur un autre identifiant, ou un emplacement qui porte encore Android Auto, attend comme avant. Le contrôle de compatibilité le signale (`@warn|alps|SPP 5 held by a device on its generic pair`). Testé sur PC. diff --git a/platform/evo_touch.cpp b/platform/evo_touch.cpp index 41884de..70ad8d4 100644 --- a/platform/evo_touch.cpp +++ b/platform/evo_touch.cpp @@ -528,8 +528,16 @@ void EvoTouch::handle(const UdpView& u, int ifindex, uint32_t now) { } ++touchPdus_; lastFrameMs_ = now; - const unsigned rawMax = mode_ == INPUT_OBSERVE ? 80 : 12; - if (rawLogged_ < rawMax) { + aa::TouchEventOut ev[16]; + tracker_.setPictureStarted(pictureStarted_); + const int n = tracker_.feed(u.data, u.len, ev, 16); + // Datagrams logged raw: observing, the first ones; forwarding, the first ones that pressed, moved or lifted a + // finger, or were not understood. The first frames of a session can all be empty (#266: twelve without a finger + // before the first touch), which left nothing to read when a swipe arrived as a tap. A message split over several + // datagrams shows its last one only. + const bool observe = mode_ == INPUT_OBSERVE; + const unsigned rawMax = observe ? 80 : 12; + if (rawLogged_ < rawMax && (observe || n != 0)) { ++rawLogged_; char hex[3 * 128 + 1]; size_t o = 0; @@ -539,9 +547,6 @@ void EvoTouch::handle(const UdpView& u, int ifindex, uint32_t now) { hex[o] = 0; ELOG("Touch", "raw %u B: %s", (unsigned)u.len, hex); } - aa::TouchEventOut ev[16]; - tracker_.setPictureStarted(pictureStarted_); - const int n = tracker_.feed(u.data, u.len, ev, 16); if (n < 0 && rawLogged_ <= rawMax) { ELOG("Touch", "touch frame incomplete or not recognised"); } From 19411f09f13a68e6f6e69a95d2963350712c29e4 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Tue, 1 Dec 2026 04:39:06 +0100 Subject: [PATCH 09/17] =?UTF-8?q?fix(bluetooth):=20redemander=20appels=20e?= =?UTF-8?q?t=20son=20au=20retour=20du=20t=C3=A9l=C3=A9phone=20(#279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bluetooth coupé puis rallumé sur le téléphone pendant Android Auto (G20, 01/12), deux essais : - appels et son fermés ensemble par le téléphone (raison 2), essais de la voiture en échec (EVTRES_OPERATION_FAIL) pendant son absence, le son revenu seul 79 s après, les appels jamais ; - son fermé par le téléphone, appels tombés seuls 0,2 s après (raison 3) : appels revenus à 15 s, son à 114 s, et d'ici là la voiture refusait tous les liens série du téléphone (son lien Android Auto compris) et l'iDrive le disait non connecté ; les liens s'ouvrent dans la seconde qui suit le retour du son (de même sur une MINI F56 et un X1 F48). Appels et son qui tombent à moins de 2 s d'écart sont une seule coupure de la liaison : si l'un est tombé seul, les deux sont redemandés comme après une coupure ; si le téléphone a fermé les deux, rien pendant son absence, puis ce qui manque est redemandé 15 s après son retour (une connexion de lui qui réussit). Un seul des deux fermé par le téléphone (réglage pour la voiture) reste tel quel. Tests sur les chronologies des relevés, et banc D-Bus. --- CHANGELOG.en.md | 1 + CHANGELOG.md | 1 + docs/ARCHITECTURE.md | 4 +- platform/alps_spp.cpp | 33 ++++-- platform/phone_audio_recall.hpp | 181 ++++++++++++++++++++++++------ tests/test_alps_spp.cpp | 24 +++- tests/test_phone_audio_recall.cpp | 93 ++++++++++++++- 7 files changed, 293 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index e1a2951..05fdee5 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -20,6 +20,7 @@ QEMU with the car's libraries). ### Fixed - Wireless: Start was refused every 5 seconds, until it gave up after 2 minutes, when a device stayed connected to Bluetooth slot 5 after a stop. On an F45 the phone connected to it within 4 seconds of Stop, and every start was refused ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). BMW does not use slot 5: when a device is connected to it on the generic UUID, the start now asks the Bluetooth stack to drop that link, as the stop does for ours, then takes the slot as soon as it is free. A link on another UUID, or a slot still carrying Android Auto, waits as before. The compatibility check reports it (`@warn|alps|SPP 5 held by a device on its generic pair`). Tested on PC. +- Wireless: Bluetooth turned off then on again on the phone during Android Auto, the calls and audio did not always come back (G20: the audio back by itself 79 s later, the calls never; the car's tries failed). When the phone closes calls and audio together (its Bluetooth off), nothing is asked while it is away; as soon as it is back on Bluetooth (the audio, or its Android Auto link), what is still missing is asked of the Bluetooth stack 15 s later, then as after a drop. When one of them is closed by the phone and the other drops on its own within 2 s, the phone's link went: both are asked for again as after a drop. It matters most for the audio: until it is back, the car refuses the phone's Android Auto link and iDrive shows the phone as not connected (114 s on the G20). Only one of them closed by the phone (a phone setting for the car) is left as it is. Tested on PC. ## [0.13.0-rc.13] - 2026-12-01 · PC diff --git a/CHANGELOG.md b/CHANGELOG.md index 687bfa5..12f62da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ QEMU avec les bibliothèques de la voiture). ### Corrigé - Sans-fil : Démarrer était refusé toutes les 5 secondes, jusqu'à l'abandon au bout de 2 minutes, quand un appareil restait connecté à l'emplacement Bluetooth 5 après un arrêt. Sur une F45, le téléphone s'y est connecté dans les 4 secondes qui ont suivi Arrêter, et chaque démarrage a été refusé ([#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). BMW ne se sert pas de l'emplacement 5 : quand un appareil y est connecté sur l'identifiant générique, le démarrage demande maintenant à la pile Bluetooth de couper ce lien, comme l'arrêt le fait pour le nôtre, puis prend l'emplacement dès qu'il est libre. Un lien sur un autre identifiant, ou un emplacement qui porte encore Android Auto, attend comme avant. Le contrôle de compatibilité le signale (`@warn|alps|SPP 5 held by a device on its generic pair`). Testé sur PC. +- Sans-fil : Bluetooth coupé puis rallumé sur le téléphone pendant Android Auto, les appels et le son ne revenaient pas toujours (G20 : le son revenu seul 79 s après, les appels jamais ; les essais de la voiture échouaient). Quand le téléphone ferme appels et son ensemble (son Bluetooth coupé), rien n'est demandé pendant son absence ; dès qu'il revient en Bluetooth (le son, ou son lien Android Auto), ce qui manque encore est redemandé à la pile Bluetooth 15 s plus tard, puis comme après une coupure. Quand l'un des deux est fermé par le téléphone et que l'autre tombe tout seul dans les 2 s, c'est la liaison du téléphone qui est partie : les deux sont redemandés comme après une coupure. Ça compte surtout pour le son : tant qu'il n'est pas revenu, la voiture refuse le lien Android Auto du téléphone et l'iDrive le dit non connecté (114 s sur la G20). Un seul des deux fermé par le téléphone (réglage du téléphone pour la voiture) reste tel quel. Testé sur PC. ## [0.13.0-rc.13] - 2026-12-01 · PC diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0138e64..00631d3 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -79,7 +79,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `ap_uapsd.hpp` | Point d'accès de la voiture sans U-APSD ni 802.11n pour le téléphone qui le rejoint (réglage en mémoire de hostapd, balise reconstruite une fois par démarrage du point d'accès, appareils déjà connectés compris, et de nouveau si un appareil est en 802.11n quand le téléphone se connecte) | | `wifi_link` | Qualité de la liaison Wi-Fi avec le téléphone, lue dans le noyau pour les journaux : entrée du téléphone (nl80211), redémarrages de la puce WL18xx comptés par son pilote (debugfs, lus sur un fil à part, jamais `fw_stats`), TCP, et l'état du lien Bluetooth des BMW Apps (testé sur PC) | | `alps_spp`, `evo_spp_snapshot` | Pile Bluetooth de la voiture : commandes, et lecture de son état en mémoire | -| `phone_audio_recall.hpp` | Appels et son du téléphone en Bluetooth redemandés à la pile pendant une séance sans fil quand ils sont tombés d'eux-mêmes (15 s après, toutes les 30 s, toutes les 2 minutes après 5 minutes) ; rien hors séance, ni quand la voiture ou le téléphone les ont coupés (testé sur PC) | +| `phone_audio_recall.hpp` | Appels et son du téléphone en Bluetooth redemandés à la pile pendant une séance sans fil quand ils sont tombés d'eux-mêmes (15 s après, toutes les 30 s, toutes les 2 minutes après 5 minutes), ou au retour du téléphone dont le Bluetooth a été coupé ; rien hors séance, ni pour un seul des deux fermé par le téléphone ou une coupure voulue par la voiture (testé sur PC) | | `evo_elf.hpp` | Symboles exportés par une bibliothèque de la voiture, lus dans son fichier | | `evo_control`, `control_address.hpp` | Commandes de l'appli vers le service, par un socket Unix au nom abstrait (ni fichier ni port réseau) | | `kombi_nav` | Service de guidage vers le compteur et la tête haute : fils, réglage `kombi-off`, annulation d'urgence | @@ -138,7 +138,7 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `tests/test_wifi_link.cpp` | Qualité du Wi-Fi : messages du noyau, redémarrages de la puce et leur fil de lecture, ligne de journal, connexion rendue en fin de session | | `tests/test_pending_restart.cpp` | Redémarrage d'Android Auto quand la case du câble USB change en marche | | `tests/test_guard_file.cpp` | Garde-fous : démarrages d'autres jours ignorés, boucle de plantages, réveils de nuit d'une voiture garée, iDrive relancé dans un même démarrage, anciennes lignes, date qui recule, ligne coupée, fichier remplacé d'un coup | -| `tests/test_phone_audio_recall.cpp` | Appels et son du téléphone redemandés, sur les chronologies de vrais journaux : téléphone dans la voiture, conducteur sorti 3 minutes, voiture qui les rebranche seule, coupure choisie, hors séance, téléphone revenu à portée, horloge qui reboucle | +| `tests/test_phone_audio_recall.cpp` | Appels et son du téléphone redemandés, sur les chronologies de vrais journaux : téléphone dans la voiture, conducteur sorti 3 minutes, voiture qui les rebranche seule, Bluetooth du téléphone coupé puis rallumé, coupure choisie, hors séance, téléphone revenu à portée, horloge qui reboucle | | `tests/test_hold_machine.cpp` | Page vide de l'iDrive : ouverture, démarrage automatique, fenêtres, modes, appels, touches | | `tests/test_media_recall.cpp` | Double appui sur MEDIA : geste lu par le vrai décodeur, conditions, demande à usage unique | | `tests/test_aa_frame.cpp`, `tests/test_aa_messages.cpp`, `tests/test_tcp_server.cpp` | Trames hostiles, messages construits, écoute TCP | diff --git a/platform/alps_spp.cpp b/platform/alps_spp.cpp index 267cc41..97a6c91 100644 --- a/platform/alps_spp.cpp +++ b/platform/alps_spp.cpp @@ -362,14 +362,31 @@ struct AlpsSppLink::Impl { } if (!monitor && phoneKnown && !memcmp(phone, addr, sizeof(phone))) { const uint32_t now = monoMs(); - if (!connecting && recall.disconnected(function, reason, now)) { - ELOG("PhoneAudio", - "phone's %s: dropped on its own (reason %u) while Android Auto runs; asked for again in %u s " - "unless the car or the phone connect it first", - PhoneAudioRecall::name(function), reason, PhoneAudioRecall::kFirstMs / 1000); - } else if (connecting && recall.connected(function, (status & 0x7f) == 0, now)) { - ELOG("PhoneAudio", "phone's %s: connected again, %u s after the drop", - PhoneAudioRecall::name(function), recall.sinceDrop(now) / 1000); + switch (connecting ? recall.connected(function, (status & 0x7f) == 0, now) + : recall.disconnected(function, reason, now)) { + case PhoneAudioRecall::kAskLater: + ELOG("PhoneAudio", + "phone's %s: dropped (reason %u) while Android Auto runs; asked for again %u s after " + "the drop unless the car or the phone connect it first", + PhoneAudioRecall::name(recall.missing()), reason, PhoneAudioRecall::kFirstMs / 1000); + break; + case PhoneAudioRecall::kWaitPhone: + ELOG("PhoneAudio", + "phone's calls and audio: closed together by the phone (its Bluetooth turned off?) while " + "Android Auto runs; asked for again once it is back on Bluetooth"); + break; + case PhoneAudioRecall::kBack: + ELOG("PhoneAudio", "phone's %s: connected again, %u s after it dropped", + PhoneAudioRecall::name(function), recall.backAfter() / 1000); + break; + case PhoneAudioRecall::kPhoneBack: + ELOG("PhoneAudio", + "phone back on Bluetooth: its %s asked for again in %u s unless the car or the phone " + "connect it first", + PhoneAudioRecall::name(recall.missing()), PhoneAudioRecall::kFirstMs / 1000); + break; + case PhoneAudioRecall::kNothing: + break; } } if (!ours) { diff --git a/platform/phone_audio_recall.hpp b/platform/phone_audio_recall.hpp index 8cd3352..70403dd 100644 --- a/platform/phone_audio_recall.hpp +++ b/platform/phone_audio_recall.hpp @@ -17,9 +17,20 @@ // then every 30 s for 5 minutes, every 2 minutes after that. Calls and audio in turn while both are missing; once one // is back, the other gets 15 s to follow by itself. The phone showing up on Bluetooth after 30 s without a sign of it // (a connection of anything else, its Android Auto link for instance) brings the next request forward to 3 s, 10 s -// after the previous one at the soonest. A request that fails is no sign of the phone. A drop the car or the phone -// chose (reason 1 or 2: Bluetooth turned off on the phone, another phone picked in the iDrive) is left alone, as is -// everything outside a wireless session: what the car does then is unchanged. +// after the previous one at the soonest. A request that fails is no sign of the phone. +// +// Bluetooth turned off on the phone drops calls and audio together, within a few tenths of a second: both with reason 2 +// (the phone closed them), or one with 2 and the other on its own (3). Turned on again, the phone does not always +// connect them back. On the G20 (01/12): once the audio came back by itself 79 s later and the calls never; once the +// calls came back at 15 s and the audio only at 114 s, and until then the car refused every serial link of the phone +// (its Android Auto link included, EVTRES_OPERATION_FAIL every few seconds) and iDrive showed it as not connected; the +// links opened within a second of the audio (the same on a MINI F56 and an X1 F48). So calls and audio that drop within +// 2 s of each other are one drop of the phone's link: when one of them dropped on its own, both are asked for again as +// above; when the phone closed both, nothing is asked while it is away, and once it is back on Bluetooth (any +// connection of it that succeeds: the audio, its Android Auto link) what is still missing is asked for 15 s later, as +// after a drop. One of them alone closed by the phone (a profile turned off for the car in its settings), or a drop +// the car chose (reason 1: another phone picked in the iDrive), is left alone, as is everything outside a wireless +// session: what the car does then is unchanged. // // Pure: the requests are sent by the caller (platform/alps_spp.cpp). tests/test_phone_audio_recall.cpp. #ifndef ENTRY_AAD_PLATFORM_PHONE_AUDIO_RECALL_HPP @@ -41,62 +52,99 @@ class PhoneAudioRecall { static const uint32_t kSlowMs = 120000; static const uint32_t kQuietMs = 30000; // no sign of the phone for that long, then one: it is back static const uint32_t kSoonMs = 3000; - static const uint32_t kGapMs = 10000; // between two requests, at the least + static const uint32_t kGapMs = 10000; // between two requests, at the least + static const uint32_t kTogetherMs = 2000; // calls and audio closed by the phone that close: its Bluetooth went off + + // What a report of the stack changed (kNothing is 0: false). + enum Event { + kNothing = 0, + kAskLater, // dropped on its own: asked for again later + kWaitPhone, // calls and audio turned off on the phone: asked for again once it is back + kBack, // a missing function connected again + kPhoneBack, // the phone back on Bluetooth after it was turned off: what is still missing asked for later + }; PhoneAudioRecall() - : running_(false), lost_(0), last_(0), lostAt_(0), next_(0), askedAt_(0), seenAt_(0), asked_(0) {} + : running_(false), + awayBoth_(false), + lost_(0), + last_(0), + away_(0), + lostAt_(0), + next_(0), + askedAt_(0), + seenAt_(0), + awayAt_(0), + backAfter_(0), + asked_(0) { + dropAt_[0] = dropAt_[1] = 0; + dropKnown_[0] = dropKnown_[1] = false; + } // Whether a wireless session runs, told on every turn of the wireless loop. One that ends forgets what dropped. void session(bool running) { running_ = running; if (!running) { - lost_ = 0; + lost_ = away_ = 0; + awayBoth_ = false; + dropKnown_[0] = dropKnown_[1] = false; } } - // The stack reports a disconnection of the phone. True when it is one to ask for again. - bool disconnected(uint64_t function, uint8_t reason, uint32_t now) { + // The stack reports a disconnection of the phone. + Event disconnected(uint64_t function, uint8_t reason, uint32_t now) { const uint64_t audio = function & (kCalls | kAudio); if (!running_) { - return false; + return kNothing; } if (!audio) { seen(now); - return false; + return kNothing; } - if (reason != kException && reason != kLinkLoss) { - lost_ &= ~audio; // the car or the phone chose it - return false; - } - if (!lost_) { - lostAt_ = now; - next_ = now + kFirstMs; - asked_ = 0; + Event result = kNothing; + for (uint64_t f = kCalls; f <= kAudio; f <<= 1) { + if (audio & f) { + const Event e = dropOne(f, reason, now); + result = e != kNothing ? e : result; + } } - lost_ |= audio; - seenAt_ = now; - return true; + return result; } - // The stack reports a connection of the phone (ok: connected, otherwise an attempt that failed). True when it - // brings back a function that had dropped. - bool connected(uint64_t function, bool ok, uint32_t now) { + // The stack reports a connection of the phone (ok: connected, otherwise an attempt that failed). + Event connected(uint64_t function, bool ok, uint32_t now) { + if (function & away_) { + if (!ok) { + return kNothing; // the car's tries while the phone's Bluetooth is off + } + away_ &= ~function; + backAfter_ = now - awayAt_; + if (awayBoth_ && away_) { + return phoneBack(now); + } + awayBoth_ = awayBoth_ && away_; + return kBack; + } + if (awayBoth_ && ok) { + return phoneBack(now); + } if (!lost_) { - return false; + return kNothing; } if (function & lost_) { if (!ok) { - return false; // a request that failed, ours or the car's + return kNothing; // a request that failed, ours or the car's } lost_ &= ~function; seenAt_ = now; + backAfter_ = now - lostAt_; if (lost_) { next_ = now + kFirstMs; // the other one often follows by itself } - return true; + return kBack; } seen(now); - return false; + return kNothing; } // The function to ask the stack to connect now, 0 for none. Counted as asked. @@ -113,9 +161,11 @@ class PhoneAudioRecall { return function; } - uint64_t missing() const { return lost_; } + // Missing: dropped on its own, or turned off on the phone with the other one (asked for once it is back). + uint64_t missing() const { return lost_ | (awayBoth_ ? away_ : 0); } unsigned requests() const { return asked_; } uint32_t sinceDrop(uint32_t now) const { return now - lostAt_; } + uint32_t backAfter() const { return backAfter_; } // the last function back (kBack): ms since it dropped static const char* name(uint64_t function) { return function == kCalls ? "calls (hands-free)" : function == kAudio ? "audio (streaming)" : "calls and audio"; @@ -124,6 +174,71 @@ class PhoneAudioRecall { private: static bool reached(uint32_t now, uint32_t at) { return static_cast(now - at) >= 0; } + // One function dropped (see disconnected), the other one's last drop at hand. + Event dropOne(uint64_t f, uint8_t reason, uint32_t now) { + const bool byPhone = reason == kByPhone, onItsOwn = reason == kException || reason == kLinkLoss; + if (!byPhone && !onItsOwn) { + lost_ &= ~f; // the car chose it + away_ &= ~f; + return kNothing; + } + const int i = f == kCalls ? 0 : 1, o = 1 - i; + const uint64_t other = f == kCalls ? kAudio : kCalls; + const bool together = dropKnown_[o] && static_cast(now - dropAt_[o]) <= int32_t(kTogetherMs) && + ((lost_ | away_) & other); + dropAt_[i] = now; + dropKnown_[i] = true; + if (onItsOwn || (together && (lost_ & other))) { + // Dropped on its own, or closed by the phone as the other one dropped on its own: the phone's link went. + if (together && (away_ & other)) { + away_ &= ~other; + lose(other, dropAt_[o]); + } + away_ &= ~f; + lose(f, now); + return kAskLater; + } + lost_ &= ~f; + if (!away_) { + awayAt_ = now; + awayBoth_ = false; + } + away_ |= f; + if (together && !awayBoth_) { + awayBoth_ = true; // closed by the phone with the other one: its Bluetooth went off + return kWaitPhone; + } + return kNothing; + } + + // Missing since at: asked for again later (the first of a drop sets the wait). + void lose(uint64_t f, uint32_t at) { + if (!lost_) { + lostAt_ = at; + next_ = at + kFirstMs; + asked_ = 0; + } + lost_ |= f; + seenAt_ = at; + } + + // The phone back on Bluetooth after calls and audio were turned off on it: what is still missing is asked for as + // after a drop, the car and the phone given 15 s first. + Event phoneBack(uint32_t now) { + if (!lost_) { + lostAt_ = awayAt_; + asked_ = 0; + next_ = now + kFirstMs; + } else if (reached(next_, now + kFirstMs)) { + next_ = now + kFirstMs; + } + lost_ |= away_; + away_ = 0; + awayBoth_ = false; + seenAt_ = now; + return kPhoneBack; + } + // Something of the phone on Bluetooth while a function is missing: after a quiet spell, it is back within reach. void seen(uint32_t now) { if (!lost_) { @@ -143,10 +258,12 @@ class PhoneAudioRecall { } } - bool running_; - uint64_t lost_, last_; - uint32_t lostAt_, next_, askedAt_, seenAt_; + bool running_, awayBoth_; + uint64_t lost_, last_, away_; + uint32_t lostAt_, next_, askedAt_, seenAt_, awayAt_, backAfter_; unsigned asked_; + uint32_t dropAt_[2]; // the last drop of the calls [0] and of the audio [1], by the phone or on its own + bool dropKnown_[2]; }; } // namespace evo diff --git a/tests/test_alps_spp.cpp b/tests/test_alps_spp.cpp index 1e4782c..cda177f 100644 --- a/tests/test_alps_spp.cpp +++ b/tests/test_alps_spp.cpp @@ -550,7 +550,6 @@ int main() { link.keepPhoneAudio(true, t0); fake.device(false, 0, 2, 0, 3); // calls: exception, the phone left fake.device(false, 0, 4, 0, 4, other); // another device's audio - fake.device(false, 0, 4, 0, 2); // the phone's audio, turned off on the phone sleepMs(50); link.keepPhoneAudio(true, t0 + 14000); sleepMs(30); @@ -588,6 +587,29 @@ int main() { link.keepPhoneAudio(true, t0 + 90000); sleepMs(30); CHECK(fake.connectRequests == 2); + // Bluetooth turned off on the phone (calls and audio closed together by it), then on again: nothing asked + // while it is away, the car's own failed try is no sign; the audio comes back by itself, the calls are asked + // for 15 s later. + t0 = evo::monoMs(); + fake.device(false, 0, 4, 0, 2); + fake.device(false, 0, 2, 0, 2); + fake.device(true, 0, 2, 4); + sleepMs(50); + link.keepPhoneAudio(true, t0 + 60000); + sleepMs(30); + CHECK(fake.connectRequests == 2); + fake.device(true, 0, 4); + sleepMs(50); + const uint32_t back = evo::monoMs(); + link.keepPhoneAudio(true, back + 14000); + sleepMs(30); + CHECK(fake.connectRequests == 2); + link.keepPhoneAudio(true, back + 16000); + CHECK(fake.awaitCount(fake.connectRequests, 3)); + { + std::lock_guard lock(fake.mu); + CHECK(fake.connected.size() == 3 && fake.connected[2] == 2); + } link.closeLink(); } { diff --git a/tests/test_phone_audio_recall.cpp b/tests/test_phone_audio_recall.cpp index 858e8d3..f86df74 100644 --- a/tests/test_phone_audio_recall.cpp +++ b/tests/test_phone_audio_recall.cpp @@ -103,7 +103,84 @@ void carReconnectsByItself() { puts("PASS what the car connects again by itself is not asked for"); } -// A drop the car or the phone chose: Bluetooth turned off on the phone (reason 2), another phone picked (reason 1). +// Bluetooth turned off on the phone, then on again (G20, service log of 01/12): calls and audio closed by the phone +// 50 ms apart; the car's own tries fail while it is off (EVTRES_OPERATION_FAIL = 4); turned on, the audio comes back +// by itself 79 s later, the calls do not (one more failed try at 445 s). The calls are asked for 15 s after the audio +// came back. +void phoneBluetoothOffThenOn() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(357.546)) == PhoneAudioRecall::kNothing); + CHECK(r.disconnected(kCalls, PhoneAudioRecall::kByPhone, ms(357.596)) == PhoneAudioRecall::kWaitPhone); + CHECK(r.missing() == (kCalls | kAudio)); + CHECK(r.connected(kCalls, false, ms(364.853)) == PhoneAudioRecall::kNothing); + CHECK(r.connected(kAudio, false, ms(365.063)) == PhoneAudioRecall::kNothing); + CHECK(r.connected(kPhonebook, false, ms(370)) == PhoneAudioRecall::kNothing); // a car's try that fails: no sign + uint32_t at = 0; + CHECK(firstDue(r, ms(358), ms(436), &at) == 0); // nothing asked while the phone is away + CHECK(r.connected(kAudio, true, ms(436.319)) == PhoneAudioRecall::kPhoneBack); + CHECK(r.missing() == kCalls && r.backAfter() == ms(436.319) - ms(357.546)); + CHECK(r.connected(kCalls, false, ms(445.142)) == PhoneAudioRecall::kNothing); + CHECK(firstDue(r, ms(436.5), ms(451.25), &at) == 0); + CHECK(firstDue(r, ms(451.5), ms(452), &at) == kCalls && at == ms(451.5)); + CHECK(r.connected(kCalls, true, ms(453)) == PhoneAudioRecall::kBack && r.missing() == 0); + CHECK(r.backAfter() == ms(453) - ms(357.546)); + + // On again, the phone connects both by itself: nothing is asked. + PhoneAudioRecall q; + q.session(true); + CHECK(q.disconnected(kCalls, PhoneAudioRecall::kByPhone, ms(10)) == PhoneAudioRecall::kNothing); + CHECK(q.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(10.04)) == PhoneAudioRecall::kWaitPhone); + CHECK(q.connected(kSpp, true, ms(60)) == PhoneAudioRecall::kPhoneBack); // its Android Auto link first + CHECK(q.connected(kCalls, true, ms(62)) == PhoneAudioRecall::kBack); + CHECK(q.connected(kAudio, true, ms(70)) == PhoneAudioRecall::kBack && q.missing() == 0); + CHECK(firstDue(q, ms(60), ms(300), &at) == 0); + + // The session ends while the phone is away: forgotten. + PhoneAudioRecall s; + s.session(true); + CHECK(s.disconnected(kCalls, PhoneAudioRecall::kByPhone, ms(0)) == PhoneAudioRecall::kNothing); + CHECK(s.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(0.1)) == PhoneAudioRecall::kWaitPhone); + s.session(false); + s.session(true); + CHECK(s.missing() == 0 && s.connected(kSpp, true, ms(30)) == PhoneAudioRecall::kNothing); + CHECK(firstDue(s, ms(30), ms(200), &at) == 0); + puts("PASS Bluetooth off then on on the phone: what is still missing is asked for 15 s after it is back"); +} + +// Bluetooth off then on once more (G20, service log of 01/12, 91 s): the audio closed by the phone, the calls dropped +// on their own 0.2 s later. The calls came back by themselves at 106 s; the audio, which the car needed before it +// took any serial link of the phone, only at 206 s. Both are one drop now: the audio is asked for 15 s after the calls +// came back, then every 30 s. +void audioClosedCallsDropped() { + PhoneAudioRecall r; + r.session(true); + CHECK(r.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(91.358)) == PhoneAudioRecall::kNothing); + CHECK(!r.disconnected(kSpp, kException, ms(91.552))); + CHECK(r.disconnected(kCalls, kException, ms(91.557)) == PhoneAudioRecall::kAskLater); + CHECK(r.missing() == (kCalls | kAudio)); + CHECK(r.connected(kSpp, false, ms(104.882)) == PhoneAudioRecall::kNothing); + CHECK(r.connected(kCalls, true, ms(106.183)) == PhoneAudioRecall::kBack && r.missing() == kAudio); + uint32_t at = 0; + CHECK(firstDue(r, ms(106.25), ms(121), &at) == 0); + CHECK(firstDue(r, ms(121.25), ms(122), &at) == kAudio && at == ms(121.25)); + CHECK(!r.connected(kAudio, false, ms(121.5))); // refused: asked again 30 s later + CHECK(firstDue(r, ms(121.5), ms(151), &at) == 0); + CHECK(firstDue(r, ms(151.25), ms(152), &at) == kAudio); + CHECK(r.connected(kAudio, true, ms(152.5)) == PhoneAudioRecall::kBack && r.missing() == 0); + + // The other way round (calls dropped on their own first, then the audio closed by the phone): the same. + PhoneAudioRecall q; + q.session(true); + CHECK(q.disconnected(kCalls, kLinkLoss, ms(10)) == PhoneAudioRecall::kAskLater); + CHECK(q.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(10.3)) == PhoneAudioRecall::kAskLater); + CHECK(q.missing() == (kCalls | kAudio)); + CHECK(firstDue(q, ms(10), ms(25), &at) == kCalls && at == ms(25)); + puts("PASS audio closed by the phone as the calls dropped on their own: both asked for again"); +} + +// One function alone closed by the phone (turned off for the car in its settings), or both but seconds apart, or a +// drop the car chose (reason 1: another phone picked): left alone. void chosenDrops() { PhoneAudioRecall r; r.session(true); @@ -112,6 +189,18 @@ void chosenDrops() { CHECK(!r.disconnected(kAudio, 0, ms(10)) && !r.disconnected(kAudio, 5, ms(10))); // unknown reasons uint32_t at = 0; CHECK(r.missing() == 0 && firstDue(r, ms(10), ms(600), &at) == 0); + CHECK(!r.connected(kSpp, true, ms(20)) && r.missing() == 0); // the phone in reach: still left alone + PhoneAudioRecall apart; + apart.session(true); + CHECK(!apart.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(10))); + CHECK( + !apart.disconnected(kCalls, PhoneAudioRecall::kByPhone, ms(15))); // 5 s later: two choices, not Bluetooth off + CHECK(!apart.connected(kSpp, true, ms(30)) && apart.missing() == 0 && firstDue(apart, ms(30), ms(300), &at) == 0); + // Closed by the phone, and the calls lost on their own 5 s later: the audio stays alone, the calls are asked for. + PhoneAudioRecall later; + later.session(true); + CHECK(!later.disconnected(kAudio, PhoneAudioRecall::kByPhone, ms(10))); + CHECK(later.disconnected(kCalls, kException, ms(15)) == PhoneAudioRecall::kAskLater && later.missing() == kCalls); // Lost first, then turned off on the phone while asked for: left alone from then on. CHECK(r.disconnected(kCalls, kLinkLoss, ms(1000))); CHECK(firstDue(r, ms(1000), ms(1015), &at) == kCalls); @@ -216,6 +305,8 @@ int main() { phoneInTheCar(); driverLeftTheCar(); carReconnectsByItself(); + phoneBluetoothOffThenOn(); + audioClosedCallsDropped(); chosenDrops(); outsideSession(); phoneShowsUp(); From 662d4b0b17f5f97ca0c60b7ef803e2bfd77125ad Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Tue, 1 Dec 2026 05:44:10 +0100 Subject: [PATCH 10/17] feat(textes): menu Android Auto avec ses accents (#280) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Les textes du menu restaient en ASCII par prudence depuis la 0.10.0 (« Demarrer », « Mettre a jour par cle USB »). Les applis de BMW rangent les leurs dans le même format (lignes id=texte d'un __Texts.zip) en UTF-8 avec les accents (fr-FR.txt « Démarrage du navigateur Internet échoué ») : make_db.py écrit maintenant les nôtres de même, en français, allemand, italien et polonais, avec les noms des langues. Seules les lettres accentuées latines des langues de l'iDrive passent (Latin-1, Latin étendu A, sans × ni ÷) : un caractère que ses polices pourraient ne pas avoir, ou un retour à la ligne, arrête la fabrication. Lignes de l'Aide toujours à 36 caractères au plus ; archive reproductible. --- CHANGELOG.en.md | 1 + CHANGELOG.md | 1 + hmiapp/make_db.py | 146 +++++++++++++++++++++++++--------------------- 3 files changed, 82 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 05fdee5..18bda86 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -16,6 +16,7 @@ QEMU with the car's libraries). ### Changed - Service log: the 12 raw touchscreen frames written each session are now the first ones that press, move or lift a finger, instead of the very first received. On an F45 those were all empty, and the log could not show why a swipe reached the phone as a tap ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Same number of lines. Tested on PC. +- The iDrive's Android Auto menu with its accents: "Démarrer Android Auto", "Mettre à jour par clé USB", "Échec : rien n'a été modifié", in French, German, Italian and Polish, and the language names ("Français", "Español", "Português"). The texts stayed ASCII out of caution since 0.10.0; they are now UTF-8, as BMW's own apps store theirs in the same format ("Démarrage du navigateur Internet échoué"). Only the accented Latin letters of the iDrive's languages are let through (Latin-1 and Latin Extended-A): a character its fonts might lack stops the build. Tested on PC. ### Fixed diff --git a/CHANGELOG.md b/CHANGELOG.md index 12f62da..64aacd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ QEMU avec les bibliothèques de la voiture). ### Modifié - Journal du service : les 12 trames brutes de l'écran tactile écrites à chaque séance sont maintenant les premières qui posent, bougent ou lèvent un doigt, au lieu des toutes premières reçues. Sur une F45, ces dernières étaient toutes vides et le journal ne montrait pas pourquoi un glissement arrivait au téléphone comme un appui ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Même nombre de lignes. Testé sur PC. +- Menu Android Auto de l'iDrive avec ses accents : « Démarrer Android Auto », « Mettre à jour par clé USB », « Échec : rien n'a été modifié », en français, allemand, italien et polonais, et les noms des langues (« Français », « Español », « Português »). Les textes restaient en ASCII par prudence depuis la 0.10.0 ; ils sont maintenant en UTF-8, comme ceux des applis de BMW rangés dans le même format (« Démarrage du navigateur Internet échoué »). Seules les lettres accentuées latines des langues de l'iDrive passent (Latin-1 et Latin étendu A) : un caractère que ses polices pourraient ne pas avoir arrête la fabrication. Testé sur PC. ### Corrigé diff --git a/hmiapp/make_db.py b/hmiapp/make_db.py index 30cd443..22ac93b 100644 --- a/hmiapp/make_db.py +++ b/hmiapp/make_db.py @@ -4,7 +4,10 @@ """Build the iDrive app's text and image databases. EntryAad_ALL_Texts.zip holds .txt ("id=text" lines, same format as BMW's PluginsCoded apps) and -EntryAad_ALL_Images.zip holds .png, from hmiapp/res. Both are reproducible: same input, same bytes. The Help +EntryAad_ALL_Images.zip holds .png, from hmiapp/res. The texts are UTF-8 with their accents, as BMW's own apps +store theirs in the same format (_common_Texts.zip, _mini_Texts.zip: fr-FR.txt "Démarrage du navigateur +Internet échoué"); the letters are limited to Latin-1 and Latin Extended-A (French, German, Spanish, Italian, +Portuguese, Polish), which the iDrive's own languages use. Both are reproducible: same input, same bytes. The Help page's title carries the project's version (VERSION), so a photo of it tells which version a car runs. Usage: make_db.py @@ -20,12 +23,12 @@ "de": "Deutsch", "en-UK": "English (UK)", "en-US": "English (US)", - "es-ES": "Espanol", - "es-US": "Espanol (US)", - "fr-FR": "Francais", - "fr-CA": "Francais (CA)", + "es-ES": "Español", + "es-US": "Español (US)", + "fr-FR": "Français", + "fr-CA": "Français (CA)", "it": "Italiano", - "pt": "Portugues", + "pt": "Português", "ru": "Russian", "pl": "Polski", } @@ -73,47 +76,47 @@ 26: "Free: github.com/Jiraiya43", 30: " ", } # blank title of the page held under Android Auto (no "Android Auto" tab during the volume) -LANG_TEXTS = { # ASCII only +LANG_TEXTS = { # printable ASCII and accented Latin letters (allowed()) "fr-FR": { 2: "Android Auto : connexion...", - 10: "Demarrer Android Auto", - 11: "Arreter Android Auto", - 13: "Connexion au telephone...", + 10: "Démarrer Android Auto", + 11: "Arrêter Android Auto", + 13: "Connexion au téléphone...", 14: "Ouvrir Android Auto", - 15: "Demarrage automatique", + 15: "Démarrage automatique", 16: "Aide", - 17: "Cable USB au lieu du sans-fil", + 17: "Câble USB au lieu du sans-fil", 18: "Garder les journaux", - 40: "Copier les journaux sur cle USB", + 40: "Copier les journaux sur clé USB", 41: "Copie des journaux...", - 42: "Journaux copies sur la cle USB", - 43: "Aucune cle USB trouvee", + 42: "Journaux copiés sur la clé USB", + 43: "Aucune clé USB trouvée", 44: "Aucun journal : cochez Garder", 45: "Copie impossible", - 46: "Mettre a jour par cle USB", - 47: "Lecture de la cle USB...", - 48: "Installer la mise a jour", - 49: "Installer la version anterieure", - 50: "Reinstaller cette version", - 51: "Terminer la mise a jour", - 52: "Deja a jour", - 53: "Aucune mise a jour sur la cle", - 54: "Mise a jour non valide", - 55: "Mise a jour incompatible", - 56: "Arret d'Android Auto...", + 46: "Mettre à jour par clé USB", + 47: "Lecture de la clé USB...", + 48: "Installer la mise à jour", + 49: "Installer la version antérieure", + 50: "Réinstaller cette version", + 51: "Terminer la mise à jour", + 52: "Déjà à jour", + 53: "Aucune mise à jour sur la clé", + 54: "Mise à jour non valide", + 55: "Mise à jour incompatible", + 56: "Arrêt d'Android Auto...", 57: "Installation, laisser le contact", - 58: "Installee : redemarrage iDrive", - 59: "Installee : redemarrer l'iDrive", - 60: "Echec : rien n'a ete modifie", - 61: "Incomplete : la reinstaller", - 62: "Occupe : reessayer plus tard", + 58: "Installée : redémarrage iDrive", + 59: "Installée : redémarrer l'iDrive", + 60: "Échec : rien n'a été modifié", + 61: "Incomplète : la réinstaller", + 62: "Occupé : réessayer plus tard", 63: "Installation non reconnue", 64: "Pas pendant un appel ni en marche AR", 20: "NAV, MAP : navigation Android Auto", 21: "MEDIA : musique Android Auto", - 22: "COM : telephone Android Auto", + 22: "COM : téléphone Android Auto", 23: "MENU : iDrive - BACK : retour", - 24: "Telephone appaire, son en Bluetooth", + 24: "Téléphone appairé, son en Bluetooth", 26: "Gratuit : github.com/Jiraiya43", }, "de": { @@ -121,7 +124,7 @@ 10: "Android Auto starten", 11: "Android Auto beenden", 13: "Verbindung zum Telefon...", - 14: "Android Auto oeffnen", + 14: "Android Auto öffnen", 15: "Automatisch starten", 16: "Hilfe", 17: "USB-Kabel statt kabellos", @@ -135,26 +138,26 @@ 46: "Update vom USB-Stick", 47: "USB-Stick wird gelesen...", 48: "Update installieren", - 49: "Aeltere Version installieren", + 49: "Ältere Version installieren", 50: "Version neu installieren", - 51: "Update abschliessen", + 51: "Update abschließen", 52: "Bereits aktuell", 53: "Kein Update auf dem USB-Stick", - 54: "Update ungueltig", + 54: "Update ungültig", 55: "Update passt nicht zum Auto", 56: "Android Auto wird beendet...", - 57: "Installation: Zuendung anlassen", + 57: "Installation: Zündung anlassen", 58: "Installiert: iDrive startet neu", 59: "Installiert: iDrive neu starten", - 60: "Fehler: nichts geaendert", - 61: "Unvollstaendig: neu installieren", - 62: "Belegt: spaeter erneut", + 60: "Fehler: nichts geändert", + 61: "Unvollständig: neu installieren", + 62: "Belegt: später erneut", 63: "Installation nicht erkannt", - 64: "Nicht bei Anruf oder Rueckwaerts", + 64: "Nicht bei Anruf oder Rückwärts", 20: "NAV, MAP: Android Auto Navigation", 21: "MEDIA: Android Auto Medien", 22: "COM: Android Auto Telefon", - 23: "MENU: iDrive - BACK: zurueck", + 23: "MENU: iDrive - BACK: zurück", 24: "Telefon gekoppelt, Ton per Bluetooth", 26: "Kostenlos: github.com/Jiraiya43", }, @@ -166,7 +169,7 @@ 14: "Apri Android Auto", 15: "Avvio automatico", 16: "Aiuto", - 17: "Cavo USB anziche wireless", + 17: "Cavo USB anziché wireless", 20: "NAV, MAP: navigazione Android Auto", 21: "MEDIA: musica Android Auto", 22: "COM: telefono Android Auto", @@ -175,45 +178,45 @@ 26: "Gratuito: github.com/Jiraiya43", }, "pl": { - 2: "Android Auto: laczenie...", + 2: "Android Auto: łączenie...", 10: "Uruchom Android Auto", 11: "Zatrzymaj Android Auto", - 13: "Laczenie z telefonem...", - 14: "Otworz Android Auto", + 13: "Łączenie z telefonem...", + 14: "Otwórz Android Auto", 15: "Automatyczne uruchamianie", 16: "Pomoc", 17: "Kabel USB zamiast WiFi", 18: "Zachowaj logi", 40: "Kopiuj logi na USB", - 41: "Kopiowanie logow...", + 41: "Kopiowanie logów...", 42: "Logi skopiowane na USB", - 43: "Nie znaleziono pamieci USB", - 44: "Brak logow: zaznacz Zachowaj logi", + 43: "Nie znaleziono pamięci USB", + 44: "Brak logów: zaznacz Zachowaj logi", 45: "Kopiowanie nieudane", - 46: "Aktualizacja z pamieci USB", - 47: "Odczytywanie pamieci USB...", - 48: "Zainstaluj aktualizacje", - 49: "Zainstaluj starsza wersje", - 50: "Przeinstaluj te wersje", - 51: "Zakoncz aktualizacje", - 52: "Juz aktualne", - 53: "Brak aktualizacji na pamieci USB", - 54: "Aktualizacja nieprawidlowa", + 46: "Aktualizacja z pamięci USB", + 47: "Odczytywanie pamięci USB...", + 48: "Zainstaluj aktualizację", + 49: "Zainstaluj starszą wersję", + 50: "Przeinstaluj tę wersję", + 51: "Zakończ aktualizację", + 52: "Już aktualne", + 53: "Brak aktualizacji na pamięci USB", + 54: "Aktualizacja nieprawidłowa", 55: "Aktualizacja nie dla tego samochodu", 56: "Zatrzymywanie Android Auto...", - 57: "Instalowanie: nie wylaczaj zaplonu", + 57: "Instalowanie: nie wyłączaj zapłonu", 58: "Zainstalowano: restartowanie iDrive", 59: "Zainstalowano: zrestartuj iDrive", - 60: "Blad aktualizacji: nic nie zmieniono", - 61: "Niedokonczono: zainstaluj ponownie", - 62: "Zajety: sprobuj ponownie za chwile", + 60: "Błąd aktualizacji: nic nie zmieniono", + 61: "Niedokończono: zainstaluj ponownie", + 62: "Zajęty: spróbuj ponownie za chwilę", 63: "Instalacja nierozpoznana", 64: "Nie w trakcie rozmowy lub cofania", 20: "NAV, MAP: nawigacja Android Auto", 21: "MEDIA: muzyka Android Auto", 22: "COM: telefon Android Auto", 23: "MENU: iDrive - BACK: wstecz", - 24: "Telefon sparowany, dzwiek przez BT", + 24: "Telefon sparowany, dźwięk przez BT", 26: "Darmowe: github.com/Jiraiya43", }, } @@ -238,6 +241,16 @@ def project_version(): return version +def allowed(text): + """Printable ASCII, and the accented Latin letters of the iDrive's own languages (Latin-1, Latin Extended-A): no + control character, no line break, nothing outside the iDrive's Latin fonts.""" + return ( + all(" " <= c <= "~" or "\u00c0" <= c <= "\u017f" for c in text) + and "\u00d7" not in text + and "\u00f7" not in text + ) + + def write_texts(path, version): """One .txt per language: English, overridden by the language's own texts.""" with zipfile.ZipFile(path, "w") as archive: @@ -246,8 +259,9 @@ def write_texts(path, version): texts.update(LANG_TEXTS.get(lang, {})) texts[HELP_TITLE] = f"{texts[16]} - {version}" body = f"100000={langname}\n" + "".join(f"{key}={value}\n" for key, value in sorted(texts.items())) - if not body.isascii(): - raise SystemExit(f"FAIL: {lang} texts must stay ASCII") + bad = [value for value in [langname, *texts.values()] if not allowed(value)] + if bad: + raise SystemExit(f"FAIL: {lang}: characters the iDrive's fonts may lack, or a line break: {bad[0]!r}") add(archive, lang + ".txt", body.encode("utf-8")) From 16ed3fc6944b09c0b22a01c6610c32cf5b1c9d3f Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 05:07:35 +0100 Subject: [PATCH 11/17] =?UTF-8?q?docs(compatibilite):=20F22=20218d=20et=20?= =?UTF-8?q?F30=20320i=20par=20c=C3=A2ble=20USB=20(#281)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit F22 218d LCI de 2019 (201811150004, 800x480, sans Wi-Fi) en 0.13.0-rc.13, par câble et par un adaptateur Android Auto sans fil sur l'USB (discussion #268) ; F30 320i de 2018 (202106151602, 800x480, sans Wi-Fi) en 0.12.0-rc.6 par câble (#202). Liste des README : F22, X1 F49 et X2 F39, déjà dans le tableau. --- README.fr.md | 2 +- README.md | 2 +- docs/COMPATIBILITE.md | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.fr.md b/README.fr.md index 29c57a2..14c785d 100644 --- a/README.fr.md +++ b/README.fr.md @@ -113,7 +113,7 @@ Signalées fonctionnelles par leurs propriétaires, sans fil, par câble ou les | | Modèles | |---|---| | **Série G** | Série 3 G20 et G21, Série 5 G30, X3 G01 | -| **Série F** | Série 1 F20, F21, F40 et F52 ; Série 2 F44 et F45 ; Série 3 F30 ; X1 F48 | +| **Série F** | Série 1 F20, F21, F40 et F52 ; Série 2 F22, F44 et F45 ; Série 3 F30 ; X1 F48 et F49 ; X2 F39 | | **i et MINI** | i3 ; MINI Clubman F54, MINI F56 et F57 | Chaque voiture, avec son logiciel iDrive, son écran, sa liaison et la version essayée, est dans diff --git a/README.md b/README.md index ac4ba3f..274590d 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Reported working by their owners, wireless, over USB or both: | | Models | |---|---| | **G series** | 3 Series G20 and G21, 5 Series G30, X3 G01 | -| **F series** | 1 Series F20, F21, F40 and F52; 2 Series F44 and F45; 3 Series F30; X1 F48 | +| **F series** | 1 Series F20, F21, F40 and F52; 2 Series F22, F44 and F45; 3 Series F30; X1 F48 and F49; X2 F39 | | **i and MINI** | i3; MINI Clubman F54, MINI F56 and F57 | Each car, with its iDrive software, screen, link and the version tried, is in diff --git a/docs/COMPATIBILITE.md b/docs/COMPATIBILITE.md index 9c09fe3..e5001d5 100644 --- a/docs/COMPATIBILITE.md +++ b/docs/COMPATIBILITE.md @@ -26,6 +26,8 @@ rapports de leurs propriétaires : elles disent ce qu'ils ont vu, avec la versio | F20 120i LCI de 2019 | `201811150004` | 1280x480 (écran de 8,8 pouces monté après coup) | USB (unité sans Wi-Fi) | 0.12.1-rc.4 | marche ; bouton vocal sans effet ([discussion #28](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/28)) | | F20 de 07/2018 | `201907031456` | 800x480 | USB ; sans fil lent | 0.13.0-rc.10 | marche ; guidage de Google Maps au compteur 6WA par MOST, venu après avoir coupé puis remis le réglage de la navigation dans l'iDrive, disparu quelques minutes à chaque changement d'itinéraire ([#101](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/101)) | | F21 de 2018 | non indiqué | non relevé | USB | 0.12.1-rc.3 | marche ; commandes vocales lentes, avec AAIdrive installé aussi ([#68](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/68)) | +| F22 218d LCI de 2019 | `201811150004` | 800x480 (6,5 pouces, sans toucher) | USB (unité sans Wi-Fi), aussi par un adaptateur Android Auto sans fil sur l'USB | 0.13.0-rc.13 | marche avec un Pixel 10 : marche arrière et caméra, touches, MEDIA et double MEDIA, MAP et NAV vers la carte, COM ([discussion #268](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/268)) | +| F30 320i de 2018 | `202106151602` | 800x480 | USB (unité sans Wi-Fi) | 0.12.0-rc.6 | marche ([#202](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/202)) | | F30 330d LCI de 2018 | `202402191339` | 1280x480 | sans fil | 0.12.0-rc.6 | marche, ancien contrôleur, pastille du volume ; MAP rendait l'écran à l'iDrive, il ouvre la navigation d'Android Auto depuis 0.13.0-rc.1, pas encore essayé ([#43](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/43)) | | F40 118i de 2019 | `202207190806` | non relevé | USB, sans fil | 0.12.1-rc.4 | marche par câble ; sans-fil très lent avec un Galaxy S25 Ultra ([#71](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/71)) | | F44 | `202402191339` | non relevé | non indiquée | non indiquée | marche, menu en polonais essayé ([#176](https://github.com/Jiraiya43/EntryNav2-Android-Auto/pull/176)) | From 2e4376d0a2928b643414730707b275059a4b1ba8 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 05:56:32 +0100 Subject: [PATCH 12/17] chore: version 0.13.0-rc.14 (#282) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Version candidate : emplacement Bluetooth 5 repris quand le téléphone le garde après un arrêt (#277), trames du toucher qui portent un doigt au journal (#278), appels et son redemandés au retour du téléphone (#279), menu accentué (#280). Merci à Bastjen, qui soutient le projet. VERSION, journal des versions fr/en, commandes d'installation, modèle de ticket. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- CHANGELOG.en.md | 11 ++++++++++- CHANGELOG.md | 10 ++++++++++ VERSION | 2 +- docs/INSTALLATION.en.md | 4 ++-- docs/INSTALLATION.md | 4 ++-- 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 60b7c63..24adc90 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: label: Project version description: The release you installed, or the commit you built. From 0.13.0-rc.10, the title of the Help page in the Android Auto menu shows it. - placeholder: 0.13.0-rc.13 + placeholder: 0.13.0-rc.14 validations: required: true - type: input diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 18bda86..4acf32a 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -2,7 +2,7 @@ > [!IMPORTANT] > This is a translation of the authoritative [French changelog](CHANGELOG.md), based on -> [`v0.13.0-rc.13`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.13/CHANGELOG.md). +> [`v0.13.0-rc.14`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.14/CHANGELOG.md). > It may become outdated; consult the French changelog for the source of truth. All notable changes to this project. Format inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), @@ -13,6 +13,15 @@ QEMU with the car's libraries). ## [Unreleased] +## [0.13.0-rc.14] - 2026-12-02 · PC + +Release candidate: Start is no longer refused when the phone keeps Android Auto's Bluetooth slot after a +stop, the phone's calls and audio come back after its Bluetooth was turned off and on, the iDrive menu has +its accents, and the service log keeps the touchscreen frames that carry a finger, to understand swipes that +reach the phone as taps. Installs from a USB stick since 0.13.0-rc.10. Tested on PC and under QEMU. + +Thanks to [Bastjen](https://github.com/Bastjen) for supporting the project. + ### Changed - Service log: the 12 raw touchscreen frames written each session are now the first ones that press, move or lift a finger, instead of the very first received. On an F45 those were all empty, and the log could not show why a swipe reached the phone as a tap ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Same number of lines. Tested on PC. diff --git a/CHANGELOG.md b/CHANGELOG.md index 64aacd0..eb37b2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,16 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +## [0.13.0-rc.14] - 2026-12-02 · PC + +Version candidate : Démarrer n'est plus refusé quand le téléphone garde l'emplacement Bluetooth d'Android +Auto après un arrêt, les appels et le son du téléphone reviennent après son Bluetooth coupé puis rallumé, +le menu de l'iDrive a ses accents, et le journal du service garde les trames de l'écran tactile qui portent +un doigt, pour comprendre les glissements qui arrivent au téléphone comme des appuis. S'installe par clé USB +depuis la 0.13.0-rc.10. Testée sur PC et sous QEMU. + +Merci à [Bastjen](https://github.com/Bastjen), qui soutient le projet. + ### Modifié - Journal du service : les 12 trames brutes de l'écran tactile écrites à chaque séance sont maintenant les premières qui posent, bougent ou lèvent un doigt, au lieu des toutes premières reçues. Sur une F45, ces dernières étaient toutes vides et le journal ne montrait pas pourquoi un glissement arrivait au téléphone comme un appui ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Même nombre de lignes. Testé sur PC. diff --git a/VERSION b/VERSION index 764f92a..c63ded3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.13.0-rc.13 +0.13.0-rc.14 diff --git a/docs/INSTALLATION.en.md b/docs/INSTALLATION.en.md index c160f6e..7587181 100644 --- a/docs/INSTALLATION.en.md +++ b/docs/INSTALLATION.en.md @@ -38,7 +38,7 @@ the one in its archive (in 0.10.0, the supervisor is called `evo-trial`, not `aa From the PC, in the archive's folder: ```sh -scp entrynav2-android-auto-0.13.0-rc.13-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.14-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -50,7 +50,7 @@ flash memory yet. Nothing is changed during this step. ```sh -V=0.13.0-rc.13 +V=0.13.0-rc.14 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 89cda47..ee93612 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -33,7 +33,7 @@ ancienne, suivre celle de l'archive (dans la 0.10.0, le superviseur s'appelle `e Depuis le PC, dans le dossier de l'archive : ```sh -scp entrynav2-android-auto-0.13.0-rc.13-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.14-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -45,7 +45,7 @@ encore écrit sur la mémoire flash. Rien n'est modifié pendant cette étape. ```sh -V=0.13.0-rc.13 +V=0.13.0-rc.14 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version From b754d5b8d1aeeae8251026f27435b6e8e88fd106 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 09:08:20 +0100 Subject: [PATCH 13/17] fix(input): ignorer les messages sans toucher, comme l'iDrive (#283) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sur des F45 (202402191339, #266), les glissements arrivaient au téléphone comme des appuis. Les trames brutes de la 0.13.0-rc.14 (journal de skha-max) le montrent : 1 à 5 ms après un appui, l'écran envoie un message sans doigt dont l'octet 2 des données de l'enregistrement 1 et l'octet 0 de celles de l'enregistrement 2 ne sont pas nuls. HmiMain3D (CTouchDataClient::decodeTouchScreenPduData) ne lit alors aucune donnée de toucher et garde ses doigts ; nous le lisions comme « plus aucun doigt » et relâchions le doigt, et la suite du geste était ignorée. aa::carriesTouchData reprend le test de l'iDrive ; TouchTracker passe ces messages (compteur skipped, résumé without_touch_data=) et ils ne repoussent plus le relâché forcé après 400 ms. Test avec les trames de la voiture (glissement et pincement), qui échoue sans le correctif. Aucune trame de ce genre dans les journaux de la G20, d'une MINI F56 ni d'une F52. --- CHANGELOG.en.md | 4 ++++ CHANGELOG.md | 4 ++++ platform/evo_touch.cpp | 19 +++++++++++---- platform/evo_touch.hpp | 3 ++- platform/evo_touch_frame.hpp | 10 ++++++++ tests/test_evo_input.cpp | 46 ++++++++++++++++++++++++++++++++++++ 6 files changed, 80 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 4acf32a..3984c41 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,6 +13,10 @@ QEMU with the car's libraries). ## [Unreleased] +### Fixed + +- Touchscreen: on some F45 (software 202402191339), swipes reached the phone as taps, and pinching barely worked ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Their screen sends, between its touch frames, messages that carry none: iDrive ignores them (HmiMain3D's `CTouchDataClient::decodeTouchScreenPduData` reads nothing when byte 2 of record 1's data, or byte 0 of record 2's, is not zero), while we read them as "no finger left" and lifted the finger 1 to 5 ms after the press; the rest of the gesture was lost. They are now ignored as iDrive does, and no longer hold off the lift of a finger whose last frame was lost. The touch summary at the end of the service log counts them (`without_touch_data=`). Found thanks to the raw frames 0.13.0-rc.14 keeps; no such frame in the logs of the G20, a MINI F56 or an F52. Tested on PC with the car's frames. + ## [0.13.0-rc.14] - 2026-12-02 · PC Release candidate: Start is no longer refused when the phone keeps Android Auto's Bluetooth slot after a diff --git a/CHANGELOG.md b/CHANGELOG.md index eb37b2d..018f222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +### Corrigé + +- Écran tactile : sur des F45 (logiciel 202402191339), les glissements arrivaient au téléphone comme des appuis, et le pincement marchait mal ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Leur écran envoie, entre ses trames tactiles, des messages qui n'en portent pas : l'iDrive les ignore (`CTouchDataClient::decodeTouchScreenPduData` de HmiMain3D ne lit rien quand l'octet 2 des données de l'enregistrement 1, ou l'octet 0 de celles de l'enregistrement 2, n'est pas nul), alors que nous les lisions comme « plus aucun doigt » et relâchions le doigt 1 à 5 ms après l'appui ; la suite du geste était perdue. Ils sont maintenant ignorés comme l'iDrive le fait, et ne retardent plus le relâché d'un doigt dont la dernière trame s'est perdue. Le résumé du toucher, à la fin du journal du service, les compte (`without_touch_data=`). Trouvé grâce aux trames brutes que garde la 0.13.0-rc.14 ; aucune trame de ce genre dans les journaux de la G20, d'une MINI F56 ni d'une F52. Testé sur PC avec les trames de la voiture. + ## [0.13.0-rc.14] - 2026-12-02 · PC Version candidate : Démarrer n'est plus refusé quand le téléphone garde l'emplacement Bluetooth d'Android diff --git a/platform/evo_touch.cpp b/platform/evo_touch.cpp index 70ad8d4..3da6241 100644 --- a/platform/evo_touch.cpp +++ b/platform/evo_touch.cpp @@ -99,7 +99,7 @@ void TouchTracker::reset() { reasm_ = aa::TouchReassembler(); haveMsg_ = false; prevSeq0_ = prevSeq1_ = 0; - messages_ = 0; + messages_ = skipped_ = 0; lastN_ = 0; } @@ -176,6 +176,10 @@ int TouchTracker::feed(const uint8_t* buf, size_t n, aa::TouchEventOut* evs, int haveMsg_ = true; prevSeq0_ = msgs[mi].seq0; prevSeq1_ = msgs[mi].seq1; + if (!aa::carriesTouchData(msgs[mi])) { + ++skipped_; // as iDrive: no finger changes (evo_touch_frame.hpp) + continue; + } aa::TouchContact c[NS]; int declared = 0; const int nc = aa::parseTouchStream(msgs[mi], c, NS, &declared); @@ -407,9 +411,9 @@ void EvoTouch::stop() { void EvoTouch::summary() const { ELOG("Touch", - "summary: mode=%s datagrams_copied=%u touch_frames=%u others=%u events=%u sent_to_aa=%u " - "received_by_our_socket=%u sender=%s:%u socket_refused=%u", - inputModeName(mode_), tapped_, touchPdus_, otherPdus_, events_, sent_, stolen_, + "summary: mode=%s datagrams_copied=%u touch_frames=%u without_touch_data=%u others=%u events=%u " + "sent_to_aa=%u received_by_our_socket=%u sender=%s:%u socket_refused=%u", + inputModeName(mode_), tapped_, touchPdus_, tracker_.skipped(), otherPdus_, events_, sent_, stolen_, source_.known() ? ipText(source_.ip()).c_str() : "?", source_.port(), stealRefused_ ? 1 : 0); } @@ -527,10 +531,15 @@ void EvoTouch::handle(const UdpView& u, int ifindex, uint32_t now) { ELOG("Touch", "touch sender: %s:%u on %s", ipText(source_.ip()).c_str(), source_.port(), name.c_str()); } ++touchPdus_; - lastFrameMs_ = now; aa::TouchEventOut ev[16]; tracker_.setPictureStarted(pictureStarted_); + const unsigned messagesBefore = tracker_.messages(), skippedBefore = tracker_.skipped(); const int n = tracker_.feed(u.data, u.len, ev, 16); + // A datagram whose messages all lacked touch data says nothing of the fingers: it does not hold off the release + // of a finger whose "up" was lost (the F45 of #266 sends such messages with no finger on the screen too). + if (tracker_.messages() != messagesBefore || tracker_.skipped() == skippedBefore) { + lastFrameMs_ = now; + } // Datagrams logged raw: observing, the first ones; forwarding, the first ones that pressed, moved or lifted a // finger, or were not understood. The first frames of a session can all be empty (#266: twelve without a finger // before the first touch), which left nothing to read when a swipe arrived as a tap. A message split over several diff --git a/platform/evo_touch.hpp b/platform/evo_touch.hpp index 65a067b..ce306c2 100644 --- a/platform/evo_touch.hpp +++ b/platform/evo_touch.hpp @@ -76,6 +76,7 @@ class TouchTracker { int releaseAll(aa::TouchEventOut* out, int max); int activeCount() const; unsigned messages() const { return messages_; } + unsigned skipped() const { return skipped_; } // messages without touch data (aa::carriesTouchData) int lastContacts(aa::TouchContact* out, int max) const; void reset(); // False until the Android Auto picture has started (true by default). @@ -108,7 +109,7 @@ class TouchTracker { aa::TouchReassembler reasm_; bool haveMsg_; unsigned char prevSeq0_, prevSeq1_; - unsigned messages_; + unsigned messages_, skipped_; aa::TouchContact last_[NS]; int lastN_; }; diff --git a/platform/evo_touch_frame.hpp b/platform/evo_touch_frame.hpp index 639c088..7cfd85f 100644 --- a/platform/evo_touch_frame.hpp +++ b/platform/evo_touch_frame.hpp @@ -56,6 +56,16 @@ inline bool isIdent(const unsigned char* p) { } } // namespace touchpdu +// Whether a joined message carries touch data, read as iDrive reads it. HmiMain3D's decoder +// (CTouchDataClient::decodeTouchScreenPduData) reads the records from the first one; when byte 2 of record 1's data, or +// byte 0 of record 2's data, is not zero, it builds no touch data, and its list of fingers stays as it was. An F45 +// (202402191339, #266) sends such messages between its touch frames, without a finger, one 1 to 5 ms after most +// presses: read as touch frames, they lifted the finger and every swipe arrived as a tap. The G20, a MINI F56 and an +// F52 sent none in their logs. A message too short for these records is left to parseTouchStream. +inline bool carriesTouchData(const TouchMsg& m) { + return m.recs < 3 || (m.d[1 * 4 + 2] == 0 && m.d[2 * 4 + 0] == 0); +} + // The contacts of a joined message, up to max (contacts with an unknown state, or an id past our table, skipped). // -1 when the message is too short for the stream's two first bytes. *declared gets the count the message claims. inline int parseTouchStream(const TouchMsg& m, TouchContact* out, int max, int* declared) { diff --git a/tests/test_evo_input.cpp b/tests/test_evo_input.cpp index 13a924d..827bcc8 100644 --- a/tests/test_evo_input.cpp +++ b/tests/test_evo_input.cpp @@ -343,6 +343,52 @@ int main(int argc, char** argv) { aa::parseTouchStream(msg[0], got, 2, &declared) == 1 && declared == 1 && got[0].state == 2 && got[0].id == 2 && got[0].x == 640 && got[0].y == 240); } + // An F45 (202402191339, #266), frames from its log: 1 ms after a press, a message without touch data as iDrive + // reads it (byte 2 of record 1's data, byte 0 of record 2's), which leaves iDrive's fingers as they were. Read as a + // touch frame it had no finger: the finger was lifted at once, and every swipe reached the phone as a tap. + { + static const unsigned char press[112] = { + 0xb0, 0x04, 0x80, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, + 0x00, 0xc5, 0x40, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xe1, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0x40, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xe3, 0x00, 0x00, 0x40, 0x0d, + 0x00, 0xc1, 0x40, 0xe4, 0x80, 0x01, 0x02, 0x6b, 0x00, 0xc1, 0x40, 0xe5, 0x00, 0x60, 0x26, 0x10, + 0x00, 0xc1, 0x40, 0xe6, 0x00, 0xfa, 0x00, 0x04, 0x00, 0xc1, 0x40, 0xe7, 0xfe, 0xfe, 0x03, 0xfd, + 0x00, 0xc1, 0x40, 0xe8, 0x00, 0xfe, 0x04, 0x00, 0x00, 0xc1, 0x40, 0xe9, 0xfa, 0xf8, 0xf6, 0xfa, + 0x00, 0xc1, 0x40, 0xea, 0xf6, 0xf8, 0xfa, 0x00, 0x00, 0xc3, 0x40, 0xeb, 0xfb, 0xfb, 0xf9, 0x01, + }; + static const unsigned char other[112] = { + 0xb0, 0x04, 0x80, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, + 0x00, 0xc5, 0x40, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xed, 0x00, 0x00, 0x2a, 0x00, + 0x00, 0xc1, 0x40, 0xee, 0x4f, 0xc0, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xef, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0x40, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xf1, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0x40, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xf3, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0x40, 0xf4, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0xf5, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0x40, 0xf6, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x40, 0xf7, 0x00, 0x00, 0x00, 0x00, + }; + evo::TouchTracker swipe; + CHECK(swipe.feed(press, sizeof(press), ev, 16) == 1 && ev[0].action == 0 && ev[0].p[0].x == 619 && + ev[0].p[0].y == 96); + CHECK(swipe.feed(other, sizeof(other), ev, 16) == 0 && swipe.activeCount() == 1 && swipe.skipped() == 1); + CHECK(frame(swipe, 640, 90, 2, 0xf8, ev) == 1 && ev[0].action == 2 && ev[0].p[0].x == 640); + CHECK(frame(swipe, 700, 80, 2, 0x04, ev) == 1 && ev[0].action == 2 && ev[0].p[0].x == 700); + CHECK(frame(swipe, 700, 80, 3, 0x10, ev) == 1 && ev[0].action == 1 && swipe.activeCount() == 0); + // Two fingers, the second down 36 ms after the first with such a message in between: a pinch, where the second + // finger used to start a gesture of its own. + static const unsigned char twoFingers[112] = { + 0xb0, 0x04, 0x80, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, + 0x00, 0xc5, 0x40, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0x69, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xc1, 0x40, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x40, 0x6b, 0x00, 0x00, 0x40, 0x17, + 0x00, 0xc1, 0x40, 0x6c, 0x40, 0x02, 0x02, 0x3d, 0x00, 0xc1, 0x40, 0x6d, 0x00, 0xfb, 0x25, 0x20, + 0x00, 0xc1, 0x40, 0x6e, 0x01, 0xf1, 0x01, 0x43, 0x00, 0xc1, 0x40, 0x6f, 0x2a, 0x11, 0x01, 0xfc, + 0x00, 0xc1, 0x40, 0x70, 0xff, 0xfd, 0x03, 0xff, 0x00, 0xc1, 0x40, 0x71, 0xfb, 0xf9, 0xf7, 0xfb, + 0x00, 0xc1, 0x40, 0x72, 0xf7, 0xf8, 0xf9, 0xff, 0x00, 0xc3, 0x40, 0x73, 0xfa, 0xfb, 0xf8, 0xff, + }; + evo::TouchTracker pinch; + CHECK(frame(pinch, 574, 251, 1, 0xe0, ev) == 1 && ev[0].action == 0); // the first finger + CHECK(pinch.feed(other, sizeof(other), ev, 16) == 0 && pinch.activeCount() == 1 && pinch.skipped() == 1); + CHECK(pinch.feed(twoFingers, sizeof(twoFingers), ev, 16) == 2 && ev[0].action == 5 && ev[0].n == 2 && + ev[0].p[ev[0].index].x == 497 && ev[1].action == 2 && pinch.activeCount() == 2); + } // A MINI: the phone's display starts 40 columns into the panel (its left margin) and is 1200x480. A finger is sent // in the phone's pixels: 40 less, kept inside its display. Before, it landed 40 pixels right of it (#78, #88). evo::TouchTracker mini; From 22943dfbb350cf6d29687bd0289318e9382977bb Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 09:30:02 +0100 Subject: [PATCH 14/17] chore: version 0.13.0-rc.15 (#284) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Version candidate : glissements et pincement des F45 au logiciel 202402191339 (#283), d'après les trames brutes de la 0.13.0-rc.14. VERSION, journal des versions fr/en, commandes d'installation, modèle de ticket. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- CHANGELOG.en.md | 8 +++++++- CHANGELOG.md | 6 ++++++ VERSION | 2 +- docs/INSTALLATION.en.md | 4 ++-- docs/INSTALLATION.md | 4 ++-- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 24adc90..3add253 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: label: Project version description: The release you installed, or the commit you built. From 0.13.0-rc.10, the title of the Help page in the Android Auto menu shows it. - placeholder: 0.13.0-rc.14 + placeholder: 0.13.0-rc.15 validations: required: true - type: input diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 3984c41..1082b3d 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -2,7 +2,7 @@ > [!IMPORTANT] > This is a translation of the authoritative [French changelog](CHANGELOG.md), based on -> [`v0.13.0-rc.14`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.14/CHANGELOG.md). +> [`v0.13.0-rc.15`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.15/CHANGELOG.md). > It may become outdated; consult the French changelog for the source of truth. All notable changes to this project. Format inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), @@ -13,6 +13,12 @@ QEMU with the car's libraries). ## [Unreleased] +## [0.13.0-rc.15] - 2026-12-02 · PC + +Release candidate: swipes and pinches on F45 with software 202402191339, which reached the phone as taps, +from the raw frames logged with 0.13.0-rc.14. Installs from a USB stick since 0.13.0-rc.10. Tested on PC +and under QEMU, with the car's frames. + ### Fixed - Touchscreen: on some F45 (software 202402191339), swipes reached the phone as taps, and pinching barely worked ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Their screen sends, between its touch frames, messages that carry none: iDrive ignores them (HmiMain3D's `CTouchDataClient::decodeTouchScreenPduData` reads nothing when byte 2 of record 1's data, or byte 0 of record 2's, is not zero), while we read them as "no finger left" and lifted the finger 1 to 5 ms after the press; the rest of the gesture was lost. They are now ignored as iDrive does, and no longer hold off the lift of a finger whose last frame was lost. The touch summary at the end of the service log counts them (`without_touch_data=`). Found thanks to the raw frames 0.13.0-rc.14 keeps; no such frame in the logs of the G20, a MINI F56 or an F52. Tested on PC with the car's frames. diff --git a/CHANGELOG.md b/CHANGELOG.md index 018f222..b0eb901 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +## [0.13.0-rc.15] - 2026-12-02 · PC + +Version candidate : les glissements et le pincement des F45 au logiciel 202402191339, qui arrivaient au +téléphone comme des appuis, d'après les trames brutes relevées avec la 0.13.0-rc.14. S'installe par clé +USB depuis la 0.13.0-rc.10. Testée sur PC et sous QEMU, avec les trames de la voiture. + ### Corrigé - Écran tactile : sur des F45 (logiciel 202402191339), les glissements arrivaient au téléphone comme des appuis, et le pincement marchait mal ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266)). Leur écran envoie, entre ses trames tactiles, des messages qui n'en portent pas : l'iDrive les ignore (`CTouchDataClient::decodeTouchScreenPduData` de HmiMain3D ne lit rien quand l'octet 2 des données de l'enregistrement 1, ou l'octet 0 de celles de l'enregistrement 2, n'est pas nul), alors que nous les lisions comme « plus aucun doigt » et relâchions le doigt 1 à 5 ms après l'appui ; la suite du geste était perdue. Ils sont maintenant ignorés comme l'iDrive le fait, et ne retardent plus le relâché d'un doigt dont la dernière trame s'est perdue. Le résumé du toucher, à la fin du journal du service, les compte (`without_touch_data=`). Trouvé grâce aux trames brutes que garde la 0.13.0-rc.14 ; aucune trame de ce genre dans les journaux de la G20, d'une MINI F56 ni d'une F52. Testé sur PC avec les trames de la voiture. diff --git a/VERSION b/VERSION index c63ded3..f0a7880 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.13.0-rc.14 +0.13.0-rc.15 diff --git a/docs/INSTALLATION.en.md b/docs/INSTALLATION.en.md index 7587181..1421068 100644 --- a/docs/INSTALLATION.en.md +++ b/docs/INSTALLATION.en.md @@ -38,7 +38,7 @@ the one in its archive (in 0.10.0, the supervisor is called `evo-trial`, not `aa From the PC, in the archive's folder: ```sh -scp entrynav2-android-auto-0.13.0-rc.14-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.15-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -50,7 +50,7 @@ flash memory yet. Nothing is changed during this step. ```sh -V=0.13.0-rc.14 +V=0.13.0-rc.15 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index ee93612..2832c41 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -33,7 +33,7 @@ ancienne, suivre celle de l'archive (dans la 0.10.0, le superviseur s'appelle `e Depuis le PC, dans le dossier de l'archive : ```sh -scp entrynav2-android-auto-0.13.0-rc.14-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.15-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -45,7 +45,7 @@ encore écrit sur la mémoire flash. Rien n'est modifié pendant cette étape. ```sh -V=0.13.0-rc.14 +V=0.13.0-rc.15 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version From bc5fb2d675c652361e9e63c827647bdd0b7425ff Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 18:21:15 +0100 Subject: [PATCH 15/17] =?UTF-8?q?docs(compatibilite):=20X2=20F39=20de=2020?= =?UTF-8?q?19,=20M2=20F87,=20fl=C3=A8ches=20sur=20la=20F22=20(#285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X2 F39 20i de 2019 (202402191339, sans fil, flèches à la tête haute, discussion #28) ; M2 F87 de 2017 (202207190806, sans fil, #265) ; F22 : flèche et distance de Maps et Waze au compteur par MOST, vues en photo (discussion #268). Liste des README : M2 F87. --- README.fr.md | 2 +- README.md | 2 +- docs/COMPATIBILITE.md | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.fr.md b/README.fr.md index 14c785d..4030ad3 100644 --- a/README.fr.md +++ b/README.fr.md @@ -113,7 +113,7 @@ Signalées fonctionnelles par leurs propriétaires, sans fil, par câble ou les | | Modèles | |---|---| | **Série G** | Série 3 G20 et G21, Série 5 G30, X3 G01 | -| **Série F** | Série 1 F20, F21, F40 et F52 ; Série 2 F22, F44 et F45 ; Série 3 F30 ; X1 F48 et F49 ; X2 F39 | +| **Série F** | Série 1 F20, F21, F40 et F52 ; Série 2 F22, F44 et F45 ; M2 F87 ; Série 3 F30 ; X1 F48 et F49 ; X2 F39 | | **i et MINI** | i3 ; MINI Clubman F54, MINI F56 et F57 | Chaque voiture, avec son logiciel iDrive, son écran, sa liaison et la version essayée, est dans diff --git a/README.md b/README.md index 274590d..b4bcad8 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Reported working by their owners, wireless, over USB or both: | | Models | |---|---| | **G series** | 3 Series G20 and G21, 5 Series G30, X3 G01 | -| **F series** | 1 Series F20, F21, F40 and F52; 2 Series F22, F44 and F45; 3 Series F30; X1 F48 and F49; X2 F39 | +| **F series** | 1 Series F20, F21, F40 and F52; 2 Series F22, F44 and F45; M2 F87; 3 Series F30; X1 F48 and F49; X2 F39 | | **i and MINI** | i3; MINI Clubman F54, MINI F56 and F57 | Each car, with its iDrive software, screen, link and the version tried, is in diff --git a/docs/COMPATIBILITE.md b/docs/COMPATIBILITE.md index e5001d5..56f5a7e 100644 --- a/docs/COMPATIBILITE.md +++ b/docs/COMPATIBILITE.md @@ -26,7 +26,7 @@ rapports de leurs propriétaires : elles disent ce qu'ils ont vu, avec la versio | F20 120i LCI de 2019 | `201811150004` | 1280x480 (écran de 8,8 pouces monté après coup) | USB (unité sans Wi-Fi) | 0.12.1-rc.4 | marche ; bouton vocal sans effet ([discussion #28](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/28)) | | F20 de 07/2018 | `201907031456` | 800x480 | USB ; sans fil lent | 0.13.0-rc.10 | marche ; guidage de Google Maps au compteur 6WA par MOST, venu après avoir coupé puis remis le réglage de la navigation dans l'iDrive, disparu quelques minutes à chaque changement d'itinéraire ([#101](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/101)) | | F21 de 2018 | non indiqué | non relevé | USB | 0.12.1-rc.3 | marche ; commandes vocales lentes, avec AAIdrive installé aussi ([#68](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/68)) | -| F22 218d LCI de 2019 | `201811150004` | 800x480 (6,5 pouces, sans toucher) | USB (unité sans Wi-Fi), aussi par un adaptateur Android Auto sans fil sur l'USB | 0.13.0-rc.13 | marche avec un Pixel 10 : marche arrière et caméra, touches, MEDIA et double MEDIA, MAP et NAV vers la carte, COM ([discussion #268](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/268)) | +| F22 218d LCI de 2019 | `201811150004` | 800x480 (6,5 pouces, sans toucher) | USB (unité sans Wi-Fi), aussi par un adaptateur Android Auto sans fil sur l'USB | 0.13.0-rc.13 | marche avec un Pixel 10 : marche arrière et caméra, touches, MEDIA et double MEDIA, MAP et NAV vers la carte, COM ; flèche et distance de Google Maps et de Waze au compteur par MOST, à la place de l'affichage du milieu (photo) ([discussion #268](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/268)) | | F30 320i de 2018 | `202106151602` | 800x480 | USB (unité sans Wi-Fi) | 0.12.0-rc.6 | marche ([#202](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/202)) | | F30 330d LCI de 2018 | `202402191339` | 1280x480 | sans fil | 0.12.0-rc.6 | marche, ancien contrôleur, pastille du volume ; MAP rendait l'écran à l'iDrive, il ouvre la navigation d'Android Auto depuis 0.13.0-rc.1, pas encore essayé ([#43](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/43)) | | F40 118i de 2019 | `202207190806` | non relevé | USB, sans fil | 0.12.1-rc.4 | marche par câble ; sans-fil très lent avec un Galaxy S25 Ultra ([#71](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/71)) | @@ -34,11 +34,13 @@ rapports de leurs propriétaires : elles disent ce qu'ils ont vu, avec la versio | F45 218i de 2017 | `201907031456` | 1280x480 | USB | 0.12.0 | marche ; pas de guidage au compteur ni à la tête haute : sur les Série F, le compteur n'est pas sur l'Ethernet ([#69](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/69), [#79](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/79)) | | F45 225xe | `202402191339` | 1280x480 | sans fil, USB | 0.13.0-rc.1 | marche ; sans-fil lent au bout de quelques minutes, fluide par câble ; glissements tactiles à l'étude ([discussion #30](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/30)) ; 0.13.0-rc.10 : compteur `HUD_Terminal` trouvé, aucune des six tailles du 6WA n'a répondu, pas encore de flèches au compteur ([#79](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/79)) | | F45 218d de 2018 | `201910211433` | 1280x480 | sans fil | non indiquée | marche après un second appairage (un téléphone appairé quand Android Auto ne tournait pas ne le voit pas, [#72](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/72)) ; par câble, rien avec un Motorola edge 40, marche avec un Galaxy S26 ([#134](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/134)) | +| M2 F87 de 2017 | `202207190806` | 1280x480 | sans fil | non indiquée | marche avec un Pixel 11 Pro, image fluide, après plusieurs appairages ; position GPS qui dérive à l'arrêt ([#265](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/265)) | | X1 F48 de 2018 | `202207190806` | 800x480 | sans fil, USB | 0.13.0-rc.3 | marche ; plus de pastille du volume au toucher en 0.13.0-rc.3 ; démarrage sans fil parfois bloqué ([#72](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/72)) | | X1 F48 | `201802230007` | 1280x480 | sans fil, USB | 0.12.1-rc.4 | marche ; coupures du sans-fil de temps en temps ; pas de guidage à la tête haute : la navigation BMW de ces voitures passe par D-Bus ([#79](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/79)) | | X1 F48 de 2018 | non indiqué | non relevé | sans fil, sans antenne Wi-Fi ajoutée | non indiquée | marche, essayé une fois avec la carte et la musique ([#175](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/175)) | | X1 F48 LCI de 2020 | `202306092158` | 1280x480 | sans fil | 0.13.0-rc.3 | marche avec un OnePlus 13, toucher et molette ; l'iDrive a redémarré une fois de trop juste après l'installation ([#103](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/103)) | | X2 F39 xDrive25e de 2021 | `202106151602` | 1280x480 | USB et sans fil (CarPlay d'usine) | 0.13.0-rc.10 | marche avec un Pixel 8a, installé depuis un Mac par câble ENET ; quelques petits ralentissements sans fil ([discussion #28](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/28)) | +| X2 F39 20i de 2019 | `202402191339` | 1280x480 | sans fil (CarPlay d'usine) | 0.13.0-rc.11 | marche avec un Honor Magic V3, flèches à la tête haute ; lenteur par moments, au départ et quand un écran BMW repasse devant ([discussion #28](https://github.com/Jiraiya43/EntryNav2-Android-Auto/discussions/28)) | | X1 F49 | non indiqué | non relevé | non indiquée | `main` d'après la 0.13.0-rc.10 | distance et rue au compteur 6WA par MOST (photo, [#79](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/79)) | | F52 de 2022 | `202012141616` | 1440x540 | USB et sans fil | 0.13.0-rc.10 avec [#190](https://github.com/Jiraiya43/EntryNav2-Android-Auto/pull/190) | image par câble (1920x1080 demandé au téléphone) ; sans fil, le téléphone fermait la séance quand on lui demandait 1920x1080 : en 1280x720 étiré à l'écran depuis #190, image sur tout l'écran et toucher justes ; pas de guidage sur la tête haute, à l'étude ([#180](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/180)) ; flèches au compteur 6WA par MOST une fois la navigation codée dans l'unité (`main` d'après la 0.13.0-rc.10, [#79](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/79)) | | i3 | `202012141616` | 800x480 | USB ; sans fil, et par un adaptateur Android Auto sur l'USB | 0.13.0-rc.6 | marche, ancien contrôleur ([#19](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/19)) ; sans fil avec un OnePlus 15 après un nouvel appairage ([#133](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/133)) | From 06e17ac93daa4c171778e470aa3bf4fcb0c7e427 Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 21:38:55 +0100 Subject: [PATCH 16/17] =?UTF-8?q?fix(hmiapp):=20couper=20le=20toucher=20de?= =?UTF-8?q?=20l'iDrive=20cach=C3=A9=20sous=20Android=20Auto=20(#286)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sur le logiciel 202402191339 (#266, #203), l'iDrive garde pour lui le port du toucher (UDP 30567) : le service ne peut que copier les trames, et l'iDrive caché sous Android Auto réagissait aussi à chaque toucher. HmiMain3D a son propre interrupteur de l'écran tactile, CHmiInputManager::enableTouchDevice(bool, ETouchDevice 1), celui que sa limitation en roulant tourne (CTouchService::onSpeedLockChanged -> CTouchDataClient::speedlockTouchCID, seulement avec la variante 0x5389). Coupé, CTouchDataClient::forwardTouchDataSync jette les touchers de l'écran. L'appli trouve le gestionnaire au démarrage (hmiplugin::get, derrière la garde des tâches différées) et, quand la page d'Android Auto devient visible sur une unité qui garde le port (essai de liaison au port avec partage refusé), coupe l'interrupteur ; elle le rallume quand la page part ou à onFinalize. Rien sans la variante 0x5389 lue à 0, ni si l'interrupteur était déjà coupé, ni si une fonction manque. Tests : logique avec un gestionnaire simulé, et vérification du port contre des sockets liées comme celles de l'iDrive (gardé / partagé). --- CHANGELOG.en.md | 4 + CHANGELOG.md | 4 + Makefile | 7 +- docs/ARCHITECTURE.md | 3 +- hmiapp/entry_aa_app.cpp | 22 ++++- hmiapp/idrive_coding.cpp | 32 +++++++ hmiapp/idrive_coding.hpp | 14 +++ hmiapp/idrive_touch.cpp | 41 +++++++++ hmiapp/idrive_touch.hpp | 71 +++++++++++++++ tests/test_idrive_lookups.py | 13 ++- tests/test_idrive_touch.cpp | 161 +++++++++++++++++++++++++++++++++++ 11 files changed, 365 insertions(+), 7 deletions(-) create mode 100644 hmiapp/idrive_touch.cpp create mode 100644 hmiapp/idrive_touch.hpp create mode 100644 tests/test_idrive_touch.cpp diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 1082b3d..00692c6 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -13,6 +13,10 @@ QEMU with the car's libraries). ## [Unreleased] +### Fixed + +- Touchscreen, software 202402191339: the iDrive hidden under Android Auto also reacted to every touch. A tap on Android Auto could press what lay under it in iDrive and bring iDrive's screen back ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266), [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). These units keep the touchscreen's port (UDP 30567) to themselves, so the service can only copy it. The iDrive app now switches the touchscreen off for iDrive while Android Auto's page is on screen, with the switch iDrive itself uses for its speed lock (`CHmiInputManager::enableTouchDevice`): iDrive then drops the screen's touches, and the service's copy is not concerned. The screen is switched back on as soon as the page goes (MENU, reverse gear, stop) or the app ends. Nothing changes on units that share the port (the reference G20), nor on a car coded with the screen's speed lock (variant 0x5389), where only that lock may turn the switch. A line in app.log says what the app found (`iDrive touchscreen switch`, `iDrive touchscreen port`). Tested on PC; not yet tried on a 2024 unit. + ## [0.13.0-rc.15] - 2026-12-02 · PC Release candidate: swipes and pinches on F45 with software 202402191339, which reached the phone as taps, diff --git a/CHANGELOG.md b/CHANGELOG.md index b0eb901..fd4b444 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +### Corrigé + +- Écran tactile, logiciel 202402191339 : l'iDrive caché sous Android Auto réagissait aussi à chaque toucher. Un appui sur Android Auto pouvait appuyer sur ce qui se trouvait dessous dans l'iDrive et ramener son écran ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266), [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Ces unités gardent pour elles le port du toucher (UDP 30567), que le service ne peut alors que copier. L'appli de l'iDrive coupe maintenant l'écran tactile pour l'iDrive tant que la page d'Android Auto est à l'écran, avec l'interrupteur que l'iDrive utilise lui-même pour sa limitation en roulant (`CHmiInputManager::enableTouchDevice`) : il jette alors les touchers de l'écran, la copie du service n'est pas concernée. L'écran est rallumé dès que la page part (MENU, marche arrière, arrêt) ou que l'appli se ferme. Rien ne change sur les unités qui partagent le port (la G20 de référence), ni sur une voiture codée avec la limitation en roulant de l'écran (variante 0x5389), où seule cette limitation doit toucher à l'interrupteur. Une ligne d'app.log dit ce que l'appli a trouvé (`iDrive touchscreen switch`, `iDrive touchscreen port`). Testé sur PC ; pas encore essayé sur une unité de 2024. + ## [0.13.0-rc.15] - 2026-12-02 · PC Version candidate : les glissements et le pincement des F45 au logiciel 202402191339, qui arrivaient au diff --git a/Makefile b/Makefile index ad297bc..a247503 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,8 @@ aa-supervisor: $(SUPERVISOR_OBJ) # iDrive PluginApp (installed in /opt/hmi/data/ro/Plugins/EntryAad, loaded by HmiMain3D at boot). Its objects are # position independent and hidden: HmiMain3D only looks up pluginAppInfo, the one symbol the library exports. HMI_SRC = hmiapp/entry_aa_app.cpp hmiapp/bmw_framework.cpp hmiapp/app_log.cpp hmiapp/app_guards.cpp \ - hmiapp/service_link.cpp hmiapp/car_signals.cpp hmiapp/hold_machine.cpp hmiapp/idrive_coding.cpp + hmiapp/service_link.cpp hmiapp/car_signals.cpp hmiapp/hold_machine.cpp hmiapp/idrive_coding.cpp \ + hmiapp/idrive_touch.cpp HMI_OBJ = $(HMI_SRC:.cpp=.o) HMI_LIBDIRS = -L$(SYSROOT)/opt/hmi/lib -Wl,-rpath-link,$(SYSROOT)/opt/hmi/lib hmiapp: hmiapp/libEntryAad.so @@ -192,6 +193,8 @@ test-host: test-parsers test-spp-host test-kombi-host test-gps-host test-capture ./tests/test-hold-machine $(HOST_CXX) $(HOST_FLAGS) tests/test_child_reaper.cpp -o tests/test-child-reaper ./tests/test-child-reaper + $(HOST_CXX) $(HOST_FLAGS) tests/test_idrive_touch.cpp hmiapp/idrive_touch.cpp -o tests/test-idrive-touch + ./tests/test-idrive-touch $(HOST_CXX) $(HOST_FLAGS) tests/test_vtable_check.cpp -o tests/test-vtable-check ./tests/test-vtable-check $(HOST_CXX) $(HOST_FLAGS) tests/test_posted_task.cpp -o tests/test-posted-task @@ -280,6 +283,8 @@ test-unit-sanitizers: ./tests/test-hold-machine $(HOST_CXX) $(HOST_FLAGS) tests/test_child_reaper.cpp -o tests/test-child-reaper ./tests/test-child-reaper + $(HOST_CXX) $(HOST_FLAGS) tests/test_idrive_touch.cpp hmiapp/idrive_touch.cpp -o tests/test-idrive-touch + ./tests/test-idrive-touch $(HOST_CXX) $(HOST_FLAGS) tests/test_vtable_check.cpp -o tests/test-vtable-check ./tests/test-vtable-check $(HOST_CXX) $(HOST_FLAGS) tests/test_pending_restart.cpp -o tests/test-pending-restart diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 00631d3..9c85b60 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -104,7 +104,8 @@ Le protocole Android Auto côté voiture, sans rien de propre à BMW. | `service_link` | Lancement du superviseur, commandes au service, arrêt, copie des journaux et mise à jour par clé USB | | `update_flow.hpp` | Ligne *Mettre à jour par clé USB* : vérification au premier appui, installation au second, arrêt d'Android Auto avant (et relance, une fois arrêté, si rien n'a été installé), textes affichés (classe pure, testée sur PC) | | `car_signals` | Marche arrière, appels, jour et nuit, mode de conduite, lus dans l'iDrive | -| `idrive_coding` | Codage de la voiture lu dans l'iDrive au démarrage de l'appli et écrit pour le service : touches du contrôleur, marque (BMW ou MINI) ; réglage de la fenêtre du mode de conduite, lu pour l'appli | +| `idrive_coding` | Codage de la voiture lu dans l'iDrive au démarrage de l'appli et écrit pour le service : touches du contrôleur, marque (BMW ou MINI) ; réglage de la fenêtre du mode de conduite, lu pour l'appli ; interrupteur de l'écran tactile de l'iDrive (`CHmiInputManager`) et codage de sa limitation en roulant | +| `idrive_touch` | Écran tactile coupé pour l'iDrive tant que la page d'Android Auto est à l'écran, sur les unités qui gardent le port du toucher pour elles (logiciel 202402191339) : l'iDrive caché ne réagit plus aux touchers ; jamais avec la limitation en roulant codée ; rallumé quand la page part ou que l'appli se ferme (testé sur PC, `tests/test_idrive_touch.cpp`) | | `posted_task.hpp` | Tâches différées de l'appli marquées pendant qu'elles tournent : les lectures de l'iDrive (cache par fil de HmiMain3D) y sont refusées, elles arrêteraient son fil (testé sur PC, `tests/test_idrive_lookups.py` garde ces lectures dans `idrive_coding`) | | `app_guards` | Interrupteur, garde-fou contre les plantages, démarrage automatique, cases du menu | | `guard_file.hpp` | Fichiers des deux garde-fous : seuls comptent les évènements des 15 dernières minutes que la marche n'a pas suivis (ou du même démarrage de l'unité), fichier remplacé d'un coup (testé sur PC) | diff --git a/hmiapp/entry_aa_app.cpp b/hmiapp/entry_aa_app.cpp index d1cb70c..aafedcf 100644 --- a/hmiapp/entry_aa_app.cpp +++ b/hmiapp/entry_aa_app.cpp @@ -43,6 +43,7 @@ #include "car_signals.hpp" #include "hold_machine.hpp" #include "idrive_coding.hpp" +#include "idrive_touch.hpp" #include "mono_clock.hpp" #include "pending_restart.hpp" #include "rhmi_ids.hpp" @@ -97,6 +98,21 @@ class AppHoldIo : public HoldIo { AppHoldIo g_holdIo; HoldMachine g_hold(g_holdIo); +// ---- iDrive's touchscreen, switched off for iDrive while Android Auto is on screen (hmiapp/idrive_touch.hpp) +// ---------- +TouchSwitchHolder g_touch; +int g_touchPortKept = -1; // asked once per iDrive start: 1 kept by iDrive, 0 shared with the service +bool touchPortKeptOnce() { + if (g_touchPortKept < 0) { + g_touchPortKept = touchPortKept() ? 1 : 0; + alog("iDrive touchscreen port %s", g_touchPortKept + ? "kept by iDrive: iDrive's touch is off while Android Auto is " + "on screen" + : "shared with the service: iDrive's touch left as it is"); + } + return g_touchPortKept == 1; +} + // iDrive's focus on the blank state, our menu or its Help page, handed to the hold machine. bool onAaFocus(void*, const bmw::Parcel& p) { try { @@ -110,7 +126,9 @@ bool onAaFocus(void*, const bmw::Parcel& p) { } bool onAaVisible(void*, const bmw::Parcel& p) { try { - g_hold.aaVisible(parcelBool(p), monoSeconds()); + const bool visible = parcelBool(p); + g_hold.aaVisible(visible, monoSeconds()); + g_touch.shown(visible, &touchPortKeptOnce); } catch (abi::__forced_unwind&) { throw; // a thread being cancelled } catch (...) { @@ -614,6 +632,7 @@ bool appOnInit(bmw::PluginApp* self) { bool ok = self->onInit(); writeIdriveCoding(); // the car's keys, brand and driver's side, for the service readDriveModePopup(); // only logged here: read again at each driving mode change + g_touch.set(findTouchSwitch()); alog("onInit: handlers registered, base onInit -> %d, start automatically %s, USB cable %s", static_cast(ok), autostartOn() ? "on" : "off", usbCableOn() ? "on" : "off"); g_runApp = self; @@ -645,6 +664,7 @@ void appOnFinalize(bmw::PluginApp* self) { try { alog("onFinalize"); g_runApp = nullptr; + g_touch.release(); // iDrive gets its touchscreen back, whatever was on screen detachCarSignals(); self->onFinalize(); } catch (abi::__forced_unwind&) { diff --git a/hmiapp/idrive_coding.cpp b/hmiapp/idrive_coding.cpp index 5f12a54..8a3a96d 100644 --- a/hmiapp/idrive_coding.cpp +++ b/hmiapp/idrive_coding.cpp @@ -252,5 +252,37 @@ DriveModePopup readDriveModePopup() { return popup; } +namespace { +// HmiMain3D's exported names (nm -D on the G20's copy): the instance cache's two steps for CHmiInputManager, as for the +// variant server above, and the two member functions (this in r0, then the arguments). +const char kInputGetUsage[] = "_ZN9hmiplugin3getI16CHmiInputManagerEENS_25CPluginInstanceCacheUsageIT_EEv"; +const char kInputUsageGet[] = "_ZNK9hmiplugin25CPluginInstanceCacheUsageI16CHmiInputManagerE3getEv"; +const char kEnableTouchDevice[] = "_ZN16CHmiInputManager17enableTouchDeviceEb12ETouchDevice"; +const char kIsTouchDeviceEnabled[] = "_ZN16CHmiInputManager20isTouchDeviceEnabledE12ETouchDevice"; +const unsigned kVariantCidSpeedLock = 0x5389; // the screen's speed lock (CTouchService::onSpeedLockChanged) +} // namespace + +IdriveTouchSwitch findTouchSwitch() { + IdriveTouchSwitch sw = {nullptr, nullptr, nullptr, -1}; + static bool refusalLogged = false; + if (lookupRefused("touchscreen switch", refusalLogged)) { + return sw; // nothing found: iDrive's touch is left as it is + } + GetUsageFn getUsage = reinterpret_cast(dlsym(RTLD_DEFAULT, kInputGetUsage)); + UsageGetFn usageGet = reinterpret_cast(dlsym(RTLD_DEFAULT, kInputUsageGet)); + if (getUsage && usageGet) { + const uintptr_t usage = getUsage(); + sw.manager = usageGet(&usage); + } + sw.enable = reinterpret_cast(dlsym(RTLD_DEFAULT, kEnableTouchDevice)); + sw.isEnabled = reinterpret_cast(dlsym(RTLD_DEFAULT, kIsTouchDeviceEnabled)); + VariantServer server; + sw.speedLockCoded = server.find(false) ? (server.isSet(kVariantCidSpeedLock) ? 1 : 0) : -1; + alog("iDrive touchscreen switch: %s, %s; speed lock coding (0x5389) %s", + sw.manager ? "manager found" : "no manager", + sw.enable && sw.isEnabled ? "its functions found" : "its functions missing", readText(sw.speedLockCoded)); + return sw; +} + } // namespace app } // namespace evo diff --git a/hmiapp/idrive_coding.hpp b/hmiapp/idrive_coding.hpp index e181605..2d975d7 100644 --- a/hmiapp/idrive_coding.hpp +++ b/hmiapp/idrive_coding.hpp @@ -32,6 +32,20 @@ struct DriveModePopup { }; DriveModePopup readDriveModePopup(); +// iDrive's own touchscreen switch, CHmiInputManager::enableTouchDevice(bool, ETouchDevice): the one its speed lock +// turns (CTouchDataClient::speedlockTouchCID, called by CTouchService::onSpeedLockChanged only on a car coded with +// variant 0x5389). Switched off, iDrive drops every frame of that device: CTouchDataClient::forwardTouchDataSync asks +// isTouchDeviceEnabled first. The manager comes from iDrive's instance cache, hmiplugin::get(), the +// two functions by their exported names; any of them missing: null. speedLockCoded: variant 0x5389, 1 or 0, -1 when it +// could not be read. Logged. Called like writeIdriveCoding() (null inside a posted task). +struct IdriveTouchSwitch { + void* manager; + void (*enable)(void* manager, bool on, int device); + bool (*isEnabled)(void* manager, int device); + int speedLockCoded; +}; +IdriveTouchSwitch findTouchSwitch(); + } // namespace app } // namespace evo diff --git a/hmiapp/idrive_touch.cpp b/hmiapp/idrive_touch.cpp new file mode 100644 index 0000000..e275780 --- /dev/null +++ b/hmiapp/idrive_touch.cpp @@ -0,0 +1,41 @@ +// Copyright (c) 2026 Jiraiya43 +// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 +#include "idrive_touch.hpp" + +#include +#include +#include +#include +#include + +#ifndef SO_REUSEPORT +#define SO_REUSEPORT 15 +#endif + +namespace evo { +namespace app { + +namespace { +const unsigned short kTouchPort = 30567; // the touchscreen's frames (platform/evo_touch.cpp) +} // namespace + +bool touchPortKept() { + const int s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); + if (s < 0) { + return false; + } + const int one = 1; + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)); + sockaddr_in a; + memset(&a, 0, sizeof(a)); + a.sin_family = AF_INET; + a.sin_port = htons(kTouchPort); + a.sin_addr.s_addr = htonl(INADDR_ANY); + const bool kept = bind(s, reinterpret_cast(&a), sizeof(a)) != 0 && errno == EADDRINUSE; + close(s); + return kept; +} + +} // namespace app +} // namespace evo diff --git a/hmiapp/idrive_touch.hpp b/hmiapp/idrive_touch.hpp new file mode 100644 index 0000000..b580018 --- /dev/null +++ b/hmiapp/idrive_touch.hpp @@ -0,0 +1,71 @@ +// Copyright (c) 2026 Jiraiya43 +// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 +// iDrive's touchscreen switched off for iDrive while Android Auto's page is on screen, on the units that keep the +// touchscreen's port to themselves. +// +// The service reads the touch frames from a copy (platform/evo_touch.hpp). Where it can also take the port, iDrive gets +// no touch while the picture is ours (the reference G20). Where it cannot (software 202402191339, #266 and #203), the +// hidden iDrive acted on every touch too: a tap on Android Auto could press what lay under it on +// iDrive's page and bring iDrive's own screen back. There, the app turns off the switch iDrive's speed lock uses +// (idrive_coding.hpp, IdriveTouchSwitch) when the page shows, and turns it back on as soon as it leaves, or when the +// app ends. Never on a car coded with that speed lock: only the lock turns this switch there, and leaving Android Auto +// must not turn the touchscreen back on while the lock wants it off. Nothing is done when the switch was already off. +// Called from iDrive's handlers (the page's visibility) and onFinalize, on iDrive's own thread. No I/O here but the +// port check (idrive_touch.cpp); tested in tests/test_idrive_touch.cpp. +#ifndef ENTRY_AAD_HMIAPP_IDRIVE_TOUCH_HPP +#define ENTRY_AAD_HMIAPP_IDRIVE_TOUCH_HPP + +#include "idrive_coding.hpp" + +namespace evo { +namespace app { + +// ETouchDevice of the screen: the device CTouchDataClient::speedlockTouchCID switches. +const int kTouchScreenDevice = 1; + +// Whether iDrive keeps the touchscreen's UDP port to itself: a socket that asks to share it, as the service's does, is +// refused. Opened and closed at once. +bool touchPortKept(); + +class TouchSwitchHolder { +public: + enum Action { kNothing, kTurnedOff, kTurnedOn }; + + TouchSwitchHolder() : sw_(), holding_(false) {} + void set(const IdriveTouchSwitch& sw) { sw_ = sw; } + // Everything found, and no speed lock coded on this car. + bool usable() const { return sw_.manager && sw_.enable && sw_.isEnabled && sw_.speedLockCoded == 0; } + bool holding() const { return holding_; } + + // Android Auto's page shown or gone. portKept is asked only when the switch would be turned off. + Action shown(bool visible, bool (*portKept)()) { + if (!visible) { + return release(); + } + if (holding_ || !usable() || !portKept || !portKept() || !sw_.isEnabled(sw_.manager, kTouchScreenDevice)) { + return kNothing; + } + sw_.enable(sw_.manager, false, kTouchScreenDevice); + holding_ = true; + return kTurnedOff; + } + + // Back on, if the app turned it off. + Action release() { + if (!holding_) { + return kNothing; + } + sw_.enable(sw_.manager, true, kTouchScreenDevice); + holding_ = false; + return kTurnedOn; + } + +private: + IdriveTouchSwitch sw_; + bool holding_; +}; + +} // namespace app +} // namespace evo + +#endif // ENTRY_AAD_HMIAPP_IDRIVE_TOUCH_HPP diff --git a/tests/test_idrive_lookups.py b/tests/test_idrive_lookups.py index 81b6644..1c2f2c2 100644 --- a/tests/test_idrive_lookups.py +++ b/tests/test_idrive_lookups.py @@ -3,8 +3,8 @@ """iDrive's per-thread lookups stay behind the posted-task guard (hmiapp/posted_task.hpp). hmiplugin::get<...>() and HmiMain3D's instance cache only work outside the app's posted tasks. The app asks them in one -place, hmiapp/idrive_coding.cpp, whose two entry points refuse to run inside a posted task; and the app's runnables run -marked. A lookup added anywhere else, or the guard or the marking dropped, fails here before it reaches a car. +place, hmiapp/idrive_coding.cpp, whose three entry points refuse to run inside a posted task; and the app's runnables +run marked. A lookup added anywhere else, or the guard or the marking dropped, fails here before it reaches a car. """ import re @@ -31,10 +31,15 @@ def main(): home = (ROOT / HOME).read_text(encoding="utf-8") if '#include "posted_task.hpp"' not in home: problems.append(f"{HOME} does not include posted_task.hpp") - for signature in ("bool writeIdriveCoding() {", "DriveModePopup readDriveModePopup() {"): + for signature in ( + "bool writeIdriveCoding() {", + "DriveModePopup readDriveModePopup() {", + "IdriveTouchSwitch findTouchSwitch() {", + ): body = entry_body(home, signature) if signature in home else "" guard = body.find("lookupRefused(") - first_lookup = min([i for i in (body.find("VariantServer"), body.find("readPopupSetting(")) if i >= 0] or [-1]) + lookups = (body.find("VariantServer"), body.find("readPopupSetting("), body.find("dlsym(")) + first_lookup = min([i for i in lookups if i >= 0] or [-1]) if guard < 0 or (first_lookup >= 0 and first_lookup < guard): problems.append(f"{HOME}: {signature[:-2]} does not refuse a posted task before its lookups") framework = (ROOT / "hmiapp/bmw_framework.cpp").read_text(encoding="utf-8") diff --git a/tests/test_idrive_touch.cpp b/tests/test_idrive_touch.cpp new file mode 100644 index 0000000..6a59326 --- /dev/null +++ b/tests/test_idrive_touch.cpp @@ -0,0 +1,161 @@ +// Copyright (c) 2026 Jiraiya43 +// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 +// iDrive's touchscreen switched off for iDrive while Android Auto is on screen (hmiapp/idrive_touch.hpp), with a +// stand-in for iDrive's input manager, and the port check against sockets bound as iDrive's are. +#include +#include +#include +#include +#include +#include + +#include "../hmiapp/idrive_touch.hpp" + +#ifndef SO_REUSEPORT +#define SO_REUSEPORT 15 +#endif + +using evo::app::IdriveTouchSwitch; +using evo::app::TouchSwitchHolder; + +static int failures = 0; +#define CHECK(x) \ + do { \ + if (!(x)) { \ + printf("FAIL line %d: %s\n", __LINE__, #x); \ + ++failures; \ + } \ + } while (0) + +// A stand-in for CHmiInputManager: one switch per device, all on, as its constructor leaves them. +struct FakeManager { + bool on[6]; + unsigned calls; +}; +static void fakeEnable(void* self, bool on, int device) { + FakeManager* m = static_cast(self); + m->on[device] = on; + ++m->calls; +} +static bool fakeIsEnabled(void* self, int device) { + return static_cast(self)->on[device]; +} +static unsigned portAsked = 0; +static bool kept() { + ++portAsked; + return true; +} +static bool shared() { + ++portAsked; + return false; +} + +static IdriveTouchSwitch found(FakeManager& m, int speedLockCoded) { + for (int i = 0; i < 6; ++i) { + m.on[i] = true; + } + m.calls = 0; + IdriveTouchSwitch sw = {&m, &fakeEnable, &fakeIsEnabled, speedLockCoded}; + return sw; +} + +// A UDP socket on port, bound as iDrive binds its touchscreen's: with or without asking to share it. +static int bindTouchPort(unsigned short port, bool share) { + const int s = socket(AF_INET, SOCK_DGRAM, 0); + const int one = 1; + if (share) { + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); + setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)); + } + sockaddr_in a; + memset(&a, 0, sizeof(a)); + a.sin_family = AF_INET; + a.sin_port = htons(port); + a.sin_addr.s_addr = htonl(INADDR_ANY); + if (bind(s, reinterpret_cast(&a), sizeof(a)) != 0) { + close(s); + return -1; + } + return s; +} + +int main() { + FakeManager m; + // A unit that keeps the port (software 202402191339): off while the page shows, back on when it goes. + { + TouchSwitchHolder t; + t.set(found(m, 0)); + CHECK(t.usable()); + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kTurnedOff && !m.on[1] && t.holding()); + CHECK(m.on[0] && m.on[2]); // the other devices (touchpad, gesture camera) untouched + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kNothing && m.calls == 1); // shown again: once + CHECK(t.shown(false, &kept) == TouchSwitchHolder::kTurnedOn && m.on[1] && !t.holding()); + CHECK(t.shown(false, &kept) == TouchSwitchHolder::kNothing && m.calls == 2); + // The app ends with the page on screen: iDrive gets its touchscreen back. + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kTurnedOff && !m.on[1]); + CHECK(t.release() == TouchSwitchHolder::kTurnedOn && m.on[1]); + CHECK(t.release() == TouchSwitchHolder::kNothing); + } + // A unit that shares the port (the reference G20): nothing changes, the port asked each time until it is kept. + { + TouchSwitchHolder t; + t.set(found(m, 0)); + portAsked = 0; + CHECK(t.shown(true, &shared) == TouchSwitchHolder::kNothing && m.on[1] && m.calls == 0 && portAsked == 1); + CHECK(t.shown(false, &shared) == TouchSwitchHolder::kNothing && portAsked == 1); // not asked when it goes + } + // Speed lock coded, or unread: never touched, the port not even asked. + for (int coded = -1; coded <= 1; coded += 2) { + TouchSwitchHolder t; + t.set(found(m, coded)); + portAsked = 0; + CHECK(!t.usable()); + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kNothing && m.on[1] && m.calls == 0 && portAsked == 0); + } + // Already off when the page shows (iDrive's own reasons): left off, and not turned on when the page goes. + { + TouchSwitchHolder t; + t.set(found(m, 0)); + m.on[1] = false; + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kNothing && !t.holding()); + CHECK(t.shown(false, &kept) == TouchSwitchHolder::kNothing && !m.on[1] && m.calls == 0); + } + // Anything missing (another iDrive build, or nothing found): never touched. + { + IdriveTouchSwitch none = {nullptr, nullptr, nullptr, -1}; + TouchSwitchHolder t; + CHECK(!t.usable() && t.shown(true, &kept) == TouchSwitchHolder::kNothing); // never set + t.set(none); + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kNothing && t.release() == TouchSwitchHolder::kNothing); + IdriveTouchSwitch noFunctions = found(m, 0); + noFunctions.enable = nullptr; + t.set(noFunctions); + CHECK(t.shown(true, &kept) == TouchSwitchHolder::kNothing && m.on[1]); + CHECK(t.shown(true, nullptr) == TouchSwitchHolder::kNothing); + } + // The port check, against sockets bound as iDrive's: kept when bound without sharing, free or shared otherwise. + { + const unsigned short port = 30567; + const int free = bindTouchPort(port, true); + if (free < 0) { + printf("SKIP port check: UDP %u already in use on this machine\n", port); + } else { + close(free); + CHECK(!evo::app::touchPortKept()); // nobody on it + const int sharing = bindTouchPort(port, true); + CHECK(sharing >= 0 && !evo::app::touchPortKept()); // as on the G20: shared + close(sharing); + const int keeping = bindTouchPort(port, false); + CHECK(keeping >= 0 && evo::app::touchPortKept()); // as on 202402191339: kept + close(keeping); + } + } + if (failures) { + return 1; + } + printf( + "PASS iDrive touchscreen switch: off while Android Auto shows on a unit that keeps the port, back on when it " + "goes " + "or the app ends, never with the speed lock coded, already off or anything missing; port check kept/shared\n"); + return 0; +} From 6a39e68aac5eb248ee39a8f70145ebf12c2b840b Mon Sep 17 00:00:00 2001 From: Jiraiya43 <11227856+Jiraiya43@users.noreply.github.com> Date: Wed, 2 Dec 2026 22:12:12 +0100 Subject: [PATCH 17/17] chore: version 0.13.0-rc.16 (#287) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Version candidate : toucher de l'iDrive caché coupé tant qu'Android Auto est à l'écran, sur le logiciel 202402191339 (#286). VERSION, journal des versions fr/en, commandes d'installation, modèle de ticket. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- CHANGELOG.en.md | 8 +++++++- CHANGELOG.md | 6 ++++++ VERSION | 2 +- docs/INSTALLATION.en.md | 4 ++-- docs/INSTALLATION.md | 4 ++-- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 3add253..bd1a0b1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -12,7 +12,7 @@ body: label: Project version description: The release you installed, or the commit you built. From 0.13.0-rc.10, the title of the Help page in the Android Auto menu shows it. - placeholder: 0.13.0-rc.15 + placeholder: 0.13.0-rc.16 validations: required: true - type: input diff --git a/CHANGELOG.en.md b/CHANGELOG.en.md index 00692c6..e1f7840 100644 --- a/CHANGELOG.en.md +++ b/CHANGELOG.en.md @@ -2,7 +2,7 @@ > [!IMPORTANT] > This is a translation of the authoritative [French changelog](CHANGELOG.md), based on -> [`v0.13.0-rc.15`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.15/CHANGELOG.md). +> [`v0.13.0-rc.16`](https://github.com/Jiraiya43/EntryNav2-Android-Auto/blob/v0.13.0-rc.16/CHANGELOG.md). > It may become outdated; consult the French changelog for the source of truth. All notable changes to this project. Format inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), @@ -13,6 +13,12 @@ QEMU with the car's libraries). ## [Unreleased] +## [0.13.0-rc.16] - 2026-12-02 · PC + +Release candidate: on software 202402191339, the iDrive hidden under Android Auto no longer reacts to +touches; its touchscreen is switched off for it while Android Auto is on screen, then given back. Installs +from a USB stick since 0.13.0-rc.10. Tested on PC and under QEMU; not yet tried on a 2024 unit. + ### Fixed - Touchscreen, software 202402191339: the iDrive hidden under Android Auto also reacted to every touch. A tap on Android Auto could press what lay under it in iDrive and bring iDrive's screen back ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266), [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). These units keep the touchscreen's port (UDP 30567) to themselves, so the service can only copy it. The iDrive app now switches the touchscreen off for iDrive while Android Auto's page is on screen, with the switch iDrive itself uses for its speed lock (`CHmiInputManager::enableTouchDevice`): iDrive then drops the screen's touches, and the service's copy is not concerned. The screen is switched back on as soon as the page goes (MENU, reverse gear, stop) or the app ends. Nothing changes on units that share the port (the reference G20), nor on a car coded with the screen's speed lock (variant 0x5389), where only that lock may turn the switch. A line in app.log says what the app found (`iDrive touchscreen switch`, `iDrive touchscreen port`). Tested on PC; not yet tried on a 2024 unit. diff --git a/CHANGELOG.md b/CHANGELOG.md index fd4b444..d98ee43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ QEMU avec les bibliothèques de la voiture). ## [Non publié] +## [0.13.0-rc.16] - 2026-12-02 · PC + +Version candidate : sur le logiciel 202402191339, l'iDrive caché sous Android Auto ne réagit plus aux +touchers ; son écran tactile lui est coupé tant qu'Android Auto est à l'écran, puis rendu. S'installe par +clé USB depuis la 0.13.0-rc.10. Testée sur PC et sous QEMU ; pas encore essayée sur une unité de 2024. + ### Corrigé - Écran tactile, logiciel 202402191339 : l'iDrive caché sous Android Auto réagissait aussi à chaque toucher. Un appui sur Android Auto pouvait appuyer sur ce qui se trouvait dessous dans l'iDrive et ramener son écran ([#266](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/266), [#203](https://github.com/Jiraiya43/EntryNav2-Android-Auto/issues/203)). Ces unités gardent pour elles le port du toucher (UDP 30567), que le service ne peut alors que copier. L'appli de l'iDrive coupe maintenant l'écran tactile pour l'iDrive tant que la page d'Android Auto est à l'écran, avec l'interrupteur que l'iDrive utilise lui-même pour sa limitation en roulant (`CHmiInputManager::enableTouchDevice`) : il jette alors les touchers de l'écran, la copie du service n'est pas concernée. L'écran est rallumé dès que la page part (MENU, marche arrière, arrêt) ou que l'appli se ferme. Rien ne change sur les unités qui partagent le port (la G20 de référence), ni sur une voiture codée avec la limitation en roulant de l'écran (variante 0x5389), où seule cette limitation doit toucher à l'interrupteur. Une ligne d'app.log dit ce que l'appli a trouvé (`iDrive touchscreen switch`, `iDrive touchscreen port`). Testé sur PC ; pas encore essayé sur une unité de 2024. diff --git a/VERSION b/VERSION index f0a7880..29468fa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.13.0-rc.15 +0.13.0-rc.16 diff --git a/docs/INSTALLATION.en.md b/docs/INSTALLATION.en.md index 1421068..b5ed6ef 100644 --- a/docs/INSTALLATION.en.md +++ b/docs/INSTALLATION.en.md @@ -38,7 +38,7 @@ the one in its archive (in 0.10.0, the supervisor is called `evo-trial`, not `aa From the PC, in the archive's folder: ```sh -scp entrynav2-android-auto-0.13.0-rc.15-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.16-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -50,7 +50,7 @@ flash memory yet. Nothing is changed during this step. ```sh -V=0.13.0-rc.15 +V=0.13.0-rc.16 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version diff --git a/docs/INSTALLATION.md b/docs/INSTALLATION.md index 2832c41..c8a09be 100644 --- a/docs/INSTALLATION.md +++ b/docs/INSTALLATION.md @@ -33,7 +33,7 @@ ancienne, suivre celle de l'archive (dans la 0.10.0, le superviseur s'appelle `e Depuis le PC, dans le dossier de l'archive : ```sh -scp entrynav2-android-auto-0.13.0-rc.15-armhf.tar root@169.254.1.0:/tmp/ +scp entrynav2-android-auto-0.13.0-rc.16-armhf.tar root@169.254.1.0:/tmp/ ssh root@169.254.1.0 ``` @@ -45,7 +45,7 @@ encore écrit sur la mémoire flash. Rien n'est modifié pendant cette étape. ```sh -V=0.13.0-rc.15 +V=0.13.0-rc.16 cd /tmp && rm -rf entrynav2-android-auto-$V && tar -xf entrynav2-android-auto-$V-armhf.tar && cd entrynav2-android-auto-$V md5sum -c MD5SUMS head -n 1 /etc/version