class StateMachineDriver

Defined at line 37 of file ../../src/sys/activity/state_machine_driver.h

StateMachineDriver is a class which drives an ActivityStateMachine based on user activity.

The responsibilities of the StateMachineDriver are:

- To receive inputs and forward them to the state machine in a sequential manner, and

- To manage timers which drive the state machine in the absence of any inputs.

StateMachineDriver dispatches work onto an asynchronous loop, which ensures sequential processing

of events from different sources (e.g. user input v.s. automated timers).

Public Methods

fuchsia::ui::activity::State GetState ()

Defined at line 26 of file ../../src/sys/activity/state_machine_driver.cc

zx_status_t RegisterObserver (ObserverId id, StateChangedCallback callback)

Defined at line 30 of file ../../src/sys/activity/state_machine_driver.cc

zx_status_t UnregisterObserver (ObserverId id)

Defined at line 35 of file ../../src/sys/activity/state_machine_driver.cc

void StateMachineDriver (async_dispatcher_t * dispatcher)

Defined at line 39 of file ../../src/sys/activity/state_machine_driver.h

void ~StateMachineDriver ()

Defined at line 43 of file ../../src/sys/activity/state_machine_driver.h

zx_status_t ReceiveDiscreteActivity (const fuchsia::ui::activity::DiscreteActivity & activity, zx::time time, VoidCallback callback)

Inputs to the state machine. These methods enqueue a work item onto the driver's async loop to

handle the given activity, scheduling the work item to run at |time|.

If |time| was before the last state transition, it is ignored and ZX_ERR_OUT_OF_BOUNDS is

returned. (Events may be interpreted differently depending on the current state.)

|callback| is invoked once the work item on the async loop is executed. If an error is

returned, |callback| is invoked immediately and synchronously.

Defined at line 44 of file ../../src/sys/activity/state_machine_driver.cc

const ActivityStateMachine & state_machine ()

Defined at line 47 of file ../../src/sys/activity/state_machine_driver.h

size_t num_observers ()

Exposed for testing

Defined at line 52 of file ../../src/sys/activity/state_machine_driver.h

zx_status_t StartOngoingActivity (OngoingActivityId id, zx::time time, VoidCallback callback)

Defined at line 62 of file ../../src/sys/activity/state_machine_driver.cc

zx_status_t EndOngoingActivity (OngoingActivityId id, zx::time time, VoidCallback callback)

Defined at line 81 of file ../../src/sys/activity/state_machine_driver.cc

void SetOverrideState (std::optional<fuchsia::ui::activity::State> state)

Force the state machine into |state|.

The state machine will continue to receive and process input, but observers will only be

notified of |state| and any future states set through this method.

Passing std::nullopt will disable the override, which has the following effects:

- Immediately notifies all listeners of the actual state of the state machine

- Returns the state machine to its original behavior, where observers are notified of

state transitions occuring due to received inputs.

Defined at line 100 of file ../../src/sys/activity/state_machine_driver.cc