Skip to content

fix: screen timeout ignored when dashboard has live camera stream#6388

Open
almirus wants to merge 1 commit intohome-assistant:mainfrom
almirus:main
Open

fix: screen timeout ignored when dashboard has live camera stream#6388
almirus wants to merge 1 commit intohome-assistant:mainfrom
almirus:main

Conversation

@almirus
Copy link

@almirus almirus commented Feb 4, 2026

Summary

Fix device screen timeout when a dashboard streams a live camera and the app setting "Keep screen on" is turned off.

Motivation: With "Keep screen on" disabled, WebView/Chromium still keeps the screen on during video playback (fullscreen custom view and inline streams), so the system screen timeout never runs (#3953).

Changes (only in WebViewActivity.kt):

  • In onShowCustomView: when "Keep screen on" is disabled, clear keepScreenOn recursively on the custom fullscreen video view and its children so Chromium cannot keep the screen on.
  • In onResume: when the setting is disabled, set webView.keepScreenOn = false after clearing the window flag, and start a periodic task that clears webView.keepScreenOn every 5 seconds while the activity is in the foreground (to override Chromium for inline video). The task is cancelled in onPause and when the setting is enabled.
  • Add clearKeepScreenOnRecursive, scheduleKeepScreenOnClearWhenDisabled, and cancelKeepScreenOnClear to implement the above.

Impact: With "Keep screen on" off, the device screen timeout works again even when the dashboard shows a live camera stream (fullscreen or inline). No change when "Keep screen on" is on.

Fixes #3953

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Screenshots

No UI changes.

Link to pull request in documentation repositories

User Documentation: home-assistant/companion.home-assistant#
Not applicable.

Developer Documentation: home-assistant/developers.home-assistant#
Not applicable.

Any other notes

  • Only app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt is modified.
  • The 5-second interval for clearing webView.keepScreenOn is a trade-off between fixing inline video and limiting extra wakeups; it can be adjusted via keepScreenOnClearIntervalMs if needed.

@jpelgrom
Copy link
Member

jpelgrom commented Feb 4, 2026

I'm not sold on this 'fix'. For normal media usage, where you want to keep the screen on while watching a video automatically, this is a regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device screen timeout has no affect when dashboard is streaming live camera

2 participants