From: Caisking <3449750381@qq.com> Date: Tue, 9 Jul 2024 08:03:29 +0000 (+0800) Subject: 修复睡眠弹窗icon消失 X-Git-Tag: release_V1.2.70_20241020_135402~833^2~4^2~3 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=18b65ac5ae840320a95b057d550b576906dd690c;p=mirrors%2FFD230.git 修复睡眠弹窗icon消失 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 5754880bb..1bab4d49a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -59,20 +59,20 @@ extern "C" static int sleep_notify_time_min = 0; static int sleep_notify_time_hour = 0; - #define SEDENTARY_TIME_RANGE (((curTime.tm_hour > sedentary_start_hour) || (curTime.tm_hour == sedentary_start_hour && curTime.tm_min >= sedentary_start_min)) && \ - ((curTime.tm_hour < sedentary_stop_hour) || (curTime.tm_hour == sedentary_stop_hour && curTime.tm_min < sedentary_stop_min))) - - #define WAKE_TIME_RANGE (((wake_time_hour < sleep_time_hour) && \ - ((curTime.tm_hour > wake_time_hour) || \ - (curTime.tm_hour == wake_time_hour && curTime.tm_min >= wake_time_min)) && \ - ((curTime.tm_hour < sleep_time_hour) || \ - (curTime.tm_hour == sleep_time_hour && curTime.tm_min < sleep_time_min))) || \ - ((wake_time_hour >= sleep_time_hour) && \ - (((curTime.tm_hour > wake_time_hour) || \ - (curTime.tm_hour == wake_time_hour && curTime.tm_min >= wake_time_min)) || \ - ((curTime.tm_hour < sleep_time_hour) || \ - (curTime.tm_hour == sleep_time_hour && curTime.tm_min < sleep_time_min))) || \ - ((curTime.tm_hour > wake_time_hour) && (curTime.tm_hour < sleep_time_hour)))) +#define SEDENTARY_TIME_RANGE (((curTime.tm_hour > sedentary_start_hour) || (curTime.tm_hour == sedentary_start_hour && curTime.tm_min >= sedentary_start_min)) && \ + ((curTime.tm_hour < sedentary_stop_hour) || (curTime.tm_hour == sedentary_stop_hour && curTime.tm_min < sedentary_stop_min))) + +#define WAKE_TIME_RANGE (((wake_time_hour < sleep_time_hour) && \ + ((curTime.tm_hour > wake_time_hour) || \ + (curTime.tm_hour == wake_time_hour && curTime.tm_min >= wake_time_min)) && \ + ((curTime.tm_hour < sleep_time_hour) || \ + (curTime.tm_hour == sleep_time_hour && curTime.tm_min < sleep_time_min))) || \ + ((wake_time_hour >= sleep_time_hour) && \ + (((curTime.tm_hour > wake_time_hour) || \ + (curTime.tm_hour == wake_time_hour && curTime.tm_min >= wake_time_min)) || \ + ((curTime.tm_hour < sleep_time_hour) || \ + (curTime.tm_hour == sleep_time_hour && curTime.tm_min < sleep_time_min))) || \ + ((curTime.tm_hour > wake_time_hour) && (curTime.tm_hour < sleep_time_hour)))) // 设置目标睡眠时间 void set_sleep_and_wake_time(void) @@ -116,7 +116,7 @@ extern "C" sleep_notify_time_min = (goal_min >= SLEPPNOTIFY) ? goal_min - SLEPPNOTIFY : ((goal_min + 60) - SLEPPNOTIFY); // 避免分钟数为负 sleep_notify_time_hour = goal_hour; if (goal_min < SLEPPNOTIFY) - { // 如果需要借位 + { // 如果需要借位 sleep_notify_time_hour -= 1; // 小时减1 } // 确保小时数正确 @@ -299,7 +299,7 @@ extern "C" // 提醒一次 if ((curTime.tm_hour == sleep_notify_time_hour) && (curTime.tm_min == sleep_notify_time_min) && (curTime.tm_sec == 0)) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "It's bedtime in 20 minutes"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "It's bedtime in 20 minutes"); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "20分钟后要睡觉啦!"); AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); // 设置状态为睡眠提醒 @@ -313,21 +313,21 @@ extern "C" uapi_dev_runtime_set_nap_status(1); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "起床啦!"); - if(curTime.tm_hour == wake_time_hour && curTime.tm_min == wake_time_min && curTime.tm_sec == 0) + if (curTime.tm_hour == wake_time_hour && curTime.tm_min == wake_time_min && curTime.tm_sec == 0) { // 早安提醒 AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + // 设置状态为小睡 + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WAKE); } - if(OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if (OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) { - OHOS::ConfigModel::GetInstance()->SetDnotdisturb(false);//关闭勿扰 + OHOS::ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰 } - // 设置状态为小睡 - OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WAKE); LOS_Msleep(1000); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL); } - //进入睡眠模式 + // 进入睡眠模式 else if ((!WAKE_TIME_RANGE) && (uapi_dev_runtime_get_sleep_status() == 0)) { uapi_dev_runtime_set_sleep_status(1); @@ -335,10 +335,17 @@ extern "C" do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); // 睡眠弹窗 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "要睡觉啦!"); - AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); - // 设置状态为睡眠 - OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEPP); - OHOS::SleepModel::GetInstance().DeleteSleepData(); // 清空前一天睡眠数据 + if (curTime.tm_hour == sleep_time_hour && curTime.tm_min == sleep_time_min && curTime.tm_sec == 0) + { + AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); + // 设置状态为睡眠 + OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEPP); + OHOS::SleepModel::GetInstance().DeleteSleepData(); // 清空前一天睡眠数据 + } + if (!OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + { + OHOS::ConfigModel::GetInstance()->SetDnotdisturb(true); // 开启勿扰 + } LOS_Msleep(1000); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SLEEPING_MODE, NULL); } diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h index a72fb113b..a6b19aa04 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/notification_manager.h @@ -29,6 +29,8 @@ #include "findwatch_notification.h" #include "drinkReminder_notification.h" #include "sedentaryReminder_notification.h" +#include "message_notification.h" +#include "sleep_notification.h" constexpr uint16_t HALF_SCREEN = 2; constexpr int16_t NOTIFY_PRIORITY_DEFAULT = 4; diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp index 29c55c339..c912dd3f9 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-11 16:12:53 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-09 15:44:49 + * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/notification_manager_customer.cpp + */ /* * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-07 18:27:45 @@ -43,6 +49,8 @@ void NotificationManager::FreeNotifyViews() FreelowPower(); FreeDrinkReminderView(); FreeSedentaryReminderView(); + FreeMessageView(); + FreeSleepView(); #ifdef SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION //Do Free notification view #endif