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 "dlp_connection_info.h"
17 
18 namespace OHOS {
19 namespace AbilityRuntime {
Marshalling(Parcel & parcel) const20 bool DlpConnectionInfo::Marshalling(Parcel &parcel) const
21 {
22     if (!parcel.WriteInt32(dlpUid)) {
23         return false;
24     }
25 
26     if (!parcel.WriteInt32(openedAbilityCount)) {
27         return false;
28     }
29 
30     return true;
31 }
32 
ReadFromParcel(Parcel & parcel)33 bool DlpConnectionInfo::ReadFromParcel(Parcel &parcel)
34 {
35     if (!parcel.ReadInt32(dlpUid)) {
36         return false;
37     }
38 
39     if (!parcel.ReadInt32(openedAbilityCount)) {
40         return false;
41     }
42 
43     return true;
44 }
45 
Unmarshalling(Parcel & parcel)46 DlpConnectionInfo *DlpConnectionInfo::Unmarshalling(Parcel &parcel)
47 {
48     DlpConnectionInfo *data = new DlpConnectionInfo();
49     if (!data->ReadFromParcel(parcel)) {
50         delete data;
51         data = nullptr;
52     }
53     return data;
54 }
55 }  // namespace AbilityRuntime
56 }  // namespace OHOS
57