}
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()) {
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())) {
"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文件