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 "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 return true;
31 }
32
Unmarshalling(Parcel & in)33 EfficiencyResourceInfo* EfficiencyResourceInfo::Unmarshalling(Parcel &in)
34 {
35 EfficiencyResourceInfo* info = new (std::nothrow) EfficiencyResourceInfo();
36 if (info && !info->ReadFromParcel(in)) {
37 BGTASK_LOGE("read from parcel failed");
38 delete info;
39 info = nullptr;
40 }
41 return info;
42 }
43
ReadFromParcel(Parcel & in)44 bool EfficiencyResourceInfo::ReadFromParcel(Parcel& in)
45 {
46 READ_PARCEL_WITH_RET(in, Uint32, resourceNumber_, false);
47 READ_PARCEL_WITH_RET(in, Bool, isApply_, false);
48 READ_PARCEL_WITH_RET(in, Uint32, timeOut_, false);
49 READ_PARCEL_WITH_RET(in, String, reason_, false);
50 READ_PARCEL_WITH_RET(in, Bool, isPersist_, false);
51 READ_PARCEL_WITH_RET(in, Bool, isProcess_, false);
52 return true;
53 }
54 }
55 }