修复目标达成异常弹出BUG 1171/1
authorhcj <1224667075@qq.com>
Sat, 12 Oct 2024 09:02:10 +0000 (17:02 +0800)
committerhcj <1224667075@qq.com>
Sat, 12 Oct 2024 09:02:10 +0000 (17:02 +0800)
code/sdk/application/wearable/fd230app/nativeui/activity/include/ActivityModel.h
code/sdk/application/wearable/fd230app/nativeui/activity/src/ActivityModel.cpp
code/sdk/application/wearable/fd230app/nativeui/goal/src/goalmodel.cpp
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp

index 7c694f9..db661a3 100644 (file)
@@ -47,8 +47,8 @@ public:
 private:\r
     ActivityModel();\r
     bool InitStepData(void);\r
-    uint32 stepCounter;\r
-    uint32 lastSavedValue;\r
+    uint32 stepCounter=0;\r
+    uint32 lastSavedValue=0;\r
     int weekToday;\r
 };\r
 }\r
index 4b7ea84..925fae3 100644 (file)
 #include "DialModelCalorie.h"
 #include "DialModelDistance.h"
 #include "cywee_service.h"
+#include "custom_runtime.h"
+#include "goal/include/goalmodel.h"
+#include "goal/include/goalview.h"
+#include "goal/include/goalother.h"
+#include "goal_notification.h"
+#include "custom_utils.h"
+// #include "goal/include/goalmodel.h"
 using namespace std;
 
 #ifdef __cplusplus
@@ -111,6 +118,8 @@ static void RefreshStepControls(const uint32_t &value, const uint16 &msgId)
     }
 }
 
+static uint8_t goal_type=0;
+
 static void Notify(void *args, const Topic topic, Request* request)
 {
     UNUSED(args);
@@ -140,6 +149,80 @@ static void Notify(void *args, const Topic topic, Request* request)
         RefreshStepControls(counter, TOPIC_EVENT_STEPDATA_UPDATE);
     }
 
+    #ifdef FD230
+        if(OHOS::GoalView::GetInstance())
+        {
+            OHOS::GoalView::GetInstance()->GoalViewrefresh();
+        }
+        if(OHOS::GoalotherView::GetInstance())
+        {
+            OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
+        }
+
+        if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
+        {
+
+            goal_type=GOAL_STEP;
+            if(get_Is_shouw_falg(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_step_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
+        {
+            goal_type=GOAL_DISTANCE;
+            if(get_Is_shouw_falg(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
+        {
+            goal_type=GOAL_FAT;
+            if(get_Is_shouw_falg(goal_type))
+            {   
+                if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
+        {
+            goal_type=GOAL_STAND;
+            if(get_Is_shouw_falg(goal_type))
+            {   
+            if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+        if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
+        {
+            goal_type=GOAL_CALOREIE;
+            if(get_Is_shouw_falg(goal_type))
+            {   
+            if(OHOS::GoalModel::GetInstance().get_other_goal_show())
+                {
+                    CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
+                }
+            }
+        }
+
+#endif
+
     if (request->msgId == TOPIC_EVENT_NEXTDAY_UPDATE) {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "STEP:TOPIC_EVENT_NEXTDAY_UPDATE");
 
index c1e1384..a4fc280 100644 (file)
@@ -43,7 +43,7 @@ namespace OHOS
    uint8_t GoalModel::getstepvalue()
    {
       int stepgoal = step;
-      int stepdata = OHOS::ActivityModel::GetInstance()->GetStepCounter();
+      int stepdata = get_step_data();//OHOS::ActivityModel::GetInstance()->GetStepCounter();
       // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%d %d %f ",stepdata,stepgoal,((float)stepdata/(float)stepgoal) * 100);
       uint8_t value = ((float)stepdata / (float)stepgoal) * 100;
 
@@ -66,7 +66,7 @@ namespace OHOS
    char stepnewstr[20];
    char *GoalModel::getstepnew()
    {
-      int stepdata = OHOS::ActivityModel::GetInstance()->GetStepCounter();
+      int stepdata = get_step_data();
       memset((void *)stepnewstr, 0, 20);
       sprintf_s(stepnewstr, 20, "%d", stepdata);
       return stepnewstr;
index 0b3241a..3c0d04a 100644 (file)
@@ -398,83 +398,11 @@ void MsgCenterNotifygoalnotificationviewProc(const Topic topic, Request* req)
   
 }
 
-  static uint8_t goal_type=0;
+
 void MsgCenterNotifystepProc(const Topic topic, Request* req)
 {
     unused(req);
-#ifdef FD230
-    if(OHOS::GoalView::GetInstance())
-    {
-        OHOS::GoalView::GetInstance()->GoalViewrefresh();
-    }
-    if(OHOS::GoalotherView::GetInstance())
-    {
-        OHOS::GoalotherView::GetInstance()->GoalViewrefresh();
-    }
-
-     if(OHOS::GoalModel::GetInstance().getstepvalue()>=100)
-    {
-
-        goal_type=GOAL_STEP;
-        if(get_Is_shouw_falg(goal_type))
-        {   
-            if(OHOS::GoalModel::GetInstance().get_step_goal_show())
-            {
-                CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-            }
-        }
-    }
-
-    if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done())
-    {
-        goal_type=GOAL_DISTANCE;
-        if(get_Is_shouw_falg(goal_type))
-        {   
-            if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-            {
-                 CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-            }
-           
-        }
-    }
-
-    if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done())
-    {
-        goal_type=GOAL_FAT;
-        if(get_Is_shouw_falg(goal_type))
-        {   
-            if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-            {
-                 CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-            }
-        }
-    }
-
-    if(OHOS::GoalModel::GetInstance().is_goal_stand_done())
-    {
-        goal_type=GOAL_STAND;
-        if(get_Is_shouw_falg(goal_type))
-        {   
-           if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-            {
-                 CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-            }
-        }
-    }
 
-    if(OHOS::GoalModel::GetInstance().is_goal_calories_done())
-    {
-        goal_type=GOAL_CALOREIE;
-        if(get_Is_shouw_falg(goal_type))
-        {   
-           if(OHOS::GoalModel::GetInstance().get_other_goal_show())
-            {
-                 CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1);
-            }
-        }
-    }
-
-#endif
     // The alarm notification is not displayed if the incoming call notification is already being processed
    // cywee_save_data();
 
@@ -1037,12 +965,13 @@ void MsgCenterNotifyCat1dialProc(const Topic topic, Request* req)
         NotificationManager::GetInstance()->ShowNotify(showSOSNotify, (uint16_t)topic, true);
         return;
     }
-        cat1_call_dial(call_data);
-        CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len);
-        CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
+    
+    cat1_call_dial(call_data);
+    CallerLogModel::GetInstance()->SetoperateNumber(call_data,req->len);
+    CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
 
-        cat1_phone_state_change_cb(OPERATE_DIALING);
-        NotificationManager::GetInstance()->SetWatchCallStatus(true);
+    cat1_phone_state_change_cb(OPERATE_DIALING);
+    NotificationManager::GetInstance()->SetWatchCallStatus(true);
     }
     free(call_data);
 }