Linux + iPhone Continuity / iMessage / SMS
fix: disabling notification mirroring breaks some messages
Zack Bartel76a406b093be
diff --git a/docs/BLUETOOTH.md b/docs/BLUETOOTH.mdindex 93e1ced..1c9df65 100644--- a/docs/BLUETOOTH.md+++ b/docs/BLUETOOTH.md@@ -122,6 +122,12 @@ Settings -> Bluetooth -> (i) for the computer's entry. Off by default.- A failed pairing can leave two records for the same computer, the toggles may appearunder either one. Check both, and delete both before retrying a clean pairing.+Mirroring can be turned off without losing messages or contacts -- they ride BR/EDR OBEX, not the+LE bearer ANCS needs. Group threads are the exception: MAP gives them no conversation identifier,+so they are recognised only by correlating a Messages notification. Note also that the phone's+toggles surface only while the advert is broadcasting, so a permission that has to be re-granted+needs mirroring on to ask for it.+Without the relevant permission, MAP or PBAP is visible at the SDP level but rejects theOBEX connection with `Forbidden` / `0x43`. That is a permissions state, not a pairingfailure (do not re-pair). A transport-level `Connection refused (111)` is different and@@ -163,6 +169,7 @@ checks the daemon does not make.| LE never connects and the log repeats `org.bluez.Error.InProgress` | BlueZ is holding an auto-connect registration that never completed | `sudo systemctl restart bluetooth` -- nothing short of that clears it, see 2026-08-19 below. With `tether-btclass@hci0` enabled the class survives the restart || The log says `could not re-arm the ANCS solicitation` | BlueZ refused to register the advertisement, so nothing is on air for the iPhone to answer | `sudo systemctl restart bluetooth`. Nothing else brings it back, and the LE link cannot form without it || LE never connects and the log repeats `le-connection-abort-by-local` | Something on this side is cancelling the connection. Tether's own cause was a `PreferredBearer` write racing the async connect, fixed; anything else writing that property during a connect will do the same | Check no other Bluetooth tool is driving the same device. The phone is not the cause: `abort-by-local` means the local host cancelled |+| Messages stopped after turning notification mirroring off | Fixed. The toggle used to restart supervision, which abandoned the MAP and PBAP sessions at obexd instead of removing them, and the iPhone serves one MAP session at a time | Nothing. Mirroring is switched in place now, and a dropped profile supervisor releases its sessions. On an older build, restart `tetherd` || Notifications stopped and never came back, while messages and contacts kept working | Fixed. The bearer supervisor used to stop retrying LE after six attempts, and only a Classic drop or a daemon restart re-armed it | Nothing. The solicitation is kept on air whenever LE is down, which is what the iPhone answers -- see 2026-08-22 || `tether --bt-status` reports `Bond: BR/EDR only` | The bond was made without cross-transport key derivation, so it has no LE half and can never carry ANCS | Forget this computer on the iPhone and pair again -- it can take more than one attempt, the derivation is flaky on identical inputs (2026-08-25). Check `secure-connections` in the same output first: re-pairing cannot help while it is off || Walked back into range and nothing reconnected for minutes | Fixed. The ANCS advert was gated on the Classic link, and the Classic backoff had no event that ended the absence | Nothing. The advert stays on air whenever LE is down, and an LE link coming up clears the Classic backoff -- see 2026-08-22 |@@ -1340,3 +1347,29 @@ did not derive. This is the first capture of what a `Device1.Pair()` bond yieldswhat the `ConnectFirst` comment in `config.hpp` claimed without evidence. One sample, on acontroller whose cross-transport derivation is already known to be flaky, so it is not yet proofthat explicit-pair cannot produce a dual bond.++### 2026-08-29 - Turning mirroring off took messages down with it++Reported as #64: unchecking "Mirror iPhone notifications" stopped message send and receive, which+read as notifications being a dependency of messages. They are not -- ANCS rides LE, MAP and PBAP+ride BR/EDR OBEX -- and two separate things made it look like one.++`bt_set_ancs` applied the preference by restarting the whole supervision stack+(`set_device()` -> `stop()` + `start()`), so a setting about LE tore down the OBEX sessions+messages ride on. `stop()` never called `profiles->reset()` and `ProfileSupervisor` had no+destructor, so those sessions were abandoned at obexd rather than removed. The iPhone serves one+MAP session at a time, so the reopen could come back `Connection refused (111)` or `forbidden`,+and `send_message()` then reported "Messages are not connected" until `tetherd` restarted. Every+`set_device()` caller leaked the same way: pairing, the Bluetooth on/off checkbox, and the+capability re-read that fires on BlueZ events.++Fixed:++- `ProfileSupervisor` releases both sessions in its destructor. That covers every path that drops+ one, not just this toggle.+- `ConnectionManager::set_ancs_enabled()` records the preference; the supervisor thread applies+ it on its next tick -- the bearer supervisor's flag, the ANCS client, and the solicitation. The+ profile supervisor is not touched. The preference and the controller's capability are re-read+ every tick, so `refresh_capability()` had nothing left to do and is gone.+- Group replies follow `ancs_enabled`, not only `ancs_content_enabled`. With mirroring off the+ correlator is never fed, so a group thread that still advertised a reply route could only fail.diff --git a/po/cs.po b/po/cs.poindex 4b75fe7..1e94aa3 100644--- a/po/cs.po+++ b/po/cs.po@@ -606,7 +606,9 @@ msgstr "Skupinové odpovědi jsou vypnuté."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Do této skupiny napsal někdo, kdo není v jejím uloženém seznamu členů, takže seznam je zastaralý. Před odpovědí jej aktualizujte v souboru groups.json."+msgstr ""+"Do této skupiny napsal někdo, kdo není v jejím uloženém seznamu členů, takže "+"seznam je zastaralý. Před odpovědí jej aktualizujte v souboru groups.json."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/de.po b/po/de.poindex 01fcfc3..553865f 100644--- a/po/de.po+++ b/po/de.po@@ -614,7 +614,10 @@ msgstr "Antworten in Gruppen sind ausgeschaltet."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Jemand, der nicht in der gespeicherten Mitgliederliste dieser Gruppe steht, hat darin geschrieben. Die Liste ist also veraltet. Aktualisieren Sie sie in groups.json, bevor Sie antworten."+msgstr ""+"Jemand, der nicht in der gespeicherten Mitgliederliste dieser Gruppe steht, "+"hat darin geschrieben. Die Liste ist also veraltet. Aktualisieren Sie sie in "+"groups.json, bevor Sie antworten."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/es.po b/po/es.poindex adeb43c..1de7b61 100644--- a/po/es.po+++ b/po/es.po@@ -611,7 +611,10 @@ msgstr "Las respuestas a grupos están desactivadas."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Alguien que no está en la lista de miembros guardada de este grupo ha escrito en él, así que la lista está desactualizada. Actualícela en groups.json antes de responder."+msgstr ""+"Alguien que no está en la lista de miembros guardada de este grupo ha "+"escrito en él, así que la lista está desactualizada. Actualícela en "+"groups.json antes de responder."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/fr.po b/po/fr.poindex 8ea77f1..76cec9a 100644--- a/po/fr.po+++ b/po/fr.po@@ -614,7 +614,10 @@ msgstr "Les réponses aux groupes sont désactivées."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Quelqu'un qui ne figure pas dans la liste des membres enregistrée de ce groupe y a écrit ; la liste est donc obsolète. Mettez-la à jour dans groups.json avant de répondre."+msgstr ""+"Quelqu'un qui ne figure pas dans la liste des membres enregistrée de ce "+"groupe y a écrit ; la liste est donc obsolète. Mettez-la à jour dans "+"groups.json avant de répondre."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/it.po b/po/it.poindex f2343f3..90aaf14 100644--- a/po/it.po+++ b/po/it.po@@ -612,7 +612,10 @@ msgstr "Le risposte di gruppo sono disattivate."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Qualcuno che non è nell'elenco dei membri salvato di questo gruppo vi ha scritto, quindi l'elenco non è aggiornato. Aggiornalo in groups.json prima di rispondere."+msgstr ""+"Qualcuno che non è nell'elenco dei membri salvato di questo gruppo vi ha "+"scritto, quindi l'elenco non è aggiornato. Aggiornalo in groups.json prima "+"di rispondere."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/ja.po b/po/ja.poindex 3e5aafb..25369c4 100644--- a/po/ja.po+++ b/po/ja.po@@ -588,7 +588,9 @@ msgstr "グループへの返信はオフになっています。"msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "このグループの保存済みメンバーリストにない相手が投稿したため、リストが古くなっています。返信する前に groups.json で更新してください。"+msgstr ""+"このグループの保存済みメンバーリストにない相手が投稿したため、リストが古く"+"なっています。返信する前に groups.json で更新してください。"#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/ko.po b/po/ko.poindex e329293..ee0572d 100644--- a/po/ko.po+++ b/po/ko.po@@ -586,7 +586,9 @@ msgstr "그룹 답장이 꺼져 있습니다."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "이 그룹의 저장된 구성원 목록에 없는 사람이 글을 보냈으므로 목록이 오래되었습니다. 답장하기 전에 groups.json에서 업데이트하세요."+msgstr ""+"이 그룹의 저장된 구성원 목록에 없는 사람이 글을 보냈으므로 목록이 오래되었습"+"니다. 답장하기 전에 groups.json에서 업데이트하세요."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/nl.po b/po/nl.poindex 7564b24..4a36e1b 100644--- a/po/nl.po+++ b/po/nl.po@@ -605,7 +605,10 @@ msgstr "Groepsantwoorden staan uit."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Iemand die niet in de opgeslagen ledenlijst van deze groep staat, heeft erin geschreven, dus de lijst is verouderd. Werk hem bij in groups.json voordat u antwoordt."+msgstr ""+"Iemand die niet in de opgeslagen ledenlijst van deze groep staat, heeft erin "+"geschreven, dus de lijst is verouderd. Werk hem bij in groups.json voordat u "+"antwoordt."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/pl.po b/po/pl.poindex 07d5b45..364cfe4 100644--- a/po/pl.po+++ b/po/pl.po@@ -610,7 +610,10 @@ msgstr "Odpowiedzi grupowe są wyłączone."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Do tej grupy napisał ktoś, kogo nie ma na jej zapisanej liście członków, więc lista jest nieaktualna. Zaktualizuj ją w pliku groups.json przed odpowiedzią."+msgstr ""+"Do tej grupy napisał ktoś, kogo nie ma na jej zapisanej liście członków, "+"więc lista jest nieaktualna. Zaktualizuj ją w pliku groups.json przed "+"odpowiedzią."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/pt_BR.po b/po/pt_BR.poindex 18f30b1..594bd73 100644--- a/po/pt_BR.po+++ b/po/pt_BR.po@@ -607,7 +607,10 @@ msgstr "As respostas em grupo estão desativadas."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Alguém que não está na lista de membros salva deste grupo escreveu nele, então a lista está desatualizada. Atualize-a em groups.json antes de responder."+msgstr ""+"Alguém que não está na lista de membros salva deste grupo escreveu nele, "+"então a lista está desatualizada. Atualize-a em groups.json antes de "+"responder."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/ru.po b/po/ru.poindex 19d96a0..1a7b460 100644--- a/po/ru.po+++ b/po/ru.po@@ -611,7 +611,9 @@ msgstr "Групповые ответы выключены."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "В эту группу написал кто-то, кого нет в её сохранённом списке участников, значит список устарел. Обновите его в groups.json, прежде чем отвечать."+msgstr ""+"В эту группу написал кто-то, кого нет в её сохранённом списке участников, "+"значит список устарел. Обновите его в groups.json, прежде чем отвечать."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/sv.po b/po/sv.poindex 4428a2c..ce4fdd0 100644--- a/po/sv.po+++ b/po/sv.po@@ -601,7 +601,9 @@ msgstr "Gruppsvar är avstängda."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Någon som inte finns i gruppens sparade medlemslista har skrivit i den, så listan är inaktuell. Uppdatera den i groups.json innan du svarar."+msgstr ""+"Någon som inte finns i gruppens sparade medlemslista har skrivit i den, så "+"listan är inaktuell. Uppdatera den i groups.json innan du svarar."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/tether.pot b/po/tether.potindex e54ea0c..7cea982 100644--- a/po/tether.pot+++ b/po/tether.pot@@ -6,9 +6,9 @@#, fuzzymsgid ""msgstr ""-"Project-Id-Version: tether 0.2.15\n"+"Project-Id-Version: tether 0.2.17\n""Report-Msgid-Bugs-To: [email protected]\n"-"POT-Creation-Date: 2026-08-28 20:29-0700\n"+"POT-Creation-Date: 2026-08-29 20:15-0700\n""PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n""Last-Translator: FULL NAME <EMAIL@ADDRESS>\n""Language-Team: LANGUAGE <[email protected]>\n"diff --git a/po/tr.po b/po/tr.poindex 3b35a29..8962a7e 100644--- a/po/tr.po+++ b/po/tr.po@@ -601,7 +601,9 @@ msgstr "Grup yanıtları kapalı."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "Bu grubun kayıtlı üye listesinde olmayan biri gruba yazdı, dolayısıyla liste güncel değil. Yanıtlamadan önce groups.json dosyasında güncelleyin."+msgstr ""+"Bu grubun kayıtlı üye listesinde olmayan biri gruba yazdı, dolayısıyla liste "+"güncel değil. Yanıtlamadan önce groups.json dosyasında güncelleyin."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/uk.po b/po/uk.poindex f6c619d..8225eb9 100644--- a/po/uk.po+++ b/po/uk.po@@ -609,7 +609,9 @@ msgstr "Групові відповіді вимкнено."msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "У цю групу написав хтось, кого немає в її збереженому списку учасників, тож список застарів. Оновіть його у файлі groups.json, перш ніж відповідати."+msgstr ""+"У цю групу написав хтось, кого немає в її збереженому списку учасників, тож "+"список застарів. Оновіть його у файлі groups.json, перш ніж відповідати."#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/po/zh_CN.po b/po/zh_CN.poindex 708aefb..a16965d 100644--- a/po/zh_CN.po+++ b/po/zh_CN.po@@ -574,7 +574,9 @@ msgstr "群组回复已关闭。"msgid """Someone who is not in this group's saved member list has posted to it, so ""the list is out of date. Update it in groups.json before replying."-msgstr "有不在该群组已保存成员列表中的人发了消息,说明该列表已过期。回复前请在 groups.json 中更新它。"+msgstr ""+"有不在该群组已保存成员列表中的人发了消息,说明该列表已过期。回复前请在 "+"groups.json 中更新它。"#: src/core/src/bluetooth/groups.cpp#, c++-formatdiff --git a/src/core/include/tether/bluetooth/connection.hpp b/src/core/include/tether/bluetooth/connection.hppindex 6c2fce9..6e02457 100644--- a/src/core/include/tether/bluetooth/connection.hpp+++ b/src/core/include/tether/bluetooth/connection.hpp@@ -40,6 +40,9 @@ namespace tether::bluetooth {// for a GATT session it will not use.void set_notification_handlers(NotificationFn on_notification, WithdrawFn on_withdraw);+ // Turns notification mirroring on or off in place, on the next supervisor tick.+ void set_ancs_enabled(bool enabled);+// Whether mirrored notifications carry their title and body, or only// which app sent them. Takes effect on the next notification.void set_ancs_content_enabled(bool enabled);@@ -61,10 +64,6 @@ namespace tether::bluetooth {// actually carry ANCS is decided here rather than by the caller.void set_device(const std::string& address, bool ancs_enabled);- // Re-decides whether notification mirroring can run, against the- // controller's current capability. Cheap and idempotent- void refresh_capability();-nlohmann::json status() const;private:diff --git a/src/core/include/tether/bluetooth/profile_supervisor.hpp b/src/core/include/tether/bluetooth/profile_supervisor.hppindex 3e966d2..14d4020 100644--- a/src/core/include/tether/bluetooth/profile_supervisor.hpp+++ b/src/core/include/tether/bluetooth/profile_supervisor.hpp@@ -63,6 +63,10 @@ namespace tether::bluetooth {public:explicit ProfileSupervisor(ProfileOps& ops);+ // Releases both obexd sessions. The iPhone serves one MAP session at a+ // time, so a session abandoned here blocks the next one.+ ~ProfileSupervisor();+// Drive periodically with a monotonic clock. `device_ready` is a paired// device, not a link: obexd opens its own transport.bool tick(int64_t now, bool device_ready);diff --git a/src/core/src/bluetooth/connection.cpp b/src/core/src/bluetooth/connection.cppindex 47179d5..5c5cab7 100644--- a/src/core/src/bluetooth/connection.cpp+++ b/src/core/src/bluetooth/connection.cpp@@ -611,11 +611,19 @@ namespace tether::bluetooth {bool ancs_ready = false;std::string ancs_reason;+ std::atomic<bool> ancs_wanted{true};+ std::atomic<bool> ancs_content_wanted{true};+void run();void sync_messages(int64_t now);void sync_contacts();void sync_ancs(int64_t now);+ // Brings the ANCS client and the bearer supervisor in line with the wanted preference and the controller's+ // current capability.+ void apply_ancs_preference();+ void build_ancs_client();+// Rebuilds the cached payload from the supervisors. Supervisor thread// only: it is the sole writer of BearerStatus and ProfileStatus, both of// which hold a std::string that no other thread may read directly.@@ -983,6 +991,58 @@ namespace tether::bluetooth {ancs_client->tick(now);}+ void ConnectionState::build_ancs_client() {+ ancs_client = std::make_unique<ancs::AncsClient>(+ *monitor,+ [this](const ancs::Notification& notification) {+ if (on_notification)+ on_notification(notification);+ },+ [this](uint32_t uid) {+ if (on_withdraw)+ on_withdraw(uid);+ },+ [this](bool ready, const std::string& reason) {+ {+ // runs on the glib thread, which must not read supervisor state.+ std::lock_guard<std::mutex> lock(status_mutex);+ ancs_ready = ready;+ ancs_reason = reason;+ if (!current_status.is_null()) {+ current_status["ancs_ready"] = ready;+ current_status["ancs_reason"] = reason;+ }+ }+ debug::log(INFO, "ancs: {}", reason);+ publish();+ });+ ancs_client->set_content_enabled(ancs_content_wanted.load());+ }++ void ConnectionState::apply_ancs_preference() {+ ancs_preference = ancs_wanted.load();+ const bool effective = ancs_preference && ancs_available();+ if (effective == ancs_enabled) {+ if (ancs_client)+ ancs_client->set_content_enabled(ancs_content_wanted.load());+ return;+ }++ ancs_enabled = effective;+ bearers->set_ancs_enabled(effective);+ ancs_absent_since = -1;+ if (effective && on_notification)+ build_ancs_client();+ else+ ancs_client.reset();+ {+ std::lock_guard<std::mutex> lock(status_mutex);+ ancs_ready = false;+ ancs_reason.clear();+ }+ debug::log(INFO, "bluetooth: notification mirroring {}", effective ? "enabled" : "disabled");+ }+void ConnectionState::run() {using namespace std::chrono;const auto started = steady_clock::now();@@ -990,6 +1050,8 @@ namespace tether::bluetooth {while (running) {const int64_t now = duration_cast<seconds>(steady_clock::now() - started).count();+ apply_ancs_preference();+const bool obex_up = profiles->status().map_open || profiles->status().pbap_open;bearers->tick(now, obex_up);@@ -1050,6 +1112,8 @@ namespace tether::bluetooth {state_->address = address;state_->ancs_preference = ancs_enabled;+ state_->ancs_wanted = ancs_enabled;+ state_->ancs_content_wanted = load_config().ancs_content_enabled;// Read the controller's capability here rather than letting each caller// latch its own copy. At startup BlueZ may not have finished enumerating// the adapter, and its free advertising-instance count drops to zero@@ -1081,35 +1145,8 @@ namespace tether::bluetooth {// Only built when the caller can actually show notifications and the// bond can carry them.- if (ancs_effective && state_->on_notification) {- auto* raw = state_.get();- state_->ancs_client = std::make_unique<ancs::AncsClient>(- *state_->monitor,- [raw](const ancs::Notification& notification) {- if (raw->on_notification)- raw->on_notification(notification);- },- [raw](uint32_t uid) {- if (raw->on_withdraw)- raw->on_withdraw(uid);- },- [raw](bool ready, const std::string& reason) {- {- // Fold straight into the cached payload: this runs on the- // GLib thread, which must not read supervisor state.- std::lock_guard<std::mutex> lock(raw->status_mutex);- raw->ancs_ready = ready;- raw->ancs_reason = reason;- if (!raw->current_status.is_null()) {- raw->current_status["ancs_ready"] = ready;- raw->current_status["ancs_reason"] = reason;- }- }- debug::log(INFO, "ancs: {}", reason);- raw->publish();- });- state_->ancs_client->set_content_enabled(load_config().ancs_content_enabled);- }+ if (ancs_effective && state_->on_notification)+ state_->build_ancs_client();state_->running = true;state_->thread = std::thread([this] { state_->run(); });@@ -1161,10 +1198,7 @@ namespace tether::bluetooth {state_->on_withdraw = std::move(on_withdraw);}- void ConnectionManager::set_ancs_content_enabled(bool enabled) {- if (state_->ancs_client)- state_->ancs_client->set_content_enabled(enabled);- }+ void ConnectionManager::set_ancs_content_enabled(bool enabled) { state_->ancs_content_wanted = enabled; }bool ConnectionManager::perform_notification_action(uint32_t uid, ancs::ActionId action) {return state_->ancs_client && state_->ancs_client->perform_action(uid, action);@@ -1186,18 +1220,7 @@ namespace tether::bluetooth {start(address, ancs_enabled);}- void ConnectionManager::refresh_capability() {- if (!state_->running || state_->address.empty())- return;- const bool wanted = state_->ancs_preference && ancs_available();- if (wanted == state_->ancs_enabled)- return;- debug::log(INFO,- "bluetooth: notification mirroring is now {} (controller capability changed)",- wanted ? "available" : "unavailable");- const std::string address = state_->address;- set_device(address, state_->ancs_preference);- }+ void ConnectionManager::set_ancs_enabled(bool enabled) { state_->ancs_wanted = enabled; }nlohmann::json ConnectionManager::status() const {// The supervisors' own status objects belong to the supervisor thread;diff --git a/src/core/src/bluetooth/profile_supervisor.cpp b/src/core/src/bluetooth/profile_supervisor.cppindex 367190c..3674dc6 100644--- a/src/core/src/bluetooth/profile_supervisor.cpp+++ b/src/core/src/bluetooth/profile_supervisor.cpp@@ -115,6 +115,8 @@ namespace tether::bluetooth {ProfileSupervisor::ProfileSupervisor(ProfileOps& ops) : ops_(ops) {}+ ProfileSupervisor::~ProfileSupervisor() { reset(); }+void ProfileSupervisor::reset() {if (!map_path_.empty())ops_.remove_session(map_path_);diff --git a/src/core/src/net.cpp b/src/core/src/net.cppindex f28ae93..2d24eee 100644--- a/src/core/src/net.cpp+++ b/src/core/src/net.cpp@@ -940,7 +940,13 @@ namespace tether {auto config = bluetooth::load_config();config.ancs_enabled = j.value("enabled", true);bluetooth::save_config(config);- std::thread(restart_supervision, config).detach();++ if (bluetooth::g_bt_connections)+ bluetooth::g_bt_connections->set_ancs_enabled(config.ancs_enabled);++ bluetooth::set_group_replies_enabled(config.group_messages_enabled &&+ config.ancs_content_enabled && config.ancs_enabled);+ broadcast_local_event(build_bt_status().dump());} else if (j.contains("command") && j["command"] == "bt_set_enabled") {auto config = bluetooth::load_config();config.enabled = j.value("enabled", true);@@ -955,7 +961,7 @@ namespace tether {// Group correlation reads notification bodies, so it// follows this toggle.bluetooth::set_group_replies_enabled(config.group_messages_enabled &&- config.ancs_content_enabled);+ config.ancs_content_enabled && config.ancs_enabled);broadcast_local_event(build_bt_status().dump());} else if (j.contains("command") && j["command"] == "bt_list_notifications") {nlohmann::json payload;diff --git a/src/daemon/main.cpp b/src/daemon/main.cppindex 061a476..0fdc7da 100644--- a/src/daemon/main.cpp+++ b/src/daemon/main.cpp@@ -220,11 +220,9 @@ int main(int argc, char** argv) {});if (bluez.start()) {tether::bluetooth::g_bluez = &bluez;- loop.addFd(bluez.event_fd(), [&bluez, &connections](int) {+ loop.addFd(bluez.event_fd(), [&bluez](int) {bluez.drain();tether::broadcast_local_event(tether::build_bt_status().dump());- // controller capability re-read on every bluez- connections.refresh_capability();});auto cap = bluez.capability();debug::log(INFO, "Bluetooth: {} mode", tether::bluetooth::to_string(cap.mode));@@ -238,7 +236,7 @@ int main(int argc, char** argv) {tether::bluetooth::g_bt_connections = &connections;tether::bluetooth::set_group_replies_enabled(bt_config.group_messages_enabled &&- bt_config.ancs_content_enabled);+ bt_config.ancs_content_enabled && bt_config.ancs_enabled);tether::bluetooth::reload_group_rosters();{diff --git a/test/test_bluetooth_supervisor.cpp b/test/test_bluetooth_supervisor.cppindex 05b2cb6..6f9c637 100644--- a/test/test_bluetooth_supervisor.cpp+++ b/test/test_bluetooth_supervisor.cpp@@ -566,6 +566,19 @@ TEST(ProfileSupervisor, ResetRemovesSessions) {EXPECT_TRUE(sup.status().map_open);}+// The iPhone serves one MAP session at a time, so a supervisor that is dropped+// without releasing its sessions blocks the next one until obexd is restarted.+TEST(ProfileSupervisor, DestructionReleasesSessions) {+ FakeProfiles ops;+ {+ ProfileSupervisor sup(ops);+ sup.tick(0, true);+ ASSERT_TRUE(sup.status().map_open);+ ASSERT_TRUE(sup.status().pbap_open);+ }+ EXPECT_EQ(ops.removed.size(), 2u);+}+TEST(ProfileSupervisor, BusySessionKeepsPollingWithoutRetryBurst) {FakeProfiles ops;ops.map_error = "Connection refused (111)";