• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 "efficiency_resource_info.h"
17 #include "ipc_util.h"
18 #include "efficiency_resource_log.h"
19 
20 namespace OHOS {
21 namespace BackgroundTaskMgr {
Marshalling(Parcel & out) const22 bool EfficiencyResourceInfo::Marshalling(Parcel& out) const
23 {
24     WRITE_PARCEL_WITH_RET(out, Uint32, resourceNumber_, false);
25     WRITE_PARCEL_WITH_RET(out, Bool, isApply_, false);
26     WRITE_PARCEL_WITH_RET(out, Uint32, timeOut_, false);
27     WRITE_PARCEL_WITH_RET(out, String, reason_, false);
28     WRITE_PARCEL_WITH_RET(out, Bool, isPersist_, false);
29     WRITE_PARCEL_WITH_RET(out, Bool, isProcess_, false);
30     WRITE_PARCEL_WITH_RET(out, Int32, uid_, false);
31     WRITE_PARCEL_WITH_RET(out, Int32, pid_, false);
32     return true;
33 }
34 
Unmarshalling(Parcel & in)35 EfficiencyResourceInfo* EfficiencyResourceInfo::Unmarshalling(Parcel &in)
36 {
37     EfficiencyResourceInfo* info = new (std::nothrow) EfficiencyResourceInfo();
38     if (info && !info->ReadFromParcel(in)) {
39         BGTASK_LOGE("read from parcel failed");
40         delete info;
41         info = nullptr;
42     }
43     return info;
44 }
45 
ReadFromParcel(Parcel & in)46 bool EfficiencyResourceInfo::ReadFromParcel(Parcel& in)
47 {
48     READ_PARCEL_WITH_RET(in, Uint32, resourceNumber_, false);
49     READ_PARCEL_WITH_RET(in, Bool, isApply_, false);
50     READ_PARCEL_WITH_RET(in, Uint32, timeOut_, false);
51     READ_PARCEL_WITH_RET(in, String, reason_, false);
52     READ_PARCEL_WITH_RET(in, Bool, isPersist_, false);
53     READ_PARCEL_WITH_RET(in, Bool, isProcess_, false);
54     READ_PARCEL_WITH_RET(in, Int32, uid_, false);
55     READ_PARCEL_WITH_RET(in, Int32, pid_, false);
56     return true;
57 }
58 }
59 }