+/***
+ * @Date: 2024-05-30 15:59:37
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-06-14 16:51:13
+ * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/set_dial/include/SetDialModel.h
+ */
/*
* Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
* Description: SetDialModel.h
void UpdateDialSetting(uint16_t ID);
uint16_t GetDialIdFromName(const std::string &dialName);
void PrintRegisteredDials(const std::unordered_map<uint16_t, std::string> &dials);
+ int GetAllDialIDs(char *allidStr);
private:
void LoadAllDialFromRam(void);
#include "DialBinParser.h"
#include "custom_utils.h"
#include "wearable_log.h"
+#include <string>
+#include <sstream>
+#include <iomanip>
namespace OHOS
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentDialID is %d,name is %s", currentDialID, registeredDials[currentDialID].c_str());
return currentDialID;
}
+ /* 获取所有表盘Id 每个表盘Id 2个字节 拼接为字符串 */
+ int SetDialModel::GetAllDialIDs(char *allidStr)
+ {
+ std::string allIDs;
+ for (const auto &entry : registeredDials)
+ {
+ // 格式化表盘ID为两个字节长度的字符串,不足两位则在前面补0
+ std::stringstream ss;
+ ss << std::setw(2) << std::setfill('0') << entry.first;
+ allIDs += ss.str();
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "allidStr is %s", allIDs.c_str());
+
+ // 将字符串拷贝到allidStr中
+ int length = allIDs.size();
+ if (length > 0)
+ {
+ strcpy(allidStr, allIDs.c_str());
+ allidStr[length] = '\0'; // 添加字符串结尾的空字符
+ }
+
+ return length;
+ }
/* 判断表盘是否存在*/
bool SetDialModel::IsDialInstalled(uint16_t ID)
{
/* 只排序离线表盘 */
std::sort(dialInfoList.begin() + dialSize, dialInfoList.end(), [](const SetDialInfo &f, const SetDialInfo &n)
{ return f.dialName < n.dialName; });
+ // 表盘Id以及表盘map打印
+ char dialId[128];
+ GetAllDialIDs(dialId);
PrintRegisteredDials(registeredDials);
}
/*加载自定义表盘*/
dialInfo.dialName = preInfo.dialName;
dialInfo.description = preInfo.description;
dialInfo.preImageInfo = info;
-
+#if 0
// 需要判断表盘是否存在 不存在->新表盘注册
if (GetDialIdFromName(dialInfo.dialName) == 0)
{
// 注册表盘,将表盘ID和表盘文件名添加到 registeredDials 中
RegisterDial(newDialId, (dialInfo.dialName).c_str());
}
-
+#endif
fclose(fp);
return 0;
}