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