From 1877e8af334ac3a8ff2d21a843203ef633286b6a Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 26 Oct 2024 09:56:43 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A03=E6=AC=A1=E8=BF=9E=E7=BB=AD?= =?utf8?q?=E9=9C=87=E5=8A=A8=EF=BC=8C=E7=BB=99=E7=9B=AE=E6=A0=87=E8=BE=BE?= =?utf8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/notify/goal_notification.cpp | 73 ++++++++++++++++++- 1 file changed, 70 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp index 880c9bc04..348a9c0e6 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/goal_notification.cpp @@ -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; } -- 2.17.1