• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_POWER_STATE_MACHINE_INFO_H
17 #define POWERMGR_POWER_STATE_MACHINE_INFO_H
18 
19 #include <string>
20 
21 #include <parcel.h>
22 
23 namespace OHOS {
24 namespace PowerMgr {
25 /*
26  * If already dimmed, extend the dim timeout but do not brighten. This flag is useful for keeping
27  * the screen on little longer without causing a visible change such as when the power key is pressed.
28  */
29 constexpr uint32_t REFRESH_ACTIVITY_NO_CHANGE_LIGHTS = 1 << 0;
30 constexpr uint32_t REFRESH_ACTIVITY_NEED_CHANGE_LIGHTS = 0;
31 
32 /*
33  * Indicate whether device enter suspend immediately
34  */
35 constexpr uint32_t SUSPEND_DEVICE_NEED_DOZE = 0;
36 constexpr uint32_t SUSPEND_DEVICE_IMMEDIATELY = 1 << 0;
37 
38 // This is use for judge whether the time is valid.
39 constexpr int DEFAULT_SYSTEM_START_TIME = 0;
40 
41 // Max datails string length
42 constexpr int MAX_STRING_LENGTH = 128;
43 
44 // Throttling interval for user activity calls.
45 constexpr int64_t MIN_TIME_MS_BETWEEN_USERACTIVITIES = 100; // 100ms
46 
47 // Throttling interval for multimode activity calls.
48 constexpr int64_t MIN_TIME_MS_BETWEEN_MULTIMODEACTIVITIES = 100; // 100ms
49 
50 // the reason for shut down device fast
51 constexpr const char* const SHUTDOWN_FAST_REASON = "STR";
52 
53 /**
54  * PowerState of Device.
55  */
56 enum class PowerState : uint32_t {
57     /**
58      * Power State: screen on and cpu on.
59      */
60     AWAKE = 0,
61 
62     /**
63      * Power State: screen on or active and some background user processes are frozen.
64      */
65     FREEZE,
66 
67     /**
68      * Power State: screen off and cpu on.
69      */
70     INACTIVE,
71 
72     /**
73      * Power State: screen off and cpu on and some user processes are frozen.
74      */
75     STAND_BY,
76 
77     /**
78      * Power State: screen off and cpu on and most user processes are frozen.
79      */
80     DOZE,
81 
82     /**
83      * Power State: screen off and cpu off and suspend to the ram.
84      */
85     SLEEP,
86 
87     /**
88      * Power State: screen off and cpu off and suspend to the disk.
89      */
90     HIBERNATE,
91 
92     /**
93      * Power State: shutdown.
94      */
95     SHUTDOWN,
96 
97     /**
98      * Power State: unknown.
99      */
100     UNKNOWN,
101 };
102 
103 /**
104  * Display State of Device.
105  */
106 enum class DisplayState : uint32_t {
107     DISPLAY_OFF = 0,
108     DISPLAY_DIM = 1,
109     DISPLAY_ON = 2,
110     DISPLAY_SUSPEND = 3,
111     DISPLAY_UNKNOWN = 4,
112 };
113 
114 // UserActivityType list, must sync with A_PMS
115 enum class UserActivityType : uint32_t {
116     USER_ACTIVITY_TYPE_OTHER = 0,
117     USER_ACTIVITY_TYPE_BUTTON = 1,
118     USER_ACTIVITY_TYPE_TOUCH = 2,
119     USER_ACTIVITY_TYPE_ACCESSIBILITY = 3,
120     USER_ACTIVITY_TYPE_ATTENTION = 4,
121     USER_ACTIVITY_TYPE_SOFTWARE = 5,
122     USER_ACTIVITY_TYPE_MAX = USER_ACTIVITY_TYPE_SOFTWARE,
123 };
124 
125 // WakeupReasonType list
126 enum class WakeupDeviceType : uint32_t {
127     WAKEUP_DEVICE_UNKNOWN = 0,
128     WAKEUP_DEVICE_POWER_BUTTON = 1,
129     WAKEUP_DEVICE_APPLICATION = 2,
130     WAKEUP_DEVICE_PLUGGED_IN = 3,
131     WAKEUP_DEVICE_GESTURE = 4,
132     WAKEUP_DEVICE_CAMERA_LAUNCH = 5,
133     WAKEUP_DEVICE_WAKE_KEY = 6,
134     WAKEUP_DEVICE_WAKE_MOTION = 7,
135     WAKEUP_DEVICE_HDMI = 8,
136     WAKEUP_DEVICE_LID = 9,
137     WAKEUP_DEVICE_DOUBLE_CLICK = 10,
138     WAKEUP_DEVICE_KEYBOARD = 11,
139     WAKEUP_DEVICE_MOUSE = 12,
140     WAKEUP_DEVICE_TOUCHPAD = 13,
141     WAKEUP_DEVICE_PEN = 14,
142     WAKEUP_DEVICE_TOUCH_SCREEN = 15,
143     WAKEUP_DEVICE_SWITCH = 16,
144     WAKEUP_DEVICE_SINGLE_CLICK = 17,
145     WAKEUP_DEVICE_MAX = WAKEUP_DEVICE_SINGLE_CLICK,
146 };
147 
148 // SuspendDeviceType list
149 enum class SuspendDeviceType : uint32_t {
150     SUSPEND_DEVICE_REASON_MIN = 0,
151     SUSPEND_DEVICE_REASON_APPLICATION = SUSPEND_DEVICE_REASON_MIN,
152     SUSPEND_DEVICE_REASON_DEVICE_ADMIN = 1,
153     SUSPEND_DEVICE_REASON_TIMEOUT = 2,
154     SUSPEND_DEVICE_REASON_LID = 3,
155     SUSPEND_DEVICE_REASON_POWER_KEY = 4,
156     SUSPEND_DEVICE_REASON_HDMI = 5,
157     SUSPEND_DEVICE_REASON_SLEEP_KEY = 6,
158     SUSPEND_DEVICE_REASON_ACCESSIBILITY = 7,
159     SUSPEND_DEVICE_REASON_FORCE_SUSPEND = 8,
160     SUSPEND_DEVICE_REASON_STR = 9,
161     SUSPEND_DEVICE_REASON_SWITCH = 10,
162     SUSPEND_DEVICE_REASON_MAX = SUSPEND_DEVICE_REASON_SWITCH,
163 };
164 
165 enum class StateChangeReason : uint32_t {
166     STATE_CHANGE_REASON_INIT = 0,
167     STATE_CHANGE_REASON_TIMEOUT = 1,
168     STATE_CHANGE_REASON_RUNNING_LOCK = 2,
169     STATE_CHANGE_REASON_BATTERY = 3,
170     STATE_CHANGE_REASON_THERMAL = 4,
171     STATE_CHANGE_REASON_WORK = 5,
172     STATE_CHANGE_REASON_SYSTEM = 6,
173     STATE_CHANGE_REASON_APPLICATION = 10,
174     STATE_CHANGE_REASON_SETTINGS = 11,
175     STATE_CHANGE_REASON_HARD_KEY = 12,
176     STATE_CHANGE_REASON_TOUCH = 13,
177     STATE_CHANGE_REASON_CABLE = 14,
178     STATE_CHANGE_REASON_SENSOR = 15,
179     STATE_CHANGE_REASON_LID = 16,
180     STATE_CHANGE_REASON_CAMERA = 17,
181     STATE_CHANGE_REASON_ACCESSIBILITY = 18,
182     STATE_CHANGE_REASON_RESET = 19,
183     STATE_CHANGE_REASON_POWER_KEY = 20,
184     STATE_CHANGE_REASON_KEYBOARD = 21,
185     STATE_CHANGE_REASON_MOUSE = 22,
186     STATE_CHANGE_REASON_DOUBLE_CLICK = 23,
187     STATE_CHANGE_REASON_REMOTE = 100,
188     STATE_CHANGE_REASON_UNKNOWN = 1000,
189 };
190 } // namespace PowerMgr
191 } // namespace OHOS
192 #endif // POWERMGR_POWER_STATE_MACHINE_INFO_H
193