增加3次连续震动,给目标达成 1261/4
authorhcj <1224667075@qq.com>
Sat, 26 Oct 2024 01:56:43 +0000 (09:56 +0800)
committerhcj <1224667075@qq.com>
Sat, 26 Oct 2024 01:56:43 +0000 (09:56 +0800)
code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp

index 880c9bc..348a9c0 100644 (file)
@@ -19,6 +19,8 @@
 #include "upg.h"
 #include "custom_runtime.h"
 #include "vibrator_service.h"
+#include "osal_timer.h"
+#include "cmsis_os2.h"
 namespace OHOS
 {
 
@@ -38,6 +40,8 @@ namespace OHOS
     static ImageAnimatorInfo *winimageAnimatorInfo{nullptr};
     static std::string winbasePath = "/user/res/Training/training_GIF/win/";
 
+      static  osTimerId_t  GoalviewShow_timer= NULL;
+
     void Freegoalview(void)
     {
        if (getView != nullptr) 
@@ -82,6 +86,18 @@ namespace OHOS
             labelgettag = nullptr;
         }
 
+        if(GoalviewShow_timer)
+        {
+            osTimerStop(GoalviewShow_timer);
+            osStatus_t  ret = osTimerDelete(GoalviewShow_timer);
+            if (ret != osOK) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed  ret = %lx!", ret);
+                return;
+            }
+            GoalviewShow_timer = nullptr;
+        }
+
+
         RootView::GetInstance()->Remove(getView);
 
         delete getView;
@@ -266,12 +282,63 @@ namespace OHOS
     getView->Add(imageAnimator);
     }
 
+    static uint8_t GoalviewShowCallBack_FALG=0;
+    
+  
+    static void GoalviewShowCallBack(int data)
+    {
+        GoalviewShowCallBack_FALG--;
+        if(GoalviewShowCallBack_FALG)
+        {
+            if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
+            {
+                ui_api_vibrate_once_func();
+            }
+        }
+        if(GoalviewShowCallBack_FALG==0)
+        {
+            if(GoalviewShow_timer)
+            {
+                osTimerStop(GoalviewShow_timer);
+                osStatus_t  ret = osTimerDelete(GoalviewShow_timer);
+                if (ret != osOK) {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed  ret = %lx!", ret);
+                    return;
+                }
+                GoalviewShow_timer = nullptr;
+            }
+        }
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hintdialtimerCallBack ??????!");
+        
+    }
+
+
     UIViewGroup *GoalviewShow()
     {
-        // 震动一次
-        if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get()))
+        // 震动3次
+
+        if(GoalviewShow_timer)
         {
-            ui_api_vibrate_once_func();
+            osTimerStop(GoalviewShow_timer);
+            osStatus_t  ret = osTimerDelete(GoalviewShow_timer);
+            if (ret != osOK) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Disatransmitting_timer failed  ret = %lx!", ret);
+                return NULL;
+            }
+            GoalviewShow_timer = nullptr;
+        }
+
+        uint32_t tick;
+        osStatus_t retTimer;
+        GoalviewShowCallBack_FALG=3;
+        GoalviewShow_timer = osTimerNew((osTimerFunc_t)GoalviewShowCallBack, osTimerPeriodic, NULL, NULL);
+        tick =osMs2Tick(1000);// osMs2Tick(1000);
+        retTimer = osTimerStart(GoalviewShow_timer, tick);
+        if (retTimer != osOK && GoalviewShow_timer != NULL) {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"StartCallTimer osTimerStart failed, ret = %lx!!", retTimer);
+            osTimerDelete(GoalviewShow_timer);
+            GoalviewShow_timer = NULL;
+            return NULL;
         }