template <typename Driver>
class Suspendable
Defined at line 92 of file ../../sdk/lib/driver/power/cpp/suspend.h
Drivers should use `Suspendable` to implement suspend and resume support for
their driver. The `fuchsia-suspendable` skill in //src/devices/skills for
agents should be able to do the basic integration. Information in that skill
is also a guide for human authors, but a summary is below.
To properly use this mix-in drivers should:
* Update their component manifest and add `suspend_enabled: "true"` to the
program stanza.
* Implement the virtual methods defined here.
* Implement `std::optional
<fidl
::ServerEnd
<fuchsia
_power_broker::ElementRunner>>
take_power_element_runner()` in the driver.
* Call `InitializeSuspend` in their start method, after
`take_power_element_runner()` can return a valid value.
`InitializeSuspend` does one of three things
1) If suspend is not enabled based on `SuspendEnabled`, it returns
`zx::ok` immediately.
2) If `Driver::take_power_element_runner` returns a value it uses calls
to `SetLevel` to levels 0 and 1 to drive calls to `BeforeSuspend` and
`AfterResume`, respectively.
3) If neither (1) nor (2), it registers a
`fuchsia.power.system/SuspendBlocker` with the `ActivityGovernor`
protocol.
The typical implementation for `take_power_element_runner()` returns the
value from `DriverContext::take_power_element_runner()` from the
`DriverContext` instance passed to the driver's `Start` hook. The driver
should take the runner from `DriverContext` during `Start` and store and
then return it from the driver's `take_power_element_runner` implementation.
Public Methods
void Suspend (SuspendCompleter completer)
Interface to be implemented.
void Resume (ResumeCompleter completer)
bool SuspendEnabled ()
void Suspendable<Driver> ()
Defined at line 99 of file ../../sdk/lib/driver/power/cpp/suspend.h
bool SuspendActive ()
Returns true if:
* suspend was enabled and we did one of the following
a) got a value from `Driver::take_power_element_runner`
b) successfully registered with SAG as a `fuchsia.power.system/SuspendBlocker`.
* suspend was not enabled
Returns false if suspend was enabled and we failed to register with SAG.
Defined at line 110 of file ../../sdk/lib/driver/power/cpp/suspend.h
void ~Suspendable<Driver> ()
Defined at line 112 of file ../../sdk/lib/driver/power/cpp/suspend.h
zx::result<> InitializeSuspend (async_dispatcher_t *dispatcher,fdf::Namespace &incoming,std::string_viewname)
Defined at line 114 of file ../../sdk/lib/driver/power/cpp/suspend.h