1 /*
2 * Copyright (c) 2021-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 "softbus_server_proxy_standard.h"
17
18 #include "message_parcel.h"
19 #include "softbus_client_stub.h"
20 #include "softbus_errcode.h"
21 #include "softbus_server_ipc_interface_code.h"
22 #include "softbus_log.h"
23
24 namespace OHOS {
25 sptr<IRemoteObject> SoftBusServerProxyFrame::clientCallbackStub_;
26 std::mutex SoftBusServerProxyFrame::instanceLock;
27
GetRemoteInstance()28 sptr<IRemoteObject> SoftBusServerProxyFrame::GetRemoteInstance()
29 {
30 if (clientCallbackStub_ == nullptr) {
31 std::lock_guard<std::mutex> autoLock(instanceLock);
32 if (clientCallbackStub_ == nullptr) {
33 clientCallbackStub_ = sptr<IRemoteObject>(new (std::nothrow) SoftBusClientStub());
34 }
35 }
36 return clientCallbackStub_;
37 }
38
StartDiscovery(const char * pkgName,const SubscribeInfo * info)39 int32_t SoftBusServerProxyFrame::StartDiscovery(const char *pkgName, const SubscribeInfo *info)
40 {
41 (void)pkgName;
42 (void)info;
43 return SOFTBUS_OK;
44 }
45
StopDiscovery(const char * pkgName,int subscribeId)46 int32_t SoftBusServerProxyFrame::StopDiscovery(const char *pkgName, int subscribeId)
47 {
48 (void)pkgName;
49 (void)subscribeId;
50 return SOFTBUS_OK;
51 }
52
PublishService(const char * pkgName,const PublishInfo * info)53 int32_t SoftBusServerProxyFrame::PublishService(const char *pkgName, const PublishInfo *info)
54 {
55 (void)pkgName;
56 (void)info;
57 return SOFTBUS_OK;
58 }
59
UnPublishService(const char * pkgName,int publishId)60 int32_t SoftBusServerProxyFrame::UnPublishService(const char *pkgName, int publishId)
61 {
62 (void)pkgName;
63 (void)publishId;
64 return SOFTBUS_OK;
65 }
66
SoftbusRegisterService(const char * clientPkgName,const sptr<IRemoteObject> & object)67 int32_t SoftBusServerProxyFrame::SoftbusRegisterService(const char *clientPkgName, const sptr<IRemoteObject>& object)
68 {
69 sptr<IRemoteObject> remote = Remote();
70 if (remote == nullptr) {
71 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "remote is nullptr!");
72 return SOFTBUS_ERR;
73 }
74
75 sptr<IRemoteObject> clientStub = SoftBusServerProxyFrame::GetRemoteInstance();
76 if (clientStub == nullptr) {
77 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "client stub is nullptr!");
78 return SOFTBUS_ERR;
79 }
80 MessageParcel data;
81 if (!data.WriteInterfaceToken(GetDescriptor())) {
82 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SoftbusRegisterService write InterfaceToken failed!");
83 return SOFTBUS_ERR;
84 }
85 if (!data.WriteRemoteObject(clientStub)) {
86 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SoftbusRegisterService write remote object failed!");
87 return SOFTBUS_ERR;
88 }
89 if (!data.WriteCString(clientPkgName)) {
90 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SoftbusRegisterService write clientPkgName failed!");
91 return SOFTBUS_ERR;
92 }
93
94 MessageParcel reply;
95 MessageOption option;
96 int32_t err = remote->SendRequest(MANAGE_REGISTER_SERVICE, data, reply, option);
97 if (err != 0) {
98 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SoftbusRegisterService send request failed!");
99 return SOFTBUS_ERR;
100 }
101 int32_t serverRet = 0;
102 if (!reply.ReadInt32(serverRet)) {
103 SoftBusLog(SOFTBUS_LOG_COMM, SOFTBUS_LOG_ERROR, "SoftbusRegisterService read serverRet failed!");
104 return SOFTBUS_ERR;
105 }
106 return serverRet;
107 }
108
CreateSessionServer(const char * pkgName,const char * sessionName)109 int32_t SoftBusServerProxyFrame::CreateSessionServer(const char *pkgName, const char *sessionName)
110 {
111 (void)pkgName;
112 (void)sessionName;
113 return SOFTBUS_OK;
114 }
115
RemoveSessionServer(const char * pkgName,const char * sessionName)116 int32_t SoftBusServerProxyFrame::RemoveSessionServer(const char *pkgName, const char *sessionName)
117 {
118 (void)pkgName;
119 (void)sessionName;
120 return SOFTBUS_OK;
121 }
122
OpenSession(const SessionParam * param,TransInfo * info)123 int32_t SoftBusServerProxyFrame::OpenSession(const SessionParam *param, TransInfo *info)
124 {
125 (void)param;
126 (void)info;
127 return SOFTBUS_OK;
128 }
129
OpenAuthSession(const char * sessionName,const ConnectionAddr * addrInfo)130 int32_t SoftBusServerProxyFrame::OpenAuthSession(const char *sessionName, const ConnectionAddr *addrInfo)
131 {
132 (void)sessionName;
133 (void)addrInfo;
134 return SOFTBUS_OK;
135 }
136
NotifyAuthSuccess(int32_t channelId,int32_t channelType)137 int32_t SoftBusServerProxyFrame::NotifyAuthSuccess(int32_t channelId, int32_t channelType)
138 {
139 (void)channelId;
140 (void)channelType;
141 return SOFTBUS_OK;
142 }
143
CloseChannel(int32_t channelId,int32_t channelType)144 int32_t SoftBusServerProxyFrame::CloseChannel(int32_t channelId, int32_t channelType)
145 {
146 (void)channelId;
147 (void)channelType;
148 return SOFTBUS_OK;
149 }
150
SendMessage(int32_t channelId,int32_t channelType,const void * data,uint32_t len,int32_t msgType)151 int32_t SoftBusServerProxyFrame::SendMessage(int32_t channelId, int32_t channelType, const void *data,
152 uint32_t len, int32_t msgType)
153 {
154 (void)channelId;
155 (void)channelType;
156 (void)data;
157 (void)len;
158 (void)msgType;
159 return SOFTBUS_OK;
160 }
161
JoinLNN(const char * pkgName,void * addr,uint32_t addrTypeLen)162 int32_t SoftBusServerProxyFrame::JoinLNN(const char *pkgName, void *addr, uint32_t addrTypeLen)
163 {
164 (void)pkgName;
165 (void)addr;
166 (void)addrTypeLen;
167 return SOFTBUS_OK;
168 }
169
JoinMetaNode(const char * pkgName,void * addr,CustomData * customData,uint32_t addrTypeLen)170 int32_t SoftBusServerProxyFrame::JoinMetaNode(const char *pkgName, void *addr, CustomData *customData,
171 uint32_t addrTypeLen)
172 {
173 (void)pkgName;
174 (void)addr;
175 (void)customData;
176 (void)addrTypeLen;
177 return SOFTBUS_OK;
178 }
179
LeaveLNN(const char * pkgName,const char * networkId)180 int32_t SoftBusServerProxyFrame::LeaveLNN(const char *pkgName, const char *networkId)
181 {
182 (void)pkgName;
183 (void)networkId;
184 return SOFTBUS_OK;
185 }
186
LeaveMetaNode(const char * pkgName,const char * networkId)187 int32_t SoftBusServerProxyFrame::LeaveMetaNode(const char *pkgName, const char *networkId)
188 {
189 (void)pkgName;
190 (void)networkId;
191 return SOFTBUS_OK;
192 }
193
GetAllOnlineNodeInfo(const char * pkgName,void ** info,uint32_t infoTypeLen,int * infoNum)194 int32_t SoftBusServerProxyFrame::GetAllOnlineNodeInfo(const char *pkgName, void **info, uint32_t infoTypeLen,
195 int *infoNum)
196 {
197 (void)pkgName;
198 (void)info;
199 (void)infoTypeLen;
200 (void)infoNum;
201 return SOFTBUS_OK;
202 }
203
GetLocalDeviceInfo(const char * pkgName,void * info,uint32_t infoTypeLen)204 int32_t SoftBusServerProxyFrame::GetLocalDeviceInfo(const char *pkgName, void *info, uint32_t infoTypeLen)
205 {
206 (void)pkgName;
207 (void)info;
208 (void)infoTypeLen;
209 return SOFTBUS_OK;
210 }
211
GetNodeKeyInfo(const char * pkgName,const char * networkId,int key,unsigned char * buf,uint32_t len)212 int32_t SoftBusServerProxyFrame::GetNodeKeyInfo(const char *pkgName, const char *networkId, int key,
213 unsigned char *buf, uint32_t len)
214 {
215 (void)pkgName;
216 (void)networkId;
217 (void)key;
218 (void)buf;
219 (void)len;
220 return SOFTBUS_OK;
221 }
222
SetNodeDataChangeFlag(const char * pkgName,const char * networkId,uint16_t dataChangeFlag)223 int32_t SoftBusServerProxyFrame::SetNodeDataChangeFlag(const char *pkgName, const char *networkId,
224 uint16_t dataChangeFlag)
225 {
226 (void)pkgName;
227 (void)networkId;
228 (void)dataChangeFlag;
229 return SOFTBUS_OK;
230 }
231
StartTimeSync(const char * pkgName,const char * targetNetworkId,int32_t accuracy,int32_t period)232 int32_t SoftBusServerProxyFrame::StartTimeSync(const char *pkgName, const char *targetNetworkId, int32_t accuracy,
233 int32_t period)
234 {
235 (void)pkgName;
236 (void)targetNetworkId;
237 (void)accuracy;
238 (void)period;
239 return SOFTBUS_OK;
240 }
241
StopTimeSync(const char * pkgName,const char * targetNetworkId)242 int32_t SoftBusServerProxyFrame::StopTimeSync(const char *pkgName, const char *targetNetworkId)
243 {
244 (void)pkgName;
245 (void)targetNetworkId;
246 return SOFTBUS_OK;
247 }
248
QosReport(int32_t channelId,int32_t chanType,int32_t appType,int32_t quality)249 int32_t SoftBusServerProxyFrame::QosReport(int32_t channelId, int32_t chanType, int32_t appType, int32_t quality)
250 {
251 (void)channelId;
252 (void)chanType;
253 (void)appType;
254 (void)quality;
255 return SOFTBUS_OK;
256 }
257
StreamStats(int32_t channelId,int32_t channelType,const StreamSendStats * data)258 int32_t SoftBusServerProxyFrame::StreamStats(int32_t channelId, int32_t channelType, const StreamSendStats *data)
259 {
260 (void)channelId;
261 (void)channelType;
262 (void)data;
263 return SOFTBUS_OK;
264 }
265
RippleStats(int32_t channelId,int32_t channelType,const TrafficStats * data)266 int32_t SoftBusServerProxyFrame::RippleStats(int32_t channelId, int32_t channelType, const TrafficStats *data)
267 {
268 (void)channelId;
269 (void)channelType;
270 (void)data;
271 return SOFTBUS_OK;
272 }
273 } // namespace OHOS