Skip to content

Fix keep-awake releasing the wakelock shortly after connect#224

Merged
d4rken merged 1 commit into
mainfrom
refactor/requires-persistent-session
May 11, 2026
Merged

Fix keep-awake releasing the wakelock shortly after connect#224
d4rken merged 1 commit into
mainfrom
refactor/requires-persistent-session

Conversation

@d4rken
Copy link
Copy Markdown
Member

@d4rken d4rken commented May 11, 2026

The keep-awake setting wasn't actually keeping the device awake. On Bluetooth connect, the partial CPU wakelock was acquired correctly, but ~15 seconds later the monitor service would stop (when the post-connect dispatcher fell idle) and release the wakelock again — leaving the user with the original problem the toggle was meant to solve.

Root cause: the requiresMonitor predicate on ManagedDevice excluded keepAwake and only flipped true for the three volume-monitoring features. So a profile with only KeepAwake enabled fell through to the "stop after idle + 15s grace" path instead of the "stay alive" path. The same predicate was used by MonitorControl for reactive auto-start, so toggling KeepAwake on an already-connected device also did nothing.

Renamed the property to requiresPersistentSession and added keepAwake to the predicate.

Behavior changes:

  • Connecting a keep-awake-enabled device now keeps the monitor service alive (and the CPU wakelock held) for the duration of the connection, not just 15 seconds.
  • Toggling keep-awake on an already-connected device auto-starts the service the same way toggling volume-lock or volume-observing already did.

Companion to the recent Bluetooth-connect timing PRs.

Test plan

  • ./gradlew assembleFossDebug
  • ./gradlew testFossDebugUnitTest (566 pass)
  • ./gradlew testGplayDebugUnitTest (566 pass)

The old name conflated 'needs ongoing service work' with the predicate's actual role, and excluding keepAwake was a real bug: keep-awake-only devices were getting the post-PR1 15s idle grace instead of staying alive, releasing the partial CPU wakelock prematurely.

Behavior changes:

- Toggling keepAwake on an already-connected device now auto-starts the foreground service (matches existing behavior for volume-lock and volume-observing toggles).

- The orchestrator now stays alive indefinitely while any keepAwake device is connected, holding the CPU wakelock as intended.
@d4rken d4rken added the bug label May 11, 2026
@d4rken d4rken merged commit 833ac0e into main May 11, 2026
11 checks passed
@d4rken d4rken deleted the refactor/requires-persistent-session branch May 11, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant