Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions shell/plugins/lock/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Item {

resetAuthenticationState()
lockRequested = true
idleBlankTimer.blanked = false
armBlankTimer()
logEvent("lock-requested")
queueSessionLock()
Expand All @@ -243,20 +244,35 @@ Item {
pendingSessionLockTimer.stop()
resetAuthenticationState()
idleBlankTimer.stop()
idleBlankTimer.blanked = false
sessionLock.locked = false
logEvent("unlocked")
runWake()
}

function armBlankTimer(delayMs) {
idleBlankTimer.interval = delayMs || idleBlankTimer.idleMs
var want = delayMs || idleBlankTimer.idleMs
// A longer pending countdown is never cut short: wake input right after
// a blank, and the output re-detection right after a resume, must not
// reset those longer graces to the idle run-up while more than the
// run-up is left. Once less of a grace remains than a run-up takes, an
// ordinary arm refreshes the countdown as before.
if (idleBlankTimer.running && idleBlankTimer.armedAt + idleBlankTimer.interval - Date.now() > want) return
idleBlankTimer.interval = want
idleBlankTimer.armedAt = Date.now()
idleBlankTimer.restart()
}

function runWake() {
if (!wakeProcess.running) wakeProcess.running = true
if (lockRequested) armBlankTimer()
if (lockRequested) {
if (idleBlankTimer.blanked) {
idleBlankTimer.blanked = false
armBlankTimer(idleBlankTimer.wakeMs)
} else {
armBlankTimer()
}
}
resumeFingerprint()
nudgeFingerprint()
}
Expand Down Expand Up @@ -349,6 +365,7 @@ Item {
}

function runBlank() {
idleBlankTimer.blanked = true
pauseFingerprint()
if (!blankProcess.running) blankProcess.running = true
}
Expand Down Expand Up @@ -771,6 +788,10 @@ Item {
// panel lights (on NVIDIA it waits out a VT switch and a modeset), so the
// idle run-up blanked the lock just as it appeared.
readonly property int resumeMs: 15000
// Displays take seconds to light after DPMS off, so the first wake after a
// blank gets a longer grace before the idle countdown reblanks.
readonly property int wakeMs: 15000
property bool blanked: false
interval: idleMs
repeat: false
property double armedAt: 0
Expand Down
49 changes: 49 additions & 0 deletions test/shell.d/fixtures/lock-fingerprint-service/shell.qml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,55 @@ ShellRoot {
check(!service.fingerprintPaused, "unlock reset clears a pause so the next lock starts the reader")
service.applyFingerprintProbe("Daemon is restarting")
check(!recheck.running, "an unknown probe outside the lock cannot restart it")

// First wake after blank grants a longer grace so the user can type
// before reblanking; bursts of wake input preserve that countdown. Move
// the armed countdown back 7s so the burst reads as seconds after the
// first wake even though both run inside the same wall-clock
// millisecond: a burst that reset or re-granted the countdown would
// move its deadline and fail the exact match.
service.lockRequested = true
service.runBlank()
service.runWake()
check(blankTimer.interval === 15000, "first wake after a blank arms the longer grace")
blankTimer.armedAt -= 7000
var initialDeadline = blankTimer.armedAt + blankTimer.interval
blankTimer.stop()

blankTimer.start()
service.runWake()
service.runWake()
check(blankTimer.interval === 15000 && blankTimer.armedAt + blankTimer.interval === initialDeadline,
"burst of wake inputs preserves the long grace deadline")
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

blankTimer.armedAt = Date.now() - 11000
service.runWake()
check(blankTimer.interval === 5000, "wake input once less than 5s of the grace remains re-arms the normal 5s interval")
blankTimer.stop()
service.runWake()
check(blankTimer.interval === 5000, "input ending a password check arms the normal 5s run-up even with grace left over")
Comment on lines +264 to +266

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Password-check case misses remaining grace

The preceding check has already changed blankTimer.interval to 5000. Stopping that timer and calling runWake() does not test the claimed case “even with grace left over.” A regression that restores the remaining 15-second grace after a password check would still pass.

Arm a fresh 15-second grace before stopping the timer, then check that ending the password check starts the normal 5-second countdown.


// A resume arms the same longer countdown, through the blank timer's
// own suspend-gap check; the wake paths that fire within a second of
// the resume must not reset it to the idle run-up.
blankTimer.interval = 5000
blankTimer.armedAt = Date.now() - 60000
blankTimer.start()
blankTimer.triggered()
check(blankTimer.interval === 15000, "a countdown frozen by suspend re-arms the resume grace instead of blanking")
service.armBlankTimer()
check(blankTimer.interval === 15000, "an output re-detection right after a resume keeps the resume grace")
service.runWake()
check(blankTimer.interval === 15000, "a wake burst right after a resume keeps the resume grace")
blankTimer.armedAt = Date.now() - 11000
service.runWake()
check(blankTimer.interval === 5000, "input once the resume grace is mostly spent re-arms the normal 5s interval")
blankTimer.stop()

service.runBlank()
service.runWake()
check(blankTimer.interval === 15000, "wake after blanking again arms the longer grace")
blankTimer.stop()
} finally {
service.lockRequested = false
service.resetAuthenticationState()
Expand Down
9 changes: 9 additions & 0 deletions test/shell.d/lock-fingerprint-service-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@

set -euo pipefail

# shellcheck disable=SC1091
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

require_quickshell "lock fingerprint service test"

qml_fixture_scratch
printf '#!/bin/bash\nexit 0\n' >"$QML_FIXTURE_TMP/bin/omarchy-system-wake"
printf '#!/bin/bash\nexit 0\n' >"$QML_FIXTURE_TMP/bin/omarchy-brightness-display"
printf '#!/bin/bash\nexit 0\n' >"$QML_FIXTURE_TMP/bin/omarchy-brightness-keyboard"
chmod +x "$QML_FIXTURE_TMP/bin/omarchy-system-wake" \
"$QML_FIXTURE_TMP/bin/omarchy-brightness-display" \
"$QML_FIXTURE_TMP/bin/omarchy-brightness-keyboard"

run_qml_fixture lock-fingerprint-service "fingerprint service handles enrollment, failures and recovery" Ui Commons
Loading