• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 <memory>
17 
18 #include "device_manager_ipc_interface_code.h"
19 #include "device_manager_service.h"
20 #include "dm_anonymous.h"
21 #include "dm_constants.h"
22 #include "dm_device_info.h"
23 #include "dm_log.h"
24 #include "dm_subscribe_info.h"
25 #include "dm_publish_info.h"
26 #include "ipc_acl_profile_req.h"
27 #include "ipc_cmd_register.h"
28 #include "ipc_def.h"
29 #include "ipc_create_pin_holder_req.h"
30 #include "ipc_destroy_pin_holder_req.h"
31 #include "ipc_notify_auth_result_req.h"
32 #include "ipc_notify_bind_result_req.h"
33 #include "ipc_notify_credential_req.h"
34 #include "ipc_notify_device_found_req.h"
35 #include "ipc_notify_device_discovery_req.h"
36 #include "ipc_notify_device_state_req.h"
37 #include "ipc_notify_discover_result_req.h"
38 #include "ipc_notify_publish_result_req.h"
39 #include "ipc_server_client_proxy.h"
40 #include "ipc_server_stub.h"
41 
42 #include "nlohmann/json.hpp"
43 
44 namespace OHOS {
45 namespace DistributedHardware {
EncodeDmDeviceInfo(const DmDeviceInfo & devInfo,MessageParcel & parcel)46 bool EncodeDmDeviceInfo(const DmDeviceInfo &devInfo, MessageParcel &parcel)
47 {
48     bool bRet = true;
49     std::string deviceIdStr(devInfo.deviceId);
50     bRet = (bRet && parcel.WriteString(deviceIdStr));
51     std::string deviceNameStr(devInfo.deviceName);
52     bRet = (bRet && parcel.WriteString(deviceNameStr));
53     bRet = (bRet && parcel.WriteUint16(devInfo.deviceTypeId));
54     std::string networkIdStr(devInfo.networkId);
55     bRet = (bRet && parcel.WriteString(networkIdStr));
56     bRet = (bRet && parcel.WriteInt32(devInfo.range));
57     bRet = (bRet && parcel.WriteInt32(devInfo.networkType));
58     bRet = (bRet && parcel.WriteInt32(devInfo.authForm));
59     bRet = (bRet && parcel.WriteString(devInfo.extraData));
60     return bRet;
61 }
62 
EncodeDmDeviceBasicInfo(const DmDeviceBasicInfo & devInfo,MessageParcel & parcel)63 bool EncodeDmDeviceBasicInfo(const DmDeviceBasicInfo &devInfo, MessageParcel &parcel)
64 {
65     bool bRet = true;
66     std::string deviceIdStr(devInfo.deviceId);
67     bRet = (bRet && parcel.WriteString(deviceIdStr));
68     std::string deviceNameStr(devInfo.deviceName);
69     bRet = (bRet && parcel.WriteString(deviceNameStr));
70     bRet = (bRet && parcel.WriteUint16(devInfo.deviceTypeId));
71     std::string networkIdStr(devInfo.networkId);
72     bRet = (bRet && parcel.WriteString(networkIdStr));
73     return bRet;
74 }
75 
EncodePeerTargetId(const PeerTargetId & targetId,MessageParcel & parcel)76 bool EncodePeerTargetId(const PeerTargetId &targetId, MessageParcel &parcel)
77 {
78     bool bRet = true;
79     bRet = (bRet && parcel.WriteString(targetId.deviceId));
80     bRet = (bRet && parcel.WriteString(targetId.brMac));
81     bRet = (bRet && parcel.WriteString(targetId.bleMac));
82     bRet = (bRet && parcel.WriteString(targetId.wifiIp));
83     bRet = (bRet && parcel.WriteUint16(targetId.wifiPort));
84     return bRet;
85 }
86 
DecodePeerTargetId(MessageParcel & parcel,PeerTargetId & targetId)87 void DecodePeerTargetId(MessageParcel &parcel, PeerTargetId &targetId)
88 {
89     targetId.deviceId = parcel.ReadString();
90     targetId.brMac = parcel.ReadString();
91     targetId.bleMac = parcel.ReadString();
92     targetId.wifiIp = parcel.ReadString();
93     targetId.wifiPort = parcel.ReadUint16();
94 }
95 
ON_IPC_SET_REQUEST(SERVER_DEVICE_STATE_NOTIFY,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)96 ON_IPC_SET_REQUEST(SERVER_DEVICE_STATE_NOTIFY, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
97 {
98     if (pBaseReq == nullptr) {
99         return ERR_DM_FAILED;
100     }
101 
102     std::shared_ptr<IpcNotifyDeviceStateReq> pReq = std::static_pointer_cast<IpcNotifyDeviceStateReq>(pBaseReq);
103     std::string pkgName = pReq->GetPkgName();
104     int32_t deviceState = pReq->GetDeviceState();
105     DmDeviceInfo deviceInfo = pReq->GetDeviceInfo();
106     DmDeviceBasicInfo deviceBasicInfo = pReq->GetDeviceBasicInfo();
107     if (!data.WriteString(pkgName)) {
108         LOGE("write pkgName failed");
109         return ERR_DM_IPC_WRITE_FAILED;
110     }
111     if (!data.WriteInt32(deviceState)) {
112         LOGE("write state failed");
113         return ERR_DM_IPC_WRITE_FAILED;
114     }
115     if (!EncodeDmDeviceInfo(deviceInfo, data)) {
116         LOGE("write dm device info failed");
117         return ERR_DM_IPC_WRITE_FAILED;
118     }
119     if (!data.WriteRawData(&deviceBasicInfo, sizeof(DmDeviceBasicInfo))) {
120         LOGE("write deviceBasicInfo failed");
121         return ERR_DM_IPC_WRITE_FAILED;
122     }
123     return DM_OK;
124 }
125 
ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)126 ON_IPC_READ_RESPONSE(SERVER_DEVICE_STATE_NOTIFY, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
127 {
128     if (pBaseRsp == nullptr) {
129         LOGE("pBaseRsp is null");
130         return ERR_DM_FAILED;
131     }
132     pBaseRsp->SetErrCode(reply.ReadInt32());
133     return DM_OK;
134 }
135 
ON_IPC_SET_REQUEST(SERVER_DEVICE_FOUND,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)136 ON_IPC_SET_REQUEST(SERVER_DEVICE_FOUND, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
137 {
138     if (pBaseReq == nullptr) {
139         return ERR_DM_FAILED;
140     }
141 
142     std::shared_ptr<IpcNotifyDeviceFoundReq> pReq = std::static_pointer_cast<IpcNotifyDeviceFoundReq>(pBaseReq);
143     std::string pkgName = pReq->GetPkgName();
144     uint16_t subscribeId = pReq->GetSubscribeId();
145     DmDeviceInfo deviceInfo = pReq->GetDeviceInfo();
146     DmDeviceBasicInfo devBasicInfo = pReq->GetDeviceBasicInfo();
147     if (!data.WriteString(pkgName)) {
148         LOGE("write pkgName failed");
149         return ERR_DM_IPC_WRITE_FAILED;
150     }
151     if (!data.WriteInt16((int16_t)subscribeId)) {
152         LOGE("write subscribeId failed");
153         return ERR_DM_IPC_WRITE_FAILED;
154     }
155     if (!EncodeDmDeviceInfo(deviceInfo, data)) {
156         LOGE("write dm device info failed");
157         return ERR_DM_IPC_WRITE_FAILED;
158     }
159     if (!EncodeDmDeviceBasicInfo(devBasicInfo, data)) {
160         LOGE("write dm device basic info failed");
161         return ERR_DM_IPC_WRITE_FAILED;
162     }
163     return DM_OK;
164 }
165 
ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)166 ON_IPC_READ_RESPONSE(SERVER_DEVICE_FOUND, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
167 {
168     if (pBaseRsp == nullptr) {
169         LOGE("pBaseRsp is null");
170         return ERR_DM_FAILED;
171     }
172     pBaseRsp->SetErrCode(reply.ReadInt32());
173     return DM_OK;
174 }
175 
ON_IPC_SET_REQUEST(SERVER_DEVICE_DISCOVERY,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)176 ON_IPC_SET_REQUEST(SERVER_DEVICE_DISCOVERY, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
177 {
178     if (pBaseReq == nullptr) {
179         return ERR_DM_FAILED;
180     }
181 
182     std::shared_ptr<IpcNotifyDeviceDiscoveryReq> pReq = std::static_pointer_cast<IpcNotifyDeviceDiscoveryReq>(pBaseReq);
183     std::string pkgName = pReq->GetPkgName();
184     uint16_t subscribeId = pReq->GetSubscribeId();
185     DmDeviceBasicInfo deviceBasicInfo = pReq->GetDeviceBasicInfo();
186     if (!data.WriteString(pkgName)) {
187         LOGE("write pkgName failed");
188         return ERR_DM_IPC_WRITE_FAILED;
189     }
190     if (!data.WriteInt16((int16_t)subscribeId)) {
191         LOGE("write subscribeId failed");
192         return ERR_DM_IPC_WRITE_FAILED;
193     }
194     if (!data.WriteRawData(&deviceBasicInfo, sizeof(DmDeviceBasicInfo))) {
195         LOGE("write deviceBasicInfo failed");
196         return ERR_DM_IPC_WRITE_FAILED;
197     }
198     return DM_OK;
199 }
200 
ON_IPC_READ_RESPONSE(SERVER_DEVICE_DISCOVERY,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)201 ON_IPC_READ_RESPONSE(SERVER_DEVICE_DISCOVERY, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
202 {
203     if (pBaseRsp == nullptr) {
204         LOGE("pBaseRsp is null");
205         return ERR_DM_FAILED;
206     }
207     pBaseRsp->SetErrCode(reply.ReadInt32());
208     return DM_OK;
209 }
210 
ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)211 ON_IPC_SET_REQUEST(SERVER_DISCOVER_FINISH, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
212 {
213     if (pBaseReq == nullptr) {
214         return ERR_DM_FAILED;
215     }
216     std::shared_ptr<IpcNotifyDiscoverResultReq> pReq = std::static_pointer_cast<IpcNotifyDiscoverResultReq>(pBaseReq);
217     std::string pkgName = pReq->GetPkgName();
218     uint16_t subscribeId = pReq->GetSubscribeId();
219     int32_t result = pReq->GetResult();
220     if (!data.WriteString(pkgName)) {
221         LOGE("write pkgName failed");
222         return ERR_DM_IPC_WRITE_FAILED;
223     }
224     if (!data.WriteInt16((int16_t)subscribeId)) {
225         LOGE("write subscribeId failed");
226         return ERR_DM_IPC_WRITE_FAILED;
227     }
228     if (!data.WriteInt32(result)) {
229         LOGE("write result failed");
230         return ERR_DM_IPC_WRITE_FAILED;
231     }
232     return DM_OK;
233 }
234 
ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)235 ON_IPC_READ_RESPONSE(SERVER_DISCOVER_FINISH, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
236 {
237     if (pBaseRsp == nullptr) {
238         LOGE("pBaseRsp is null");
239         return ERR_DM_FAILED;
240     }
241     pBaseRsp->SetErrCode(reply.ReadInt32());
242     return DM_OK;
243 }
244 
ON_IPC_SET_REQUEST(SERVER_PUBLISH_FINISH,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)245 ON_IPC_SET_REQUEST(SERVER_PUBLISH_FINISH, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
246 {
247     if (pBaseReq == nullptr) {
248         return ERR_DM_FAILED;
249     }
250     std::shared_ptr<IpcNotifyPublishResultReq> pReq = std::static_pointer_cast<IpcNotifyPublishResultReq>(pBaseReq);
251     std::string pkgName = pReq->GetPkgName();
252     int32_t publishId = pReq->GetPublishId();
253     int32_t result = pReq->GetResult();
254     if (!data.WriteString(pkgName)) {
255         LOGE("write pkgName failed");
256         return ERR_DM_IPC_WRITE_FAILED;
257     }
258     if (!data.WriteInt32(publishId)) {
259         LOGE("write publishId failed");
260         return ERR_DM_IPC_WRITE_FAILED;
261     }
262     if (!data.WriteInt32(result)) {
263         LOGE("write result failed");
264         return ERR_DM_IPC_WRITE_FAILED;
265     }
266     return DM_OK;
267 }
268 
ON_IPC_READ_RESPONSE(SERVER_PUBLISH_FINISH,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)269 ON_IPC_READ_RESPONSE(SERVER_PUBLISH_FINISH, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
270 {
271     if (pBaseRsp == nullptr) {
272         LOGE("pBaseRsp is null");
273         return ERR_DM_FAILED;
274     }
275     pBaseRsp->SetErrCode(reply.ReadInt32());
276     return DM_OK;
277 }
278 
ON_IPC_SET_REQUEST(SERVER_AUTH_RESULT,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)279 ON_IPC_SET_REQUEST(SERVER_AUTH_RESULT, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
280 {
281     if (pBaseReq == nullptr) {
282         return ERR_DM_FAILED;
283     }
284     std::shared_ptr<IpcNotifyAuthResultReq> pReq = std::static_pointer_cast<IpcNotifyAuthResultReq>(pBaseReq);
285 
286     std::string pkgName = pReq->GetPkgName();
287     std::string deviceId = pReq->GetDeviceId();
288     std::string token = pReq->GetPinToken();
289     int32_t status = pReq->GetStatus();
290     int32_t reason = pReq->GetReason();
291     if (!data.WriteString(pkgName)) {
292         LOGE("write pkgName failed");
293         return ERR_DM_IPC_WRITE_FAILED;
294     }
295     if (!data.WriteString(deviceId)) {
296         LOGE("write deviceId failed");
297         return ERR_DM_IPC_WRITE_FAILED;
298     }
299     if (!data.WriteString(token)) {
300         LOGE("write token failed");
301         return ERR_DM_IPC_WRITE_FAILED;
302     }
303     if (!data.WriteInt32(status)) {
304         LOGE("write status failed");
305         return ERR_DM_IPC_WRITE_FAILED;
306     }
307     if (!data.WriteInt32(reason)) {
308         LOGE("write reason failed");
309         return ERR_DM_IPC_WRITE_FAILED;
310     }
311     return DM_OK;
312 }
313 
ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)314 ON_IPC_READ_RESPONSE(SERVER_AUTH_RESULT, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
315 {
316     if (pBaseRsp == nullptr) {
317         LOGE("pBaseRsp is null");
318         return ERR_DM_FAILED;
319     }
320     pBaseRsp->SetErrCode(reply.ReadInt32());
321     return DM_OK;
322 }
323 
ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)324 ON_IPC_SET_REQUEST(SERVER_DEVICE_FA_NOTIFY, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
325 {
326     if (pBaseReq == nullptr) {
327         return ERR_DM_FAILED;
328     }
329 
330     std::shared_ptr<IpcNotifyDMFAResultReq> pReq = std::static_pointer_cast<IpcNotifyDMFAResultReq>(pBaseReq);
331 
332     std::string packagname = pReq->GetPkgName();
333     std::string paramJson = pReq->GetJsonParam();
334     if (!data.WriteString(packagname)) {
335         LOGE("write pkgName failed");
336         return ERR_DM_IPC_WRITE_FAILED;
337     }
338     if (!data.WriteString(paramJson)) {
339         LOGE("write paramJson failed");
340         return ERR_DM_IPC_WRITE_FAILED;
341     }
342     return DM_OK;
343 }
344 
ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)345 ON_IPC_READ_RESPONSE(SERVER_DEVICE_FA_NOTIFY, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
346 {
347     if (pBaseRsp == nullptr) {
348         LOGE("pBaseRsp is null");
349         return ERR_DM_FAILED;
350     }
351     pBaseRsp->SetErrCode(reply.ReadInt32());
352     return DM_OK;
353 }
354 
ON_IPC_CMD(GET_TRUST_DEVICE_LIST,MessageParcel & data,MessageParcel & reply)355 ON_IPC_CMD(GET_TRUST_DEVICE_LIST, MessageParcel &data, MessageParcel &reply)
356 {
357     std::string pkgName = data.ReadString();
358     std::string extra = data.ReadString();
359     bool isRefresh = data.ReadBool();
360     DeviceManagerService::GetInstance().ShiftLNNGear(pkgName, pkgName, isRefresh);
361     std::vector<DmDeviceInfo> deviceList;
362     int32_t result = DeviceManagerService::GetInstance().GetTrustedDeviceList(pkgName, extra, deviceList);
363     if (!reply.WriteInt32((int32_t)deviceList.size())) {
364         LOGE("write device list size failed");
365         return ERR_DM_IPC_WRITE_FAILED;
366     }
367     for (const auto &devInfo : deviceList) {
368         if (!EncodeDmDeviceInfo(devInfo, reply)) {
369             LOGE("write dm device info failed");
370             return ERR_DM_IPC_WRITE_FAILED;
371         }
372     }
373     if (!reply.WriteInt32(result)) {
374         LOGE("write result failed");
375         return ERR_DM_IPC_WRITE_FAILED;
376     }
377     return DM_OK;
378 }
379 
ON_IPC_CMD(GET_AVAILABLE_DEVICE_LIST,MessageParcel & data,MessageParcel & reply)380 ON_IPC_CMD(GET_AVAILABLE_DEVICE_LIST, MessageParcel &data, MessageParcel &reply)
381 {
382     std::string pkgName = data.ReadString();
383     std::vector<DmDeviceBasicInfo> deviceList;
384     int32_t result = DeviceManagerService::GetInstance().GetAvailableDeviceList(pkgName, deviceList);
385     int32_t infoNum = (int32_t)(deviceList.size());
386     DmDeviceBasicInfo deviceBasicInfo;
387     if (!reply.WriteInt32(infoNum)) {
388         LOGE("write infoNum failed");
389         return ERR_DM_IPC_WRITE_FAILED;
390     }
391     if (!deviceList.empty()) {
392         for (; !deviceList.empty();) {
393             deviceBasicInfo = deviceList.back();
394             deviceList.pop_back();
395 
396             if (!reply.WriteRawData(&deviceBasicInfo, sizeof(DmDeviceBasicInfo))) {
397                 LOGE("write subscribeInfo failed");
398                 return ERR_DM_IPC_WRITE_FAILED;
399             }
400         }
401     }
402     if (!reply.WriteInt32(result)) {
403         LOGE("write result failed");
404         return ERR_DM_IPC_WRITE_FAILED;
405     }
406     return DM_OK;
407 }
408 
ON_IPC_CMD(CHECK_API_ACCESS_PERMISSION,MessageParcel & data,MessageParcel & reply)409 ON_IPC_CMD(CHECK_API_ACCESS_PERMISSION, MessageParcel &data, MessageParcel &reply)
410 {
411     int32_t result = DeviceManagerService::GetInstance().CheckApiPermission();
412     if (!reply.WriteInt32(result)) {
413         LOGE("write result failed");
414         return ERR_DM_IPC_WRITE_FAILED;
415     }
416     return DM_OK;
417 }
418 
ON_IPC_CMD(CHECK_API_ACCESS_NEWPERMISSION,MessageParcel & data,MessageParcel & reply)419 ON_IPC_CMD(CHECK_API_ACCESS_NEWPERMISSION, MessageParcel &data, MessageParcel &reply)
420 {
421     int32_t result = DeviceManagerService::GetInstance().CheckNewApiPermission();
422     if (!reply.WriteInt32(result)) {
423         LOGE("write result failed");
424         return ERR_DM_IPC_WRITE_FAILED;
425     }
426     return DM_OK;
427 }
428 
ON_IPC_CMD(REGISTER_DEVICE_MANAGER_LISTENER,MessageParcel & data,MessageParcel & reply)429 ON_IPC_CMD(REGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParcel &reply)
430 {
431     std::string pkgName = data.ReadString();
432     sptr<IRemoteObject> listener = data.ReadRemoteObject();
433     if (listener == nullptr) {
434         LOGE("read remote object failed.");
435         return ERR_DM_POINT_NULL;
436     }
437     sptr<IpcServerClientProxy> callback(new IpcServerClientProxy(listener));
438     if (callback == nullptr) {
439         LOGE("create ipc server client proxy failed.");
440         return ERR_DM_POINT_NULL;
441     }
442     DeviceManagerService::GetInstance().RegisterDeviceManagerListener(pkgName);
443     int32_t result = IpcServerStub::GetInstance().RegisterDeviceManagerListener(pkgName, callback);
444     if (!reply.WriteInt32(result)) {
445         LOGE("write result failed");
446         return ERR_DM_IPC_WRITE_FAILED;
447     }
448     return DM_OK;
449 }
450 
ON_IPC_CMD(UNREGISTER_DEVICE_MANAGER_LISTENER,MessageParcel & data,MessageParcel & reply)451 ON_IPC_CMD(UNREGISTER_DEVICE_MANAGER_LISTENER, MessageParcel &data, MessageParcel &reply)
452 {
453     std::string pkgName = data.ReadString();
454     DeviceManagerService::GetInstance().UnRegisterDeviceManagerListener(pkgName);
455     int32_t result = IpcServerStub::GetInstance().UnRegisterDeviceManagerListener(pkgName);
456     if (!reply.WriteInt32(result)) {
457         LOGE("write result failed");
458         return ERR_DM_IPC_WRITE_FAILED;
459     }
460     return DM_OK;
461 }
462 
ON_IPC_CMD(START_DEVICE_DISCOVER,MessageParcel & data,MessageParcel & reply)463 ON_IPC_CMD(START_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply)
464 {
465     std::string pkgName = data.ReadString();
466     std::string extra = data.ReadString();
467     DmSubscribeInfo *subscribeInfo =
468         static_cast<DmSubscribeInfo *>(const_cast<void *>(data.ReadRawData(sizeof(DmSubscribeInfo))));
469     int32_t result = ERR_DM_POINT_NULL;
470 
471     if (subscribeInfo != nullptr) {
472         result = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, *subscribeInfo, extra);
473     }
474     if (!reply.WriteInt32(result)) {
475         LOGE("write result failed");
476         return ERR_DM_IPC_WRITE_FAILED;
477     }
478     return DM_OK;
479 }
480 
ON_IPC_CMD(START_DEVICE_DISCOVERY,MessageParcel & data,MessageParcel & reply)481 ON_IPC_CMD(START_DEVICE_DISCOVERY, MessageParcel &data, MessageParcel &reply)
482 {
483     std::string pkgName = data.ReadString();
484     std::string filterOption = data.ReadString();
485     uint16_t subscribeId = data.ReadUint16();
486     int32_t result = DeviceManagerService::GetInstance().StartDeviceDiscovery(pkgName, subscribeId, filterOption);
487     if (!reply.WriteInt32(result)) {
488         LOGE("write result failed");
489         return ERR_DM_IPC_WRITE_FAILED;
490     }
491     return DM_OK;
492 }
493 
ON_IPC_CMD(STOP_DEVICE_DISCOVER,MessageParcel & data,MessageParcel & reply)494 ON_IPC_CMD(STOP_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply)
495 {
496     std::string pkgName = data.ReadString();
497     uint16_t subscribeId = data.ReadUint16();
498     int32_t result = DeviceManagerService::GetInstance().StopDeviceDiscovery(pkgName, subscribeId);
499     if (!reply.WriteInt32(result)) {
500         LOGE("write result failed");
501         return ERR_DM_IPC_WRITE_FAILED;
502     }
503     return DM_OK;
504 }
505 
ON_IPC_CMD(PUBLISH_DEVICE_DISCOVER,MessageParcel & data,MessageParcel & reply)506 ON_IPC_CMD(PUBLISH_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply)
507 {
508     std::string pkgName = data.ReadString();
509     DmPublishInfo *publishInfo =
510         static_cast<DmPublishInfo *>(const_cast<void *>(data.ReadRawData(sizeof(DmPublishInfo))));
511     int32_t result = ERR_DM_POINT_NULL;
512 
513     if (publishInfo != nullptr) {
514         result = DeviceManagerService::GetInstance().PublishDeviceDiscovery(pkgName, *publishInfo);
515     }
516     if (!reply.WriteInt32(result)) {
517         LOGE("write result failed");
518         return ERR_DM_IPC_WRITE_FAILED;
519     }
520     return DM_OK;
521 }
522 
ON_IPC_CMD(UNPUBLISH_DEVICE_DISCOVER,MessageParcel & data,MessageParcel & reply)523 ON_IPC_CMD(UNPUBLISH_DEVICE_DISCOVER, MessageParcel &data, MessageParcel &reply)
524 {
525     std::string pkgName = data.ReadString();
526     int32_t publishId = data.ReadInt32();
527     int32_t result = DeviceManagerService::GetInstance().UnPublishDeviceDiscovery(pkgName, publishId);
528     if (!reply.WriteInt32(result)) {
529         LOGE("write result failed");
530         return ERR_DM_IPC_WRITE_FAILED;
531     }
532     return DM_OK;
533 }
534 
ON_IPC_CMD(AUTHENTICATE_DEVICE,MessageParcel & data,MessageParcel & reply)535 ON_IPC_CMD(AUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply)
536 {
537     std::string pkgName = data.ReadString();
538     std::string extra = data.ReadString();
539     std::string deviceId = data.ReadString();
540     int32_t authType = data.ReadInt32();
541 
542     int32_t result = DM_OK;
543     result = DeviceManagerService::GetInstance().AuthenticateDevice(pkgName, authType, deviceId, extra);
544     if (!reply.WriteInt32(result)) {
545         LOGE("write result failed");
546         return ERR_DM_IPC_WRITE_FAILED;
547     }
548     return DM_OK;
549 }
550 
ON_IPC_CMD(UNAUTHENTICATE_DEVICE,MessageParcel & data,MessageParcel & reply)551 ON_IPC_CMD(UNAUTHENTICATE_DEVICE, MessageParcel &data, MessageParcel &reply)
552 {
553     std::string pkgName = data.ReadString();
554     std::string deviceId = data.ReadString();
555     int32_t result = DeviceManagerService::GetInstance().UnAuthenticateDevice(pkgName, deviceId);
556     if (!reply.WriteInt32(result)) {
557         LOGE("write result failed");
558         return ERR_DM_IPC_WRITE_FAILED;
559     }
560     return DM_OK;
561 }
562 
ON_IPC_CMD(GET_DEVICE_INFO,MessageParcel & data,MessageParcel & reply)563 ON_IPC_CMD(GET_DEVICE_INFO, MessageParcel &data, MessageParcel &reply)
564 {
565     std::string networkId = data.ReadString();
566     DmDeviceInfo deviceInfo;
567     int32_t result = DeviceManagerService::GetInstance().GetDeviceInfo(networkId, deviceInfo);
568     if (!EncodeDmDeviceInfo(deviceInfo, reply)) {
569         LOGE("write dm device info failed");
570         return ERR_DM_IPC_WRITE_FAILED;
571     }
572     if (!reply.WriteInt32(result)) {
573         LOGE("write result failed");
574         return ERR_DM_IPC_WRITE_FAILED;
575     }
576     return DM_OK;
577 }
578 
ON_IPC_CMD(GET_LOCAL_DEVICE_INFO,MessageParcel & data,MessageParcel & reply)579 ON_IPC_CMD(GET_LOCAL_DEVICE_INFO, MessageParcel &data, MessageParcel &reply)
580 {
581     (void)data;
582     DmDeviceInfo localDeviceInfo;
583     int32_t result = DeviceManagerService::GetInstance().GetLocalDeviceInfo(localDeviceInfo);
584     if (!EncodeDmDeviceInfo(localDeviceInfo, reply)) {
585         LOGE("write dm device info failed");
586         return ERR_DM_IPC_WRITE_FAILED;
587     }
588     if (!reply.WriteInt32(result)) {
589         LOGE("write result failed");
590         return ERR_DM_IPC_WRITE_FAILED;
591     }
592     return DM_OK;
593 }
594 
ON_IPC_CMD(GET_LOCAL_DEVICE_NETWORKID,MessageParcel & data,MessageParcel & reply)595 ON_IPC_CMD(GET_LOCAL_DEVICE_NETWORKID, MessageParcel &data, MessageParcel &reply)
596 {
597     std::string networkId = "";
598     int32_t result = DeviceManagerService::GetInstance().GetLocalDeviceNetworkId(networkId);
599     if (!reply.WriteString(networkId)) {
600         LOGE("write LocalDeviceNetworkId failed");
601     }
602     if (!reply.WriteInt32(result)) {
603         LOGE("write result failed");
604         return ERR_DM_IPC_WRITE_FAILED;
605     }
606     return DM_OK;
607 }
608 
ON_IPC_CMD(GET_LOCAL_DEVICEID,MessageParcel & data,MessageParcel & reply)609 ON_IPC_CMD(GET_LOCAL_DEVICEID, MessageParcel &data, MessageParcel &reply)
610 {
611     std::string pkgName = data.ReadString();
612     std::string deviceId = "";
613     int32_t result = DeviceManagerService::GetInstance().GetLocalDeviceId(pkgName, deviceId);
614     if (!reply.WriteString(deviceId)) {
615         LOGE("write GetLocalDeviceId failed");
616     }
617     if (!reply.WriteInt32(result)) {
618         LOGE("write result failed");
619         return ERR_DM_IPC_WRITE_FAILED;
620     }
621     return DM_OK;
622 }
623 
ON_IPC_CMD(GET_LOCAL_DEVICE_NAME,MessageParcel & data,MessageParcel & reply)624 ON_IPC_CMD(GET_LOCAL_DEVICE_NAME, MessageParcel &data, MessageParcel &reply)
625 {
626     std::string deviceName = "";
627     int32_t result = DeviceManagerService::GetInstance().GetLocalDeviceName(deviceName);
628     if (!reply.WriteString(deviceName)) {
629         LOGE("write GetLocalDeviceName failed");
630     }
631     if (!reply.WriteInt32(result)) {
632         LOGE("write result failed");
633         return ERR_DM_IPC_WRITE_FAILED;
634     }
635     return DM_OK;
636 }
637 
ON_IPC_CMD(GET_LOCAL_DEVICE_TYPE,MessageParcel & data,MessageParcel & reply)638 ON_IPC_CMD(GET_LOCAL_DEVICE_TYPE, MessageParcel &data, MessageParcel &reply)
639 {
640     int32_t deviceType = 0;
641     int32_t result = DeviceManagerService::GetInstance().GetLocalDeviceType(deviceType);
642     if (!reply.WriteInt32(deviceType)) {
643         LOGE("write GetLocalDeviceName failed");
644     }
645     if (!reply.WriteInt32(result)) {
646         LOGE("write result failed");
647         return ERR_DM_IPC_WRITE_FAILED;
648     }
649     return DM_OK;
650 }
651 
ON_IPC_CMD(GET_UDID_BY_NETWORK,MessageParcel & data,MessageParcel & reply)652 ON_IPC_CMD(GET_UDID_BY_NETWORK, MessageParcel &data, MessageParcel &reply)
653 {
654     std::string pkgName = data.ReadString();
655     std::string netWorkId = data.ReadString();
656     std::string udid;
657     int32_t result = DeviceManagerService::GetInstance().GetUdidByNetworkId(pkgName, netWorkId, udid);
658 
659     if (!reply.WriteInt32(result)) {
660         LOGE("write result failed");
661         return ERR_DM_IPC_WRITE_FAILED;
662     }
663     if (!reply.WriteString(udid)) {
664         LOGE("write result failed");
665         return ERR_DM_IPC_WRITE_FAILED;
666     }
667     return DM_OK;
668 }
669 
ON_IPC_CMD(GET_UUID_BY_NETWORK,MessageParcel & data,MessageParcel & reply)670 ON_IPC_CMD(GET_UUID_BY_NETWORK, MessageParcel &data, MessageParcel &reply)
671 {
672     std::string pkgName = data.ReadString();
673     std::string netWorkId = data.ReadString();
674     std::string uuid;
675     int32_t result = DeviceManagerService::GetInstance().GetUuidByNetworkId(pkgName, netWorkId, uuid);
676 
677     if (!reply.WriteInt32(result)) {
678         LOGE("write result failed");
679         return ERR_DM_IPC_WRITE_FAILED;
680     }
681     if (!reply.WriteString(uuid)) {
682         LOGE("write result failed");
683         return ERR_DM_IPC_WRITE_FAILED;
684     }
685     return DM_OK;
686 }
687 
ON_IPC_CMD(SERVER_USER_AUTH_OPERATION,MessageParcel & data,MessageParcel & reply)688 ON_IPC_CMD(SERVER_USER_AUTH_OPERATION, MessageParcel &data, MessageParcel &reply)
689 {
690     std::string packageName = data.ReadString();
691     int32_t action = data.ReadInt32();
692     std::string params = data.ReadString();
693     int result = DeviceManagerService::GetInstance().SetUserOperation(packageName, action, params);
694     if (!reply.WriteInt32(result)) {
695         return ERR_DM_IPC_WRITE_FAILED;
696     }
697     return result;
698 }
699 
ON_IPC_CMD(REQUEST_CREDENTIAL,MessageParcel & data,MessageParcel & reply)700 ON_IPC_CMD(REQUEST_CREDENTIAL, MessageParcel &data, MessageParcel &reply)
701 {
702     std::string packageName = data.ReadString();
703     std::string reqParaStr = data.ReadString();
704     std::map<std::string, std::string> requestParam;
705     ParseMapFromJsonString(reqParaStr, requestParam);
706     std::string returnJsonStr;
707     int32_t ret;
708     if (requestParam[DM_CREDENTIAL_TYPE] == DM_TYPE_OH) {
709         ret = DeviceManagerService::GetInstance().RequestCredential(requestParam[DM_CREDENTIAL_REQJSONSTR],
710                                                                     returnJsonStr);
711     }
712     if (requestParam[DM_CREDENTIAL_TYPE] == DM_TYPE_MINE) {
713         ret = DeviceManagerService::GetInstance().MineRequestCredential(packageName, returnJsonStr);
714     }
715     if (!reply.WriteInt32(ret)) {
716         LOGE("write ret failed");
717         return ERR_DM_IPC_WRITE_FAILED;
718     }
719     if (ret == DM_OK && !returnJsonStr.empty()) {
720         if (!reply.WriteString(returnJsonStr)) {
721             LOGE("write returnJsonStr failed");
722             return ERR_DM_IPC_WRITE_FAILED;
723         }
724     }
725     return DM_OK;
726 }
727 
ON_IPC_CMD(IMPORT_CREDENTIAL,MessageParcel & data,MessageParcel & reply)728 ON_IPC_CMD(IMPORT_CREDENTIAL, MessageParcel &data, MessageParcel &reply)
729 {
730     std::string packageName = data.ReadString();
731     std::string reqParaStr = data.ReadString();
732     std::map<std::string, std::string> requestParam;
733     ParseMapFromJsonString(reqParaStr, requestParam);
734     std::string returnJsonStr;
735     std::map<std::string, std::string> outputResult;
736     int32_t ret;
737     if (requestParam[DM_CREDENTIAL_TYPE] == DM_TYPE_OH) {
738         ret = DeviceManagerService::GetInstance().ImportCredential(packageName, requestParam[DM_CREDENTIAL_REQJSONSTR]);
739         outputResult.emplace(DM_CREDENTIAL_TYPE, DM_TYPE_OH);
740     }
741     if (requestParam[DM_CREDENTIAL_TYPE] == DM_TYPE_MINE) {
742         ret = DeviceManagerService::GetInstance().ImportCredential(packageName, requestParam[DM_CREDENTIAL_REQJSONSTR],
743                                                                    returnJsonStr);
744         outputResult.emplace(DM_CREDENTIAL_TYPE, DM_TYPE_MINE);
745         outputResult.emplace(DM_CREDENTIAL_RETURNJSONSTR, returnJsonStr);
746     }
747     if (!reply.WriteInt32(ret)) {
748         LOGE("write ret failed");
749         return ERR_DM_IPC_WRITE_FAILED;
750     }
751     if (ret == DM_OK && !returnJsonStr.empty()) {
752         std::string outParaStr = ConvertMapToJsonString(outputResult);
753         if (!reply.WriteString(outParaStr)) {
754         LOGE("write returnJsonStr failed");
755         return ERR_DM_IPC_WRITE_FAILED;
756         }
757     }
758     return DM_OK;
759 }
760 
ON_IPC_CMD(DELETE_CREDENTIAL,MessageParcel & data,MessageParcel & reply)761 ON_IPC_CMD(DELETE_CREDENTIAL, MessageParcel &data, MessageParcel &reply)
762 {
763     std::string packageName = data.ReadString();
764     std::string reqParaStr = data.ReadString();
765     std::map<std::string, std::string> requestParam;
766     ParseMapFromJsonString(reqParaStr, requestParam);
767     std::map<std::string, std::string> outputResult;
768     std::string returnJsonStr;
769     int32_t ret;
770     if (requestParam[DM_CREDENTIAL_TYPE] == DM_TYPE_OH) {
771         ret = DeviceManagerService::GetInstance().DeleteCredential(packageName, requestParam[DM_CREDENTIAL_REQJSONSTR]);
772         outputResult.emplace(DM_CREDENTIAL_TYPE, DM_TYPE_OH);
773     }
774     if (requestParam[DM_CREDENTIAL_TYPE] == DM_TYPE_MINE) {
775         ret = DeviceManagerService::GetInstance().DeleteCredential(packageName, requestParam[DM_CREDENTIAL_REQJSONSTR],
776                                                                    returnJsonStr);
777         outputResult.emplace(DM_CREDENTIAL_TYPE, DM_TYPE_MINE);
778         outputResult.emplace(DM_CREDENTIAL_RETURNJSONSTR, returnJsonStr);
779     }
780     if (!reply.WriteInt32(ret)) {
781         LOGE("write ret failed");
782         return ERR_DM_IPC_WRITE_FAILED;
783     }
784     if (ret == DM_OK && !returnJsonStr.empty()) {
785         std::string outParaStr = ConvertMapToJsonString(outputResult);
786         if (!reply.WriteString(outParaStr)) {
787             LOGE("write returnJsonStr failed");
788             return ERR_DM_IPC_WRITE_FAILED;
789         }
790     }
791     return DM_OK;
792 }
793 
ON_IPC_CMD(SERVER_GET_DMFA_INFO,MessageParcel & data,MessageParcel & reply)794 ON_IPC_CMD(SERVER_GET_DMFA_INFO, MessageParcel &data, MessageParcel &reply)
795 {
796     std::string packageName = data.ReadString();
797     std::string reqJsonStr = data.ReadString();
798     std::string returnJsonStr;
799     int32_t ret = DeviceManagerService::GetInstance().CheckCredential(packageName, reqJsonStr, returnJsonStr);
800     if (!reply.WriteInt32(ret)) {
801         LOGE("write ret failed");
802         return ERR_DM_IPC_WRITE_FAILED;
803     }
804     if (ret == DM_OK && !returnJsonStr.empty()) {
805         if (!reply.WriteString(returnJsonStr)) {
806             LOGE("write returnJsonStr failed");
807             return ERR_DM_IPC_WRITE_FAILED;
808         }
809     }
810     return DM_OK;
811 }
812 
ON_IPC_CMD(REGISTER_CREDENTIAL_CALLBACK,MessageParcel & data,MessageParcel & reply)813 ON_IPC_CMD(REGISTER_CREDENTIAL_CALLBACK, MessageParcel &data, MessageParcel &reply)
814 {
815     std::string packageName = data.ReadString();
816     int result = DeviceManagerService::GetInstance().RegisterCredentialCallback(packageName);
817     if (!reply.WriteInt32(result)) {
818         LOGE("write result failed");
819         return ERR_DM_IPC_WRITE_FAILED;
820     }
821     return result;
822 }
823 
ON_IPC_CMD(UNREGISTER_CREDENTIAL_CALLBACK,MessageParcel & data,MessageParcel & reply)824 ON_IPC_CMD(UNREGISTER_CREDENTIAL_CALLBACK, MessageParcel &data, MessageParcel &reply)
825 {
826     std::string packageName = data.ReadString();
827     int result = DeviceManagerService::GetInstance().UnRegisterCredentialCallback(packageName);
828     if (!reply.WriteInt32(result)) {
829         LOGE("write result failed");
830         return ERR_DM_IPC_WRITE_FAILED;
831     }
832     return result;
833 }
834 
ON_IPC_CMD(NOTIFY_EVENT,MessageParcel & data,MessageParcel & reply)835 ON_IPC_CMD(NOTIFY_EVENT, MessageParcel &data, MessageParcel &reply)
836 {
837     std::string pkgName = data.ReadString();
838     int32_t eventId = data.ReadInt32();
839     std::string event = data.ReadString();
840     int32_t result = DeviceManagerService::GetInstance().NotifyEvent(pkgName, eventId, event);
841     if (!reply.WriteInt32(result)) {
842         LOGE("write result failed");
843         return ERR_DM_IPC_WRITE_FAILED;
844     }
845     return DM_OK;
846 }
847 
ON_IPC_SET_REQUEST(SERVER_CREDENTIAL_RESULT,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)848 ON_IPC_SET_REQUEST(SERVER_CREDENTIAL_RESULT, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
849 {
850     if (pBaseReq == nullptr) {
851         return ERR_DM_FAILED;
852     }
853     std::shared_ptr<IpcNotifyCredentialReq> pReq = std::static_pointer_cast<IpcNotifyCredentialReq>(pBaseReq);
854     std::string pkgName = pReq->GetPkgName();
855     int32_t action = pReq->GetCredentialAction();
856     std::string credentialResult = pReq->GetCredentialResult();
857     if (!data.WriteString(pkgName)) {
858         LOGE("write pkgName failed");
859         return ERR_DM_IPC_WRITE_FAILED;
860     }
861     if (!data.WriteInt32(action)) {
862         LOGE("write action failed");
863         return ERR_DM_IPC_WRITE_FAILED;
864     }
865     if (!data.WriteString(credentialResult)) {
866         LOGE("write credentialResult failed");
867         return ERR_DM_IPC_WRITE_FAILED;
868     }
869 
870     return DM_OK;
871 }
872 
ON_IPC_READ_RESPONSE(SERVER_CREDENTIAL_RESULT,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)873 ON_IPC_READ_RESPONSE(SERVER_CREDENTIAL_RESULT, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
874 {
875     if (pBaseRsp == nullptr) {
876         LOGE("pBaseRsp is null");
877         return ERR_DM_FAILED;
878     }
879     pBaseRsp->SetErrCode(reply.ReadInt32());
880     return DM_OK;
881 }
882 
ON_IPC_CMD(GET_ENCRYPTED_UUID_BY_NETWOEKID,MessageParcel & data,MessageParcel & reply)883 ON_IPC_CMD(GET_ENCRYPTED_UUID_BY_NETWOEKID, MessageParcel &data, MessageParcel &reply)
884 {
885     std::string pkgName = data.ReadString();
886     std::string networkId = data.ReadString();
887     std::string uuid;
888 
889     int32_t result = DeviceManagerService::GetInstance().GetEncryptedUuidByNetworkId(pkgName, networkId, uuid);
890     if (!reply.WriteInt32(result)) {
891         LOGE("write result failed");
892         return ERR_DM_IPC_WRITE_FAILED;
893     }
894     if (!reply.WriteString(uuid)) {
895         LOGE("write uuid failed");
896         return ERR_DM_IPC_WRITE_FAILED;
897     }
898     return DM_OK;
899 }
900 
ON_IPC_CMD(GENERATE_ENCRYPTED_UUID,MessageParcel & data,MessageParcel & reply)901 ON_IPC_CMD(GENERATE_ENCRYPTED_UUID, MessageParcel &data, MessageParcel &reply)
902 {
903     std::string pkgName = data.ReadString();
904     std::string uuid = data.ReadString();
905     std::string appId = data.ReadString();
906     std::string encryptedUuid;
907 
908     int32_t result = DeviceManagerService::GetInstance().GenerateEncryptedUuid(pkgName, uuid, appId, encryptedUuid);
909     if (!reply.WriteInt32(result)) {
910         LOGE("write result failed");
911         return ERR_DM_IPC_WRITE_FAILED;
912     }
913     if (!reply.WriteString(encryptedUuid)) {
914         LOGE("write encryptedUuid failed");
915         return ERR_DM_IPC_WRITE_FAILED;
916     }
917     return DM_OK;
918 }
919 
ON_IPC_CMD(BIND_DEVICE,MessageParcel & data,MessageParcel & reply)920 ON_IPC_CMD(BIND_DEVICE, MessageParcel &data, MessageParcel &reply)
921 {
922     std::string pkgName = data.ReadString();
923     std::string bindParam = data.ReadString();
924     std::string deviceId = data.ReadString();
925     int32_t bindType = data.ReadInt32();
926     int32_t result = DM_OK;
927     result = DeviceManagerService::GetInstance().BindDevice(pkgName, bindType, deviceId, bindParam);
928     if (!reply.WriteInt32(result)) {
929         LOGE("write result failed");
930         return ERR_DM_IPC_WRITE_FAILED;
931     }
932     return DM_OK;
933 }
934 
ON_IPC_CMD(UNBIND_DEVICE,MessageParcel & data,MessageParcel & reply)935 ON_IPC_CMD(UNBIND_DEVICE, MessageParcel &data, MessageParcel &reply)
936 {
937     std::string pkgName = data.ReadString();
938     std::string deviceId = data.ReadString();
939     int32_t result = DeviceManagerService::GetInstance().UnBindDevice(pkgName, deviceId);
940     if (!reply.WriteInt32(result)) {
941         LOGE("write result failed");
942         return ERR_DM_IPC_WRITE_FAILED;
943     }
944     return DM_OK;
945 }
946 
ON_IPC_CMD(GET_NETWORKTYPE_BY_NETWORK,MessageParcel & data,MessageParcel & reply)947 ON_IPC_CMD(GET_NETWORKTYPE_BY_NETWORK, MessageParcel &data, MessageParcel &reply)
948 {
949     std::string pkgName = data.ReadString();
950     std::string netWorkId = data.ReadString();
951     int32_t networkType = -1;
952     int32_t result = DeviceManagerService::GetInstance().GetNetworkTypeByNetworkId(pkgName, netWorkId, networkType);
953     if (!reply.WriteInt32(result)) {
954         LOGE("write result failed");
955         return ERR_DM_IPC_WRITE_FAILED;
956     }
957     if (!reply.WriteInt32(networkType)) {
958         LOGE("write result failed");
959         return ERR_DM_IPC_WRITE_FAILED;
960     }
961     return DM_OK;
962 }
963 
ON_IPC_CMD(REGISTER_UI_STATE_CALLBACK,MessageParcel & data,MessageParcel & reply)964 ON_IPC_CMD(REGISTER_UI_STATE_CALLBACK, MessageParcel &data, MessageParcel &reply)
965 {
966     std::string pkgName = data.ReadString();
967     int32_t result = DeviceManagerService::GetInstance().RegisterUiStateCallback(pkgName);
968     if (!reply.WriteInt32(result)) {
969         LOGE("write result failed");
970         return ERR_DM_IPC_WRITE_FAILED;
971     }
972     return DM_OK;
973 }
974 
ON_IPC_CMD(UNREGISTER_UI_STATE_CALLBACK,MessageParcel & data,MessageParcel & reply)975 ON_IPC_CMD(UNREGISTER_UI_STATE_CALLBACK, MessageParcel &data, MessageParcel &reply)
976 {
977     std::string pkgName = data.ReadString();
978     int32_t result = DeviceManagerService::GetInstance().UnRegisterUiStateCallback(pkgName);
979     if (!reply.WriteInt32(result)) {
980         LOGE("write result failed");
981         return ERR_DM_IPC_WRITE_FAILED;
982     }
983     return DM_OK;
984 }
985 
ON_IPC_CMD(IMPORT_AUTH_CODE,MessageParcel & data,MessageParcel & reply)986 ON_IPC_CMD(IMPORT_AUTH_CODE, MessageParcel &data, MessageParcel &reply)
987 {
988     std::string pkgName = data.ReadString();
989     std::string authCode = data.ReadString();
990     int32_t result = DeviceManagerService::GetInstance().ImportAuthCode(pkgName, authCode);
991     if (!reply.WriteInt32(result)) {
992         LOGE("write result failed");
993         return ERR_DM_IPC_WRITE_FAILED;
994     }
995     return DM_OK;
996 }
997 
ON_IPC_CMD(EXPORT_AUTH_CODE,MessageParcel & data,MessageParcel & reply)998 ON_IPC_CMD(EXPORT_AUTH_CODE, MessageParcel &data, MessageParcel &reply)
999 {
1000     std::string authCode = "";
1001     int32_t result = DeviceManagerService::GetInstance().ExportAuthCode(authCode);
1002     if (!reply.WriteString(authCode)) {
1003         LOGE("write result failed");
1004         return ERR_DM_IPC_WRITE_FAILED;
1005     }
1006     if (!reply.WriteInt32(result)) {
1007         LOGE("write result failed");
1008         return ERR_DM_IPC_WRITE_FAILED;
1009     }
1010     return DM_OK;
1011 }
1012 
ON_IPC_CMD(REGISTER_DISCOVERY_CALLBACK,MessageParcel & data,MessageParcel & reply)1013 ON_IPC_CMD(REGISTER_DISCOVERY_CALLBACK, MessageParcel &data, MessageParcel &reply)
1014 {
1015     std::string pkgName = data.ReadString();
1016     std::string discParaStr = data.ReadString();
1017     std::string filterOpStr = data.ReadString();
1018     std::map<std::string, std::string> discoverParam;
1019     ParseMapFromJsonString(discParaStr, discoverParam);
1020     std::map<std::string, std::string> filterOptions;
1021     ParseMapFromJsonString(filterOpStr, filterOptions);
1022     int32_t result = DeviceManagerService::GetInstance().EnableDiscoveryListener(pkgName, discoverParam, filterOptions);
1023     if (!reply.WriteInt32(result)) {
1024         LOGE("write result failed");
1025         return ERR_DM_IPC_WRITE_FAILED;
1026     }
1027     return DM_OK;
1028 }
1029 
ON_IPC_CMD(UNREGISTER_DISCOVERY_CALLBACK,MessageParcel & data,MessageParcel & reply)1030 ON_IPC_CMD(UNREGISTER_DISCOVERY_CALLBACK, MessageParcel &data, MessageParcel &reply)
1031 {
1032     std::string pkgName = data.ReadString();
1033     std::string extraParaStr = data.ReadString();
1034     std::map<std::string, std::string> extraParam;
1035     ParseMapFromJsonString(extraParaStr, extraParam);
1036     int32_t result = DeviceManagerService::GetInstance().DisableDiscoveryListener(pkgName, extraParam);
1037     if (!reply.WriteInt32(result)) {
1038         LOGE("write result failed");
1039         return ERR_DM_IPC_WRITE_FAILED;
1040     }
1041     return DM_OK;
1042 }
1043 
ON_IPC_CMD(START_DISCOVERING,MessageParcel & data,MessageParcel & reply)1044 ON_IPC_CMD(START_DISCOVERING, MessageParcel &data, MessageParcel &reply)
1045 {
1046     std::string pkgName = data.ReadString();
1047     std::string discParaStr = data.ReadString();
1048     std::string filterOpStr = data.ReadString();
1049     std::map<std::string, std::string> discoverParam;
1050     ParseMapFromJsonString(discParaStr, discoverParam);
1051     std::map<std::string, std::string> filterOptions;
1052     ParseMapFromJsonString(filterOpStr, filterOptions);
1053     int32_t result = DeviceManagerService::GetInstance().StartDiscovering(pkgName, discoverParam, filterOptions);
1054     if (!reply.WriteInt32(result)) {
1055         LOGE("write result failed");
1056         return ERR_DM_IPC_WRITE_FAILED;
1057     }
1058     return DM_OK;
1059 }
1060 
ON_IPC_CMD(STOP_DISCOVERING,MessageParcel & data,MessageParcel & reply)1061 ON_IPC_CMD(STOP_DISCOVERING, MessageParcel &data, MessageParcel &reply)
1062 {
1063     std::string pkgName = data.ReadString();
1064     std::string discParaStr = data.ReadString();
1065     std::map<std::string, std::string> discoverParam;
1066     ParseMapFromJsonString(discParaStr, discoverParam);
1067     int32_t result = DeviceManagerService::GetInstance().StopDiscovering(pkgName, discoverParam);
1068     if (!reply.WriteInt32(result)) {
1069         LOGE("write result failed");
1070         return ERR_DM_IPC_WRITE_FAILED;
1071     }
1072     return DM_OK;
1073 }
1074 
ON_IPC_CMD(START_ADVERTISING,MessageParcel & data,MessageParcel & reply)1075 ON_IPC_CMD(START_ADVERTISING, MessageParcel &data, MessageParcel &reply)
1076 {
1077     std::string pkgName = data.ReadString();
1078     std::string adverParaStr = data.ReadString();
1079     std::map<std::string, std::string> advertiseParam;
1080     ParseMapFromJsonString(adverParaStr, advertiseParam);
1081     int32_t result = DeviceManagerService::GetInstance().StartAdvertising(pkgName, advertiseParam);
1082     if (!reply.WriteInt32(result)) {
1083         LOGE("write result failed");
1084         return ERR_DM_IPC_WRITE_FAILED;
1085     }
1086     return DM_OK;
1087 }
1088 
ON_IPC_CMD(STOP_ADVERTISING,MessageParcel & data,MessageParcel & reply)1089 ON_IPC_CMD(STOP_ADVERTISING, MessageParcel &data, MessageParcel &reply)
1090 {
1091     std::string pkgName = data.ReadString();
1092     std::string adverParaStr = data.ReadString();
1093     std::map<std::string, std::string> advertiseParam;
1094     ParseMapFromJsonString(adverParaStr, advertiseParam);
1095     int32_t result = DeviceManagerService::GetInstance().StopAdvertising(pkgName, advertiseParam);
1096     if (!reply.WriteInt32(result)) {
1097         LOGE("write result failed");
1098         return ERR_DM_IPC_WRITE_FAILED;
1099     }
1100     return DM_OK;
1101 }
1102 
ON_IPC_CMD(BIND_TARGET,MessageParcel & data,MessageParcel & reply)1103 ON_IPC_CMD(BIND_TARGET, MessageParcel &data, MessageParcel &reply)
1104 {
1105     std::string pkgName = data.ReadString();
1106     PeerTargetId targetId;
1107     DecodePeerTargetId(data, targetId);
1108     std::string bindParamStr = data.ReadString();
1109     std::map<std::string, std::string> bindParam;
1110     ParseMapFromJsonString(bindParamStr, bindParam);
1111     int32_t result = DeviceManagerService::GetInstance().BindTarget(pkgName, targetId, bindParam);
1112     if (!reply.WriteInt32(result)) {
1113         LOGE("write result failed");
1114         return ERR_DM_IPC_WRITE_FAILED;
1115     }
1116     return DM_OK;
1117 }
1118 
ON_IPC_CMD(UNBIND_TARGET,MessageParcel & data,MessageParcel & reply)1119 ON_IPC_CMD(UNBIND_TARGET, MessageParcel &data, MessageParcel &reply)
1120 {
1121     std::string pkgName = data.ReadString();
1122     PeerTargetId targetId;
1123     DecodePeerTargetId(data, targetId);
1124     std::string unbindParamStr = data.ReadString();
1125     std::map<std::string, std::string> unbindParam;
1126     ParseMapFromJsonString(unbindParamStr, unbindParam);
1127     int32_t result = DeviceManagerService::GetInstance().UnbindTarget(pkgName, targetId, unbindParam);
1128     if (!reply.WriteInt32(result)) {
1129         LOGE("write result failed");
1130         return ERR_DM_IPC_WRITE_FAILED;
1131     }
1132     return DM_OK;
1133 }
1134 
ON_IPC_SET_REQUEST(BIND_TARGET_RESULT,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)1135 ON_IPC_SET_REQUEST(BIND_TARGET_RESULT, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
1136 {
1137     if (pBaseReq == nullptr) {
1138         return ERR_DM_FAILED;
1139     }
1140     std::shared_ptr<IpcNotifyBindResultReq> pReq = std::static_pointer_cast<IpcNotifyBindResultReq>(pBaseReq);
1141     std::string pkgName = pReq->GetPkgName();
1142     PeerTargetId targetId = pReq->GetPeerTargetId();
1143     int32_t result = pReq->GetResult();
1144     int32_t status = pReq->GetStatus();
1145     std::string content = pReq->GetContent();
1146 
1147     if (!data.WriteString(pkgName)) {
1148         LOGE("write bind pkgName failed");
1149         return ERR_DM_IPC_WRITE_FAILED;
1150     }
1151     if (!EncodePeerTargetId(targetId, data)) {
1152         LOGE("write bind peer target id failed");
1153         return ERR_DM_IPC_WRITE_FAILED;
1154     }
1155     if (!data.WriteInt32(result)) {
1156         LOGE("write bind result code failed");
1157         return ERR_DM_IPC_WRITE_FAILED;
1158     }
1159     if (!data.WriteInt32(status)) {
1160         LOGE("write bind result status failed");
1161         return ERR_DM_IPC_WRITE_FAILED;
1162     }
1163     if (!data.WriteString(content)) {
1164         LOGE("write bind result content failed");
1165         return ERR_DM_IPC_WRITE_FAILED;
1166     }
1167     return DM_OK;
1168 }
1169 
ON_IPC_READ_RESPONSE(BIND_TARGET_RESULT,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)1170 ON_IPC_READ_RESPONSE(BIND_TARGET_RESULT, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
1171 {
1172     if (pBaseRsp == nullptr) {
1173         LOGE("pBaseRsp is null");
1174         return ERR_DM_FAILED;
1175     }
1176     pBaseRsp->SetErrCode(reply.ReadInt32());
1177     return DM_OK;
1178 }
1179 
ON_IPC_SET_REQUEST(UNBIND_TARGET_RESULT,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)1180 ON_IPC_SET_REQUEST(UNBIND_TARGET_RESULT, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
1181 {
1182     if (pBaseReq == nullptr) {
1183         return ERR_DM_FAILED;
1184     }
1185     std::shared_ptr<IpcNotifyBindResultReq> pReq = std::static_pointer_cast<IpcNotifyBindResultReq>(pBaseReq);
1186     std::string pkgName = pReq->GetPkgName();
1187     PeerTargetId targetId = pReq->GetPeerTargetId();
1188     int32_t result = pReq->GetResult();
1189     std::string content = pReq->GetContent();
1190 
1191     if (!data.WriteString(pkgName)) {
1192         LOGE("write unbind pkgName failed");
1193         return ERR_DM_IPC_WRITE_FAILED;
1194     }
1195     if (!EncodePeerTargetId(targetId, data)) {
1196         LOGE("write unbind peer target id failed");
1197         return ERR_DM_IPC_WRITE_FAILED;
1198     }
1199     if (!data.WriteInt32(result)) {
1200         LOGE("write unbind result code failed");
1201         return ERR_DM_IPC_WRITE_FAILED;
1202     }
1203     if (!data.WriteString(content)) {
1204         LOGE("write unbind result content failed");
1205         return ERR_DM_IPC_WRITE_FAILED;
1206     }
1207     return DM_OK;
1208 }
1209 
ON_IPC_READ_RESPONSE(UNBIND_TARGET_RESULT,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)1210 ON_IPC_READ_RESPONSE(UNBIND_TARGET_RESULT, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
1211 {
1212     if (pBaseRsp == nullptr) {
1213         LOGE("pBaseRsp is null");
1214         return ERR_DM_FAILED;
1215     }
1216     pBaseRsp->SetErrCode(reply.ReadInt32());
1217     return DM_OK;
1218 }
1219 
ON_IPC_CMD(REGISTER_PIN_HOLDER_CALLBACK,MessageParcel & data,MessageParcel & reply)1220 ON_IPC_CMD(REGISTER_PIN_HOLDER_CALLBACK, MessageParcel &data, MessageParcel &reply)
1221 {
1222     std::string pkgName = data.ReadString();
1223     int32_t result = DeviceManagerService::GetInstance().RegisterPinHolderCallback(pkgName);
1224     if (!reply.WriteInt32(result)) {
1225         LOGE("write result failed");
1226         return ERR_DM_IPC_WRITE_FAILED;
1227     }
1228     return DM_OK;
1229 }
1230 
ON_IPC_CMD(CREATE_PIN_HOLDER,MessageParcel & data,MessageParcel & reply)1231 ON_IPC_CMD(CREATE_PIN_HOLDER, MessageParcel &data, MessageParcel &reply)
1232 {
1233     std::string pkgName = data.ReadString();
1234     PeerTargetId targetId;
1235     DecodePeerTargetId(data, targetId);
1236     std::string payload = data.ReadString();
1237     DmPinType pinType = static_cast<DmPinType>(data.ReadInt32());
1238     int32_t result = DeviceManagerService::GetInstance().CreatePinHolder(pkgName, targetId, pinType, payload);
1239     if (!reply.WriteInt32(result)) {
1240         LOGE("write result failed");
1241         return ERR_DM_IPC_WRITE_FAILED;
1242     }
1243     return DM_OK;
1244 }
1245 
ON_IPC_CMD(DESTROY_PIN_HOLDER,MessageParcel & data,MessageParcel & reply)1246 ON_IPC_CMD(DESTROY_PIN_HOLDER, MessageParcel &data, MessageParcel &reply)
1247 {
1248     std::string pkgName = data.ReadString();
1249     PeerTargetId targetId;
1250     DecodePeerTargetId(data, targetId);
1251     DmPinType pinType = static_cast<DmPinType>(data.ReadInt32());
1252     std::string payload = data.ReadString();
1253     int32_t result = DeviceManagerService::GetInstance().DestroyPinHolder(pkgName, targetId, pinType, payload);
1254     if (!reply.WriteInt32(result)) {
1255         LOGE("write result failed");
1256         return ERR_DM_IPC_WRITE_FAILED;
1257     }
1258     return DM_OK;
1259 }
1260 
ON_IPC_SET_REQUEST(SERVER_CREATE_PIN_HOLDER,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)1261 ON_IPC_SET_REQUEST(SERVER_CREATE_PIN_HOLDER, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
1262 {
1263     if (pBaseReq == nullptr) {
1264         return ERR_DM_FAILED;
1265     }
1266     std::shared_ptr<IpcCreatePinHolderReq> pReq = std::static_pointer_cast<IpcCreatePinHolderReq>(pBaseReq);
1267     std::string pkgName = pReq->GetPkgName();
1268     std::string deviceId = pReq->GetDeviceId();
1269     int32_t pinType = pReq->GetPinType();
1270     std::string payload = pReq->GetPayload();
1271 
1272     if (!data.WriteString(pkgName)) {
1273         LOGE("write pkgName failed");
1274         return ERR_DM_IPC_WRITE_FAILED;
1275     }
1276     if (!data.WriteString(deviceId)) {
1277         LOGE("write deviceId failed");
1278         return ERR_DM_IPC_WRITE_FAILED;
1279     }
1280     if (!data.WriteInt32(pinType)) {
1281         LOGE("write pinType failed");
1282         return ERR_DM_IPC_WRITE_FAILED;
1283     }
1284     if (!data.WriteString(payload)) {
1285         LOGE("write payload failed");
1286         return ERR_DM_IPC_WRITE_FAILED;
1287     }
1288     return DM_OK;
1289 }
1290 
ON_IPC_READ_RESPONSE(SERVER_CREATE_PIN_HOLDER,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)1291 ON_IPC_READ_RESPONSE(SERVER_CREATE_PIN_HOLDER, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
1292 {
1293     if (pBaseRsp == nullptr) {
1294         LOGE("pBaseRsp is null");
1295         return ERR_DM_FAILED;
1296     }
1297     pBaseRsp->SetErrCode(reply.ReadInt32());
1298     return DM_OK;
1299 }
1300 
ON_IPC_SET_REQUEST(SERVER_DESTROY_PIN_HOLDER,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)1301 ON_IPC_SET_REQUEST(SERVER_DESTROY_PIN_HOLDER, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
1302 {
1303     if (pBaseReq == nullptr) {
1304         return ERR_DM_FAILED;
1305     }
1306     std::shared_ptr<IpcDestroyPinHolderReq> pReq = std::static_pointer_cast<IpcDestroyPinHolderReq>(pBaseReq);
1307     std::string pkgName = pReq->GetPkgName();
1308     int32_t pinType = pReq->GetPinType();
1309     std::string payload = pReq->GetPayload();
1310 
1311     if (!data.WriteString(pkgName)) {
1312         LOGE("write pkgName failed");
1313         return ERR_DM_IPC_WRITE_FAILED;
1314     }
1315     if (!data.WriteInt32(pinType)) {
1316         LOGE("write pinType failed");
1317         return ERR_DM_IPC_WRITE_FAILED;
1318     }
1319     if (!data.WriteString(payload)) {
1320         LOGE("write payload failed");
1321         return ERR_DM_IPC_WRITE_FAILED;
1322     }
1323     return DM_OK;
1324 }
1325 
ON_IPC_READ_RESPONSE(SERVER_DESTROY_PIN_HOLDER,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)1326 ON_IPC_READ_RESPONSE(SERVER_DESTROY_PIN_HOLDER, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
1327 {
1328     if (pBaseRsp == nullptr) {
1329         LOGE("pBaseRsp is null");
1330         return ERR_DM_FAILED;
1331     }
1332     pBaseRsp->SetErrCode(reply.ReadInt32());
1333     return DM_OK;
1334 }
1335 
ON_IPC_SET_REQUEST(SERVER_CREATE_PIN_HOLDER_RESULT,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)1336 ON_IPC_SET_REQUEST(SERVER_CREATE_PIN_HOLDER_RESULT, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
1337 {
1338     if (pBaseReq == nullptr) {
1339         return ERR_DM_FAILED;
1340     }
1341     std::shared_ptr<IpcNotifyPublishResultReq> pReq = std::static_pointer_cast<IpcNotifyPublishResultReq>(pBaseReq);
1342     std::string pkgName = pReq->GetPkgName();
1343     int32_t result = pReq->GetResult();
1344 
1345     if (!data.WriteString(pkgName)) {
1346         LOGE("write pkgName failed");
1347         return ERR_DM_IPC_WRITE_FAILED;
1348     }
1349     if (!data.WriteInt32(result)) {
1350         LOGE("write result failed");
1351         return ERR_DM_IPC_WRITE_FAILED;
1352     }
1353     return DM_OK;
1354 }
1355 
ON_IPC_READ_RESPONSE(SERVER_CREATE_PIN_HOLDER_RESULT,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)1356 ON_IPC_READ_RESPONSE(SERVER_CREATE_PIN_HOLDER_RESULT, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
1357 {
1358     if (pBaseRsp == nullptr) {
1359         LOGE("pBaseRsp is null");
1360         return ERR_DM_FAILED;
1361     }
1362     pBaseRsp->SetErrCode(reply.ReadInt32());
1363     return DM_OK;
1364 }
1365 
ON_IPC_SET_REQUEST(SERVER_DESTROY_PIN_HOLDER_RESULT,std::shared_ptr<IpcReq> pBaseReq,MessageParcel & data)1366 ON_IPC_SET_REQUEST(SERVER_DESTROY_PIN_HOLDER_RESULT, std::shared_ptr<IpcReq> pBaseReq, MessageParcel &data)
1367 {
1368     if (pBaseReq == nullptr) {
1369         return ERR_DM_FAILED;
1370     }
1371     std::shared_ptr<IpcNotifyPublishResultReq> pReq = std::static_pointer_cast<IpcNotifyPublishResultReq>(pBaseReq);
1372     std::string pkgName = pReq->GetPkgName();
1373     int32_t result = pReq->GetResult();
1374 
1375     if (!data.WriteString(pkgName)) {
1376         LOGE("write pkgName failed");
1377         return ERR_DM_IPC_WRITE_FAILED;
1378     }
1379     if (!data.WriteInt32(result)) {
1380         LOGE("write result failed");
1381         return ERR_DM_IPC_WRITE_FAILED;
1382     }
1383     return DM_OK;
1384 }
1385 
ON_IPC_READ_RESPONSE(SERVER_DESTROY_PIN_HOLDER_RESULT,MessageParcel & reply,std::shared_ptr<IpcRsp> pBaseRsp)1386 ON_IPC_READ_RESPONSE(SERVER_DESTROY_PIN_HOLDER_RESULT, MessageParcel &reply, std::shared_ptr<IpcRsp> pBaseRsp)
1387 {
1388     if (pBaseRsp == nullptr) {
1389         LOGE("pBaseRsp is null");
1390         return ERR_DM_FAILED;
1391     }
1392     pBaseRsp->SetErrCode(reply.ReadInt32());
1393     return DM_OK;
1394 }
1395 
ON_IPC_CMD(DP_ACL_ADD,MessageParcel & data,MessageParcel & reply)1396 ON_IPC_CMD(DP_ACL_ADD, MessageParcel &data, MessageParcel &reply)
1397 {
1398     std::string udid = data.ReadString();
1399     int32_t result = DeviceManagerService::GetInstance().DpAclAdd(udid);
1400     if (!reply.WriteInt32(result)) {
1401         LOGE("write result failed");
1402         return ERR_DM_IPC_WRITE_FAILED;
1403     }
1404     return DM_OK;
1405 }
1406 } // namespace DistributedHardware
1407 } // namespace OHOS