diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp index d8584b2b3ee3ec4bcb978b792ffb29ce4596205f..2c62215a9a49ad9417a949be645c00ad3aa39d1a 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_client_manager.cpp @@ -88,6 +88,7 @@ int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr r CHECK_NULL_RETURN(rsp, ERR_DM_POINT_NULL); std::string pkgName = req->GetPkgName(); if (!IsInit(pkgName)) { + LOGE("dm init failed."); return ERR_DM_INIT_FAILED; } return serverProxy_.SendCmd(cmdCode, req, rsp); @@ -95,7 +96,14 @@ int32_t IpcClientManager::SendRequest(int32_t cmdCode, std::shared_ptr r bool IpcClientManager::IsInit(const std::string &pkgName) { - return (packageInitSet_.count(pkgName) > 0); + for (auto &iter : packageInitSet_) { + size_t len = iter.size(); + std::string tmp = pkgName.substr(0, len); + if (tmp == iter) { + return true; + } + } + return false; } int32_t IpcClientManager::OnDmServiceDied() diff --git a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp index a3c291e938360fe97e89476a1f714c167ef19204..2013c8204d9632be85ae1d6b928836f96ef504c2 100644 --- a/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp +++ b/interfaces/inner_kits/native_cpp/src/ipc/lite/ipc_cmd_parser.cpp @@ -21,6 +21,7 @@ #include "dm_log.h" #include "dm_subscribe_info.h" #include "ipc_cmd_register.h" +#include "ipc_common_param_req.h" #include "ipc_def.h" #include "ipc_get_device_info_rsp.h" #include "ipc_get_info_by_network_req.h" @@ -349,5 +350,70 @@ ON_IPC_READ_RESPONSE(SYNC_CALLBACK, IpcIo &reply, std::shared_ptr pBaseR { return SetRspErrCode(reply, pBaseRsp); } + +ON_IPC_SET_REQUEST(START_DISCOVERING, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, + size_t buffLen) +{ + LOGI("start."); + std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); + std::string pkgName = pReq->GetPkgName(); + std::string discParaStr = pReq->GetFirstParam(); + std::string filterOpStr = pReq->GetSecondParam(); + + IpcIoInit(&request, buffer, buffLen, 0); + WriteString(&request, pkgName.c_str()); + WriteString(&request, discParaStr.c_str()); + WriteString(&request, filterOpStr.c_str()); + return DM_OK; +} + +ON_IPC_READ_RESPONSE(START_DISCOVERING, IpcIo &reply, std::shared_ptr pBaseRsp) +{ + LOGI("start."); + return SetRspErrCode(reply, pBaseRsp); +} + +ON_IPC_SET_REQUEST(STOP_DISCOVERING, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, + size_t buffLen) +{ + LOGI("start."); + std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); + std::string pkgName = pReq->GetPkgName(); + std::string discParaStr = pReq->GetFirstParam(); + + IpcIoInit(&request, buffer, buffLen, 0); + WriteString(&request, pkgName.c_str()); + WriteString(&request, discParaStr.c_str()); + return DM_OK; +} + +ON_IPC_READ_RESPONSE(STOP_DISCOVERING, IpcIo &reply, std::shared_ptr pBaseRsp) +{ + LOGI("start."); + return SetRspErrCode(reply, pBaseRsp); +} + +ON_IPC_SET_REQUEST(GET_LOCAL_DEVICE_INFO, std::shared_ptr pBaseReq, IpcIo &request, uint8_t *buffer, + size_t buffLen) +{ + std::shared_ptr pReq = std::static_pointer_cast(pBaseReq); + std::string pkgName = pReq->GetPkgName(); + + IpcIoInit(&request, buffer, buffLen, 0); + WriteString(&request, pkgName.c_str()); + return DM_OK; +} + +ON_IPC_READ_RESPONSE(GET_LOCAL_DEVICE_INFO, IpcIo &reply, std::shared_ptr pBaseRsp) +{ + std::shared_ptr pRsp = std::static_pointer_cast(pBaseRsp); + DmDeviceInfo deviceInfo; + DecodeDmDeviceInfo(reply, deviceInfo); + int32_t ret = 0; + ReadInt32(&reply, &ret); + pRsp->SetLocalDeviceInfo(deviceInfo); + pRsp->SetErrCode(ret); + return DM_OK; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/service/src/ipc/lite/ipc_cmd_parser.cpp b/services/service/src/ipc/lite/ipc_cmd_parser.cpp index 37bec133e610254c2a34d144830565b3639e44ea..00d71d515835952432481037fa2937cea161cb35 100644 --- a/services/service/src/ipc/lite/ipc_cmd_parser.cpp +++ b/services/service/src/ipc/lite/ipc_cmd_parser.cpp @@ -251,5 +251,39 @@ ON_IPC_SERVER_CMD(SYNC_CALLBACK, IpcIo &req, IpcIo &reply) int32_t ret = DeviceManagerServiceNotify::GetInstance().RegisterCallBack(dmCommonNotifyEvent, processInfo); WriteInt32(&reply, ret); } + +ON_IPC_SERVER_CMD(START_DISCOVERING, IpcIo &req, IpcIo &reply) +{ + LOGI("start."); + std::string pkgName = (const char *)ReadString(&req, nullptr); + std::string discParaStr = (const char *)ReadString(&req, nullptr); + std::string filterOpStr = (const char *)ReadString(&req, nullptr); + std::map discoverParam; + ParseMapFromJsonString(discParaStr, discoverParam); + std::map filterOptions; + ParseMapFromJsonString(filterOpStr, filterOptions); + int32_t result = DeviceManagerService::GetInstance().StartDiscovering(pkgName, discoverParam, filterOptions); + WriteInt32(&reply, result); +} + +ON_IPC_SERVER_CMD(STOP_DISCOVERING, IpcIo &req, IpcIo &reply) +{ + LOGI("start."); + std::string pkgName = (const char *)ReadString(&req, nullptr); + std::string discParaStr = (const char *)ReadString(&req, nullptr); + std::map discoverParam; + ParseMapFromJsonString(discParaStr, discoverParam); + int32_t result = DeviceManagerService::GetInstance().StopDiscovering(pkgName, discoverParam); + WriteInt32(&reply, result); +} + +ON_IPC_SERVER_CMD(GET_LOCAL_DEVICE_INFO, IpcIo &req, IpcIo &reply) +{ + LOGI("start."); + DmDeviceInfo localDeviceInfo; + int32_t result = DeviceManagerService::GetInstance().GetLocalDeviceInfo(localDeviceInfo); + EncodeDmDeviceInfo(localDeviceInfo, reply); + WriteInt32(&reply, result); +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/service/src/softbus/mine_softbus_listener.cpp b/services/service/src/softbus/mine_softbus_listener.cpp index db86dab66d03c63ca5db8d465c7faba6b5057540..1cdce65e5bef56990df0df0dd604c36dd3784f68 100644 --- a/services/service/src/softbus/mine_softbus_listener.cpp +++ b/services/service/src/softbus/mine_softbus_listener.cpp @@ -519,13 +519,13 @@ int32_t MineSoftbusListener::SendBroadcastInfo(const string &pkgName, SubscribeI #if (defined(MINE_HARMONY)) subscribeInfo.custData = base64Out; subscribeInfo.custDataLen = base64OutLen; -#endif IRefreshCallback softbusRefreshCallback_ = SoftbusListener::GetSoftbusRefreshCb(); retValue = RefreshLNN(DM_PKG_NAME, &subscribeInfo, &softbusRefreshCallback_); if (retValue != SOFTBUS_OK) { LOGE("failed to start to refresh quick discovery with ret: %{public}d.", retValue); return ERR_DM_FAILED; } +#endif LOGI("send search broadcast info by softbus successfully with dataLen: %{public}zu, pkgName: %{public}s.", base64OutLen, pkgName.c_str()); return DM_OK;