home-assistant / android

:iphone: Home Assistant Companion for Android
https://companion.home-assistant.io/
Apache License 2.0
2.34k stars 653 forks source link

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

Open raldred opened 1 year ago

raldred commented 1 year ago

Home Assistant Android app version(s): 2023.10.2-full Android version(s): 11, 13, 14 Device model(s): Galaxy Tab A, Pixel 6 Home Assistant version: 2023.10.3 Last working Home Assistant release (if known): unknown Description of problem, include YAML if issue is related to notifications:

Context: Tried two separate Android devices, both exhibit the problem described below. Both have their OS screen timeout set to 15 seconds. Both have their companion app with "Keep on screen" setting "off" Issue presents whether charging or not.

Issue: When a the dashboard has a live camera stream, the device's screen timeout has no effect, the dashboard remains on and active. When the dashboard has NO live camera stream, the device's screen timeout works as expected.

Companion App Logs: Too long to share here, over github comment limit of 65536 characters Google drive link: https://drive.google.com/file/d/1UaXKwMCnvQV3ZC6XuHDeeht4AmLf5v1S/view?usp=sharing

Screenshot or video of problem: Note, my Nest camera's "auto" view shows a weird blank image since I transferred it to the Google Home app.


Videos: Too big for github's 10MB limit Google photos link: https://photos.app.goo.gl/XUoTM3B7mAkuKL6x6

Additional information: This issue has been reported before but has been closed, I was asked to create a new issue. https://github.com/home-assistant/android/issues/2881

dshokouhi commented 1 year ago

Not quite sure this is something in teh apps control, might be specific to WebView here.

spawn-guy commented 2 months ago

That is an interesting issue.

I would, actually, like my screen Not to timeout. my Samsung tab a6 (android 5.1.1) does not have a Screen option to never timeout (max 30 mins).

And it was not timing out with hass app open.. Until I cleared all app data (wanted to fix a neerslag-app addon issue, alas). But I did have a live view card. it is now not visible on screen, when neerslag chart fails.

So, that is what I need to fix - make live view visible for screen not to timeout šŸ¤”

Oh, an update: I totally missed the toggle in companion app settings šŸ˜” cause the liveview is visible on screen, but it timed out

raldred commented 2 months ago

I think as @dshokouhi alluded to, this is related to the underlying webview which prevents screen timeout when a video stream is playing. android.webkit.WebView maintains a visibility property which applies or removes the FLAG_KEEP_SCREEN_ON flag.

I think we'd need introduce something to manipulate the visibility with webView.setVisibility(View.GONE); based on the devices configured screen timeout, this is sually available with

Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT);

If we maintained a timer within the app, we could apply flip the visibility to VIew.Gone if the apps "Keep screen on" is disabled.