• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 "ipc_codec.h"
17 #include "common/sharing_log.h"
18 
19 namespace OHOS {
20 namespace Sharing {
21 namespace IPC_CODEC {
22 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,bool attr)23 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, bool attr)
24 {
25     SHARING_LOGD("trace.");
26     return pIpcMsg.WriteBool(attr);
27 }
28 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,int8_t attr)29 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, int8_t attr)
30 {
31     SHARING_LOGD("trace.");
32     return pIpcMsg.WriteInt8(attr);
33 }
34 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,int16_t attr)35 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, int16_t attr)
36 {
37     SHARING_LOGD("trace.");
38     return pIpcMsg.WriteInt16(attr);
39 }
40 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,int32_t attr)41 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, int32_t attr)
42 {
43     SHARING_LOGD("trace.");
44     return pIpcMsg.WriteInt32(attr);
45 }
46 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,int64_t attr)47 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, int64_t attr)
48 {
49     SHARING_LOGD("trace.");
50     return pIpcMsg.WriteInt64(attr);
51 }
52 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,uint8_t attr)53 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, uint8_t attr)
54 {
55     SHARING_LOGD("trace.");
56     return pIpcMsg.WriteUint8(attr);
57 }
58 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,uint16_t attr)59 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, uint16_t attr)
60 {
61     SHARING_LOGD("trace.");
62     return pIpcMsg.WriteUint16(attr);
63 }
64 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,uint32_t attr)65 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, uint32_t attr)
66 {
67     SHARING_LOGD("trace.");
68     return pIpcMsg.WriteUint32(attr);
69 }
70 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,uint64_t attr)71 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, uint64_t attr)
72 {
73     SHARING_LOGD("trace.");
74     return pIpcMsg.WriteUint64(attr);
75 }
76 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,float attr)77 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, float attr)
78 {
79     SHARING_LOGD("trace.");
80     return pIpcMsg.WriteFloat(attr);
81 }
82 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,double attr)83 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, double attr)
84 {
85     SHARING_LOGD("trace.");
86     return pIpcMsg.WriteDouble(attr);
87 }
88 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,std::string & attr)89 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, std::string &attr)
90 {
91     SHARING_LOGD("trace.");
92     return pIpcMsg.WriteString(attr);
93 }
94 
IpcEncodeBindAttr(MessageParcel & pIpcMsg,sptr<IRemoteObject> & attr)95 bool IpcEncodeBindAttr(MessageParcel &pIpcMsg, sptr<IRemoteObject> &attr)
96 {
97     SHARING_LOGD("trace.");
98     return pIpcMsg.WriteRemoteObject(attr);
99 }
100 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,bool & attr)101 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, bool &attr)
102 {
103     SHARING_LOGD("trace.");
104     return pIpcMsg.ReadBool(attr);
105 }
106 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,int8_t & attr)107 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, int8_t &attr)
108 {
109     SHARING_LOGD("trace.");
110     return pIpcMsg.ReadInt8(attr);
111 }
112 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,int16_t & attr)113 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, int16_t &attr)
114 {
115     SHARING_LOGD("trace.");
116     return pIpcMsg.ReadInt16(attr);
117 }
118 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,int32_t & attr)119 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, int32_t &attr)
120 {
121     SHARING_LOGD("trace.");
122     return pIpcMsg.ReadInt32(attr);
123 }
124 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,int64_t & attr)125 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, int64_t &attr)
126 {
127     SHARING_LOGD("trace.");
128     return pIpcMsg.ReadInt64(attr);
129 }
130 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,uint8_t & attr)131 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, uint8_t &attr)
132 {
133     SHARING_LOGD("trace.");
134     return pIpcMsg.ReadUint8(attr);
135 }
136 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,uint16_t & attr)137 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, uint16_t &attr)
138 {
139     SHARING_LOGD("trace.");
140     return pIpcMsg.ReadUint16(attr);
141 }
142 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,uint32_t & attr)143 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, uint32_t &attr)
144 {
145     SHARING_LOGD("trace.");
146     return pIpcMsg.ReadUint32(attr);
147 }
148 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,uint64_t & attr)149 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, uint64_t &attr)
150 {
151     SHARING_LOGD("trace.");
152     return pIpcMsg.ReadUint64(attr);
153 }
154 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,float & attr)155 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, float &attr)
156 {
157     SHARING_LOGD("trace.");
158     return pIpcMsg.ReadFloat(attr);
159 }
160 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,double & attr)161 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, double &attr)
162 {
163     SHARING_LOGD("trace.");
164     return pIpcMsg.ReadDouble(attr);
165 }
166 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,std::string & attr)167 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, std::string &attr)
168 {
169     SHARING_LOGD("trace.");
170     return pIpcMsg.ReadString(attr);
171 }
172 
IpcDecodeBindAttr(MessageParcel & pIpcMsg,sptr<IRemoteObject> & attr)173 bool IpcDecodeBindAttr(MessageParcel &pIpcMsg, sptr<IRemoteObject> &attr)
174 {
175     SHARING_LOGD("trace.");
176     attr = pIpcMsg.ReadRemoteObject();
177     if (attr == nullptr) {
178         return false;
179     }
180 
181     return true;
182 }
183 
184 } // namespace IPC_CODEC
185 } // namespace Sharing
186 } // namespace OHOS