-
-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Screen turns off while patching due to wrong WakeLock #2147
base: compose-dev
Are you sure you want to change the base?
Conversation
The incorrect use of |
Isn't this purpose already achieved by foreground service? |
That was what I heard from the previous maintainer, but it was a while ago so I might be wrong. Also, it appears |
I could not find any information in the official documentation that foreground services are also limited without WakeLock, but I did find such information on StackOverflow. But WakeLock is not related to background task killing by Android. What's your opinion? |
Keeping the CPU on while patching might be desirable. I am not sure if we should use @Ushie and @validcube may have ideas here. |
What's the progress of this PR? |
Fix a issue that screen timeout is activated during patching.
This is caused by WakeLock not being set correctly.
The current code is passing
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
tonewWakeLock()
.But this is wrong.
It is true that the document says that
PowerManager.FULL_WAKE_LOCK
is deprecated and useWindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
instead.However, this does not mean passing the
FLAG_KEEP_SCREEN_ON
flag tonewWakeLock()
.The flag have to be passed to
window.addFlags()
.https://developer.android.com/develop/background-work/background-tasks/scheduling/wakelock#screen
Therefore, I removed WakeLock and add window.addFlags().
Since the window requires Activity context, it can't be handled from PatcherWorker, so I added it to the UI code.
I've checked this sets KEEP_SCREEN_ON correctly at the start of patching, and clears the flag correctly when succeeded or failed to patching, or patching was canceled.