Enum Class WakeLockAvailability

java.lang.Object
java.lang.Enum<WakeLockAvailability>
com.vaadin.flow.component.wakelock.WakeLockAvailability
All Implemented Interfaces:
Serializable, Comparable<WakeLockAvailability>, Constable

public enum WakeLockAvailability extends Enum<WakeLockAvailability>
Whether the browser can hold a screen wake lock in the current page context.

Held by WakeLock.availabilitySignal(). Reading the value does not call the browser API ? it reports whether the next WakeLock.request() has any chance of succeeding.

Typical usage: hide a "keep screen on" toggle entirely when the value is UNSUPPORTED (no user action can change this), and otherwise offer it and observe WakeLock.activeSignal(UI) for the actual state.

Since:
25.2
  • Enum Constant Details

    • SUPPORTED

      public static final WakeLockAvailability SUPPORTED
      The browser exposes the Screen Wake Lock API and the page is served from a secure context, so WakeLock.request() has a chance of succeeding. Whether the browser actually grants the lock still depends on page visibility, battery state, and other transient conditions ? observe WakeLock.activeSignal(UI) for the actual outcome.
    • UNSUPPORTED

      public static final WakeLockAvailability UNSUPPORTED
      The Screen Wake Lock API is not usable in the current page context ? the browser does not implement it, or the page is served over an insecure connection (plain HTTP rather than HTTPS or localhost). No user action can change this; applications should hide wake-lock-related controls entirely instead of offering a button that would always fail.
    • UNKNOWN

      public static final WakeLockAvailability UNKNOWN
      The browser has not yet reported a value. This is the seed value held during the brief window between UI attach and the bootstrap response being processed; in practice applications see it only as a transient state.
  • Method Details

    • values

      public static WakeLockAvailability[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static WakeLockAvailability valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null