From be31ab2bce753d4578e27fd9cc8f93b6debc6cb4 Mon Sep 17 00:00:00 2001 From: BrainL Date: Sat, 30 Aug 2025 16:02:51 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BrainL --- .../include/ohos.distributedDeviceManager.h | 18 +++++++++++++ .../src/ohos.distributedDeviceManager.cpp | 26 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h b/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h index 0242f0efa..29035767b 100644 --- a/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h +++ b/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h @@ -19,6 +19,8 @@ #include #include "device_manager_callback.h" #include "dm_device_info.h" +#include "dm_constants.h" +#include "dm_error_type.h" #include "ohos.distributedDeviceManager.proj.hpp" #include "ohos.distributedDeviceManager.impl.hpp" #include "taihe/callback.hpp" @@ -27,8 +29,24 @@ namespace ANI::distributedDeviceManager { enum DMBussinessErrorCode { + // OK + ERR_OK = 0, + // Permission verify failed. ERR_NO_PERMISSION = 201, + // The caller is not a system application. + ERR_NOT_SYSTEM_APP = 202, + // Input parameter error. + ERR_INVALID_PARAMS = 401, + // Failed to execute the function. DM_ERR_FAILED = 11600101, + // Failed to obtain the service. + DM_ERR_OBTAIN_SERVICE = 11600102, + // Authentication invalid. + DM_ERR_AUTHENTICALTION_INVALID = 11600103, + // Discovery invalid. + DM_ERR_DISCOVERY_INVALID = 11600104, + // Publish invalid. + DM_ERR_PUBLISH_INVALID = 11600105, }; class DeviceManagerImpl { diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index a05aeefca..331866d69 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -45,6 +45,22 @@ std::map> g_discover std::map> g_dmUiCallbackMap; } //namespace +int32_t TransformErrCode(const int32_t errCode) +{ + switch (errCode) { + case OHOS::DistributedHardware::ERR_DM_NO_PERMISSION: + return ERR_NO_PERMISSION; + case OHOS::DistributedHardware::ERR_DM_INPUT_PARA_INVALID: + case OHOS::DistributedHardware::ERR_DM_UNSUPPORTED_AUTH_TYPE: + return ERR_INVALID_PARAMS; + case ERR_NOT_SYSTEM_APP: + return ERR_NOT_SYSTEM_APP; + default: + return DM_ERR_FAILED; + } + return 0; +} + DeviceManagerImpl::DeviceManagerImpl(const std::string& bundleName) : bundleName_(bundleName) { @@ -130,9 +146,12 @@ std::string DeviceManagerImpl::GetLocalDeviceId() void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) { + LOGI("*********UnbindTarget start"); int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().UnBindDevice( bundleName_, std::string(deviceId)); + LOGI("*********error %{public}d", ret); if (ret != 0) { + ret = TransformErrCode(ret); LOGE("UnBindDevice for bundleName %{public}s failed, ret %{public}d", bundleName_.c_str(), ret); taihe::set_business_error(DM_ERR_FAILED, "UnbindTarget for failed"); @@ -142,10 +161,13 @@ void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) double DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) { + LOGI("*********GetDeviceType start"); int32_t deviceType; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetDeviceType( bundleName_, std::string(networkId), deviceType); + LOGI("*********error %{public}d", ret); if (ret != 0) { + ret = TransformErrCode(ret); taihe::set_business_error(DM_ERR_FAILED, "GetDeviceType for failed"); return DEVICE_TYPE_UNKNOWN; } @@ -154,10 +176,13 @@ double DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) std::string DeviceManagerImpl::GetDeviceName(taihe::string_view networkId) { + LOGI("*********GetDeviceName start"); std::string deviceName; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetDeviceName( bundleName_, std::string(networkId), deviceName); + LOGI("*********error %{public}d", ret); if (ret != 0) { + ret = TransformErrCode(ret); taihe::set_business_error(DM_ERR_FAILED, "GetDeviceName for failed"); return DEVICE_TYPE_EMPTY_STR; } @@ -173,6 +198,7 @@ std::string DeviceManagerImpl::GetLocalDeviceNetworkId() std::string networkId; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetLocalDeviceNetWorkId( bundleName_, networkId); + LOGI("*********error %{public}d", ret); if (ret != 0) { LOGE("GetLocalDeviceNetworkId for failed, ret %{public}d", ret); taihe::set_business_error(DM_ERR_FAILED, "GetLocalDeviceNetworkId failed"); -- Gitee From 30a1c4c92eecac8bf579339b02f083741ddb4abc Mon Sep 17 00:00:00 2001 From: BrainL Date: Sat, 30 Aug 2025 16:06:03 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: BrainL --- .../kits/taihe/include/ohos.distributedDeviceManager.h | 2 +- .../kits/taihe/src/ohos.distributedDeviceManager.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h b/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h index 29035767b..9d6d6111f 100644 --- a/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h +++ b/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h @@ -57,7 +57,7 @@ public: ~DeviceManagerImpl() = default; std::string GetLocalDeviceId(); void UnbindTarget(taihe::string_view deviceId); - double GetDeviceType(taihe::string_view networkId); + int32_t GetDeviceType(taihe::string_view networkId); std::string GetDeviceName(taihe::string_view networkId); std::string GetLocalDeviceNetworkId(); diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index 331866d69..f8c257caa 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -25,7 +25,7 @@ namespace ANI::distributedDeviceManager { namespace { -constexpr double DEVICE_TYPE_UNKNOWN = -1.0; +constexpr int32_t DEVICE_TYPE_UNKNOWN = -1; constexpr const char *DEVICE_TYPE_EMPTY_STR = ""; constexpr const char *ERROR_DEVICE_ID = "error deviceId"; constexpr const char *ERROR_NETWORK_ID = "error networkId"; @@ -159,7 +159,7 @@ void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) } } -double DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) +int32_t DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) { LOGI("*********GetDeviceType start"); int32_t deviceType; @@ -171,7 +171,7 @@ double DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) taihe::set_business_error(DM_ERR_FAILED, "GetDeviceType for failed"); return DEVICE_TYPE_UNKNOWN; } - return static_cast(deviceType); + return static_cast(deviceType); } std::string DeviceManagerImpl::GetDeviceName(taihe::string_view networkId) @@ -336,7 +336,7 @@ void DeviceManagerImpl::OnServiceDie(taihe::callback_view onServiceDiecb { if (OHOS::DistributedHardware::DeviceManager::GetInstance().CheckNewAPIAccessPermission() != 0) { taihe::set_business_error(OHOS::DistributedHardware::ERR_DM_NO_PERMISSION, - "OnReplyResult check permission failed"); + "OnServiceDie check permission failed"); return; } @@ -499,7 +499,7 @@ void DeviceManagerImpl::OffServiceDie(taihe::optional_view Date: Sat, 30 Aug 2025 20:09:59 +0800 Subject: [PATCH 3/7] modify set business error arg Signed-off-by: BrainL --- .../kits/taihe/src/ohos.distributedDeviceManager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index f8c257caa..b8d14529b 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -84,7 +84,7 @@ ohos::distributedDeviceManager::DeviceManager CreateDeviceManager(taihe::string_ std::string(bundleName), initCallback); if (ret != 0) { LOGE("CreateDeviceManager for bundleName %{public}s failed, ret %{public}d.", bundleName.c_str(), ret); - taihe::set_business_error(DM_ERR_FAILED, "CreateDeviceManager for failed"); + taihe::set_business_error(ERR_INVALID_PARAMS, "CreateDeviceManager for failed"); return taihe::make_holder(); } { @@ -138,7 +138,7 @@ std::string DeviceManagerImpl::GetLocalDeviceId() std::string deviceId; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetLocalDeviceId(bundleName_, deviceId); if (ret != 0) { - taihe::set_business_error(DM_ERR_FAILED, "GetLocalDeviceId for failed2"); + taihe::set_business_error(ERR_INVALID_PARAMS, "GetLocalDeviceId for failed2"); return ERROR_DEVICE_ID; } return std::string(deviceId); @@ -154,7 +154,7 @@ void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) ret = TransformErrCode(ret); LOGE("UnBindDevice for bundleName %{public}s failed, ret %{public}d", bundleName_.c_str(), ret); - taihe::set_business_error(DM_ERR_FAILED, "UnbindTarget for failed"); + taihe::set_business_error(ERR_INVALID_PARAMS, "UnbindTarget for failed"); return; } } @@ -168,7 +168,7 @@ int32_t DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) LOGI("*********error %{public}d", ret); if (ret != 0) { ret = TransformErrCode(ret); - taihe::set_business_error(DM_ERR_FAILED, "GetDeviceType for failed"); + taihe::set_business_error(ERR_INVALID_PARAMS, "GetDeviceType for failed"); return DEVICE_TYPE_UNKNOWN; } return static_cast(deviceType); @@ -183,7 +183,7 @@ std::string DeviceManagerImpl::GetDeviceName(taihe::string_view networkId) LOGI("*********error %{public}d", ret); if (ret != 0) { ret = TransformErrCode(ret); - taihe::set_business_error(DM_ERR_FAILED, "GetDeviceName for failed"); + taihe::set_business_error(ERR_INVALID_PARAMS, "GetDeviceName for failed"); return DEVICE_TYPE_EMPTY_STR; } return std::string(deviceName); @@ -201,7 +201,7 @@ std::string DeviceManagerImpl::GetLocalDeviceNetworkId() LOGI("*********error %{public}d", ret); if (ret != 0) { LOGE("GetLocalDeviceNetworkId for failed, ret %{public}d", ret); - taihe::set_business_error(DM_ERR_FAILED, "GetLocalDeviceNetworkId failed"); + taihe::set_business_error(ERR_INVALID_PARAMS, "GetLocalDeviceNetworkId failed"); return ERROR_NETWORK_ID; } return std::string(networkId); -- Gitee From 5d2ec7915d1ac13ab7ebfd6eb8e724973aeab62a Mon Sep 17 00:00:00 2001 From: BrainL Date: Sat, 30 Aug 2025 23:11:55 +0800 Subject: [PATCH 4/7] modify param error Signed-off-by: BrainL --- .../include/ohos.distributedDeviceManager.h | 9 ++- .../src/ohos.distributedDeviceManager.cpp | 69 +++++++++++++------ 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h b/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h index 9d6d6111f..63b29f1d0 100644 --- a/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h +++ b/interfaces/kits/taihe/include/ohos.distributedDeviceManager.h @@ -19,7 +19,6 @@ #include #include "device_manager_callback.h" #include "dm_device_info.h" -#include "dm_constants.h" #include "dm_error_type.h" #include "ohos.distributedDeviceManager.proj.hpp" #include "ohos.distributedDeviceManager.impl.hpp" @@ -28,7 +27,7 @@ namespace ANI::distributedDeviceManager { -enum DMBussinessErrorCode { +enum ANIBussinessErrorCode { // OK ERR_OK = 0, // Permission verify failed. @@ -55,11 +54,11 @@ public: explicit DeviceManagerImpl(std::shared_ptr impl); explicit DeviceManagerImpl(const std::string& bundleName); ~DeviceManagerImpl() = default; - std::string GetLocalDeviceId(); + taihe::string GetLocalDeviceId(); void UnbindTarget(taihe::string_view deviceId); int32_t GetDeviceType(taihe::string_view networkId); - std::string GetDeviceName(taihe::string_view networkId); - std::string GetLocalDeviceNetworkId(); + taihe::string GetDeviceName(taihe::string_view networkId); + taihe::string GetLocalDeviceNetworkId(); void OnDeviceNameChange(taihe::callback_view onDeviceNameChangecb); diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index b8d14529b..386621204 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -26,6 +26,7 @@ namespace ANI::distributedDeviceManager { namespace { constexpr int32_t DEVICE_TYPE_UNKNOWN = -1; +const int32_t DM_STR_BUF_LENGTH = 256; constexpr const char *DEVICE_TYPE_EMPTY_STR = ""; constexpr const char *ERROR_DEVICE_ID = "error deviceId"; constexpr const char *ERROR_NETWORK_ID = "error networkId"; @@ -45,18 +46,28 @@ std::map> g_discover std::map> g_dmUiCallbackMap; } //namespace +inline int32_t StringCheck(const taihe::string_view &str) +{ + auto strPara = std::string(str); + LOGI("*****strPara = %{public}s", strPara); + if (strPara.size() == 0 || strPara.size() >= DM_STR_BUF_LENGTH) { + return ANIBussinessErrorCode::ERR_INVALID_PARAMS; + } + return ANIBussinessErrorCode::ERR_OK; +} + int32_t TransformErrCode(const int32_t errCode) { switch (errCode) { case OHOS::DistributedHardware::ERR_DM_NO_PERMISSION: - return ERR_NO_PERMISSION; + return ANIBussinessErrorCode::ERR_NO_PERMISSION; case OHOS::DistributedHardware::ERR_DM_INPUT_PARA_INVALID: case OHOS::DistributedHardware::ERR_DM_UNSUPPORTED_AUTH_TYPE: - return ERR_INVALID_PARAMS; - case ERR_NOT_SYSTEM_APP: - return ERR_NOT_SYSTEM_APP; + return ANIBussinessErrorCode::ERR_INVALID_PARAMS; + case ANIBussinessErrorCode::ERR_NOT_SYSTEM_APP: + return ANIBussinessErrorCode::ERR_NOT_SYSTEM_APP; default: - return DM_ERR_FAILED; + return ANIBussinessErrorCode::DM_ERR_FAILED; } return 0; } @@ -84,7 +95,7 @@ ohos::distributedDeviceManager::DeviceManager CreateDeviceManager(taihe::string_ std::string(bundleName), initCallback); if (ret != 0) { LOGE("CreateDeviceManager for bundleName %{public}s failed, ret %{public}d.", bundleName.c_str(), ret); - taihe::set_business_error(ERR_INVALID_PARAMS, "CreateDeviceManager for failed"); + taihe::set_business_error(DM_ERR_FAILED, "Failed to execute the function"); return taihe::make_holder(); } { @@ -129,24 +140,29 @@ ohos::distributedDeviceManager::DeviceStateChangeResult MakeDeviceStateChangeRes return {deviceStateChange, deviceBasicInfo}; } -std::string DeviceManagerImpl::GetLocalDeviceId() +taihe::string DeviceManagerImpl::GetLocalDeviceId() { if (OHOS::DistributedHardware::DeviceManager::GetInstance().CheckNewAPIAccessPermission() != 0) { taihe::set_business_error(OHOS::DistributedHardware::ERR_DM_NO_PERMISSION, "GetLocalDeviceId for failed1"); return DEVICE_TYPE_EMPTY_STR; } - std::string deviceId; + std::string deviceId = ""; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetLocalDeviceId(bundleName_, deviceId); if (ret != 0) { - taihe::set_business_error(ERR_INVALID_PARAMS, "GetLocalDeviceId for failed2"); + taihe::set_business_error(DM_ERR_FAILED, "Failed to execute the function"); return ERROR_DEVICE_ID; } - return std::string(deviceId); + return taihe::string(deviceId.c_str()); } void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) { LOGI("*********UnbindTarget start"); + int32_t checkRet = StringCheck(deviceId); + if (checkRet != 0) { + taihe::set_business_error(checkRet, "Input parameter error"); + return; + } int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().UnBindDevice( bundleName_, std::string(deviceId)); LOGI("*********error %{public}d", ret); @@ -154,7 +170,7 @@ void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) ret = TransformErrCode(ret); LOGE("UnBindDevice for bundleName %{public}s failed, ret %{public}d", bundleName_.c_str(), ret); - taihe::set_business_error(ERR_INVALID_PARAMS, "UnbindTarget for failed"); + taihe::set_business_error(ret, "Failed to execute the function"); return; } } @@ -162,49 +178,60 @@ void DeviceManagerImpl::UnbindTarget(taihe::string_view deviceId) int32_t DeviceManagerImpl::GetDeviceType(taihe::string_view networkId) { LOGI("*********GetDeviceType start"); + int32_t checkRet = StringCheck(networkId); + if (checkRet != 0) { + taihe::set_business_error(checkRet, "Input parameter error"); + return DEVICE_TYPE_UNKNOWN; + } int32_t deviceType; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetDeviceType( bundleName_, std::string(networkId), deviceType); LOGI("*********error %{public}d", ret); if (ret != 0) { ret = TransformErrCode(ret); - taihe::set_business_error(ERR_INVALID_PARAMS, "GetDeviceType for failed"); + taihe::set_business_error(ret, "Failed to execute the function"); return DEVICE_TYPE_UNKNOWN; } - return static_cast(deviceType); + return deviceType; } -std::string DeviceManagerImpl::GetDeviceName(taihe::string_view networkId) +taihe::string DeviceManagerImpl::GetDeviceName(taihe::string_view networkId) { + int32_t checkRet = StringCheck(networkId); + if (checkRet != 0) { + taihe::set_business_error(checkRet, "Input parameter error"); + return DEVICE_TYPE_EMPTY_STR; + } LOGI("*********GetDeviceName start"); - std::string deviceName; + std::string deviceName = ""; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetDeviceName( bundleName_, std::string(networkId), deviceName); LOGI("*********error %{public}d", ret); if (ret != 0) { ret = TransformErrCode(ret); - taihe::set_business_error(ERR_INVALID_PARAMS, "GetDeviceName for failed"); + taihe::set_business_error(ret, "Failed to execute the function"); return DEVICE_TYPE_EMPTY_STR; } - return std::string(deviceName); + return taihe::string(deviceName.c_str()); } -std::string DeviceManagerImpl::GetLocalDeviceNetworkId() +taihe::string DeviceManagerImpl::GetLocalDeviceNetworkId() { if (OHOS::DistributedHardware::DeviceManager::GetInstance().CheckNewAPIAccessPermission() != 0) { taihe::set_business_error(OHOS::DistributedHardware::ERR_DM_NO_PERMISSION, "GetLocalDeviceNetworkId failed"); return DEVICE_TYPE_EMPTY_STR; } - std::string networkId; + std::string networkId = ""; int32_t ret = OHOS::DistributedHardware::DeviceManager::GetInstance().GetLocalDeviceNetWorkId( bundleName_, networkId); LOGI("*********error %{public}d", ret); if (ret != 0) { + ret = TransformErrCode(ret); LOGE("GetLocalDeviceNetworkId for failed, ret %{public}d", ret); - taihe::set_business_error(ERR_INVALID_PARAMS, "GetLocalDeviceNetworkId failed"); + taihe::set_business_error(ret, "Failed to execute the function"); return ERROR_NETWORK_ID; } - return std::string(networkId); + return taihe::string(networkId.c_str()); } void DeviceManagerImpl::OnDeviceNameChange(taihe::callback_view Date: Sat, 30 Aug 2025 23:40:59 +0800 Subject: [PATCH 5/7] modify , Signed-off-by: BrainL --- interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index 386621204..0f64508d6 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -49,7 +49,7 @@ std::map> g_dmUiCallb inline int32_t StringCheck(const taihe::string_view &str) { auto strPara = std::string(str); - LOGI("*****strPara = %{public}s", strPara); + LOGI("*****strPara = %{public}s", strPara); if (strPara.size() == 0 || strPara.size() >= DM_STR_BUF_LENGTH) { return ANIBussinessErrorCode::ERR_INVALID_PARAMS; } -- Gitee From 19844488d53544946868b3b37f28dc1618855a02 Mon Sep 17 00:00:00 2001 From: BrainL Date: Mon, 1 Sep 2025 09:10:10 +0800 Subject: [PATCH 6/7] char to string Signed-off-by: BrainL --- interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index 0f64508d6..022ed3ed4 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -49,7 +49,7 @@ std::map> g_dmUiCallb inline int32_t StringCheck(const taihe::string_view &str) { auto strPara = std::string(str); - LOGI("*****strPara = %{public}s", strPara); + LOGI("*****strPara = %{public}s", c_str()); if (strPara.size() == 0 || strPara.size() >= DM_STR_BUF_LENGTH) { return ANIBussinessErrorCode::ERR_INVALID_PARAMS; } -- Gitee From bd1bb97eb1801fb961b9b34f03a90e6c9524f70b Mon Sep 17 00:00:00 2001 From: BrainL Date: Mon, 1 Sep 2025 09:32:18 +0800 Subject: [PATCH 7/7] update string c_str() Signed-off-by: BrainL --- interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp index 022ed3ed4..e9f8c869a 100644 --- a/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp +++ b/interfaces/kits/taihe/src/ohos.distributedDeviceManager.cpp @@ -49,7 +49,7 @@ std::map> g_dmUiCallb inline int32_t StringCheck(const taihe::string_view &str) { auto strPara = std::string(str); - LOGI("*****strPara = %{public}s", c_str()); + LOGI("*****strPara = %{public}s", strPara.c_str()); if (strPara.size() == 0 || strPara.size() >= DM_STR_BUF_LENGTH) { return ANIBussinessErrorCode::ERR_INVALID_PARAMS; } -- Gitee