• 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 "configuration_policy.h"
17 
18 #include "hilog_tag_wrapper.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)22 bool ConfigurationPolicy::ReadFromParcel(Parcel &parcel)
23 {
24     if (!parcel.ReadInt8(maxCountPerBatch)) {
25         TAG_LOGE(AAFwkTag::APPMGR, "maxCountPerBatch read int8 failed.");
26         return false;
27     }
28     if (!parcel.ReadInt16(intervalTime)) {
29         TAG_LOGE(AAFwkTag::APPMGR, "intervalTime read int16 failed.");
30         return false;
31     }
32 
33     return true;
34 }
35 
Unmarshalling(Parcel & parcel)36 ConfigurationPolicy *ConfigurationPolicy::Unmarshalling(Parcel &parcel)
37 {
38     ConfigurationPolicy *policy = new (std::nothrow) ConfigurationPolicy();
39     if (policy && !policy->ReadFromParcel(parcel)) {
40         delete policy;
41         policy = nullptr;
42     }
43     return policy;
44 }
45 
Marshalling(Parcel & parcel) const46 bool ConfigurationPolicy::Marshalling(Parcel &parcel) const
47 {
48     if (!parcel.WriteInt8(maxCountPerBatch)) {
49         TAG_LOGE(AAFwkTag::APPMGR, "countPerTime write int8 failed.");
50         return false;
51     }
52 
53     if (!parcel.WriteInt16(intervalTime)) {
54         TAG_LOGE(AAFwkTag::APPMGR, "intervalTime write int16 failed.");
55         return false;
56     }
57 
58     return true;
59 }
60 } // namespace AppExecFwk
61 } // namespace OHOS