Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[expo-keep-awake] [android] mixing tags breaks keepAwake functionality #6031

Closed
sy1vain opened this issue Oct 19, 2019 · 0 comments 路 Fixed by #7197
Closed

[expo-keep-awake] [android] mixing tags breaks keepAwake functionality #6031

sy1vain opened this issue Oct 19, 2019 · 0 comments 路 Fixed by #7197

Comments

@sy1vain
Copy link

sy1vain commented Oct 19, 2019

馃悰 Bug Report

Environment

SDK 35 on Android

Steps to Reproduce

  • Activate KeepAwake with two different tags -> device stays on
  • Deactivate only one tag -> device will go to sleep after a while
  • Re-active that tag -> device will go to sleep after a while
  • Deactivate all tags -> device will go to sleep after a while
  • Re-active one or multiple tags -> device stays on

When turning on keepAwake with two or more different tags and then turning off only one the device will go to sleep after a while. KeepAwake can then only be activated again by first turning it of for all tags and then turning one (or multiple) on.

Expected Behavior

The device should not sleep while there is at least one tag active (as is the behavior on iOS)

Actual Behavior

Deactivating a keepAwake tag will enable the device to sleep even if there are other tags still trying to keep the device awake. It is impossible to reactive the keepAwake functionality until all tags are deactivated first.

Glancing at the source code on Android it will always turn off the keepAwake functionality, even if there are tags left:

if (isActivated() && activity != null) {
activity.runOnUiThread(() -> activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
}

But when there are already tags on the list it won't turn on the keepAwake functionality:

if (!isActivated()) {
if (activity != null) {
activity.runOnUiThread(() -> activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON));
}
}

iOS checks this by using a shouldBeActive function

Reproducible Demo

Use this Snack on Android

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

Successfully merging a pull request may close this issue.

3 participants