From 7f96cc5c13a515a52feb1b92b064f9a545fe3a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 10 Feb 2025 14:57:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=B9=E5=A4=96?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../native_cpp/include/dm_device_info.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/interfaces/inner_kits/native_cpp/include/dm_device_info.h b/interfaces/inner_kits/native_cpp/include/dm_device_info.h index 00d087fcb..4fa27ac36 100644 --- a/interfaces/inner_kits/native_cpp/include/dm_device_info.h +++ b/interfaces/inner_kits/native_cpp/include/dm_device_info.h @@ -347,16 +347,16 @@ typedef enum { MAX = 9, } DmCommonNotifyEvent; -const std::string DEVICE_TYPE_UNKNOWN_STRING = "UNKNOWN"; -const std::string DEVICE_TYPE_PHONE_STRING = "PHONE"; -const std::string DEVICE_TYPE_PAD_STRING = "PAD"; -const std::string DEVICE_TYPE_TV_STRING = "TV"; -const std::string DEVICE_TYPE_CAR_STRING = "CAR"; -const std::string DEVICE_TYPE_WATCH_STRING = "WATCH"; -const std::string DEVICE_TYPE_WIFICAMERA_STRING = "WiFiCamera"; -const std::string DEVICE_TYPE_PC_STRING = "PC"; -const std::string DEVICE_TYPE_SMART_DISPLAY_STRING = "SMART_DISPLAY"; -const std::string DEVICE_TYPE_2IN1_STRING = "2IN1"; +constexpr const char* DEVICE_TYPE_UNKNOWN_STRING = "UNKNOWN"; +constexpr const char* DEVICE_TYPE_PHONE_STRING = "PHONE"; +constexpr const char* DEVICE_TYPE_PAD_STRING = "PAD"; +constexpr const char* DEVICE_TYPE_TV_STRING = "TV"; +constexpr const char* DEVICE_TYPE_CAR_STRING = "CAR"; +constexpr const char* DEVICE_TYPE_WATCH_STRING = "WATCH"; +constexpr const char* DEVICE_TYPE_WIFICAMERA_STRING = "WiFiCamera"; +constexpr const char* DEVICE_TYPE_PC_STRING = "PC"; +constexpr const char* DEVICE_TYPE_SMART_DISPLAY_STRING = "SMART_DISPLAY"; +constexpr const char* DEVICE_TYPE_2IN1_STRING = "2IN1"; typedef struct DmAccessCaller { std::string accountId; -- Gitee From 2080b2e8029b65e0c12c722e4891570261d345b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 10 Feb 2025 15:46:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../cj/kits/src/device_manager_utils.cpp | 22 +++++++++---------- interfaces/kits/js4.0/src/dm_native_util.cpp | 22 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/interfaces/cj/kits/src/device_manager_utils.cpp b/interfaces/cj/kits/src/device_manager_utils.cpp index f7c89749f..b81e2ed43 100644 --- a/interfaces/cj/kits/src/device_manager_utils.cpp +++ b/interfaces/cj/kits/src/device_manager_utils.cpp @@ -188,23 +188,23 @@ void DmFfiBindTargetCallback::OnBindResult(const PeerTargetId &targetId, int32_t const std::string &GetDeviceTypeById(DmDeviceType type) { const static std::pair mapArray[] = { - {DEVICE_TYPE_UNKNOWN, DEVICE_TYPE_UNKNOWN_STRING}, - {DEVICE_TYPE_PHONE, DEVICE_TYPE_PHONE_STRING}, - {DEVICE_TYPE_PAD, DEVICE_TYPE_PAD_STRING}, - {DEVICE_TYPE_TV, DEVICE_TYPE_TV_STRING}, - {DEVICE_TYPE_CAR, DEVICE_TYPE_CAR_STRING}, - {DEVICE_TYPE_WATCH, DEVICE_TYPE_WATCH_STRING}, - {DEVICE_TYPE_WIFI_CAMERA, DEVICE_TYPE_WIFICAMERA_STRING}, - {DEVICE_TYPE_PC, DEVICE_TYPE_PC_STRING}, - {DEVICE_TYPE_SMART_DISPLAY, DEVICE_TYPE_SMART_DISPLAY_STRING}, - {DEVICE_TYPE_2IN1, DEVICE_TYPE_2IN1_STRING}, + {DEVICE_TYPE_UNKNOWN, std::string(DEVICE_TYPE_UNKNOWN_STRING)}, + {DEVICE_TYPE_PHONE, std::string(DEVICE_TYPE_PHONE_STRING)}, + {DEVICE_TYPE_PAD, std::string(DEVICE_TYPE_PAD_STRING)}, + {DEVICE_TYPE_TV, std::string(DEVICE_TYPE_TV_STRING)}, + {DEVICE_TYPE_CAR, std::string(DEVICE_TYPE_CAR_STRING)}, + {DEVICE_TYPE_WATCH, std::string(DEVICE_TYPE_WATCH_STRING)}, + {DEVICE_TYPE_WIFI_CAMERA, std::string(DEVICE_TYPE_WIFICAMERA_STRING)}, + {DEVICE_TYPE_PC, std::string(DEVICE_TYPE_PC_STRING)}, + {DEVICE_TYPE_SMART_DISPLAY, std::string(DEVICE_TYPE_SMART_DISPLAY_STRING)}, + {DEVICE_TYPE_2IN1, std::string(DEVICE_TYPE_2IN1_STRING)}, }; for (const auto& item : mapArray) { if (item.first == type) { return item.second; } } - return DEVICE_TYPE_UNKNOWN_STRING; + return std::string(DEVICE_TYPE_UNKNOWN_STRING); } char *MallocCStr(const char *in) diff --git a/interfaces/kits/js4.0/src/dm_native_util.cpp b/interfaces/kits/js4.0/src/dm_native_util.cpp index 8b08c668a..da5e313cd 100644 --- a/interfaces/kits/js4.0/src/dm_native_util.cpp +++ b/interfaces/kits/js4.0/src/dm_native_util.cpp @@ -127,23 +127,23 @@ int32_t GetIntFromJsObj(const napi_env &env, const napi_value &object, const std std::string GetDeviceTypeById(DmDeviceType type) { const static std::pair mapArray[] = { - {DEVICE_TYPE_UNKNOWN, DEVICE_TYPE_UNKNOWN_STRING}, - {DEVICE_TYPE_PHONE, DEVICE_TYPE_PHONE_STRING}, - {DEVICE_TYPE_PAD, DEVICE_TYPE_PAD_STRING}, - {DEVICE_TYPE_TV, DEVICE_TYPE_TV_STRING}, - {DEVICE_TYPE_CAR, DEVICE_TYPE_CAR_STRING}, - {DEVICE_TYPE_WATCH, DEVICE_TYPE_WATCH_STRING}, - {DEVICE_TYPE_WIFI_CAMERA, DEVICE_TYPE_WIFICAMERA_STRING}, - {DEVICE_TYPE_PC, DEVICE_TYPE_PC_STRING}, - {DEVICE_TYPE_SMART_DISPLAY, DEVICE_TYPE_SMART_DISPLAY_STRING}, - {DEVICE_TYPE_2IN1, DEVICE_TYPE_2IN1_STRING}, + {DEVICE_TYPE_UNKNOWN, std::string(DEVICE_TYPE_UNKNOWN_STRING)}, + {DEVICE_TYPE_PHONE, std::string(DEVICE_TYPE_PHONE_STRING)}, + {DEVICE_TYPE_PAD, std::string(DEVICE_TYPE_PAD_STRING)}, + {DEVICE_TYPE_TV, std::string(DEVICE_TYPE_TV_STRING)}, + {DEVICE_TYPE_CAR, std::string(DEVICE_TYPE_CAR_STRING)}, + {DEVICE_TYPE_WATCH, std::string(DEVICE_TYPE_WATCH_STRING)}, + {DEVICE_TYPE_WIFI_CAMERA, std::string(DEVICE_TYPE_WIFICAMERA_STRING)}, + {DEVICE_TYPE_PC, std::string(DEVICE_TYPE_PC_STRING)}, + {DEVICE_TYPE_SMART_DISPLAY, std::string(DEVICE_TYPE_SMART_DISPLAY_STRING)}, + {DEVICE_TYPE_2IN1, std::string(DEVICE_TYPE_2IN1_STRING)}, }; for (const auto& item : mapArray) { if (item.first == type) { return item.second; } } - return DEVICE_TYPE_UNKNOWN_STRING; + return std::string(DEVICE_TYPE_UNKNOWN_STRING); } bool CheckArgsVal(napi_env env, bool assertion, const std::string ¶m, const std::string &msg) -- Gitee