class TimeoutWakeLease

Defined at line 130 of file ../../sdk/lib/driver/power/cpp/wake-lease.h

Wrapper around usage of fuchsia.power.system/ActivityGovernor.AcquireWakeLease. The wrapper

reduces SAG wake lease creation by allowing callers to set timeout after which to drop the

lease and provides mechanisms to extend that timeout.

Public Methods

bool IsResumed ()

Returns `true` if the instance thinks the system is currently resumed.

This value may be wrong if the instance has not observed any system state

changes since it was created.

Defined at line 185 of file ../../sdk/lib/driver/power/cpp/wake-lease.h

void SetSuspended (bool suspended)

Defined at line 187 of file ../../sdk/lib/driver/power/cpp/wake-lease.h

void TimeoutWakeLease (async_dispatcher_t * dispatcher, std::string_view lease_name, fidl::ClientEnd<fuchsia_power_system::ActivityGovernor> sag_client, inspect::Node * parent_node, bool log, uint32_t long_duration_threshold)

If |log| is set to true, logs will be emitted when acquiring leases and when lease times out.

An invalid |sag_client| will result in silently disabling wake lease acquisition.

Defined at line 261 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc

bool HandleInterrupt (zx::duration timeout)

Ensure that the system stays awake until the timeout is reached. To accomplish this we either:

* obtain a SAG wake lease immediately if the system is currently suspended

* obtain a SAG wake lease in the future if the system begins suspension before the timeout

is reached

If a SAG wake lease is acquired, it is dropped when the timeout is reached. The timeout may be

extended by additional calls to `HandleInterrupt` or `AcquireWakeLease`. If the system is not

suspended and does not attempt suspension during the timeout period, no wake lease is obtained.

Ideally this is only called after we wake up due to an interrupt. Note that a duration is

taken because the deadline is computed once the lease is acquired, rather than at the point

this method is called.

Returns `false` if it was necessary to obtain a SAG wake lease and it failed to do so. Returns

`true` if it already had a wake lease or if it did not and it succeeded in obtaining one.

Defined at line 271 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc

bool AcquireWakeLease (zx::duration timeout)

Acquire a SAG wake lease and automatically drop it after the specified timeout. If a lease was

still already held, it will be extended until the new timeout. Note that a duration is taken

because the deadline is computed once the SAG lease is acquired,rather than at the point this

method is called.

Returns `false` if it was necessary to obtain a SAG wake lease and it failed to do so. Returns

`true` if it already had a wake lease or if it did not and it succeeded in obtaining one.

Defined at line 293 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc

void DepositWakeLease (zx::eventpair wake_lease, zx::time timeout_deadline)

Provide a SAG wake lease to the `TimeWakeLease` which will be dropped either:

* immediately if there is already a SAG wake lease with a later deadline

* at the specified deadline

In the latter case any previous SAG lease held by this object is dropped immediately.

Defined at line 299 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc

zx::result<zx::eventpair> TakeWakeLease ()

Cancel timeout and take the SAG wake lease. Returns ZX_ERR_BAD_HANDLE if we don't currently

have a wake lease.

Defined at line 312 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc

zx::result<zx::eventpair> GetWakeLeaseCopy ()

Get a duplicate of the stored SAG wake lease. Returns ZX_ERR_BAD_HANDLE if we don't currently

have a SAG wake lease.

Defined at line 317 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc

zx_time_t GetNextTimeout ()

Get the time our next timeout will occur. If there is no currently active

timeout this will be ZX_TIME_INFINITE.

Defined at line 291 of file ../../sdk/lib/driver/power/cpp/wake-lease.cc