Linux + iPhone Continuity / iMessage / SMS
packaging: finalize bt setup
Zack Bartel1b15395fa551
diff --git a/CMakeLists.txt b/CMakeLists.txtindex baa31c2..38f704f 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -128,7 +128,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/man/tetherd.8"DESTINATION ${CMAKE_INSTALL_MANDIR}/man8)# Bluetooth CoD unit. Installed but not enabled: it changes how the machine presents itself over Bluetooth, so turning it on is the user's call.-set(SYSTEMD_UNIT_DIR "${CMAKE_INSTALL_LIBDIR}/systemd/system" CACHE PATH "systemd system unit directory")+# Not CMAKE_INSTALL_LIBDIR: that is multiarch on Debian, where units still live in /usr/lib/systemd.+set(SYSTEMD_UNIT_DIR "lib/systemd/system" CACHE PATH "systemd system unit directory")install(FILES packaging/systemd/[email protected]DESTINATION "${SYSTEMD_UNIT_DIR}")diff --git a/PKGBUILD b/PKGBUILDindex f83863c..012488b 100644--- a/PKGBUILD+++ b/PKGBUILD@@ -9,6 +9,7 @@ depends=('gtk3' 'libnotify' 'openssl' 'wayland' 'avahi' 'glib2' 'bluez' 'bluez-umakedepends=('cmake' 'ninja' 'git')provides=('tether' 'tether-bin')conflicts=('tether' 'tether-bin')+install=packaging/tether.installsource=("git+https://github.com/zackb/tether.git")sha256sums=('SKIP')diff --git a/README.md b/README.mdindex a64ed4e..d83165b 100644--- a/README.md+++ b/README.md@@ -138,21 +138,22 @@ make installtether pair```-3. Bluetooth pair via GUI or CLI (for Messages and Notifications):+3. Bluetooth (for Messages and Notifications):- Check that your machine has the Bluetooth features first.-- This sets the Bluetooth adapter class to "A/V Hands-Free" instead of "Computer":+ First, one-time system setup. This prints only the steps your machine still+ needs, with the exact commands:```bash- ./scripts/bt-probe.sh --set-class+ tether --bt-setup```- Then, in the GTK app, pick your iPhone under BLUETOOTH on the Devices page- and press "Pair over Bluetooth". Confirm the code on both the iPhone and- Linux. Afterwards the iPhone offers "Show Message Notifications" and "Sync- Contacts" under Settings > Bluetooth > (i) for this computer. Enable these, both are needed.- They can take a few minutes to appear. "Show iPhone Permissions" in the same pane can re-advertise so they show up again.+ Tether never applies these itself: they change how the machine behaves over+ Bluetooth outside of Tether, so running them is your call. The same steps+ appear in the GTK app's Devices page, with a "Copy commands" button.++ Then pair. In the GTK app, pick your iPhone under BLUETOOTH on the Devices+ page and press "Pair over Bluetooth". Confirm the code on both the iPhone and+ Linux.or@@ -162,6 +163,11 @@ make installtether --bt-connection # what is up, and what is not```+4. On the iPhone, under Settings > Bluetooth > (i) for this computer, enable+ "Show Message Notifications" and "Sync Contacts". Both are needed. They can+ take a few minutes to appear; "Show iPhone Permissions" in the GTK app+ re-advertises so they show up again.+## Roadmap- [x] Complete iOS app developmentdiff --git a/docs/BLUETOOTH.md b/docs/BLUETOOTH.mdindex 3502624..b6a3756 100644--- a/docs/BLUETOOTH.md+++ b/docs/BLUETOOTH.md@@ -20,14 +20,22 @@ Not every machine can do all of it, so Tether resolves one of two modes from livBlueZ >= 5.86 running with its experimental bearer API (org.bluez.Bearer.LE1).- Compatibility mode: MAP + PBAP only. Messages and contacts work, notification mirroring does not (older BlueZ).-Run the probe to find out which applies:+`tether --bt-status` reports which applies. `scripts/bt-probe.sh` is a+repo-only development probe that covers a few things the daemon does not check+(BlueZ version, `obex.service`, tooling); it is not installed by any package.++## Setup requirements++Two of them need a system change, and both are reported with the exact command by:```bash-./scripts/bt-probe.sh # read-only-./scripts/bt-probe.sh --set-class # also fixes the adapter Class of Device+tether --bt-setup```-## Setup requirements+It prints only what is still missing and never applies anything: both steps+change how the machine behaves over Bluetooth outside Tether. The GTK app shows+the same list on the Devices page with a "Copy commands" button. The rest of this+section is what those commands do and why.Class of Device must be A/V Hands-Free (major 4, minor 8). iOS only offers the"Show Message Notifications" and "Sync Contacts" permissions to a device presenting this@@ -90,8 +98,11 @@ These are properties of what iOS exposes:## Troubleshooting-Start with the two read-only checks. `./scripts/bt-probe.sh` says what the hardware and the-stack can do. `tether --bt-connection` says what is actually up right now.+Start with the read-only checks. `tether --bt-setup` says what system setup is+still missing, `tether --bt-status` says what the hardware and the stack can do,+and `tether --bt-connection` says what is actually up right now. From a source+checkout, `./scripts/bt-probe.sh` adds BlueZ-version, tooling, and `obexd`+checks the daemon does not make.| Symptom | Cause | What to do ||---|---|---|diff --git a/docs/man/man1/tether.1.in b/docs/man/man1/tether.1.inindex aea47a5..8ae9c64 100644--- a/docs/man/man1/tether.1.in+++ b/docs/man/man1/tether.1.in@@ -46,6 +46,55 @@ Accept a pending pairing request locally for the specified device fingerprint..TP\fB\-\-pair\fRSend a pairing request over TCP to the daemon.+.SH BLUETOOTH OPTIONS+Bluetooth carries iPhone messages (MAP), contacts (PBAP), and notification+mirroring (ANCS). It is independent of the Wi-Fi pairing above.+.TP+\fB\-\-bt-setup\fR+Show the one-time system setup Bluetooth still needs, with the command for each+step. Nothing is applied: the steps change how the machine behaves over+Bluetooth outside Tether, so running them is left to the user. One step enables+\fBtether-btclass@\fR\fIADAPTER\fR\fB.service\fR, which is installed by the+package but never enabled for you.+.TP+\fB\-\-bt-status\fR+Show Bluetooth adapter capability and delivery mode.+.TP+\fB\-\-bt-devices\fR+List Bluetooth devices known to BlueZ.+.TP+\fB\-\-bt-connection\fR+Show Bluetooth link and profile connection state.+.TP+\fB\-\-bt-pair\fR \fIADDRESS\fR+Pair with an iPhone over Bluetooth.+.TP+\fB\-\-bt-unpair\fR \fIADDRESS\fR+Remove a Bluetooth bond.+.TP+\fB\-\-bt-solicit\fR+Re-advertise for ANCS so the iPhone shows its permission toggles again.+.TP+\fB\-\-bt-threads\fR+List iPhone message conversations.+.TP+\fB\-\-bt-messages\fR \fITHREAD\fR+Show messages in one conversation.+.TP+\fB\-\-bt-send\fR \fITHREAD\fR \fITEXT\fR+Reply in one conversation.+.TP+\fB\-\-bt-notifications\fR+List mirrored iPhone notifications.+.TP+\fB\-\-bt-ancs\fR \fIon\fR|\fIoff\fR+Turn notification mirroring on or off.+.TP+\fB\-\-bt-ancs-content\fR \fIon\fR|\fIoff\fR+Mirror notification titles and bodies, not just the app.+.TP+\fB\-\-bt-diagnostics\fR+Print a redacted Bluetooth report for a bug report..SH EXAMPLESRetrieve clipboard:.IP@@ -62,6 +111,16 @@ tether \-\-discoverSend a file:.IPtether \-f document.pdf+.PP+See what Bluetooth still needs before pairing an iPhone:+.IP+tether \-\-bt-setup+.SH FILES+.TP+\fB/usr/lib/systemd/system/tether\[email protected]\fR+Sets the Bluetooth adapter's Class of Device to A/V Hands\-Free, which iOS+requires before it will offer its Messages and Contacts permissions. Installed+but not enabled; see \fB\-\-bt-setup\fR..SH SEE ALSO.BR tetherd (8),.BR tether-gtk (1)diff --git a/packaging/tether.install b/packaging/tether.installnew file mode 100644index 0000000..b88d714--- /dev/null+++ b/packaging/tether.install@@ -0,0 +1,18 @@+post_install() {+ cat <<'MSG'++Bluetooth (iPhone messages and notifications) needs one-time system setup.+[email protected] is installed but NOT enabled. Enabling it changes how+this machine presents itself over Bluetooth, so that is your call to make.++To see exactly what is left, and the commands to run:++ tether --bt-setup++MSG+}++post_upgrade() {+ post_install+}diff --git a/scripts/bt-probe.sh b/scripts/bt-probe.shindex d192e26..89ae7d8 100755--- a/scripts/bt-probe.sh+++ b/scripts/bt-probe.sh@@ -150,12 +150,6 @@ fi# which looks nothing like a permissions problem and wastes a lot of debugging.echoecho "Conflicts"-if systemctl --user is-active --quiet blueferry.service 2>/dev/null; then- clash "blueferry.service is running and will hold the iPhone's MAP session"- note "Stop it while testing Tether: systemctl --user stop blueferry.service"-else- ok "no other known MAP consumer running"-fiif systemctl --user is-active --quiet obex.service 2>/dev/null; thenok "obexd active (required for MAP and PBAP)"diff --git a/scripts/release.sh b/scripts/release.shindex 0db274c..216305d 100755--- a/scripts/release.sh+++ b/scripts/release.sh@@ -71,10 +71,11 @@ gh release create "$TAG" "$TARBALL" "$DEB" "$RPM" --title "Release $TAG" --generif [ -d "$AUR_GIT_DIR" ]; thenecho "🧬 Updating tether-git AUR..."sed -i "s/^pkgver=.*/pkgver=$VERSION/" "$AUR_GIT_DIR/PKGBUILD"+ cp "$REPO_ROOT/packaging/tether.install" "$AUR_GIT_DIR/tether.install"(cd "$AUR_GIT_DIR"makepkg --printsrcinfo > .SRCINFO- git add PKGBUILD .SRCINFO+ git add PKGBUILD .SRCINFO tether.installgit commit -m "update to $VERSION"git push)@@ -89,10 +90,11 @@ if [ -d "$AUR_BIN_DIR" ]; thenSHA256=$(sha256sum "$TARBALL" | cut -d' ' -f1)sed -i "s/^pkgver=.*/pkgver=$VERSION/" "$AUR_BIN_DIR/PKGBUILD"sed -i "s/^sha256sums=.*/sha256sums=('$SHA256')/" "$AUR_BIN_DIR/PKGBUILD"+ cp "$REPO_ROOT/packaging/tether.install" "$AUR_BIN_DIR/tether.install"(cd "$AUR_BIN_DIR"makepkg --printsrcinfo > .SRCINFO- git add PKGBUILD .SRCINFO+ git add PKGBUILD .SRCINFO tether.installgit commit -m "update to $VERSION"git push)diff --git a/src/cli/main.cpp b/src/cli/main.cppindex 0ef8980..29b9944 100644--- a/src/cli/main.cpp+++ b/src/cli/main.cpp@@ -3,6 +3,7 @@#include <ctime>#include <iostream>#include <nlohmann/json.hpp>+#include <sstream>#include <string>#include <tether/client.hpp>#include <tether/crypto.hpp>@@ -106,6 +107,7 @@ void print_help() {<< " --port <num> Connect over TCP port (default 5134).\n"<< " --timeout <ms> Discovery scan duration in milliseconds (default 3000).\n"<< " --list-devices List all paired connection devices.\n"+ << " --bt-setup Show the one-time system setup Bluetooth still needs.\n"<< " --bt-status Show Bluetooth adapter capability and delivery mode.\n"<< " --bt-devices List Bluetooth devices known to BlueZ.\n"<< " --bt-connection Show Bluetooth link and profile connection state.\n"@@ -132,6 +134,47 @@ void print_help() {<< " tether --accept 9a4f21...\n";}+// The two known gaps (adapter class, experimental API) change the machine+// outside Tether, so they are printed for the user to run, never applied here.+static int print_bt_setup(tether::Client& client) {+ nlohmann::json resp;+ try {+ resp = nlohmann::json::parse(client.send_and_wait("{\"command\":\"bt_status\"}\n"));+ } catch (const std::exception&) {+ debug::log(ERR, "Could not read Bluetooth status from the daemon.\n");+ return 1;+ }++ if (!resp.value("available", false)) {+ fprintf(stdout, "Bluetooth: unavailable (is bluetoothd running?)\n");+ return 1;+ }++ const auto& cap = resp["capability"];+ const auto& setup = cap["setup"];+ if (setup.empty()) {+ fprintf(stdout, "Bluetooth setup is complete. Nothing to do.\n");+ return 0;+ }++ fprintf(stdout,+ "\n%zu step%s left before the iPhone Bluetooth features work:\n",+ setup.size(),+ setup.size() == 1 ? "" : "s");++ size_t n = 0;+ for (const auto& step : setup) {+ fprintf(stdout, "\n%zu. %s\n\n", ++n, step.value("what", "").c_str());+ // Indent every line so a multi-line command still reads as one block.+ std::istringstream lines(step.value("command", ""));+ for (std::string line; std::getline(lines, line);)+ fprintf(stdout, " %s\n", line.c_str());+ }++ fprintf(stdout, "\nRe-run 'tether --bt-setup' afterwards to confirm.\n");+ return 0;+}+static int print_bt_status(tether::Client& client) {nlohmann::json resp;try {@@ -166,6 +209,10 @@ static int print_bt_status(tether::Client& client) {for (const auto& reason : cap["reasons"])fprintf(stdout, " - %s\n", reason.get<std::string>().c_str());}++ const size_t pending = cap.contains("setup") ? cap["setup"].size() : 0;+ if (pending > 0)+ fprintf(stdout, "\n%zu setup step%s remaining. Run: tether --bt-setup\n", pending, pending == 1 ? "" : "s");return 0;}@@ -496,6 +543,8 @@ int main(int argc, char* argv[]) {action = "discover";} else if (arg == "--list-devices") {action = "list";+ } else if (arg == "--bt-setup") {+ action = "bt_setup";} else if (arg == "--bt-status") {action = "bt_status";} else if (arg == "--bt-devices") {@@ -654,6 +703,8 @@ int main(int argc, char* argv[]) {debug::log(INFO, "File transfer delivered.\n");} else if (action == "native") {run_native_messaging_host(client);+ } else if (action == "bt_setup") {+ return print_bt_setup(client);} else if (action == "bt_status") {return print_bt_status(client);} else if (action == "bt_devices") {diff --git a/src/core/include/tether/bluetooth/objects.hpp b/src/core/include/tether/bluetooth/objects.hppindex b1acf7e..ab31da4 100644--- a/src/core/include/tether/bluetooth/objects.hpp+++ b/src/core/include/tether/bluetooth/objects.hpp@@ -90,6 +90,13 @@ namespace tether::bluetooth {// only meaningful once a bond exists.enum class BearerApi { Unknown, Confirmed, Absent };+ struct SetupStep {+ std::string what;+ std::string command;++ bool operator==(const SetupStep&) const = default;+ };+struct Capability {DeliveryMode mode = DeliveryMode::Blocked;BearerApi bearer_api = BearerApi::Unknown;@@ -99,8 +106,12 @@ namespace tether::bluetooth {bool le_peripheral = false;bool advertising = false;bool class_ok = false;+ // Adapter the steps below apply to, e.g. "hci0". The class unit is templated on it.+ std::string adapter_id;// Human-readable explanations for anything short of full mode, shown verbatimstd::vector<std::string> reasons;+ // Remediable gaps only. Anything the user cannot act on stays in reasons.+ std::vector<SetupStep> setup;bool operator==(const Capability&) const = default;};@@ -117,6 +128,7 @@ namespace tether::bluetooth {nlohmann::json to_json(const Adapter& adapter);nlohmann::json to_json(const Device& device);+ nlohmann::json to_json(const SetupStep& step);nlohmann::json to_json(const Capability& capability);} // namespace tether::bluetoothdiff --git a/src/core/src/bluetooth/objects.cpp b/src/core/src/bluetooth/objects.cppindex 7b3bb0b..eb1cf56 100644--- a/src/core/src/bluetooth/objects.cpp+++ b/src/core/src/bluetooth/objects.cpp@@ -2,6 +2,7 @@#include <algorithm>#include <cstring>+#include <filesystem>namespace tether::bluetooth {@@ -249,6 +250,20 @@ namespace tether::bluetooth {return out;}+ namespace {++ // Arch = /usr/lib, Debian and Fedora = /usr/libexec.+ std::string bluetoothd_path() {+ for (const char* candidate : {"/usr/lib/bluetooth/bluetoothd", "/usr/libexec/bluetooth/bluetoothd"}) {+ std::error_code ec;+ if (std::filesystem::exists(candidate, ec))+ return candidate;+ }+ return "/usr/lib/bluetooth/bluetoothd";+ }++ } // namespace+Capability resolve_capability(const BluezObjects& objects) {Capability cap;@@ -270,6 +285,7 @@ namespace tether::bluetooth {}cap.adapter_present = true;+ cap.adapter_id = adapter->path.substr(adapter->path.find_last_of('/') + 1);cap.powered = adapter->powered;cap.le_central = adapter->has_role("central");cap.le_peripheral = adapter->has_role("peripheral");@@ -277,7 +293,7 @@ namespace tether::bluetooth {cap.class_ok = adapter->class_is_handsfree();for (const auto& d : objects.devices) {- if (d.has_le_bearer)+ if (d.has_le_bearer || d.has_classic_bearer)cap.bearer_api = BearerApi::Confirmed;}if (cap.bearer_api != BearerApi::Confirmed)@@ -307,15 +323,22 @@ namespace tether::bluetooth {cap.mode = DeliveryMode::Compatibility;}if (cap.bearer_api == BearerApi::Absent) {- cap.reasons.emplace_back("BlueZ is not exposing org.bluez.Bearer.LE1. Run bluetoothd with "- "--experimental to enable notification mirroring.");+ cap.setup.push_back({"Notification mirroring needs BlueZ's experimental bearer API "+ "(org.bluez.Bearer.LE1), which bluetoothd is not exposing.",+ "sudo mkdir -p /etc/systemd/system/bluetooth.service.d\n"+ "printf '[Service]\\nExecStart=\\nExecStart=" ++ bluetoothd_path() ++ " --experimental\\n' \\\n"+ " | sudo tee /etc/systemd/system/bluetooth.service.d/experimental.conf\n"+ "sudo systemctl daemon-reload && sudo systemctl restart bluetooth"});cap.mode = DeliveryMode::Compatibility;} else if (cap.bearer_api == BearerApi::Unknown) {cap.reasons.emplace_back("Bearer API support is unconfirmed until a device is bonded.");}if (!cap.class_ok) {- cap.reasons.emplace_back("Adapter Class of Device is not A/V Hands-Free (major 4, minor 8); "- "the iPhone will not offer its Messages and Contacts permissions.");+ cap.setup.push_back({"The iPhone will not offer its Messages and Contacts permissions until this "+ "adapter presents itself as A/V Hands-Free (major 4, minor 8).",+ "sudo systemctl enable --now tether-btclass@" + cap.adapter_id});}return cap;@@ -355,7 +378,18 @@ namespace tether::bluetooth {};}+ nlohmann::json to_json(const SetupStep& s) {+ return {+ {"what", s.what},+ {"command", s.command},+ };+ }+nlohmann::json to_json(const Capability& c) {+ nlohmann::json setup = nlohmann::json::array();+ for (const auto& step : c.setup)+ setup.push_back(to_json(step));+return {{"mode", to_string(c.mode)},{"bearer_api", to_string(c.bearer_api)},@@ -365,7 +399,9 @@ namespace tether::bluetooth {{"le_peripheral", c.le_peripheral},{"advertising", c.advertising},{"class_ok", c.class_ok},+ {"adapter_id", c.adapter_id},{"reasons", c.reasons},+ {"setup", setup},};}diff --git a/src/gtk/devices_view.cpp b/src/gtk/devices_view.cppindex 206082c..b5626ce 100644--- a/src/gtk/devices_view.cpp+++ b/src/gtk/devices_view.cpp@@ -43,6 +43,10 @@ namespace tether::ui {std::string selected_bt_name;GtkWidget* lbl_bt_name = nullptr;+ GtkWidget* bt_setup_box = nullptr;+ GtkWidget* lbl_bt_setup_what = nullptr;+ GtkWidget* lbl_bt_setup_command = nullptr;+ std::string bt_setup_commands;GtkWidget* lbl_bt_mode = nullptr;GtkWidget* lbl_bt_link = nullptr;GtkWidget* lbl_bt_messages = nullptr;@@ -113,9 +117,28 @@ namespace tether::ui {set_markup(g_devices.lbl_bt_name, "<b>" + escape_markup(g_devices.selected_bt_name) + "</b>");+ const nlohmann::json capability = g_devices.bt_status.value("capability", nlohmann::json());++ std::string what;+ std::string commands;+ if (capability.is_object() && capability.contains("setup")) {+ int n = 0;+ for (const auto& step : capability["setup"]) {+ if (!what.empty())+ what += "\n";+ what += std::to_string(++n) + ". " + step.value("what", "");+ if (!commands.empty())+ commands += "\n";+ commands += step.value("command", "");+ }+ }+ g_devices.bt_setup_commands = commands;+ set_text(g_devices.lbl_bt_setup_what, what);+ set_text(g_devices.lbl_bt_setup_command, commands);+ gtk_widget_set_visible(g_devices.bt_setup_box, !commands.empty());+std::string mode;if (!g_devices.bt_status.empty()) {- const nlohmann::json capability = g_devices.bt_status.value("capability", nlohmann::json());if (!available || capability.is_null()) {mode = "Bluetooth is unavailable on this machine.";} else if (capability.value("mode", "") == "full") {@@ -323,6 +346,11 @@ namespace tether::ui {{"enabled", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) == TRUE}});}+ void on_bt_setup_copy_click(GtkWidget*, gpointer) {+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), g_devices.bt_setup_commands.c_str(), -1);+ set_status_main("Setup commands copied to the clipboard.");+ }+void on_bt_solicit_click(GtkWidget*, gpointer) {if (!daemon_send({{"command", "bt_solicit"}})) {set_text(g_devices.lbl_bt_progress, "Could not reach the Tether daemon.");@@ -892,6 +920,39 @@ namespace tether::ui {gtk_label_set_xalign(GTK_LABEL(g_devices.lbl_bt_name), 0.0);gtk_box_pack_start(GTK_BOX(bt_box), g_devices.lbl_bt_name, FALSE, FALSE, 0);+ // One-time system setup, shown only while something is actually missing.+ g_devices.bt_setup_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);+ gtk_style_context_add_class(gtk_widget_get_style_context(g_devices.bt_setup_box), "tether-setup");+ gtk_box_pack_start(GTK_BOX(bt_box), g_devices.bt_setup_box, FALSE, FALSE, 0);++ GtkWidget* lbl_setup_title = gtk_label_new(nullptr);+ gtk_label_set_xalign(GTK_LABEL(lbl_setup_title), 0.0);+ gtk_label_set_markup(GTK_LABEL(lbl_setup_title), "<b>Bluetooth needs one-time system setup</b>");+ gtk_box_pack_start(GTK_BOX(g_devices.bt_setup_box), lbl_setup_title, FALSE, FALSE, 0);++ g_devices.lbl_bt_setup_what = gtk_label_new(nullptr);+ gtk_label_set_xalign(GTK_LABEL(g_devices.lbl_bt_setup_what), 0.0);+ gtk_label_set_line_wrap(GTK_LABEL(g_devices.lbl_bt_setup_what), TRUE);+ gtk_box_pack_start(GTK_BOX(g_devices.bt_setup_box), g_devices.lbl_bt_setup_what, FALSE, FALSE, 0);++ // Selectable so the command can be copied by hand as well as by the button.+ g_devices.lbl_bt_setup_command = gtk_label_new(nullptr);+ gtk_label_set_xalign(GTK_LABEL(g_devices.lbl_bt_setup_command), 0.0);+ gtk_label_set_selectable(GTK_LABEL(g_devices.lbl_bt_setup_command), TRUE);+ gtk_label_set_line_wrap(GTK_LABEL(g_devices.lbl_bt_setup_command), TRUE);+ gtk_style_context_add_class(gtk_widget_get_style_context(g_devices.lbl_bt_setup_command),+ "tether-setup-command");+ gtk_box_pack_start(GTK_BOX(g_devices.bt_setup_box), g_devices.lbl_bt_setup_command, FALSE, FALSE, 0);++ GtkWidget* setup_actions = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);+ GtkWidget* btn_setup_copy = gtk_button_new_with_label("Copy commands");+ gtk_widget_set_tooltip_text(btn_setup_copy,+ "Run these in a terminal. Tether does not change your Bluetooth "+ "adapter or bluetoothd on its own.");+ g_signal_connect(btn_setup_copy, "clicked", G_CALLBACK(on_bt_setup_copy_click), nullptr);+ gtk_box_pack_start(GTK_BOX(setup_actions), btn_setup_copy, FALSE, FALSE, 0);+ gtk_box_pack_start(GTK_BOX(g_devices.bt_setup_box), setup_actions, FALSE, FALSE, 0);+g_devices.lbl_bt_mode = gtk_label_new(nullptr);gtk_label_set_xalign(GTK_LABEL(g_devices.lbl_bt_mode), 0.0);gtk_label_set_line_wrap(GTK_LABEL(g_devices.lbl_bt_mode), TRUE);diff --git a/src/gtk/ui_util.cpp b/src/gtk/ui_util.cppindex e541d5b..350b4c8 100644--- a/src/gtk/ui_util.cpp+++ b/src/gtk/ui_util.cpp@@ -52,6 +52,18 @@ namespace tether::ui {opacity: 0.5;}+.tether-setup {+ background-color: alpha(@theme_fg_color, 0.07);+ border: 1px solid alpha(@theme_fg_color, 0.18);+ border-radius: 8px;+ padding: 12px;+}++.tether-setup-command {+ font-family: monospace;+ font-size: 92%;+}+.tether-badge {background-color: @theme_selected_bg_color;color: @theme_selected_fg_color;diff --git a/test/test_bluetooth_objects.cpp b/test/test_bluetooth_objects.cppindex 7beae7a..c078353 100644--- a/test/test_bluetooth_objects.cpp+++ b/test/test_bluetooth_objects.cpp@@ -184,6 +184,7 @@ TEST(Capability, FullModeWhenBearerConfirmed) {EXPECT_TRUE(cap.advertising);EXPECT_TRUE(cap.class_ok);EXPECT_TRUE(cap.reasons.empty());+ EXPECT_TRUE(cap.setup.empty());}// Without --experimental the bearer interface can never appear, so its absence@@ -201,7 +202,30 @@ TEST(Capability, CompatibilityWhenExperimentalIsOff) {EXPECT_EQ(cap.mode, DeliveryMode::Compatibility);EXPECT_EQ(cap.bearer_api, BearerApi::Absent);- EXPECT_FALSE(cap.reasons.empty());+ ASSERT_EQ(cap.setup.size(), 1u);+ EXPECT_NE(cap.setup[0].command.find("--experimental"), std::string::npos);+}++// BlueZ stopped gating the Bearer API on --experimental, so bluetoothd's command+// line is not evidence against it. Reading it as proof told users whose+// notification mirroring already worked to install a drop-in that changes nothing.+// A bearer object is the observation that settles it, and BREDR1 answers the+// question without an LE phone in range.+TEST(Capability, AClassicBearerConfirmsTheApiWithoutTheExperimentalFlag) {+ Payload p(join(ADAPTER_FULL, R"({+ '/org/bluez/hci0/dev_F8_D3_F0_3C_84_4A': {+ 'org.bluez.Device1': { 'Paired': <true>, 'Bonded': <true> },+ 'org.bluez.Bearer.BREDR1': { 'Bonded': <true>, 'Connected': <false> }+ }+ })")+ .c_str());+ auto objects = parse_managed_objects(p.v);+ objects.experimental_api = false;+ auto cap = resolve_capability(objects);++ EXPECT_EQ(cap.bearer_api, BearerApi::Confirmed);+ EXPECT_EQ(cap.mode, DeliveryMode::Full);+ EXPECT_TRUE(cap.setup.empty());}// Headsets and game controllers are bonded but never expose a bearer under any@@ -286,7 +310,10 @@ TEST(Capability, WrongClassIsReportedButDoesNotDowngradeMode) {EXPECT_EQ(cap.mode, DeliveryMode::Full);EXPECT_FALSE(cap.class_ok);- EXPECT_FALSE(cap.reasons.empty());+ // The unit is templated on the adapter, so the wrong id makes the command a no-op.+ EXPECT_EQ(cap.adapter_id, "hci0");+ ASSERT_EQ(cap.setup.size(), 1u);+ EXPECT_EQ(cap.setup[0].command, "sudo systemctl enable --now tether-btclass@hci0");}TEST(Capability, PrefersAPoweredAdapter) {