With SCREEN_BRIGHT_WAKE_LOCK deprecated, how can I keep the screen on in Wear OS?

747 Views Asked by At

For my Wear OS watch face project, I was using the flag SCREEN_BRIGHT_WAKE_LOCK to acquire a wakelock that keeps the screen fully on for one minute (triggered by the user as needed). This flag has been deprecated. The flag PARTIAL_WAKE_LOCK is still valid, but does not keep the screen on. What is the correct way to do this now?

1

There are 1 best solutions below

2
On

I believe the watch controls this and it's usually a user setting to enable "Always on Display". Even in this mode, it's likely that the app also runs in ambient mode.

For Watchfaces, you can check the drawMode

https://github.com/android/wear-os-samples/blob/main/WatchFaceKotlin/app/src/main/java/com/example/android/wearable/alpha/AnalogWatchCanvasRenderer.kt#L221-L226

 override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {
        val backgroundColor = if (renderParameters.drawMode == DrawMode.AMBIENT) {

When it

For Apps

This AlwaysOnKotlin sample demonstrates how to support your app drawing in Ambient mode

Awake

Ambient

It uses Ambient Mode