• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_mgr_service_ipc_adapter.h"
17 #include "power_common.h"
18 #include "power_log.h"
19 #include "power_xcollie.h"
20 #include "xcollie/watchdog.h"
21 
22 namespace OHOS {
23 namespace PowerMgr {
24 namespace {
25 constexpr int32_t INIT_VALUE = -1;
26 constexpr int32_t MAX_PARAM_NUM = 2000;
27 } // namespace
28 
RebootDeviceIpc(const std::string & reason,int32_t & powerError)29 int32_t PowerMgrServiceAdapter::RebootDeviceIpc(const std::string& reason, int32_t& powerError)
30 {
31     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RebootDevice", false);
32     powerError = static_cast<int32_t>(RebootDevice(reason));
33     return ERR_OK;
34 }
35 
RebootDeviceForDeprecatedIpc(const std::string & reason,int32_t & powerError)36 int32_t PowerMgrServiceAdapter::RebootDeviceForDeprecatedIpc(const std::string& reason, int32_t& powerError)
37 {
38     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RebootDeviceForDeprecated", false);
39     powerError = static_cast<int32_t>(RebootDeviceForDeprecated(reason));
40     return ERR_OK;
41 }
42 
ShutDownDeviceIpc(const std::string & reason,int32_t & powerError)43 int32_t PowerMgrServiceAdapter::ShutDownDeviceIpc(const std::string& reason, int32_t& powerError)
44 {
45     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ShutDownDevice", false);
46     powerError = static_cast<int32_t>(ShutDownDevice(reason));
47     return ERR_OK;
48 }
49 
SetSuspendTagIpc(const std::string & tag,int32_t & powerError)50 int32_t PowerMgrServiceAdapter::SetSuspendTagIpc(const std::string& tag, int32_t& powerError)
51 {
52     PowerXCollie powerXCollie("PowerMgrServiceAdapter::SetSuspendTag", false);
53     powerError = static_cast<int32_t>(SetSuspendTag(tag));
54     return ERR_OK;
55 }
56 
SuspendDeviceIpc(int64_t callTimeMs,int32_t reasonValue,bool suspendImmed,const std::string & apiVersion,int32_t & powerError)57 int32_t PowerMgrServiceAdapter::SuspendDeviceIpc(int64_t callTimeMs, int32_t reasonValue, bool suspendImmed,
58     const std::string& apiVersion, int32_t& powerError)
59 {
60     PowerXCollie powerXCollie("PowerMgrServiceAdapter::SuspendDevice", false);
61     SuspendDeviceType reason = static_cast<SuspendDeviceType>(reasonValue);
62     powerError = static_cast<int32_t>(SuspendDevice(callTimeMs, reason, suspendImmed, apiVersion));
63     return ERR_OK;
64 }
65 
WakeupDeviceIpc(int64_t callTimeMs,int32_t reasonValue,const std::string & details,const std::string & apiVersion,int32_t & powerError)66 int32_t PowerMgrServiceAdapter::WakeupDeviceIpc(int64_t callTimeMs, int32_t reasonValue,
67     const std::string& details, const std::string& apiVersion, int32_t& powerError)
68 {
69     PowerXCollie powerXCollie("PowerMgrServiceAdapter::WakeupDevice", false);
70     WakeupDeviceType reason = static_cast<WakeupDeviceType>(reasonValue);
71     powerError = static_cast<int32_t>(WakeupDevice(callTimeMs, reason, details, apiVersion));
72     return ERR_OK;
73 }
74 
WakeupDeviceAsyncIpc(int64_t callTimeMs,int32_t reasonValue,const std::string & details,const std::string & apiVersion)75 int32_t PowerMgrServiceAdapter::WakeupDeviceAsyncIpc(
76     int64_t callTimeMs, int32_t reasonValue, const std::string& details, const std::string& apiVersion)
77 {
78     WakeupDeviceType reason = static_cast<WakeupDeviceType>(reasonValue);
79     return static_cast<int32_t>(WakeupDevice(callTimeMs, reason, details, apiVersion));
80 }
81 
RefreshActivityIpc(int64_t callTimeMs,int32_t activityType,bool needChangeBacklight)82 int32_t PowerMgrServiceAdapter::RefreshActivityIpc(int64_t callTimeMs, int32_t activityType, bool needChangeBacklight)
83 {
84     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RefreshActivity", false);
85     UserActivityType type = static_cast<UserActivityType>(activityType);
86     RefreshActivity(callTimeMs, type, needChangeBacklight);
87     return ERR_OK;
88 }
89 
OverrideScreenOffTimeIpc(int64_t timeout,const std::string & apiVersion,int32_t & powerError)90 int32_t PowerMgrServiceAdapter::OverrideScreenOffTimeIpc(
91     int64_t timeout, const std::string& apiVersion, int32_t& powerError)
92 {
93     PowerXCollie powerXCollie("PowerMgrServiceAdapter::OverrideScreenOffTime", false);
94     powerError = static_cast<int32_t>(OverrideScreenOffTime(timeout, apiVersion));
95     return ERR_OK;
96 }
97 
RestoreScreenOffTimeIpc(const std::string & apiVersion,int32_t & powerError)98 int32_t PowerMgrServiceAdapter::RestoreScreenOffTimeIpc(const std::string& apiVersion, int32_t& powerError)
99 {
100     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RestoreScreenOffTime", false);
101     powerError = static_cast<int32_t>(RestoreScreenOffTime(apiVersion));
102     return ERR_OK;
103 }
104 
GetStateIpc(int32_t & powerState)105 int32_t PowerMgrServiceAdapter::GetStateIpc(int32_t& powerState)
106 {
107     PowerXCollie powerXCollie("PowerMgrServiceAdapter::GetState", false);
108     powerState = static_cast<int32_t>(GetState());
109     return ERR_OK;
110 }
111 
IsScreenOnIpc(bool needPrintLog,bool & isScreenOn)112 int32_t PowerMgrServiceAdapter::IsScreenOnIpc(bool needPrintLog, bool& isScreenOn)
113 {
114     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsScreenOn", false);
115     isScreenOn = IsScreenOn(needPrintLog);
116     return ERR_OK;
117 }
118 
IsFoldScreenOnIpc(bool & isFoldScreenOn)119 int32_t PowerMgrServiceAdapter::IsFoldScreenOnIpc(bool& isFoldScreenOn)
120 {
121     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsFoldScreenOn", false);
122     isFoldScreenOn = IsFoldScreenOn();
123     return ERR_OK;
124 }
125 
126 
IsCollaborationScreenOnIpc(bool & isCollaborationScreenOn)127 int32_t PowerMgrServiceAdapter::IsCollaborationScreenOnIpc(bool& isCollaborationScreenOn)
128 {
129     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsCollaborationScreenOn", false);
130     isCollaborationScreenOn = IsCollaborationScreenOn();
131     return ERR_OK;
132 }
133 
ForceSuspendDeviceIpc(int64_t callTimeMs,const std::string & apiVersion,const sptr<IPowerMgrAsync> & powerProxy)134 int32_t PowerMgrServiceAdapter::ForceSuspendDeviceIpc(
135     int64_t callTimeMs, const std::string& apiVersion, const sptr<IPowerMgrAsync>& powerProxy)
136 {
137     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ForceSuspendDevice", false);
138     int32_t result = static_cast<int32_t>(ForceSuspendDevice(callTimeMs, apiVersion));
139     powerProxy->SendAsyncReply(result);
140     return result;
141 }
142 
HibernateIpc(bool clearMemory,const std::string & reason,const std::string & apiVersion,const sptr<IPowerMgrAsync> & powerProxy)143 int32_t PowerMgrServiceAdapter::HibernateIpc(bool clearMemory, const std::string& reason,
144     const std::string& apiVersion, const sptr<IPowerMgrAsync>& powerProxy)
145 {
146     PowerXCollie powerXCollie("PowerMgrServiceAdapter::Hibernate", false);
147     int32_t result = static_cast<int32_t>(Hibernate(clearMemory, reason, apiVersion));
148     powerProxy->SendAsyncReply(result);
149     return result;
150 }
151 
CreateRunningLockIpc(const sptr<IRemoteObject> & remoteObj,const RunningLockInfo & runningLockInfo,int32_t & powerError)152 int32_t PowerMgrServiceAdapter::CreateRunningLockIpc(
153     const sptr<IRemoteObject>& remoteObj, const RunningLockInfo& runningLockInfo, int32_t& powerError)
154 {
155     PowerXCollie powerXCollie("PowerMgrServiceAdapter::CreateRunningLock", true);
156     powerError = static_cast<int32_t>(CreateRunningLock(remoteObj, runningLockInfo));
157     return ERR_OK;
158 }
159 
ReleaseRunningLockIpc(const sptr<IRemoteObject> & remoteObj,const std::string & name)160 int32_t PowerMgrServiceAdapter::ReleaseRunningLockIpc(const sptr<IRemoteObject>& remoteObj, const std::string& name)
161 {
162     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ReleaseRunningLock", true);
163     ReleaseRunningLock(remoteObj, name);
164     return ERR_OK;
165 }
166 
IsRunningLockTypeSupportedIpc(int32_t lockType,bool & lockSupported)167 int32_t PowerMgrServiceAdapter::IsRunningLockTypeSupportedIpc(int32_t lockType, bool& lockSupported)
168 {
169     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsRunningLockTypeSupported", false);
170     RunningLockType type = static_cast<RunningLockType>(lockType);
171     lockSupported = IsRunningLockTypeSupported(type);
172     return ERR_OK;
173 }
174 
UpdateWorkSourceIpc(const sptr<IRemoteObject> & remoteObj,const std::vector<int32_t> & workSources)175 int32_t PowerMgrServiceAdapter::UpdateWorkSourceIpc(
176     const sptr<IRemoteObject>& remoteObj, const std::vector<int32_t>& workSources)
177 {
178     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UpdateWorkSource", true);
179     UpdateWorkSource(remoteObj, workSources);
180     return ERR_OK;
181 }
182 
LockIpc(const sptr<IRemoteObject> & remoteObj,int32_t timeOutMs,int32_t & powerError)183 int32_t PowerMgrServiceAdapter::LockIpc(const sptr<IRemoteObject>& remoteObj, int32_t timeOutMs, int32_t& powerError)
184 {
185     PowerXCollie powerXCollie("PowerMgrServiceAdapter::Lock", true);
186     powerError = static_cast<int32_t>(Lock(remoteObj, timeOutMs));
187     return ERR_OK;
188 }
189 
UnLockIpc(const sptr<IRemoteObject> & remoteObj,const std::string & name,int32_t & powerError)190 int32_t PowerMgrServiceAdapter::UnLockIpc(
191     const sptr<IRemoteObject>& remoteObj, const std::string& name, int32_t& powerError)
192 {
193     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnLock", true);
194     powerError = static_cast<int32_t>(UnLock(remoteObj, name));
195     return ERR_OK;
196 }
197 
QueryRunningLockListsIpc(std::map<std::string,RunningLockInfo> & runningLockLists)198 int32_t PowerMgrServiceAdapter::QueryRunningLockListsIpc(std::map<std::string, RunningLockInfo>& runningLockLists)
199 {
200     PowerXCollie powerXCollie("PowerMgrServiceAdapter::QueryRunningLockLists", true);
201     QueryRunningLockLists(runningLockLists);
202     int32_t num = static_cast<int32_t>(runningLockLists.size());
203     RETURN_IF_WITH_RET(num > MAX_PARAM_NUM, INIT_VALUE);
204     return ERR_OK;
205 }
206 
RegisterRunningLockCallbackIpc(const sptr<IPowerRunninglockCallback> & callback)207 int32_t PowerMgrServiceAdapter::RegisterRunningLockCallbackIpc(const sptr<IPowerRunninglockCallback>& callback)
208 {
209     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterRunningLockCallback", false);
210     RegisterRunningLockCallback(callback);
211     return ERR_OK;
212 }
213 
UnRegisterRunningLockCallbackIpc(const sptr<IPowerRunninglockCallback> & callback)214 int32_t PowerMgrServiceAdapter::UnRegisterRunningLockCallbackIpc(const sptr<IPowerRunninglockCallback>& callback)
215 {
216     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterRunningLockCallback", false);
217     UnRegisterRunningLockCallback(callback);
218     return ERR_OK;
219 }
220 
IsUsedIpc(const sptr<IRemoteObject> & remoteObj,bool & isUsed)221 int32_t PowerMgrServiceAdapter::IsUsedIpc(const sptr<IRemoteObject>& remoteObj, bool& isUsed)
222 {
223     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsUsed", true);
224     isUsed = IsUsed(remoteObj);
225     return ERR_OK;
226 }
227 
ProxyRunningLockIpc(bool isProxied,pid_t pid,pid_t uid)228 int32_t PowerMgrServiceAdapter::ProxyRunningLockIpc(bool isProxied, pid_t pid, pid_t uid)
229 {
230     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ProxyRunningLock", true);
231     if (!ProxyRunningLock(isProxied, pid, uid)) {
232         POWER_HILOGI(FEATURE_SUSPEND, "ProxyRunningLock failed");
233         return INIT_VALUE;
234     }
235     return ERR_OK;
236 }
237 
ProxyRunningLocksIpc(bool isProxied,const VectorPair & vectorPairInfos)238 int32_t PowerMgrServiceAdapter::ProxyRunningLocksIpc(bool isProxied, const VectorPair& vectorPairInfos)
239 {
240     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ProxyRunningLocks", true);
241     const std::vector<std::pair<pid_t, pid_t>>& processInfos = vectorPairInfos.GetProcessInfos();
242     if (!ProxyRunningLocks(isProxied, processInfos)) {
243         POWER_HILOGI(FEATURE_SUSPEND, "ProxyRunningLocks failed");
244         return INIT_VALUE;
245     }
246     return ERR_OK;
247 }
248 
ResetRunningLocksIpc()249 int32_t PowerMgrServiceAdapter::ResetRunningLocksIpc()
250 {
251     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ResetRunningLocks", true);
252     if (!ResetRunningLocks()) {
253         POWER_HILOGI(FEATURE_SUSPEND, "ResetRunningLocks failed");
254         return INIT_VALUE;
255     }
256     return ERR_OK;
257 }
258 
RegisterPowerStateCallbackIpc(const sptr<IPowerStateCallback> & callback,bool isSync)259 int32_t PowerMgrServiceAdapter::RegisterPowerStateCallbackIpc(const sptr<IPowerStateCallback>& callback, bool isSync)
260 {
261     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterPowerStateCallback", false);
262     RegisterPowerStateCallback(callback, isSync);
263     return ERR_OK;
264 }
265 
UnRegisterPowerStateCallbackIpc(const sptr<IPowerStateCallback> & callback)266 int32_t PowerMgrServiceAdapter::UnRegisterPowerStateCallbackIpc(const sptr<IPowerStateCallback>& callback)
267 {
268     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterPowerStateCallback", false);
269     UnRegisterPowerStateCallback(callback);
270     return ERR_OK;
271 }
272 
RegisterSyncSleepCallbackIpc(const sptr<ISyncSleepCallback> & callback,int32_t priorityValue)273 int32_t PowerMgrServiceAdapter::RegisterSyncSleepCallbackIpc(
274     const sptr<ISyncSleepCallback>& callback, int32_t priorityValue)
275 {
276     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterSyncSleepCallback", false);
277     SleepPriority priority = static_cast<SleepPriority>(priorityValue);
278     RegisterSyncSleepCallback(callback, priority);
279     return ERR_OK;
280 }
281 
UnRegisterSyncSleepCallbackIpc(const sptr<ISyncSleepCallback> & callback)282 int32_t PowerMgrServiceAdapter::UnRegisterSyncSleepCallbackIpc(const sptr<ISyncSleepCallback>& callback)
283 {
284     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterSyncSleepCallback", false);
285     UnRegisterSyncSleepCallback(callback);
286     return ERR_OK;
287 }
288 
RegisterSyncHibernateCallbackIpc(const sptr<ISyncHibernateCallback> & callback)289 int32_t PowerMgrServiceAdapter::RegisterSyncHibernateCallbackIpc(const sptr<ISyncHibernateCallback>& callback)
290 {
291     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterSyncHibernateCallback", false);
292     RegisterSyncHibernateCallback(callback);
293     return ERR_OK;
294 }
295 
UnRegisterSyncHibernateCallbackIpc(const sptr<ISyncHibernateCallback> & callback)296 int32_t PowerMgrServiceAdapter::UnRegisterSyncHibernateCallbackIpc(const sptr<ISyncHibernateCallback>& callback)
297 {
298     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterSyncHibernateCallback", false);
299     UnRegisterSyncHibernateCallback(callback);
300     return ERR_OK;
301 }
302 
RegisterPowerModeCallbackIpc(const sptr<IPowerModeCallback> & callback)303 int32_t PowerMgrServiceAdapter::RegisterPowerModeCallbackIpc(const sptr<IPowerModeCallback>& callback)
304 {
305     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterPowerModeCallback", false);
306     RegisterPowerModeCallback(callback);
307     return ERR_OK;
308 }
309 
RegisterSuspendTakeoverCallbackIpc(const sptr<ITakeOverSuspendCallback> & callback,int32_t priority)310 int32_t PowerMgrServiceAdapter::RegisterSuspendTakeoverCallbackIpc(
311     const sptr<ITakeOverSuspendCallback>& callback, int32_t priority)
312 {
313 #ifdef POWER_MANAGER_TAKEOVER_SUSPEND
314     if (callback == nullptr) {
315         POWER_HILOGE(FEATURE_SUSPEND, "callback is nullptr");
316         return INIT_VALUE;
317     }
318     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterSuspendTakeoverCallback", false);
319     if (priority < static_cast<int32_t>(TakeOverSuspendPriority::LOW) ||
320         priority > static_cast<int32_t>(TakeOverSuspendPriority::HIGH)) {
321         return INIT_VALUE;
322     }
323     TakeOverSuspendPriority takeOverSuspendPriority = static_cast<TakeOverSuspendPriority>(priority);
324     RegisterSuspendTakeoverCallback(callback, takeOverSuspendPriority);
325     return ERR_OK;
326 #else
327     return ERR_OK;
328 #endif
329 }
330 
UnRegisterSuspendTakeoverCallbackIpc(const sptr<ITakeOverSuspendCallback> & callback)331 int32_t PowerMgrServiceAdapter::UnRegisterSuspendTakeoverCallbackIpc(const sptr<ITakeOverSuspendCallback>& callback)
332 {
333 #ifdef POWER_MANAGER_TAKEOVER_SUSPEND
334     if (callback == nullptr) {
335         POWER_HILOGE(FEATURE_SUSPEND, "callback is nullptr");
336         return INIT_VALUE;
337     }
338     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterSuspendTakeoverCallback", false);
339     UnRegisterSuspendTakeoverCallback(callback);
340     return ERR_OK;
341 #else
342     return ERR_OK;
343 #endif
344 }
345 
UnRegisterPowerModeCallbackIpc(const sptr<IPowerModeCallback> & callback)346 int32_t PowerMgrServiceAdapter::UnRegisterPowerModeCallbackIpc(const sptr<IPowerModeCallback>& callback)
347 {
348     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterPowerModeCallback", false);
349     UnRegisterPowerModeCallback(callback);
350     return ERR_OK;
351 }
352 
RegisterScreenStateCallbackIpc(int32_t remainTime,const sptr<IScreenOffPreCallback> & callback)353 int32_t PowerMgrServiceAdapter::RegisterScreenStateCallbackIpc(
354     int32_t remainTime, const sptr<IScreenOffPreCallback>& callback)
355 {
356     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterScreenStateCallback", false);
357     RegisterScreenStateCallback(remainTime, callback);
358     return ERR_OK;
359 }
360 
UnRegisterScreenStateCallbackIpc(const sptr<IScreenOffPreCallback> & callback)361 int32_t PowerMgrServiceAdapter::UnRegisterScreenStateCallbackIpc(const sptr<IScreenOffPreCallback>& callback)
362 {
363     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterScreenStateCallback", false);
364     UnRegisterScreenStateCallback(callback);
365     return ERR_OK;
366 }
367 
SetDisplaySuspendIpc(bool enable)368 int32_t PowerMgrServiceAdapter::SetDisplaySuspendIpc(bool enable)
369 {
370     PowerXCollie powerXCollie("PowerMgrServiceAdapter::SetDisplaySuspend", false);
371     SetDisplaySuspend(enable);
372     return ERR_OK;
373 }
374 
SetDeviceModeIpc(int32_t modeValue,int32_t & powerError)375 int32_t PowerMgrServiceAdapter::SetDeviceModeIpc(int32_t modeValue, int32_t& powerError)
376 {
377     PowerXCollie powerXCollie("PowerMgrServiceAdapter::SetDeviceMode", false);
378     PowerMode mode = static_cast<PowerMode>(modeValue);
379     powerError = static_cast<int32_t>(SetDeviceMode(mode));
380     return ERR_OK;
381 }
382 
GetDeviceModeIpc(int32_t & powerMode)383 int32_t PowerMgrServiceAdapter::GetDeviceModeIpc(int32_t& powerMode)
384 {
385     PowerXCollie powerXCollie("PowerMgrServiceAdapter::GetDeviceMode", false);
386     powerMode = static_cast<int32_t>(GetDeviceMode());
387     return ERR_OK;
388 }
389 
ShellDumpIpc(const std::vector<std::string> & args,uint32_t argc,std::string & returnDump)390 int32_t PowerMgrServiceAdapter::ShellDumpIpc(
391     const std::vector<std::string>& args, uint32_t argc, std::string& returnDump)
392 {
393     PowerXCollie powerXCollie("PowerMgrServiceAdapter::ShellDump", false);
394     returnDump = ShellDump(args, argc);
395     return ERR_OK;
396 }
397 
RegisterShutdownCallbackIpc(const sptr<ITakeOverShutdownCallback> & callback,int32_t priorityValue)398 int32_t PowerMgrServiceAdapter::RegisterShutdownCallbackIpc(
399     const sptr<ITakeOverShutdownCallback>& callback, int32_t priorityValue)
400 {
401     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterShutdownCallback TakeOver", false);
402     ShutdownPriority priority = static_cast<ShutdownPriority>(priorityValue);
403     RegisterShutdownCallback(callback, priority);
404     return ERR_OK;
405 }
406 
UnRegisterShutdownCallbackIpc(const sptr<ITakeOverShutdownCallback> & callback)407 int32_t PowerMgrServiceAdapter::UnRegisterShutdownCallbackIpc(const sptr<ITakeOverShutdownCallback>& callback)
408 {
409     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterShutdownCallback TakeOver", false);
410     UnRegisterShutdownCallback(callback);
411     return ERR_OK;
412 }
413 
RegisterShutdownCallbackIpc(const sptr<IAsyncShutdownCallback> & callback,int32_t priorityValue)414 int32_t PowerMgrServiceAdapter::RegisterShutdownCallbackIpc(
415     const sptr<IAsyncShutdownCallback>& callback, int32_t priorityValue)
416 {
417     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterShutdownCallback Async", false);
418     ShutdownPriority priority = static_cast<ShutdownPriority>(priorityValue);
419     RegisterShutdownCallback(callback, priority);
420     return ERR_OK;
421 }
422 
UnRegisterShutdownCallbackIpc(const sptr<IAsyncShutdownCallback> & callback)423 int32_t PowerMgrServiceAdapter::UnRegisterShutdownCallbackIpc(const sptr<IAsyncShutdownCallback>& callback)
424 {
425     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterShutdownCallback Async", false);
426     UnRegisterShutdownCallback(callback);
427     return ERR_OK;
428 }
429 
RegisterShutdownCallbackIpc(const sptr<ISyncShutdownCallback> & callback,int32_t priorityValue)430 int32_t PowerMgrServiceAdapter::RegisterShutdownCallbackIpc(
431     const sptr<ISyncShutdownCallback>& callback, int32_t priorityValue)
432 {
433     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RegisterShutdownCallback Sync", false);
434     ShutdownPriority priority = static_cast<ShutdownPriority>(priorityValue);
435     RegisterShutdownCallback(callback, priority);
436     return ERR_OK;
437 }
438 
UnRegisterShutdownCallbackIpc(const sptr<ISyncShutdownCallback> & callback)439 int32_t PowerMgrServiceAdapter::UnRegisterShutdownCallbackIpc(const sptr<ISyncShutdownCallback>& callback)
440 {
441     PowerXCollie powerXCollie("PowerMgrServiceAdapter::UnRegisterShutdownCallback Sync", false);
442     UnRegisterShutdownCallback(callback);
443     return ERR_OK;
444 }
445 
IsStandbyIpc(bool & isStandby,int32_t & powerError)446 int32_t PowerMgrServiceAdapter::IsStandbyIpc(bool& isStandby, int32_t& powerError)
447 {
448     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsStandby", false);
449     powerError = static_cast<int32_t>(IsStandby(isStandby));
450     return ERR_OK;
451 }
452 
SetForceTimingOutIpc(bool enabled,const sptr<IRemoteObject> & token,int32_t & powerError)453 int32_t PowerMgrServiceAdapter::SetForceTimingOutIpc(
454     bool enabled, const sptr<IRemoteObject>& token, int32_t& powerError)
455 {
456     PowerXCollie powerXCollie("PowerMgrServiceAdapter::SetForceTimingOut", false);
457     powerError = static_cast<int32_t>(SetForceTimingOut(enabled, token));
458     return ERR_OK;
459 }
460 
LockScreenAfterTimingOutIpc(bool enabledLockScreen,bool checkLock,bool sendScreenOffEvent,const sptr<IRemoteObject> & token,int32_t & powerError)461 int32_t PowerMgrServiceAdapter::LockScreenAfterTimingOutIpc(bool enabledLockScreen, bool checkLock,
462     bool sendScreenOffEvent, const sptr<IRemoteObject>& token, int32_t& powerError)
463 {
464     PowerXCollie powerXCollie("PowerMgrServiceAdapter::LockScreenAfterTimingOut", false);
465     powerError = static_cast<int32_t>(
466         LockScreenAfterTimingOut(enabledLockScreen, checkLock, sendScreenOffEvent, token));
467     return ERR_OK;
468 }
469 
IsRunningLockEnabledIpc(int32_t lockType,bool & result,int32_t & powerError)470 int32_t PowerMgrServiceAdapter::IsRunningLockEnabledIpc(int32_t lockType, bool& result, int32_t& powerError)
471 {
472     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsRunningLockEnabled", false);
473     RunningLockType type = static_cast<RunningLockType>(lockType);
474     powerError = static_cast<int32_t>(IsRunningLockEnabled(type, result));
475     return ERR_OK;
476 }
477 
IsForceSleepingIpc(bool & isForceSleeping)478 int32_t PowerMgrServiceAdapter::IsForceSleepingIpc(bool& isForceSleeping)
479 {
480     PowerXCollie powerXCollie("PowerMgrServiceAdapter::IsForceSleeping", false);
481     isForceSleeping = IsForceSleeping();
482     return ERR_OK;
483 }
484 
RefreshActivityIpc(int64_t callTimeMs,int32_t activityType,const std::string & refreshReason,int32_t & powerError)485 int32_t PowerMgrServiceAdapter::RefreshActivityIpc(
486     int64_t callTimeMs, int32_t activityType, const std::string& refreshReason, int32_t& powerError)
487 {
488     PowerXCollie powerXCollie("PowerMgrServiceAdapter::RefreshActivity LongIntStringInt", false);
489     UserActivityType type = static_cast<UserActivityType>(activityType);
490     powerError = static_cast<int32_t>(RefreshActivity(callTimeMs, type, refreshReason));
491     return ERR_OK;
492 }
493 } // namespace PowerMgr
494 } // namespace OHOS
495