• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef POWERMGR_IDEVICE_STATE_ACTION_H
17 #define POWERMGR_IDEVICE_STATE_ACTION_H
18 
19 #include <functional>
20 #include <string>
21 
22 #include "power_state_machine_info.h"
23 
24 namespace OHOS {
25 namespace PowerMgr {
26 enum ActionResult {
27     SUCCESS = 0,
28     FAILED = 1,
29 };
30 enum ActionEvent {
31     DISPLAY_ON_DONE = 0,
32     DISPLAY_OFF_DONE,
33 };
34 
35 class IDeviceStateAction {
36 public:
37     IDeviceStateAction() = default;
38     virtual ~IDeviceStateAction() = default;
39 
40     virtual void Suspend(int64_t callTimeMs, SuspendDeviceType type, uint32_t flags) = 0;
41     virtual void ForceSuspend() = 0;
42     virtual void Wakeup(int64_t callTimeMs, WakeupDeviceType type, const std::string& details,
43         const std::string& pkgName) = 0;
44     virtual void RefreshActivity(int64_t callTimeMs, UserActivityType type, uint32_t flags) = 0;
45     virtual DisplayState GetDisplayState() = 0;
46     virtual uint32_t SetDisplayState(DisplayState state,
47         StateChangeReason reason = StateChangeReason::STATE_CHANGE_REASON_UNKNOWN) = 0;
48     virtual uint32_t GoToSleep(const std::function<void()> onSuspend,
49         const std::function<void()> onWakeup, bool force) = 0;
50     virtual void RegisterCallback(std::function<void(uint32_t)>& callback) = 0;
51 };
52 } // namespace PowerMgr
53 } // namespace OHOS
54 #endif // POWERMGR_IDEVICE_STATE_ACTION_H
55