0

How WebView works with wake lock?

Flag Value               CPU   Screen   Keyboard
PARTIAL_WAKE_LOCK        On*    Off      Off
SCREEN_DIM_WAKE_LOCK     On     Dim      Off
SCREEN_BRIGHT_WAKE_LOCK  On    Bright    Off
FULL_WAKE_LOCK           On    Bright   Bright

*If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the user presses the power button. In all other wake locks, the CPU will run, but the user can still put the device to sleep using the power button.

In addition, you can add two more flags, which affect behavior of the screen only. These flags have no effect when combined with a PARTIAL_WAKE_LOCK.

This two FLAGS:

ACQUIRE_CAUSES_WAKEUP Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately.

ON_AFTER_RELEASE If this flag is set, the user activity timer will be reset when the WakeLock is released, causing the illumination to remain on a bit longer. This can be used to reduce flicker if you are cycling between wake lock conditions.

Scenario: App running one webview that need wait for onPageFinished() to do the processing (And yes, I need to use wake lock, this is just the simplest scenario)

Community
  • 1
  • 1
TroniPM
  • 329
  • 3
  • 13

1 Answers1

-1

WebView doesn't aquire wakelocks by itself, it's all up to your app's code.

Mikhail Naganov
  • 6,643
  • 1
  • 26
  • 26
  • It's not what i asked. – TroniPM Oct 08 '15 at 18:02
  • Sorry, then I'm not sure what your question is. Are you asking, whether WebView will work after your app acquires a wakelock? – Mikhail Naganov Oct 08 '15 at 19:22
  • I asked how is the webview behaviour when wake lock resource is active on a app. If I use _PARTIAL_WAKE_LOCK_, will the webview load properly (normal loading, even with the screen off)? If I use _SCREEN_DIM_WAKE_LOCK_, the webview will load the content normally? Etc... This is what i wanna know. – TroniPM Oct 08 '15 at 20:49
  • I would say that WebView will work like any other framework component. As CPU will continue running, that means WebView will be able to do any loads and page code execution. There is no need to have screen turned on in order to lay out web pages -- WebView just needs to know its size for that. – Mikhail Naganov Oct 09 '15 at 15:18