• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "power_utils.h"
17 
18 namespace OHOS {
19 namespace PowerMgr {
GetReasonTypeString(StateChangeReason type)20 const std::string PowerUtils::GetReasonTypeString(StateChangeReason type)
21 {
22     switch (type) {
23         case StateChangeReason::STATE_CHANGE_REASON_INIT:
24             return std::string("INIT");
25         case StateChangeReason::STATE_CHANGE_REASON_TIMEOUT:
26             return std::string("TIMEOUT");
27         case StateChangeReason::STATE_CHANGE_REASON_RUNNING_LOCK:
28             return std::string("RUNNING_LOCK");
29         case StateChangeReason::STATE_CHANGE_REASON_BATTERY:
30             return std::string("BATTERY");
31         case StateChangeReason::STATE_CHANGE_REASON_THERMAL:
32             return std::string("THERMAL");
33         case StateChangeReason::STATE_CHANGE_REASON_WORK:
34             return std::string("WORK");
35         case StateChangeReason::STATE_CHANGE_REASON_SYSTEM:
36             return std::string("SYSTEM");
37         case StateChangeReason::STATE_CHANGE_REASON_APPLICATION:
38             return std::string("APPLICATION");
39         case StateChangeReason::STATE_CHANGE_REASON_SETTINGS:
40             return std::string("SETTINGS");
41         case StateChangeReason::STATE_CHANGE_REASON_HARD_KEY:
42             return std::string("HARD_KEY");
43         case StateChangeReason::STATE_CHANGE_REASON_TOUCH:
44             return std::string("TOUCH");
45         case StateChangeReason::STATE_CHANGE_REASON_CABLE:
46             return std::string("CABLE");
47         case StateChangeReason::STATE_CHANGE_REASON_SENSOR:
48             return std::string("SENSOR");
49         case StateChangeReason::STATE_CHANGE_REASON_LID:
50             return std::string("LID");
51         case StateChangeReason::STATE_CHANGE_REASON_CAMERA:
52             return std::string("CAMERA");
53         case StateChangeReason::STATE_CHANGE_REASON_ACCESSIBILITY:
54             return std::string("ACCESS");
55         case StateChangeReason::STATE_CHANGE_REASON_POWER_KEY:
56             return std::string("POWER_KEY");
57         case StateChangeReason::STATE_CHANGE_REASON_KEYBOARD:
58             return std::string("KEYBOARD");
59         case StateChangeReason::STATE_CHANGE_REASON_MOUSE:
60             return std::string("MOUSE");
61         case StateChangeReason::STATE_CHANGE_REASON_REMOTE:
62             return std::string("REMOTE");
63         case StateChangeReason::STATE_CHANGE_REASON_UNKNOWN:
64             return std::string("UNKNOWN");
65         default:
66             break;
67     }
68     return std::string("UNKNOWN");
69 }
70 
GetPowerStateString(PowerState state)71 const std::string PowerUtils::GetPowerStateString(PowerState state)
72 {
73     switch (state) {
74         case PowerState::AWAKE:
75             return std::string("AWAKE");
76         case PowerState::FREEZE:
77             return std::string("FREEZE");
78         case PowerState::INACTIVE:
79             return std::string("INACTIVE");
80         case PowerState::STAND_BY:
81             return std::string("STAND_BY");
82         case PowerState::DOZE:
83             return std::string("DOZE");
84         case PowerState::SLEEP:
85             return std::string("SLEEP");
86         case PowerState::HIBERNATE:
87             return std::string("HIBERNATE");
88         case PowerState::SHUTDOWN:
89             return std::string("SHUTDOWN");
90         case PowerState::UNKNOWN:
91             return std::string("UNKNOWN");
92         default:
93             break;
94     }
95     return std::string("UNKNOWN");
96 }
97 
GetDisplayStateString(DisplayState state)98 const std::string PowerUtils::GetDisplayStateString(DisplayState state)
99 {
100     switch (state) {
101         case DisplayState::DISPLAY_OFF:
102             return std::string("DISPLAY_OFF");
103         case DisplayState::DISPLAY_DIM:
104             return std::string("DISPLAY_DIM");
105         case DisplayState::DISPLAY_ON:
106             return std::string("DISPLAY_ON");
107         case DisplayState::DISPLAY_SUSPEND:
108             return std::string("DISPLAY_SUSPEND");
109         case DisplayState::DISPLAY_UNKNOWN:
110             return std::string("DISPLAY_UNKNOWN");
111         default:
112             break;
113     }
114     return std::string("DISPLAY_UNKNOWN");
115 }
116 
GetRunningLockTypeString(RunningLockType type)117 const std::string PowerUtils::GetRunningLockTypeString(RunningLockType type)
118 {
119     switch (type) {
120         case RunningLockType::RUNNINGLOCK_SCREEN:
121             return "SCREEN";
122         case RunningLockType::RUNNINGLOCK_BACKGROUND:
123             return "BACKGROUND";
124         case RunningLockType::RUNNINGLOCK_PROXIMITY_SCREEN_CONTROL:
125             return "PROXIMITY_SCREEN_CONTROL";
126         case RunningLockType::RUNNINGLOCK_COORDINATION:
127             return "RUNNINGLOCK_COORDINATION";
128         case RunningLockType::RUNNINGLOCK_BACKGROUND_PHONE:
129             return "BACKGROUND_PHONE";
130         case RunningLockType::RUNNINGLOCK_BACKGROUND_NOTIFICATION:
131             return "BACKGROUND_NOTIFICATION";
132         case RunningLockType::RUNNINGLOCK_BACKGROUND_AUDIO:
133             return "BACKGROUND_AUDIO";
134         case RunningLockType::RUNNINGLOCK_BACKGROUND_SPORT:
135             return "BACKGROUND_SPORT";
136         case RunningLockType::RUNNINGLOCK_BACKGROUND_NAVIGATION:
137             return "BACKGROUND_NAVIGATION";
138         case RunningLockType::RUNNINGLOCK_BACKGROUND_TASK:
139             return "BACKGROUND_TASK";
140         case RunningLockType::RUNNINGLOCK_BUTT:
141             return "BUTT";
142         default:
143             break;
144     }
145     return "UNKNOWN";
146 }
147 } // namespace PowerMgr
148 } // namespace OHOS
149