BatteryStatusProvider Class

The source of the battery status of the device (https://w3c.github.io/battery/), read by navigator.getBattery(), of the browsing contexts that share a BrowsingContextOptions (BatteryStatusOptions.Provider). The default implementation returns BatteryStatusProvider.Status, set by the application (e.g. to simulate a battery). Override BatteryStatusProvider.GetStatus to read another source, and call BatteryStatusProvider.OnStatusChanged when the status changes, to update the BatteryManager objects of the documents.

public class BatteryStatusProvider

Remarks

A provider can be shared by several browsing contexts, and used from any thread.

Constructors

NameDescription
BatteryStatusProvider()

BatteryStatusProvider()

BatteryStatus.cs
public BatteryStatusProvider()

No documentation is available.

Properties

NameDescription
StatusGets or sets the status returned by the default implementation of BatteryStatusProvider.GetStatus (BatteryStatus.Default by default). Setting it updates the BatteryManager objects of the documents, which fire their change events.

Gets or sets the status returned by the default implementation of BatteryStatusProvider.GetStatus (BatteryStatus.Default by default). Setting it updates the BatteryManager objects of the documents, which fire their change events.

public BatteryStatus Status { get; set; }

Property value

BatteryStatus

Methods

NameDescription
GetStatus()Returns the status of the battery. The default implementation returns BatteryStatusProvider.Status. It is called on the thread of an event loop, and must not block it.
OnStatusChanged()Raises BatteryStatusProvider.StatusChanged, then reads the status again for the BatteryManager objects of the documents, which fire their change events. It can be called from any thread.

GetStatus()

BatteryStatus.cs

Returns the status of the battery. The default implementation returns BatteryStatusProvider.Status. It is called on the thread of an event loop, and must not block it.

public virtual BatteryStatus GetStatus()

OnStatusChanged()

BatteryStatus.cs

Raises BatteryStatusProvider.StatusChanged, then reads the status again for the BatteryManager objects of the documents, which fire their change events. It can be called from any thread.

protected void OnStatusChanged()

Events

NameDescription
StatusChangedRaised when the status changes (BatteryStatusProvider.OnStatusChanged).

StatusChanged

Raised when the status changes (BatteryStatusProvider.OnStatusChanged).

public event EventHandler? StatusChanged