From 73e146ccb3ac9b79ce3ee49f4b08a5bb07201250 Mon Sep 17 00:00:00 2001 From: Caisking Date: Thu, 24 Jul 2025 14:54:36 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E8=A1=A8=E7=9B=98=E5=88=A0?= =?utf8?q?=E9=99=A4=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/set_dial/src/SetDialModel.cpp | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp index 32ddbfd5c..3f8b169f8 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp @@ -207,7 +207,19 @@ uint16_t SetDialModel::GetDialIdFromName(const std::string &dialName) { } return 0; // 如果未找到对应的表盘名称,返回0或者其他适当的默认值 } - +/*通过表盘Id查询名称*/ +std::string SetDialModel::GetdialPath(int Id) { + //判断Id是否在map中 + if (registeredDials.find(Id) != registeredDials.end()) { + // 先将第一个字符串字面量转换为std::string,后续拼接会自动兼容 + std::string path = + std::string(APP_DEFAULT_DIAL_PATH) + "/" + registeredDials[Id] + ".bin"; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetdialPath is %s", path.c_str()); + return path; + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetdialPath is error"); + return ""; +} /* 获取当前表盘Id */ uint16_t SetDialModel::GetCurrentDialID() { if (registeredDials.find(currentDialID) != registeredDials.end()) { @@ -252,8 +264,9 @@ bool SetDialModel::IsDialInstalled(uint16_t ID) { return false; } } -/*删除自定义表盘*/ +/*删除自定义表盘文件*/ bool SetDialModel::DeleteCustomDial(uint16_t Id) { +#if 0 // 删除配置文件 std::string filename = GetSaveDir(Id) + "/" + std::to_string(Id) + ".bin"; if (!uapi_delete_files(filename.c_str())) { @@ -356,11 +369,19 @@ bool SetDialModel::DeleteCustomDial(uint16_t Id) { "DeleteCustomDial: Invalid dial ID: %d", Id); return false; // ID 不合法 } +#endif + std::string dirpath = GetSaveDir(Id) + "/"; + if (uapi_delete_folder(dirpath.c_str()) == -1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "DeleteCustomDial: Failed to delete dial directory: %s", + dirpath.c_str()); + return false; + } // 所有操作成功 重新加载list registeredDials.erase(Id); LoadAllDial(); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DeleteCustomDial: Successfully deleted custom dial with ID %d", Id); //删除表盘,更新id文件 -- 2.17.1