| // Copyright 2020 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef COBALT_SRC_PUBLIC_ACTIVITY_LISTENER_INTERFACE_H_ |
| #define COBALT_SRC_PUBLIC_ACTIVITY_LISTENER_INTERFACE_H_ |
| |
| #include <functional> |
| |
| namespace cobalt { |
| |
| // The possible device states that Cobalt is prepared to handle. |
| enum ActivityState { ACTIVE, IDLE, UNKNOWN }; |
| |
| class ActivityListenerInterface { |
| public: |
| ActivityListenerInterface() = default; |
| virtual ~ActivityListenerInterface() = default; |
| |
| // Triggers the listener to begin listening for changes in the device state. |
| // |
| // This method should be called only once and should be called before the ActivityState is read |
| // directly. |
| // |
| // |callback| will be called when the device state changes and when device state is received for |
| // the first time. |
| virtual void Start(const std::function<void(ActivityState)>& callback) = 0; |
| |
| // Returns the current activity state of the device. Start() must be called before the |
| // ActivityState value is read directly. |
| // |
| // Start() should be |
| virtual ActivityState state() = 0; |
| }; |
| |
| } // namespace cobalt |
| |
| #endif // COBALT_SRC_PUBLIC_ACTIVITY_LISTENER_INTERFACE_H_ |