• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "background_task_mgr_proxy.h"
17 
18 #include <message_parcel.h>
19 #include <string_ex.h>
20 
21 #include "bgtaskmgr_log_wrapper.h"
22 #include "ibackground_task_mgr_ipc_interface_code.h"
23 
24 using namespace std;
25 
26 namespace OHOS {
27 namespace BackgroundTaskMgr {
BackgroundTaskMgrProxy(const sptr<IRemoteObject> & impl)28 BackgroundTaskMgrProxy::BackgroundTaskMgrProxy(const sptr<IRemoteObject>& impl)
29     :IRemoteProxy<IBackgroundTaskMgr>(impl) {}
~BackgroundTaskMgrProxy()30 BackgroundTaskMgrProxy::~BackgroundTaskMgrProxy() {}
31 
RequestSuspendDelay(const std::u16string & reason,const sptr<IExpiredCallback> & callback,std::shared_ptr<DelaySuspendInfo> & delayInfo)32 ErrCode BackgroundTaskMgrProxy::RequestSuspendDelay(const std::u16string& reason,
33     const sptr<IExpiredCallback>& callback, std::shared_ptr<DelaySuspendInfo> &delayInfo)
34 {
35     if (callback == nullptr) {
36         BGTASK_LOGE("RequestSuspendDelay callback is null");
37         return ERR_CALLBACK_NULL_OR_TYPE_ERR;
38     }
39 
40     MessageParcel data;
41     MessageParcel reply;
42     MessageOption option = {MessageOption::TF_SYNC};
43     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
44         BGTASK_LOGE("RequestSuspendDelay write descriptor failed");
45         return ERR_BGTASK_PARCELABLE_FAILED;
46     }
47     if (!data.WriteString16(reason)) {
48         BGTASK_LOGE("RequestSuspendDelay write reason failed");
49         return ERR_BGTASK_PARCELABLE_FAILED;
50     }
51     if (!data.WriteRemoteObject(callback->AsObject())) {
52         BGTASK_LOGE("RequestSuspendDelay write callback failed");
53         return ERR_BGTASK_PARCELABLE_FAILED;
54     }
55     ErrCode result = InnerTransact(static_cast<uint32_t>(
56         BackgroundTaskMgrStubInterfaceCode::REQUEST_SUSPEND_DELAY), option, data, reply);
57     if (result != ERR_OK) {
58         BGTASK_LOGE("RequestSuspendDelay transact ErrCode=%{public}d", result);
59         return ERR_BGTASK_TRANSACT_FAILED;
60     }
61     if (!reply.ReadInt32(result)) {
62         BGTASK_LOGE("RequestSuspendDelay fail: read result failed.");
63         return ERR_BGTASK_PARCELABLE_FAILED;
64     }
65     delayInfo = DelaySuspendInfo::Unmarshalling(reply);
66     if (delayInfo == nullptr) {
67         BGTASK_LOGE("RequestSuspendDelay read result failed");
68         return ERR_BGTASK_PARCELABLE_FAILED;
69     }
70     return result;
71 }
72 
CancelSuspendDelay(int32_t requestId)73 ErrCode BackgroundTaskMgrProxy::CancelSuspendDelay(int32_t requestId)
74 {
75     MessageParcel data;
76     MessageParcel reply;
77     MessageOption option = {MessageOption::TF_SYNC};
78     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
79         BGTASK_LOGE("RequestSuspendDelay write descriptor failed");
80         return ERR_BGTASK_PARCELABLE_FAILED;
81     }
82     if (!data.WriteInt32(requestId)) {
83         BGTASK_LOGE("RequestSuspendDelay write requestId failed");
84         return ERR_BGTASK_PARCELABLE_FAILED;
85     }
86 
87     ErrCode result = InnerTransact(static_cast<uint32_t>(
88         BackgroundTaskMgrStubInterfaceCode::CANCEL_SUSPEND_DELAY), option, data, reply);
89     if (result != ERR_OK) {
90         BGTASK_LOGE("RequestSuspendDelay fail: transact ErrCode=%{public}d", result);
91         return ERR_BGTASK_TRANSACT_FAILED;
92     }
93     if (!reply.ReadInt32(result)) {
94         BGTASK_LOGE("RequestSuspendDelay fail: read result failed.");
95         return ERR_BGTASK_PARCELABLE_FAILED;
96     }
97     return result;
98 }
99 
GetRemainingDelayTime(int32_t requestId,int32_t & delayTime)100 ErrCode BackgroundTaskMgrProxy::GetRemainingDelayTime(int32_t requestId, int32_t &delayTime)
101 {
102     MessageParcel data;
103     MessageParcel reply;
104     MessageOption option = {MessageOption::TF_SYNC};
105     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
106         BGTASK_LOGE(" BackgroundTaskMgrProxy::%{public}s, write descriptor failed", __func__);
107         return ERR_BGTASK_PARCELABLE_FAILED;
108     }
109     if (!data.WriteInt32(requestId)) {
110         BGTASK_LOGE(" BackgroundTaskMgrProxy::%{public}s, write requestId failed", __func__);
111         return ERR_BGTASK_PARCELABLE_FAILED;
112     }
113 
114     ErrCode result = InnerTransact(static_cast<uint32_t>(
115         BackgroundTaskMgrStubInterfaceCode::GET_REMAINING_DELAY_TIME), option, data, reply);
116     if (result != ERR_OK) {
117         BGTASK_LOGE("GetRemainingDelayTime fail: transact ErrCode=%{public}d", result);
118         return ERR_BGTASK_TRANSACT_FAILED;
119     }
120     if (!reply.ReadInt32(result)) {
121         BGTASK_LOGE("GetRemainingDelayTime fail: read result failed.");
122         return ERR_BGTASK_PARCELABLE_FAILED;
123     }
124     if (!reply.ReadInt32(delayTime)) {
125         BGTASK_LOGE("GetRemainingDelayTime fail: read result failed.");
126         return ERR_BGTASK_PARCELABLE_FAILED;
127     }
128     return result;
129 }
130 
RequestBackgroundRunningForInner(const sptr<ContinuousTaskParamForInner> & taskParam)131 ErrCode BackgroundTaskMgrProxy::RequestBackgroundRunningForInner(const sptr<ContinuousTaskParamForInner> &taskParam)
132 {
133     if (taskParam == nullptr) {
134         return ERR_BGTASK_INVALID_PARAM;
135     }
136 
137     MessageParcel dataInfo;
138     if (!dataInfo.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
139         return ERR_BGTASK_PARCELABLE_FAILED;
140     }
141 
142     if (!dataInfo.WriteParcelable(taskParam)) {
143         return ERR_BGTASK_PARCELABLE_FAILED;
144     }
145 
146     MessageParcel reply;
147     MessageOption option = {MessageOption::TF_SYNC};
148 
149     ErrCode result = InnerTransact(static_cast<uint32_t>(
150         BackgroundTaskMgrStubInterfaceCode::REQUEST_BACKGROUND_RUNNING_FOR_INNER), option, dataInfo, reply);
151     if (result != ERR_OK) {
152         BGTASK_LOGE("RequestBackgroundRunningForInner fail: transact ErrCode=%{public}d", result);
153         return ERR_BGTASK_TRANSACT_FAILED;
154     }
155     if (!reply.ReadInt32(result)) {
156         BGTASK_LOGE("RequestBackgroundRunningForInner fail: read result failed.");
157         return ERR_BGTASK_PARCELABLE_FAILED;
158     }
159     return result;
160 }
161 
StartBackgroundRunning(const sptr<ContinuousTaskParam> & taskParam)162 ErrCode BackgroundTaskMgrProxy::StartBackgroundRunning(const sptr<ContinuousTaskParam> &taskParam)
163 {
164     if (taskParam == nullptr) {
165         return ERR_BGTASK_INVALID_PARAM;
166     }
167 
168     MessageParcel data;
169     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
170         return ERR_BGTASK_PARCELABLE_FAILED;
171     }
172 
173     if (!data.WriteParcelable(taskParam)) {
174         return ERR_BGTASK_PARCELABLE_FAILED;
175     }
176 
177     MessageParcel reply;
178     MessageOption option = {MessageOption::TF_SYNC};
179 
180     ErrCode result = InnerTransact(static_cast<uint32_t>(
181         BackgroundTaskMgrStubInterfaceCode::START_BACKGROUND_RUNNING), option, data, reply);
182     if (result != ERR_OK) {
183         BGTASK_LOGE("StartBackgroundRunning fail: transact ErrCode=%{public}d", result);
184         return ERR_BGTASK_TRANSACT_FAILED;
185     }
186     if (!reply.ReadInt32(result)) {
187         BGTASK_LOGE("StartBackgroundRunning fail: read result failed.");
188         return ERR_BGTASK_PARCELABLE_FAILED;
189     }
190     return result;
191 }
192 
StopBackgroundRunning(const std::string & abilityName,const sptr<IRemoteObject> & abilityToken)193 ErrCode BackgroundTaskMgrProxy::StopBackgroundRunning(const std::string &abilityName,
194     const sptr<IRemoteObject> &abilityToken)
195 {
196     MessageParcel data;
197     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
198         return ERR_BGTASK_PARCELABLE_FAILED;
199     }
200 
201     std::u16string u16AbilityName = Str8ToStr16(abilityName);
202     if (!data.WriteString16(u16AbilityName)) {
203         BGTASK_LOGE("StopBackgroundRunning parcel ability Name failed");
204         return ERR_BGTASK_PARCELABLE_FAILED;
205     }
206 
207     if (!data.WriteRemoteObject(abilityToken)) {
208         BGTASK_LOGE("StopBackgroundRunning parcel ability token failed");
209         return ERR_BGTASK_PARCELABLE_FAILED;
210     }
211 
212     MessageParcel reply;
213     MessageOption option = {MessageOption::TF_SYNC};
214 
215     ErrCode result = InnerTransact(static_cast<uint32_t>(
216         BackgroundTaskMgrStubInterfaceCode::STOP_BACKGROUND_RUNNING), option, data, reply);
217     if (result != ERR_OK) {
218         BGTASK_LOGE("StopBackgroundRunning transact ErrCode=%{public}d", result);
219         return ERR_BGTASK_TRANSACT_FAILED;
220     }
221     if (!reply.ReadInt32(result)) {
222         BGTASK_LOGE("StopBackgroundRunning read result failed.");
223         return ERR_BGTASK_PARCELABLE_FAILED;
224     }
225     return result;
226 }
227 
SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> & subscriber)228 ErrCode BackgroundTaskMgrProxy::SubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber)
229 {
230     if (subscriber == nullptr) {
231         BGTASK_LOGE("SubscribeBackgroundTask subscriber is null");
232         return ERR_BGTASK_PARCELABLE_FAILED;
233     }
234 
235     MessageParcel data;
236     MessageParcel reply;
237     MessageOption option = {MessageOption::TF_SYNC};
238     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
239         BGTASK_LOGE("SubscribeBackgroundTask write descriptor failed");
240         return ERR_BGTASK_PARCELABLE_FAILED;
241     }
242     if (!data.WriteRemoteObject(subscriber->AsObject())) {
243         BGTASK_LOGE("SubscribeBackgroundTask write subscriber failed");
244         return ERR_BGTASK_PARCELABLE_FAILED;
245     }
246 
247     ErrCode result = InnerTransact(static_cast<uint32_t>(
248         BackgroundTaskMgrStubInterfaceCode::SUBSCRIBE_BACKGROUND_TASK), option, data, reply);
249     if (result != ERR_OK) {
250         BGTASK_LOGE("SubscribeBackgroundTask fail: transact ErrCode=%{public}d", result);
251         return ERR_BGTASK_TRANSACT_FAILED;
252     }
253     if (!reply.ReadInt32(result)) {
254         BGTASK_LOGE("SubscribeBackgroundTask fail: read result failed.");
255         return ERR_BGTASK_PARCELABLE_FAILED;
256     }
257     return result;
258 }
259 
UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber> & subscriber)260 ErrCode BackgroundTaskMgrProxy::UnsubscribeBackgroundTask(const sptr<IBackgroundTaskSubscriber>& subscriber)
261 {
262     if (subscriber == nullptr) {
263         BGTASK_LOGE("UnsubscribeBackgroundTask subscriber is null");
264         return ERR_BGTASK_PARCELABLE_FAILED;
265     }
266 
267     MessageParcel data;
268     MessageParcel reply;
269     MessageOption option = {MessageOption::TF_SYNC};
270     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
271         BGTASK_LOGE("UnsubscribeBackgroundTask write descriptor failed");
272         return ERR_BGTASK_PARCELABLE_FAILED;
273     }
274     if (!data.WriteRemoteObject(subscriber->AsObject())) {
275         BGTASK_LOGE("UnsubscribeBackgroundTask write subscriber failed");
276         return ERR_BGTASK_PARCELABLE_FAILED;
277     }
278 
279     ErrCode result = InnerTransact(static_cast<uint32_t>(
280         BackgroundTaskMgrStubInterfaceCode::UNSUBSCRIBE_BACKGROUND_TASK), option, data, reply);
281     if (result != ERR_OK) {
282         BGTASK_LOGE("UnsubscribeBackgroundTask fail: transact ErrCode=%{public}d", result);
283         return ERR_BGTASK_TRANSACT_FAILED;
284     }
285     if (!reply.ReadInt32(result)) {
286         BGTASK_LOGE("UnsubscribeBackgroundTask fail: read result failed.");
287         return ERR_BGTASK_PARCELABLE_FAILED;
288     }
289     return result;
290 }
291 
GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> & list)292 ErrCode BackgroundTaskMgrProxy::GetTransientTaskApps(std::vector<std::shared_ptr<TransientTaskAppInfo>> &list)
293 {
294     MessageParcel data;
295     MessageParcel reply;
296     MessageOption option = {MessageOption::TF_SYNC};
297     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
298         BGTASK_LOGE("GetTransientTaskApps write descriptor failed");
299         return ERR_BGTASK_PARCELABLE_FAILED;
300     }
301 
302     ErrCode result = InnerTransact(static_cast<uint32_t>(
303         BackgroundTaskMgrStubInterfaceCode::GET_TRANSIENT_TASK_APPS), option, data, reply);
304     if (result != ERR_OK) {
305         BGTASK_LOGE("GetTransientTaskApps fail: transact ErrCode=%{public}d", result);
306         return ERR_BGTASK_TRANSACT_FAILED;
307     }
308     if (!reply.ReadInt32(result)) {
309         BGTASK_LOGE("GetTransientTaskApps fail: read result failed.");
310         return ERR_BGTASK_PARCELABLE_FAILED;
311     }
312 
313     int32_t infoSize = reply.ReadInt32();
314     for (int32_t i = 0; i < infoSize; i++) {
315         auto info = TransientTaskAppInfo::Unmarshalling(reply);
316         if (!info) {
317             BGTASK_LOGE("GetTransientTaskApps Read Parcelable infos failed.");
318             return ERR_BGTASK_PARCELABLE_FAILED;
319         }
320         list.emplace_back(info);
321     }
322 
323     return result;
324 }
325 
GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> & list)326 ErrCode BackgroundTaskMgrProxy::GetContinuousTaskApps(std::vector<std::shared_ptr<ContinuousTaskCallbackInfo>> &list)
327 {
328     MessageParcel data;
329     MessageParcel reply;
330     MessageOption option = {MessageOption::TF_SYNC};
331     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
332         BGTASK_LOGE("GetContinuousTaskApps write descriptor failed");
333         return ERR_BGTASK_PARCELABLE_FAILED;
334     }
335 
336     ErrCode result = InnerTransact(static_cast<uint32_t>(
337         BackgroundTaskMgrStubInterfaceCode::GET_CONTINUOUS_TASK_APPS), option, data, reply);
338     if (result != ERR_OK) {
339         BGTASK_LOGE("GetContinuousTaskApps fail: transact ErrCode=%{public}d", result);
340         return ERR_BGTASK_TRANSACT_FAILED;
341     }
342     if (!reply.ReadInt32(result)) {
343         BGTASK_LOGE("GetContinuousTaskApps fail: read result failed.");
344         return ERR_BGTASK_PARCELABLE_FAILED;
345     }
346 
347     if (result != ERR_OK) {
348         BGTASK_LOGE("GetContinuousTaskApps failed.");
349         return result;
350     }
351 
352     int32_t infoSize = reply.ReadInt32();
353     for (int32_t i = 0; i < infoSize; i++) {
354         auto info = ContinuousTaskCallbackInfo::Unmarshalling(reply);
355         if (!info) {
356             BGTASK_LOGE("GetContinuousTaskApps Read Parcelable infos failed.");
357             return ERR_BGTASK_PARCELABLE_FAILED;
358         }
359         list.emplace_back(info);
360     }
361 
362     return result;
363 }
364 
StopContinuousTask(int32_t uid,int32_t pid,uint32_t taskType)365 ErrCode BackgroundTaskMgrProxy::StopContinuousTask(int32_t uid, int32_t pid, uint32_t taskType)
366 {
367     MessageParcel data;
368     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
369         return ERR_BGTASK_PARCELABLE_FAILED;
370     }
371 
372     if (!data.WriteInt32(uid)) {
373         BGTASK_LOGE("StopContinuousTask parcel uid failed");
374         return ERR_BGTASK_PARCELABLE_FAILED;
375     }
376 
377     if (!data.WriteInt32(pid)) {
378         BGTASK_LOGE("StopContinuousTask parcel pid failed");
379         return ERR_BGTASK_PARCELABLE_FAILED;
380     }
381 
382     if (!data.WriteUint32(taskType)) {
383         BGTASK_LOGE("StopContinuousTask parcel taskType failed");
384         return ERR_BGTASK_PARCELABLE_FAILED;
385     }
386 
387     MessageParcel reply;
388     MessageOption option = {MessageOption::TF_SYNC};
389 
390     ErrCode result = InnerTransact(static_cast<uint32_t>(
391         BackgroundTaskMgrStubInterfaceCode::STOP_CONTINUOUS_TASK), option, data, reply);
392     if (result != ERR_OK) {
393         BGTASK_LOGE("StopContinuousTask transact ErrCode=%{public}d", result);
394         return ERR_BGTASK_TRANSACT_FAILED;
395     }
396     if (!reply.ReadInt32(result)) {
397         BGTASK_LOGE("StopContinuousTask read result failed.");
398         return ERR_BGTASK_PARCELABLE_FAILED;
399     }
400     return result;
401 }
402 
InnerTransact(uint32_t code,MessageOption & flags,MessageParcel & data,MessageParcel & reply)403 ErrCode BackgroundTaskMgrProxy::InnerTransact(uint32_t code, MessageOption &flags,
404     MessageParcel &data, MessageParcel &reply)
405 {
406     auto remote = Remote();
407     if (remote == nullptr) {
408         BGTASK_LOGE("InnerTransact get Remote fail code %{public}d", code);
409         return ERR_DEAD_OBJECT;
410     }
411     int32_t err = remote->SendRequest(code, data, reply, flags);
412     switch (err) {
413         case NO_ERROR: {
414             return ERR_OK;
415         }
416         case DEAD_OBJECT: {
417             BGTASK_LOGE("[InnerTransact] fail: ipcErr=%{public}d code %{public}u", err, code);
418             return ERR_DEAD_OBJECT;
419         }
420         default: {
421             BGTASK_LOGE("[InnerTransact] fail: ipcErr=%{public}d code %{public}u", err, code);
422             return ERR_BGTASK_TRANSACT_FAILED;
423         }
424     }
425 }
426 
ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> & resourceInfo)427 ErrCode BackgroundTaskMgrProxy::ApplyEfficiencyResources(const sptr<EfficiencyResourceInfo> &resourceInfo)
428 {
429     if (resourceInfo == nullptr) {
430         return ERR_BGTASK_INVALID_PARAM;
431     }
432 
433     MessageParcel data;
434     MessageParcel reply;
435     MessageOption option = {MessageOption::TF_SYNC};
436     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
437         BGTASK_LOGE("ApplyEfficiencyResources write descriptor failed");
438         return ERR_BGTASK_PARCELABLE_FAILED;
439     }
440 
441     if (!data.WriteParcelable(resourceInfo)) {
442         return ERR_BGTASK_PARCELABLE_FAILED;
443     }
444     BGTASK_LOGD("start send data in apply res function from bgtask proxy");
445     ErrCode result = InnerTransact(static_cast<uint32_t>(
446         BackgroundTaskMgrStubInterfaceCode::APPLY_EFFICIENCY_RESOURCES), option, data, reply);
447     if (result != ERR_OK) {
448         BGTASK_LOGE("ApplyEfficiencyResources fail: transact ErrCode=%{public}d", result);
449         return ERR_BGTASK_TRANSACT_FAILED;
450     }
451     if (!reply.ReadInt32(result)) {
452         BGTASK_LOGE("ApplyEfficiencyResources fail: read result failed.");
453         return ERR_BGTASK_PARCELABLE_FAILED;
454     }
455     return result;
456 }
457 
ResetAllEfficiencyResources()458 ErrCode BackgroundTaskMgrProxy::ResetAllEfficiencyResources()
459 {
460     MessageParcel data;
461     MessageParcel reply;
462     MessageOption option = {MessageOption::TF_SYNC};
463     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
464         BGTASK_LOGE("ResetAllEfficiencyResources write descriptor failed");
465         return ERR_BGTASK_PARCELABLE_FAILED;
466     }
467     BGTASK_LOGD("start send data in reset all res function from bgtask proxy");
468     ErrCode result = InnerTransact(static_cast<uint32_t>(
469         BackgroundTaskMgrStubInterfaceCode::RESET_ALL_EFFICIENCY_RESOURCES), option, data, reply);
470     if (result != ERR_OK) {
471         BGTASK_LOGE("ResetAllEfficiencyResources fail: transact ErrCode=%{public}d", result);
472         return ERR_BGTASK_TRANSACT_FAILED;
473     }
474     if (!reply.ReadInt32(result)) {
475         BGTASK_LOGE("ResetAllEfficiencyResources fail: read result failed.");
476         return ERR_BGTASK_PARCELABLE_FAILED;
477     }
478     return result;
479 }
480 
GetEfficiencyResourcesInfos(std::vector<std::shared_ptr<ResourceCallbackInfo>> & appList,std::vector<std::shared_ptr<ResourceCallbackInfo>> & procList)481 ErrCode BackgroundTaskMgrProxy::GetEfficiencyResourcesInfos(std::vector<std::shared_ptr<
482     ResourceCallbackInfo>> &appList, std::vector<std::shared_ptr<ResourceCallbackInfo>> &procList)
483 {
484     MessageParcel data;
485     MessageParcel reply;
486     MessageOption option = {MessageOption::TF_SYNC};
487     if (!data.WriteInterfaceToken(BackgroundTaskMgrProxy::GetDescriptor())) {
488         BGTASK_LOGE("GetEfficiencyResourcesInfos write descriptor failed");
489         return ERR_BGTASK_PARCELABLE_FAILED;
490     }
491 
492     ErrCode result = InnerTransact(static_cast<uint32_t>(
493         BackgroundTaskMgrStubInterfaceCode::GET_EFFICIENCY_RESOURCES_INFOS), option, data, reply);
494     if (result != ERR_OK) {
495         BGTASK_LOGE("GetEfficiencyResourcesInfos fail: transact ErrCode=%{public}d", result);
496         return ERR_BGTASK_TRANSACT_FAILED;
497     }
498     if (!reply.ReadInt32(result)) {
499         BGTASK_LOGE("GetEfficiencyResourcesInfos fail: read result failed.");
500         return ERR_BGTASK_PARCELABLE_FAILED;
501     }
502 
503     if (result != ERR_OK) {
504         return result;
505     }
506 
507     int32_t infoSize = reply.ReadInt32();
508     for (int32_t i = 0; i < infoSize; i++) {
509         auto info = ResourceCallbackInfo::Unmarshalling(reply);
510         if (!info) {
511             BGTASK_LOGE("GetContinuousTaskApps Read Parcelable infos failed.");
512             return ERR_BGTASK_PARCELABLE_FAILED;
513         }
514         appList.emplace_back(info);
515     }
516 
517     infoSize = reply.ReadInt32();
518     for (int32_t i = 0; i < infoSize; i++) {
519         auto info = ResourceCallbackInfo::Unmarshalling(reply);
520         if (!info) {
521             BGTASK_LOGE("GetContinuousTaskApps Read Parcelable infos failed.");
522             return ERR_BGTASK_PARCELABLE_FAILED;
523         }
524         procList.emplace_back(info);
525     }
526 
527     return result;
528 }
529 }  // namespace BackgroundTaskMgr
530 }  // namespace OHOS