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 AllowInfo *AllowInfo::Unmarshalling(Parcel& in)
31 {
32 auto info = new (std::nothrow) AllowInfo();
33 if (info != nullptr && !info->ReadFromParcel(in)) {
34 STANDBYSERVICE_LOGE("read from parcel failed");
35 delete info;
36 info = nullptr;
37 }
38 return info;
39 }
40
ReadFromParcel(Parcel & in)41 bool AllowInfo::ReadFromParcel(Parcel& in)
42 {
43 READ_PARCEL_WITH_RET(in, Uint32, allowType_, false);
44 READ_PARCEL_WITH_RET(in, String, name_, false);
45 READ_PARCEL_WITH_RET(in, Int32, duration_, false);
46 return true;
47 }
48 } // namespace DevStandbyMgr
49 } // namespace OHOS