Probe for 10s and log its outcome before locking

The phone's beacon app pauses advertising for stretches while in range,
which is what the 3s probe could not bridge. Give the controller a 10s
window to find the phone, and log probe outcomes at INFO/WARN so the
journal explains every lock decision.
This commit is contained in:
Bastian Mäuser committed 2026-11-05 14:57:48 +01:00
1 parent 43a79d8a43
commit c25ccde58e
2 files changed
+12 -8

No files matched your search

+2 -2
View File
@@ -39,7 +39,7 @@ The daemon adapts it to a small state machine:
Locking goes through `loginctl lock-session` (works with GNOME, KDE, Sway,
...), configurable via `lock_command`. Before locking, the daemon attempts a
short (3s) LE connection to the paired phone: a phone in range accepts it,
short (10s) LE connection to the paired phone: a phone in range accepts it,
which cancels the lock — silence in the advertisement stream alone is not
proof of absence.
@@ -122,7 +122,7 @@ See `config.toml.example`; every knob is documented there. Highlights:
identical RSSI values (its property cache suppresses unchanged values), so
a stationary phone can go quiet in the event stream while in range. Two
countermeasures: the radio escalates duty while updates are stalled (see
Present above), and the lock decision is gated on a 3s LE connect probe.
Present above), and the lock decision is gated on a 10s LE connect probe.
`--dry-run` on your hardware remains the arbiter. The AdvertisementMonitor
roadmap removes this class of problem.
- While the screen is locked the daemon keeps low-duty scanning to notice
+10 -6
View File
@@ -176,9 +176,10 @@ struct Target {
}
/// How long to wait for the connect probe before concluding the phone is
/// gone. LE connection setup with the phone in range completes well within
/// this; aborting cancels BlueZ's connection attempt.
const PROBE_TIMEOUT: Duration = Duration::from_secs(3);
/// gone. The controller scans for the phone's advertisements for this whole
/// window, so slow or intermittent advertising still gets caught; aborting
/// cancels BlueZ's connection attempt.
const PROBE_TIMEOUT: Duration = Duration::from_secs(10);
/// Attempt a short LE connection to the paired phone. Returns true if the
/// device accepted the connection (it is in range); the connection is closed
@@ -190,7 +191,7 @@ async fn probe_reachable(conn: &Connection, target: Option<&Target>) -> bool {
let proxy = match Proxy::new(conn, BLUEZ, target.path.clone(), DEVICE_IFACE).await {
Ok(p) => p,
Err(e) => {
debug!("probe: proxy setup failed: {e:#}");
warn!("probe: proxy setup failed: {e:#}");
return false;
}
};
@@ -207,11 +208,14 @@ async fn probe_reachable(conn: &Connection, target: Option<&Target>) -> bool {
true
}
Ok(Err(e)) => {
debug!("probe: connect rejected: {e:#}");
info!("probe: connect rejected: {e:#}");
false
}
Err(_) => {
debug!("probe: timed out");
warn!(
"probe: no connection within {}s, treating phone as out of range",
PROBE_TIMEOUT.as_secs()
);
// Cancel the pending connection attempt so BlueZ does not keep
// paging for the device in the background.
let _ = tokio::time::timeout(