1 /*
2 * Copyright (c) 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 "allow_info.h"
17 #include "ipc_util.h"
18 #include "standby_service_log.h"
19
20 namespace OHOS {
21 namespace DevStandbyMgr {
Marshalling(Parcel & out) const22 bool AllowInfo::Marshalling(Parcel& out) const
23 {
24 WRITE_PARCEL_WITH_RET(out, Uint32, allowType_, false);
25 WRITE_PARCEL_WITH_RET(out, String, name_, false);
26 WRITE_PARCEL_WITH_RET(out, Int32, duration_, false);
27 return true;
28 }
29
Unmarshalling(Parcel & in)30 sptr<AllowInfo> AllowInfo::Unmarshalling(Parcel& in)
31 {
32 sptr<AllowInfo> info = new (std::nothrow) AllowInfo();
33 if (info != nullptr && !info->ReadFromParcel(in)) {
34 STANDBYSERVICE_LOGE("read from parcel failed");
35 info = nullptr;
36 }
37 return info;
38 }
39
ReadFromParcel(Parcel & in)40 bool AllowInfo::ReadFromParcel(Parcel& in)
41 {
42 READ_PARCEL_WITH_RET(in, Uint32, allowType_, false);
43 READ_PARCEL_WITH_RET(in, String, name_, false);
44 READ_PARCEL_WITH_RET(in, Int32, duration_, false);
45 return true;
46 }
47 } // namespace DevStandbyMgr
48 } // namespace OHOS