From: Caisking Date: Thu, 24 Jul 2025 06:54:36 +0000 (+0800) Subject: 优化表盘删除的函数 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~176^2~6 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=73e146ccb3ac9b79ce3ee49f4b08a5bb07201250;p=mirrors%2FFD230.git 优化表盘删除的函数 --- 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文件