diff --git a/interfaces/kits/js4.0/src/dm_native_util.cpp b/interfaces/kits/js4.0/src/dm_native_util.cpp index 91d06911debe71488143e41c24f3e3f9281d5114..5b44ab07876b54c38ae90ebaa4a170dad80bb2b3 100644 --- a/interfaces/kits/js4.0/src/dm_native_util.cpp +++ b/interfaces/kits/js4.0/src/dm_native_util.cpp @@ -290,7 +290,8 @@ void DmDeviceBasicToJsObject(napi_env env, const DmDeviceBasicInfo &devInfo, nap { SetValueUtf8String(env, "deviceId", devInfo.deviceId, result); SetValueUtf8String(env, "networkId", devInfo.networkId, result); - SetValueUtf8String(env, "deviceName", devInfo.deviceName, result); + std::string anonyDeviceName = GetAnonyString(std::string(devInfo.deviceName)); + SetValueUtf8String(env, "deviceName", anonyDeviceName.c_str(), result); std::string deviceType = GetDeviceTypeById(static_cast(devInfo.deviceTypeId)); SetValueUtf8String(env, "deviceType", deviceType.c_str(), result); SetValueUtf8String(env, "extraData", devInfo.extraData.c_str(), result); diff --git a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp index 48fe2775bc6a22d56d821e315b3142950aa28ea8..ac3c116fa2daf8d26d5f08f9a1df5407b51c9386 100644 --- a/interfaces/kits/js4.0/src/native_devicemanager_js.cpp +++ b/interfaces/kits/js4.0/src/native_devicemanager_js.cpp @@ -1387,8 +1387,9 @@ napi_value DeviceManagerNapi::GetLocalDeviceName(napi_env env, napi_callback_inf CreateBusinessError(env, ret); return result; } - LOGI("DeviceManager::GetLocalDeviceName deviceName:%{public}s", GetAnonyString(std::string(deviceName)).c_str()); - napi_create_string_utf8(env, deviceName.c_str(), deviceName.size(), &result); + std::string anonyDeviceName = GetAnonyString(deviceName); + LOGI("DeviceManager::GetLocalDeviceName deviceName:%{public}s", anonyDeviceName.c_str()); + napi_create_string_utf8(env, anonyDeviceName.c_str(), anonyDeviceName.size(), &result); return result; } @@ -1447,8 +1448,9 @@ napi_value DeviceManagerNapi::GetDeviceName(napi_env env, napi_callback_info inf CreateBusinessError(env, ret); return result; } - LOGI("DeviceManager::GetDeviceName deviceName:%{public}s", GetAnonyString(std::string(deviceName)).c_str()); - napi_create_string_utf8(env, deviceName.c_str(), deviceName.size(), &result); + std::string anonyDeviceName = GetAnonyString(deviceName); + LOGI("DeviceManager::GetDeviceName deviceName:%{public}s", anonyDeviceName.c_str()); + napi_create_string_utf8(env, anonyDeviceName.c_str(), anonyDeviceName.size(), &result); return result; }