• 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 #include "power_mgr_stub.h"
17 
18 #include <message_parcel.h>
19 #include <string_ex.h>
20 
21 #include "power_common.h"
22 #include "power_errors.h"
23 #include "power_mgr_proxy.h"
24 #include "xcollie.h"
25 
26 using namespace OHOS::HiviewDFX;
27 
28 namespace OHOS {
29 namespace PowerMgr {
30 namespace {
31 constexpr uint32_t PARAM_MAX_NUM = 10;
32 }
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)33 int PowerMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
34     MessageParcel &reply, MessageOption &option)
35 {
36     POWER_HILOGD(COMP_FWK, "cmd = %{public}u, flags= %{public}d", code, option.GetFlags());
37     std::u16string descripter = PowerMgrStub::GetDescriptor();
38     std::u16string remoteDescripter = data.ReadInterfaceToken();
39     if (descripter != remoteDescripter) {
40         POWER_HILOGE(COMP_FWK, "Descriptor is not matched");
41         return E_GET_POWER_SERVICE_FAILED;
42     }
43     const int DFX_DELAY_MS = 10000;
44     int id = HiviewDFX::XCollie::GetInstance().SetTimer("PowerMgrStub", DFX_DELAY_MS, nullptr, nullptr,
45         HiviewDFX::XCOLLIE_FLAG_NOOP);
46 
47     int ret = ERR_OK;
48     switch (code) {
49         case static_cast<int>(IPowerMgr::WAKEUP_DEVICE):
50             ret = WakeupDeviceStub(data, reply);
51             break;
52         case static_cast<int>(IPowerMgr::SUSPEND_DEVICE):
53             ret = SuspendDeviceStub(data, reply);
54             break;
55         case static_cast<int>(IPowerMgr::REFRESH_ACTIVITY):
56             ret = RefreshActivityStub(data);
57             break;
58         case static_cast<int>(IPowerMgr::REBOOT_DEVICE):
59             ret = RebootDeviceStub(data, reply);
60             break;
61         case static_cast<int>(IPowerMgr::REBOOT_DEVICE_FOR_DEPRECATED):
62             ret = RebootDeviceForDeprecatedStub(data, reply);
63             break;
64         case static_cast<int>(IPowerMgr::SHUTDOWN_DEVICE):
65             ret = ShutDownDeviceStub(data, reply);
66             break;
67         case static_cast<int>(IPowerMgr::OVERRIDE_DISPLAY_OFF_TIME):
68             ret = OverrideScreenOffTimeStub(data, reply);
69             break;
70         case static_cast<int>(IPowerMgr::RESTORE_DISPLAY_OFF_TIME):
71             ret = RestoreScreenOffTimeStub(reply);
72             break;
73         case static_cast<int>(IPowerMgr::GET_STATE):
74             ret = GetStateStub(reply);
75             break;
76         case static_cast<int>(IPowerMgr::IS_SCREEN_ON):
77             ret = IsScreeOnStub(reply);
78             break;
79         case static_cast<int>(IPowerMgr::FORCE_DEVICE_SUSPEND):
80             ret = ForceSuspendDeviceStub(data, reply);
81             break;
82         case static_cast<int>(IPowerMgr::CREATE_RUNNINGLOCK):
83             ret = CreateRunningLockStub(data, reply);
84             break;
85         case static_cast<int>(IPowerMgr::RELEASE_RUNNINGLOCK):
86             ret = ReleaseRunningLockStub(data);
87             break;
88         case static_cast<int>(IPowerMgr::IS_RUNNINGLOCK_TYPE_SUPPORTED):
89             ret = IsRunningLockTypeSupportedStub(data, reply);
90             break;
91         case static_cast<int>(IPowerMgr::RUNNINGLOCK_LOCK):
92             ret = LockStub(data);
93             break;
94         case static_cast<int>(IPowerMgr::RUNNINGLOCK_UNLOCK):
95             ret = UnLockStub(data);
96             break;
97         case static_cast<int>(IPowerMgr::RUNNINGLOCK_SET_WORK_TRIGGER_LIST):
98             ret = SetWorkTriggerListStub(data);
99             break;
100         case static_cast<int>(IPowerMgr::PROXY_RUNNINGLOCK):
101             ret = ProxyRunningLockStub(data);
102             break;
103         case static_cast<int>(IPowerMgr::RUNNINGLOCK_ISUSED):
104             ret = IsUsedStub(data, reply);
105             break;
106         case static_cast<int>(IPowerMgr::REG_POWER_STATE_CALLBACK):
107             ret = RegisterPowerStateCallbackStub(data);
108             break;
109         case static_cast<int>(IPowerMgr::UNREG_POWER_STATE_CALLBACK):
110             ret = UnRegisterPowerStateCallbackStub(data);
111             break;
112         case static_cast<int>(IPowerMgr::REG_SHUTDOWN_CALLBACK):
113             ret = RegisterShutdownCallbackStub(data);
114             break;
115         case static_cast<int>(IPowerMgr::UNREG_SHUTDOWN_CALLBACK):
116             ret = UnRegisterShutdownCallbackStub(data);
117             break;
118         case static_cast<int>(IPowerMgr::REG_POWER_MODE_CALLBACK):
119             ret = RegisterPowerModeCallbackStub(data);
120             break;
121         case static_cast<int>(IPowerMgr::UNREG_POWER_MODE_CALLBACK):
122             ret = UnRegisterPowerModeCallbackStub(data);
123             break;
124         case static_cast<int>(IPowerMgr::SET_DISPLAY_SUSPEND):
125             ret = SetDisplaySuspendStub(data);
126             break;
127         case static_cast<int>(IPowerMgr::SETMODE_DEVICE):
128             ret = SetDeviceModeStub(data, reply);
129             break;
130         case static_cast<int>(IPowerMgr::GETMODE_DEVICE):
131             ret = GetDeviceModeStub(reply);
132             break;
133         case static_cast<int>(IPowerMgr::SHELL_DUMP):
134             ret = ShellDumpStub(data, reply);
135             break;
136         default:
137             ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
138     }
139     HiviewDFX::XCollie::GetInstance().CancelTimer(id);
140     return ret;
141 }
142 
CreateRunningLockStub(MessageParcel & data,MessageParcel & reply)143 int32_t PowerMgrStub::CreateRunningLockStub(MessageParcel& data, MessageParcel& reply)
144 {
145     sptr<IRemoteObject> remoteObj = data.ReadRemoteObject();
146     RETURN_IF_WITH_RET((remoteObj == nullptr), E_READ_PARCEL_ERROR);
147     std::unique_ptr<RunningLockInfo> runningLockInfo(data.ReadParcelable<RunningLockInfo>());
148     RETURN_IF_WITH_RET((runningLockInfo == nullptr), E_READ_PARCEL_ERROR);
149     PowerErrors error = CreateRunningLock(remoteObj, *runningLockInfo);
150     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
151     return ERR_OK;
152 }
153 
ReleaseRunningLockStub(MessageParcel & data)154 int32_t PowerMgrStub::ReleaseRunningLockStub(MessageParcel& data)
155 {
156     sptr<IRemoteObject> remoteObj = data.ReadRemoteObject();
157     RETURN_IF_WITH_RET((remoteObj == nullptr), E_READ_PARCEL_ERROR);
158     ReleaseRunningLock(remoteObj);
159     return ERR_OK;
160 }
161 
IsRunningLockTypeSupportedStub(MessageParcel & data,MessageParcel & reply)162 int32_t PowerMgrStub::IsRunningLockTypeSupportedStub(MessageParcel& data, MessageParcel& reply)
163 {
164     uint32_t type = 0;
165     bool ret = false;
166     READ_PARCEL_WITH_RET(data, Uint32, type, E_READ_PARCEL_ERROR);
167     ret = IsRunningLockTypeSupported(type);
168     if (!reply.WriteBool(ret)) {
169         POWER_HILOGE(FEATURE_SUSPEND, "WriteBool fail");
170         return E_WRITE_PARCEL_ERROR;
171     }
172     return ERR_OK;
173 }
174 
LockStub(MessageParcel & data)175 int32_t PowerMgrStub::LockStub(MessageParcel& data)
176 {
177     sptr<IRemoteObject> remoteObj = data.ReadRemoteObject();
178     RETURN_IF_WITH_RET((remoteObj == nullptr), E_READ_PARCEL_ERROR);
179     std::unique_ptr<RunningLockInfo> runningLockInfo(data.ReadParcelable<RunningLockInfo>());
180     RETURN_IF_WITH_RET((runningLockInfo == nullptr), E_READ_PARCEL_ERROR);
181     uint32_t timeOutMs = 0;
182     READ_PARCEL_WITH_RET(data, Uint32, timeOutMs, E_READ_PARCEL_ERROR);
183     Lock(remoteObj, *runningLockInfo, timeOutMs);
184     return ERR_OK;
185 }
186 
UnLockStub(MessageParcel & data)187 int32_t PowerMgrStub::UnLockStub(MessageParcel& data)
188 {
189     sptr<IRemoteObject> remoteObj = data.ReadRemoteObject();
190     RETURN_IF_WITH_RET((remoteObj == nullptr), E_READ_PARCEL_ERROR);
191     UnLock(remoteObj);
192     return ERR_OK;
193 }
194 
IsUsedStub(MessageParcel & data,MessageParcel & reply)195 int32_t PowerMgrStub::IsUsedStub(MessageParcel& data, MessageParcel& reply)
196 {
197     sptr<IRemoteObject> remoteObj = data.ReadRemoteObject();
198     RETURN_IF_WITH_RET((remoteObj == nullptr), E_READ_PARCEL_ERROR);
199     bool ret = IsUsed(remoteObj);
200     WRITE_PARCEL_WITH_RET(reply, Bool, ret, E_WRITE_PARCEL_ERROR);
201     return ERR_OK;
202 }
203 
SetWorkTriggerListStub(MessageParcel & data)204 int32_t PowerMgrStub::SetWorkTriggerListStub(MessageParcel& data)
205 {
206     sptr<IRemoteObject> remoteObj = data.ReadRemoteObject();
207     RETURN_IF_WITH_RET((remoteObj == nullptr), E_READ_PARCEL_ERROR);
208     WorkTriggerList workTriggerList;
209     RunningLockInfo::ReadFromParcelWorkTriggerList(data, workTriggerList);
210     SetWorkTriggerList(remoteObj, workTriggerList);
211     return ERR_OK;
212 }
213 
ProxyRunningLockStub(MessageParcel & data)214 int32_t PowerMgrStub::ProxyRunningLockStub(MessageParcel& data)
215 {
216     bool proxyLock = false;
217     pid_t uid;
218     pid_t pid;
219     READ_PARCEL_WITH_RET(data, Bool, proxyLock, E_READ_PARCEL_ERROR);
220     READ_PARCEL_WITH_RET(data, Int32, uid, E_READ_PARCEL_ERROR);
221     READ_PARCEL_WITH_RET(data, Int32, pid, E_READ_PARCEL_ERROR);
222     ProxyRunningLock(proxyLock, uid, pid);
223     return ERR_OK;
224 }
225 
RebootDeviceStub(MessageParcel & data,MessageParcel & reply)226 int32_t PowerMgrStub::RebootDeviceStub(MessageParcel& data, MessageParcel& reply)
227 {
228     std::string reason = Str16ToStr8(data.ReadString16());
229     PowerErrors error = RebootDevice(reason);
230     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
231     return ERR_OK;
232 }
233 
RebootDeviceForDeprecatedStub(MessageParcel & data,MessageParcel & reply)234 int32_t PowerMgrStub::RebootDeviceForDeprecatedStub(MessageParcel& data, MessageParcel& reply)
235 {
236     std::string reason = Str16ToStr8(data.ReadString16());
237     PowerErrors error = RebootDeviceForDeprecated(reason);
238     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
239     return ERR_OK;
240 }
241 
ShutDownDeviceStub(MessageParcel & data,MessageParcel & reply)242 int32_t PowerMgrStub::ShutDownDeviceStub(MessageParcel& data, MessageParcel& reply)
243 {
244     std::string reason = Str16ToStr8(data.ReadString16());
245     PowerErrors error = ShutDownDevice(reason);
246     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
247     return ERR_OK;
248 }
249 
WakeupDeviceStub(MessageParcel & data,MessageParcel & reply)250 int32_t PowerMgrStub::WakeupDeviceStub(MessageParcel& data, MessageParcel& reply)
251 {
252     int64_t time = 0;
253     uint32_t reason = 0;
254 
255     READ_PARCEL_WITH_RET(data, Int64, time, E_READ_PARCEL_ERROR);
256     READ_PARCEL_WITH_RET(data, Uint32, reason, E_READ_PARCEL_ERROR);
257     std::string details = Str16ToStr8(data.ReadString16());
258 
259     PowerErrors error = WakeupDevice(time, static_cast<WakeupDeviceType>(reason), details);
260     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
261     return ERR_OK;
262 }
263 
SuspendDeviceStub(MessageParcel & data,MessageParcel & reply)264 int32_t PowerMgrStub::SuspendDeviceStub(MessageParcel& data, MessageParcel& reply)
265 {
266     int64_t time = 0;
267     uint32_t reason = 0;
268     bool suspendImmed = true;
269 
270     READ_PARCEL_WITH_RET(data, Int64, time, E_READ_PARCEL_ERROR);
271     READ_PARCEL_WITH_RET(data, Uint32, reason, E_READ_PARCEL_ERROR);
272     READ_PARCEL_WITH_RET(data, Bool, suspendImmed, E_READ_PARCEL_ERROR);
273 
274     PowerErrors error = SuspendDevice(time, static_cast<SuspendDeviceType>(reason), suspendImmed);
275     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
276     return ERR_OK;
277 }
278 
RefreshActivityStub(MessageParcel & data)279 int32_t PowerMgrStub::RefreshActivityStub(MessageParcel& data)
280 {
281     int64_t time = 0;
282     uint32_t type = 0;
283     bool needChangeBacklight = true;
284 
285     READ_PARCEL_WITH_RET(data, Int64, time, E_READ_PARCEL_ERROR);
286     READ_PARCEL_WITH_RET(data, Uint32, type, E_READ_PARCEL_ERROR);
287     READ_PARCEL_WITH_RET(data, Bool, needChangeBacklight, E_READ_PARCEL_ERROR);
288 
289     RefreshActivity(time, static_cast<UserActivityType>(type), needChangeBacklight);
290     return ERR_OK;
291 }
292 
OverrideScreenOffTimeStub(MessageParcel & data,MessageParcel & reply)293 int32_t PowerMgrStub::OverrideScreenOffTimeStub(MessageParcel& data, MessageParcel& reply)
294 {
295     int64_t timeout = 0;
296 
297     READ_PARCEL_WITH_RET(data, Int64, timeout, E_READ_PARCEL_ERROR);
298 
299     bool ret = OverrideScreenOffTime(timeout);
300     if (!reply.WriteBool(ret)) {
301         POWER_HILOGE(COMP_FWK, "WriteBool fail");
302         return E_WRITE_PARCEL_ERROR;
303     }
304     return ERR_OK;
305 }
306 
RestoreScreenOffTimeStub(MessageParcel & reply)307 int32_t PowerMgrStub::RestoreScreenOffTimeStub(MessageParcel& reply)
308 {
309     bool ret = RestoreScreenOffTime();
310     if (!reply.WriteBool(ret)) {
311         POWER_HILOGE(COMP_FWK, "WriteBool fail");
312         return E_WRITE_PARCEL_ERROR;
313     }
314     return ERR_OK;
315 }
316 
ForceSuspendDeviceStub(MessageParcel & data,MessageParcel & reply)317 int32_t PowerMgrStub::ForceSuspendDeviceStub(MessageParcel& data, MessageParcel& reply)
318 {
319     bool ret = false;
320     int64_t time = 0;
321 
322     READ_PARCEL_WITH_RET(data, Int64, time, E_READ_PARCEL_ERROR);
323 
324     ret = ForceSuspendDevice(time);
325     if (!reply.WriteBool(ret)) {
326         POWER_HILOGE(FEATURE_SUSPEND, "WriteBool fail");
327         return E_WRITE_PARCEL_ERROR;
328     }
329     return ERR_OK;
330 }
331 
GetStateStub(MessageParcel & reply)332 int32_t PowerMgrStub::GetStateStub(MessageParcel& reply)
333 {
334     PowerState ret = GetState();
335     if (!reply.WriteUint32(static_cast<uint32_t>(ret))) {
336         POWER_HILOGE(FEATURE_POWER_STATE, "WriteUint32 fail");
337         return E_WRITE_PARCEL_ERROR;
338     }
339     return ERR_OK;
340 }
341 
IsScreeOnStub(MessageParcel & reply)342 int32_t PowerMgrStub::IsScreeOnStub(MessageParcel& reply)
343 {
344     bool ret = false;
345     ret = IsScreenOn();
346     if (!reply.WriteBool(ret)) {
347         POWER_HILOGE(COMP_FWK, "WriteBool fail");
348         return E_WRITE_PARCEL_ERROR;
349     }
350     return ERR_OK;
351 }
352 
RegisterPowerStateCallbackStub(MessageParcel & data)353 int32_t PowerMgrStub::RegisterPowerStateCallbackStub(MessageParcel& data)
354 {
355     sptr<IRemoteObject> obj = data.ReadRemoteObject();
356     RETURN_IF_WITH_RET((obj == nullptr), E_READ_PARCEL_ERROR);
357     sptr<IPowerStateCallback> callback = iface_cast<IPowerStateCallback>(obj);
358     RETURN_IF_WITH_RET((callback == nullptr), E_READ_PARCEL_ERROR);
359     RegisterPowerStateCallback(callback);
360     return ERR_OK;
361 }
362 
UnRegisterPowerStateCallbackStub(MessageParcel & data)363 int32_t PowerMgrStub::UnRegisterPowerStateCallbackStub(MessageParcel& data)
364 {
365     sptr<IRemoteObject> obj = data.ReadRemoteObject();
366     RETURN_IF_WITH_RET((obj == nullptr), E_READ_PARCEL_ERROR);
367     sptr<IPowerStateCallback> callback = iface_cast<IPowerStateCallback>(obj);
368     RETURN_IF_WITH_RET((callback == nullptr), E_READ_PARCEL_ERROR);
369     UnRegisterPowerStateCallback(callback);
370     return ERR_OK;
371 }
372 
RegisterShutdownCallbackStub(MessageParcel & data)373 int32_t PowerMgrStub::RegisterShutdownCallbackStub(MessageParcel& data)
374 {
375     uint32_t priority;
376     READ_PARCEL_WITH_RET(data, Uint32, priority, E_READ_PARCEL_ERROR);
377     sptr<IRemoteObject> obj = data.ReadRemoteObject();
378     RETURN_IF_WITH_RET((obj == nullptr), E_READ_PARCEL_ERROR);
379     sptr<IShutdownCallback> callback = iface_cast<IShutdownCallback>(obj);
380     RETURN_IF_WITH_RET((callback == nullptr), E_READ_PARCEL_ERROR);
381     RegisterShutdownCallback(static_cast<IShutdownCallback::ShutdownPriority>(priority), callback);
382     return ERR_OK;
383 }
384 
UnRegisterShutdownCallbackStub(MessageParcel & data)385 int32_t PowerMgrStub::UnRegisterShutdownCallbackStub(MessageParcel& data)
386 {
387     sptr<IRemoteObject> obj = data.ReadRemoteObject();
388     RETURN_IF_WITH_RET((obj == nullptr), E_READ_PARCEL_ERROR);
389     sptr<IShutdownCallback> callback = iface_cast<IShutdownCallback>(obj);
390     RETURN_IF_WITH_RET((callback == nullptr), E_READ_PARCEL_ERROR);
391     UnRegisterShutdownCallback(callback);
392     return ERR_OK;
393 }
394 
RegisterPowerModeCallbackStub(MessageParcel & data)395 int32_t PowerMgrStub::RegisterPowerModeCallbackStub(MessageParcel& data)
396 {
397     sptr<IRemoteObject> obj = data.ReadRemoteObject();
398     RETURN_IF_WITH_RET((obj == nullptr), E_READ_PARCEL_ERROR);
399     sptr<IPowerModeCallback> callback = iface_cast<IPowerModeCallback>(obj);
400     RETURN_IF_WITH_RET((callback == nullptr), E_READ_PARCEL_ERROR);
401     RegisterPowerModeCallback(callback);
402     return ERR_OK;
403 }
404 
UnRegisterPowerModeCallbackStub(MessageParcel & data)405 int32_t PowerMgrStub::UnRegisterPowerModeCallbackStub(MessageParcel& data)
406 {
407     sptr<IRemoteObject> obj = data.ReadRemoteObject();
408     RETURN_IF_WITH_RET((obj == nullptr), E_READ_PARCEL_ERROR);
409     sptr<IPowerModeCallback> callback = iface_cast<IPowerModeCallback>(obj);
410     RETURN_IF_WITH_RET((callback == nullptr), E_READ_PARCEL_ERROR);
411     UnRegisterPowerModeCallback(callback);
412     return ERR_OK;
413 }
414 
SetDisplaySuspendStub(MessageParcel & data)415 int32_t PowerMgrStub::SetDisplaySuspendStub(MessageParcel& data)
416 {
417     bool enable = false;
418     READ_PARCEL_WITH_RET(data, Bool, enable, E_READ_PARCEL_ERROR);
419     SetDisplaySuspend(enable);
420     return ERR_OK;
421 }
422 
SetDeviceModeStub(MessageParcel & data,MessageParcel & reply)423 int32_t PowerMgrStub::SetDeviceModeStub(MessageParcel& data, MessageParcel& reply)
424 {
425     uint32_t mode = 0;
426     READ_PARCEL_WITH_RET(data, Uint32, mode, E_READ_PARCEL_ERROR);
427     PowerErrors error = SetDeviceMode(static_cast<PowerMode>(mode));
428     WRITE_PARCEL_WITH_RET(reply, Int32, static_cast<int32_t>(error), E_WRITE_PARCEL_ERROR);
429     return ERR_OK;
430 }
431 
GetDeviceModeStub(MessageParcel & reply)432 int32_t PowerMgrStub::GetDeviceModeStub(MessageParcel& reply)
433 {
434     uint32_t ret = 0;
435     ret = static_cast<uint32_t>(GetDeviceMode());
436     if (!reply.WriteUint32(static_cast<uint32_t>(ret))) {
437         POWER_HILOGE(FEATURE_POWER_MODE, "WriteUint32 fail");
438         return E_WRITE_PARCEL_ERROR;
439     }
440     return ERR_OK;
441 }
442 
ShellDumpStub(MessageParcel & data,MessageParcel & reply)443 int32_t PowerMgrStub::ShellDumpStub(MessageParcel& data, MessageParcel& reply)
444 {
445     uint32_t argc;
446     std::vector<std::string> args;
447 
448     if (!data.ReadUint32(argc)) {
449         POWER_HILOGE(COMP_FWK, "ReadUint32 fail");
450         return E_READ_PARCEL_ERROR;
451     }
452 
453     if (argc >= PARAM_MAX_NUM) {
454         POWER_HILOGW(COMP_FWK, "params exceed limit, argc=%{public}d", argc);
455         return E_EXCEED_PARAM_LIMIT;
456     }
457 
458     for (uint32_t i = 0; i < argc; i++) {
459         std::string arg = data.ReadString();
460         if (arg.empty()) {
461             POWER_HILOGW(COMP_FWK, "read args fail, arg index=%{public}d", i);
462             return E_READ_PARCEL_ERROR;
463         }
464         args.push_back(arg);
465     }
466 
467     std::string ret = ShellDump(args, argc);
468     if (!reply.WriteString(ret)) {
469         POWER_HILOGE(COMP_FWK, "WriteString fail");
470         return E_WRITE_PARCEL_ERROR;
471     }
472     return ERR_OK;
473 }
474 } // namespace PowerMgr
475 } // namespace OHOS
476