Skip to content

fix(airplane): correct radio presence and Bluetooth settle behavior#396

Merged
cachebag merged 9 commits into
masterfrom
fix/airplane-mode
May 8, 2026
Merged

fix(airplane): correct radio presence and Bluetooth settle behavior#396
cachebag merged 9 commits into
masterfrom
fix/airplane-mode

Conversation

@cachebag
Copy link
Copy Markdown
Collaborator

@cachebag cachebag commented May 8, 2026

Fixes a bug where turning airplane mode on could shut off Wi‑Fi (and Bluetooth) while clients still saw “airplane off”: failures or missing BlueZ were surfaced as errors after Wi‑Fi had already been soft‑blocked, read‑after‑write could catch Bluetooth’s Powered before it updated, and absent Wi‑Fi/WWAN/Bluetooth hardware was still folded into AirplaneModeState, so is_airplane_mode never matched what the user expected.

This change treats absent radios as not present, treats unavailable Bluetooth as a no‑op when turning airplane on so the call still succeeds for Wi‑Fi/WWAN, waits for BlueZ power state with bounded latency (one device pass plus a single overall settle timeout), and reduces redundant D‑Bus work by enumerating NM devices once for the combined state. When Bluetooth is skipped because BlueZ is unavailable, a warning is logged so “silent” failures are still diagnosable.

@cachebag cachebag requested a review from Copilot May 8, 2026 02:58
@cachebag cachebag self-assigned this May 8, 2026
@cachebag cachebag added nmrs Changes to nmrs api-surface Public API design, re-exports, and semver-relevant changes wifi WiFi connection management bluetooth Bluetooth device/adapter management labels May 8, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines nmrs airplane-mode behavior so hosts without certain radios (notably Bluetooth/WWAN) don’t get “stuck” in a non-airplane state and so BlueZ toggles are less prone to read-after-write races.

Changes:

  • Add RadioState::present (+ with_presence) and update airplane-mode aggregation helpers to ignore absent radios.
  • Treat missing/absent BlueZ as “not present” for aggregation and downgrade BluezUnavailable during set_airplane_mode to avoid failing the overall toggle.
  • After setting BlueZ Powered, wait (bounded) for the property to reflect the change to reduce transient stale reads.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
nmrs/src/types/constants.rs Adds NM device type constant for modem/WWAN detection.
nmrs/src/core/airplane.rs Implements radio presence detection, BlueZ Powered settling wait, and set_airplane_mode behavior change for missing BlueZ.
nmrs/src/api/network_manager.rs Updates public API docs to describe presence semantics and BlueZ no-op behavior.
nmrs/src/api/models/radio.rs Extends RadioState with present, updates AirplaneModeState logic, and adds unit tests.
nmrs/CHANGELOG.md Documents the new present field and airplane-mode fixes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/src/core/airplane.rs Outdated
@cachebag cachebag force-pushed the fix/airplane-mode branch from 2feb100 to 8e38775 Compare May 8, 2026 19:55
@cachebag cachebag requested a review from Copilot May 8, 2026 19:56
@cachebag cachebag force-pushed the fix/airplane-mode branch 2 times, most recently from 5be3a0a to 2a0d89b Compare May 8, 2026 19:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Comment thread nmrs/src/core/airplane.rs
Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/src/core/airplane.rs
Comment thread nmrs/src/api/network_manager.rs Outdated
@cachebag cachebag force-pushed the fix/airplane-mode branch from 2a0d89b to f3cb9e6 Compare May 8, 2026 20:03
cachebag and others added 3 commits May 8, 2026 16:04
…Powered to settle so toggling airplane mode no longer leaves wifi soft-killed on hosts without bluetooth
@cachebag cachebag force-pushed the fix/airplane-mode branch from f3cb9e6 to f2b5051 Compare May 8, 2026 20:04
Copilot stopped work on behalf of cachebag due to an error May 8, 2026 20:08
…Bluetooth toggle vs stack-unavailable errors
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Comment thread nmrs/src/api/network_manager.rs
Comment thread nmrs/src/api/network_manager.rs
Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/CHANGELOG.md Outdated
@cachebag cachebag requested a review from Copilot May 8, 2026 20:19
@cachebag cachebag changed the title fix(airplane): treat absent radios as not-present and wait for bluez Powered to settle so toggling airplane mode no longer leaves wifi soft-killed on hosts without bluetooth fix(airplane): correct radio presence and Bluetooth settle behavior May 8, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

nmrs/src/core/airplane.rs:176

  • set_bluetooth_radio_enabled wraps any error from enumerate_bluetooth_adapters into a new ConnectionError::BluezUnavailable. Since enumerate_bluetooth_adapters already returns ConnectionError (often already BluezUnavailable), this will double-prefix the error message (e.g. "bluetooth stack unavailable: failed to enumerate adapters: bluetooth stack unavailable: …") and can discard the original error variant/context. Prefer propagating the original error (?) or adding context without re-wrapping an existing ConnectionError.
    let adapter_paths = enumerate_bluetooth_adapters(conn).await.map_err(|e| {
        ConnectionError::BluezUnavailable(format!("failed to enumerate adapters: {e}"))
    })?;

Comment thread nmrs/src/core/airplane.rs Outdated
Comment thread nmrs/src/api/network_manager.rs Outdated
Comment thread nmrs/CHANGELOG.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread nmrs/src/core/airplane.rs Outdated
@cachebag cachebag enabled auto-merge (rebase) May 8, 2026 20:36
@cachebag cachebag disabled auto-merge May 8, 2026 20:36
@cachebag cachebag merged commit 7619e5a into master May 8, 2026
6 checks passed
@cachebag cachebag deleted the fix/airplane-mode branch May 8, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-surface Public API design, re-exports, and semver-relevant changes bluetooth Bluetooth device/adapter management nmrs Changes to nmrs wifi WiFi connection management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants