diff --git a/interfaces/kits/js/src/native_devicemanager_js.cpp b/interfaces/kits/js/src/native_devicemanager_js.cpp index acd42777c69c23f3363bd3782cbf4779003312ce..d138a5d77d66af473be0199cf2b5f36c46204ee7 100644 --- a/interfaces/kits/js/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js/src/native_devicemanager_js.cpp @@ -577,6 +577,7 @@ void DeviceManagerNapi::DeviceInfoToJsArray(const napi_env &env, const std::vect napi_create_object(env, &result); SetValueUtf8String(env, "deviceId", vecDevInfo[idx].deviceId, result); + SetValueUtf8String(env, "networkId", vecDevInfo[idx].networkId, result); SetValueUtf8String(env, "deviceName", vecDevInfo[idx].deviceName, result); SetValueInt32(env, "deviceType", (int)vecDevInfo[idx].deviceTypeId, result); diff --git a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp index e3e8586725a27cf7c8f364ae03beacbcf3911eb2..b4deb0222c98de870392153b5c27268eab35db5e 100644 --- a/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp +++ b/services/devicemanagerservice/src/dependency/softbus/softbus_connector.cpp @@ -427,11 +427,6 @@ ConnectionAddr *SoftbusConnector::GetConnectAddr(const std::string &deviceId, st int32_t SoftbusConnector::CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nodeBasicInfo, DmDeviceInfo &dmDeviceInfo) { (void)memset_s(&dmDeviceInfo, sizeof(DmDeviceInfo), 0, sizeof(DmDeviceInfo)); - if (memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), nodeBasicInfo.networkId, - std::min(sizeof(dmDeviceInfo.deviceId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { - LOGE("CovertNodeBasicInfoToDmDevice copy deviceId data failed"); - } - if (memcpy_s(dmDeviceInfo.networkId, sizeof(dmDeviceInfo.networkId), nodeBasicInfo.networkId, std::min(sizeof(dmDeviceInfo.networkId), sizeof(nodeBasicInfo.networkId))) != DM_OK) { LOGE("CovertNodeBasicInfoToDmDevice copy networkId data failed"); @@ -441,7 +436,14 @@ int32_t SoftbusConnector::CovertNodeBasicInfoToDmDevice(const NodeBasicInfo &nod std::min(sizeof(dmDeviceInfo.deviceName), sizeof(nodeBasicInfo.deviceName))) != DM_OK) { LOGE("CovertNodeBasicInfoToDmDevice copy deviceName data failed"); } + std::string deviceID; + GetUdidByNetworkId(dmDeviceInfo.networkId, deviceID); + if (memcpy_s(dmDeviceInfo.deviceId, sizeof(dmDeviceInfo.deviceId), deviceID.c_str(), + std::min(sizeof(dmDeviceInfo.deviceId), sizeof(deviceID))) != DM_OK) { + LOGE("CovertNodeBasicInfoToDmDevice copy deviceId data failed"); + } dmDeviceInfo.deviceTypeId = nodeBasicInfo.deviceTypeId; + LOGI("GetTrustedDeviceList for deviceId %s, networkId %s", dmDeviceInfo.deviceId, dmDeviceInfo.networkId); return DM_OK; }