Skip to content

fix: harden Linux, Android, AACP, and Nix workflows - #892

Open
91sexboy wants to merge 171 commits into
librepods-org:linux/rustfrom
91sexboy:fix-linux-bugs
Open

91sexboy wants to merge 171 commits into
librepods-org:linux/rustfrom
91sexboy:fix-linux-bugs

Conversation

@91sexboy

@91sexboy 91sexboy commented Nov 3, 2026 •

Copy link
Copy Markdown

Summary

This PR consolidates the verified fix-linux-bugs work onto the upstream linux/rust branch. It combines lifecycle, protocol, battery, tray, persistence, packaging, and CI fixes that interact across the Linux and Android implementations.

Linux / AACP

  • harden AACP packet validation, device persistence, listener replacement, and stale-session fencing
  • make PulseAudio/A2DP recovery resilient to missing cards, delayed profile enumeration, blocking profile actions, and ownership races
  • make tray state device-confirmed rather than queue-confirmed, with request IDs, failure/timeout handling, and bounded transports
  • improve tray/window behavior on KDE and Wayland, including activation, app IDs, theme contrast, and missing-tray fallback
  • handle partial/unknown battery observations without displaying sentinel values as percentages

Legacy Qt / system D-Bus

  • restrict PropertiesChanged admission to the BlueZ sender and Device1 argument before Qt queues dictionary payloads
  • prevent unrelated sender/interface traffic from exhausting receive storage while a property reply is delayed
  • verify real-monitor socket drainage, device identity, notification order, and reconnects on Qt 6.4.2 and 6.11.2 without changing production broker quotas or adding restart timers

Android

  • scope AACP and ATT work to exact generation/socket ownership
  • prevent stale callbacks, delayed work, profile operations, and service recreation from mutating replacement sessions
  • drain accepted callbacks and operation leases before clearing global state or reopening the connection gate
  • merge battery readings by component and preserve absent/unknown states across AACP and BLE paths
  • scope automatic media resume to the active AACP session so reconnecting cannot restart stale playback

Protocol, Nix, and CI

  • correct AAP battery labels, subscription bytes, and Smart Routing media-key casing
  • normalize Nix metadata and inputs, remove redundant nixpkgs, and refresh flake.lock
  • add a scheduled, least-privilege lock updater with immutable, read-only PR validation and visible status reporting
  • strengthen Linux CI with packaging/AppStream checks, Nix validation, formatting, Clippy, all-target tests, release builds, and scoped release permissions

Linked issues

Closes #421
Closes #422
Closes #446
Closes #548
Closes #549
Closes #550
Closes #635
Closes #636
Closes #680
Closes #681
Closes #682
Closes #683
Closes #737
Closes #738
Closes #770
Closes #771
Closes #795
Closes #798
Closes #799
Closes #842
Closes #889

Related to #817: this verifies the admission/backpressure path; the original rare three-day incident is not uniquely diagnosed without its binary and pre-recovery thread backtraces.

Validation

Review note

This is intentionally a consolidation PR because several fixes share lifecycle and state-machine invariants. The branch is a direct descendant of upstream linux/rust; no unrelated-history fallback or force-push is involved. The commits retain focused RED/GREEN regression slices where applicable so reviewers can inspect each behavior independently.

Upstream pull-request workflows for the current head are action_required and await maintainer approval. The fork CI cited above is complete; this pending upstream authorization is not a test failure.

Keep an already-active A2DP sink codec instead of recreating the PipeWire sink during activation. Continue switching from off and headset profiles.

Refs librepods-org#680
Resolve the current PipeWire card by Bluetooth MAC before activation and deactivation. Replace stale cached indices, clear the cache when lookup fails, and cover the async lookup paths without retaining media state guards.

Refs librepods-org#681
Give profile enumeration a grace probe before restarting WirePlumber, then use bounded post-restart retries with a fresh card lookup by MAC.

Add deterministic sequencing tests for grace success, retries, bounded failure, restart failure, and connection changes.

Refs librepods-org#682
Track listener generations and abort handles by normalized AirPods MAC so reconnecting replaces only the prior same-device task. Fence takeover work around activation and packet sends, with deterministic lifecycle coverage.

Refs librepods-org#683
Bind receiver dispatch and every resulting state/event mutation to the active connection generation. Reject unknown ear status bytes and validate the variable-length information envelope before parsing fields.
Read-modify-write information and proximity-key updates against the latest device registry, preserve LE keys, and move registry I/O to Tokio blocking workers. Serialize durable updates with connection generation transitions so replacement state cannot be overwritten.
Fsync parent directories after atomic settings/device replacement and after removing migrated legacy settings. Cover rename and deletion ordering through the real filesystem seam.
Represent each UI settings action as a one-key patch so stale in-memory values cannot overwrite concurrently persisted theme, tray, or stem-control changes.
Pause local playback and tear down A2DP before polling the ownership acknowledgement. Carry the inbound connection generation into a one-second bounded send so queue stalls and replacements cancel the stale acknowledgement.
Track takeover completion separately from observed playback so failed, skipped, or connection-aborted attempts retry while media remains active. Commit outcome state only while the listener generation is still current.
Install rustfmt and Clippy in the remote Rust job, fail on formatting or lint warnings before tests, and clean up formatting/boolean assertions plus an avoidable address-string comparison.
Route an initial missing PipeWire card through the bounded A2DP recovery path, refresh the card index before switching, and preserve active A2DP profiles. Own the one-time setup activation with the playback listener generation so replacement cancels stale setup work.\n\nRefs librepods-org#795
Test-only RED for librepods-org#799. The injected request operation is intentionally a no-op; BlueZ ConnectProfile remains unimplemented.
Resolve the BlueZ Device1 by normalized Address, request the A2DP sink profile once per MediaController connection, and continue bounded recovery on request errors.
Cover recreated-card profile selection and recovery, activation serialization, listener-generation fencing, and Pulse callback failures. Add behavior-neutral seams so each regression reaches the affected decision boundary.
@91sexboy

91sexboy commented Nov 3, 2026

Copy link
Copy Markdown
Author

@kavishdevar This is ready for review. The exact-head CI on the fork is green; GitHub currently marks the upstream PR workflows as action_required, awaiting maintainer approval for a first-time contributor.

Adapt the approved native SDK fixture to the integration property-offset loader without importing the other Android base. Existing one-call, disabled policy and forwarding cases characterize current behavior. The new null-record regression is expected to fail before a production guard fix.
The native public-boundary regression failed at an unconditional null record log argument in run 41844216908. Move only that field log inside its existing non-null guard; preserve original SDK forwarding, status and handle behavior.
Exercise the actual derivation source and require a full Nix package build. The existing fileset excludes the newly embedded icon; publish this diagnostic before changing production packaging.
The actual evaluated package source failed its icon asset gate in run 41959518431. Include only the required icon in the fileset; preserve the byte-comparison assertion and full Nix build gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant