Skip to content

fix(android): prevent screen from turning off during active video calls in example application#1057

Open
mechtech-mind wants to merge 8 commits into
livekit:mainfrom
mechtech-mind:main
Open

fix(android): prevent screen from turning off during active video calls in example application#1057
mechtech-mind wants to merge 8 commits into
livekit:mainfrom
mechtech-mind:main

Conversation

@mechtech-mind
Copy link
Copy Markdown
Contributor

This PR fixes an issue in the Android example application where the device screen turns off automatically during an active video call due to screen timeout.

Problem

During an ongoing LiveKit call on Android, the screen is not kept awake, which leads to:

  • Poor user experience during video calls
  • Interrupted visibility when no user interaction occurs

Solution

This PR adds native Android window flag handling in MainActivity to ensure the screen remains active while a call is in progress:

  • Uses native flags to prevent screen timeout
  • Uses native flags as well to handle lock screen visibility

The flags are:

  • Enabled when the room is active
  • Cleared when the room is disposed

Copy link
Copy Markdown
Contributor Author

@mechtech-mind mechtech-mind left a comment

Choose a reason for hiding this comment

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

@hiroshihorie is it ok?

Copy link
Copy Markdown
Contributor Author

@mechtech-mind mechtech-mind left a comment

Choose a reason for hiding this comment

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

yeah looks ok

Copy link
Copy Markdown
Member

@hiroshihorie hiroshihorie left a comment

Choose a reason for hiding this comment

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

Left a few small notes. The keep-awake idea makes sense; I think this just needs a little tightening before merge.

Comment thread example/lib/pages/room.dart Outdated
Comment thread example/android/app/src/main/kotlin/io/livekit/example/MainActivity.kt Outdated
Comment thread pubspec.lock Outdated
@mechtech-mind
Copy link
Copy Markdown
Contributor Author

Hi @hiroshihorie,

I have updated the PR as per the changes you suggested:

wrapped the in-call flag calls with Android platform checks
removed the lockscreen/wake-over-screen behavior
removed the unrelated lockfile changes

Thanks again for the review.

Copy link
Copy Markdown
Member

@hiroshihorie hiroshihorie left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. The lockfile and lock screen parts look fixed. I left two small platform notes.

Comment thread example/lib/pages/room.dart Outdated
Comment thread example/lib/pages/room.dart Outdated
Refactor platform check for enabling and disabling in-call flags also removed dart.io import
@mechtech-mind
Copy link
Copy Markdown
Contributor Author

@hiroshihorie Thanks again for the reviews. I have updated the file as per the requirements. I will make sure to check thoroughly before creating the PR.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants