修复自定义表盘ID不能对应问题 1005/5
authorhcj <1224667075@qq.com>
Tue, 24 Sep 2024 03:54:10 +0000 (11:54 +0800)
committerhcj <1224667075@qq.com>
Tue, 24 Sep 2024 03:54:10 +0000 (11:54 +0800)
code/sdk/application/wearable/fd230app/nativeui/set_dial/src/SetDialModel.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp

index 0f9c730..365c179 100644 (file)
@@ -178,7 +178,12 @@ namespace OHOS
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "currentDialID is %d,name is %s", currentDialID, registeredDials[currentDialID].c_str());
         }
-        return currentDialID;
+        uint16_t id=currentDialID;
+        if(currentDialID<=5)
+        {
+            id--;
+        }
+        return id;
     }
     /* 获取所有表盘Id 每个表盘Id 2个字节 拼接为字符串 */
     int SetDialModel::GetAllDialIDs(char *allidStr)
@@ -202,6 +207,11 @@ namespace OHOS
     /* 判断表盘是否存在*/
     bool SetDialModel::IsDialInstalled(uint16_t ID)
     {
+        if(ID<=4)
+        {
+            ID++;
+        }
+
         if (registeredDials.find(ID) != registeredDials.end())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dial %d is install!", ID);
@@ -216,6 +226,10 @@ namespace OHOS
     /* 删除表盘 */
     bool SetDialModel::UninstallDial(uint16_t ID)
     {
+        if(ID<=4)
+        {
+            ID++;
+        }
         if (registeredDials.find(ID) != registeredDials.end())
         {
             // 默认表盘不删除[日志提醒]
@@ -255,6 +269,11 @@ namespace OHOS
     /*更新表盘*/
     void SetDialModel::UpdateDialSetting(uint16_t ID)
     {
+        if(ID<=4)
+        {
+            ID++;
+        }
+
         if (registeredDials.find(ID) != registeredDials.end())
         {
             std::string dialname = registeredDials[ID]; // 根据ID找到对应的表盘名称
index 2e3086e..7fe6914 100644 (file)
@@ -872,10 +872,6 @@ uint16_t ble_get_dial_id(void)
 
    
    uint16_t id= OHOS::SetDialModel::GetInstance().GetCurrentDialID();
-   if(id<=5)
-   {
-    id--;
-   }
    return id;
 #else
     return 0;