From a9e809908d59d74a931ddbae2b671205a7c19718 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E8=A2=81=E6=B8=85=E6=A2=A6?= <3449750381@qq.com> Date: Tue, 16 Jul 2024 01:35:46 +0000 Subject: [PATCH] Merge #521 into sdk602patch0626 from refs/changes/521/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 袁清梦 * refs/changes/521/head: (4 commits squashed) - 修复主界面上拉消息item的index获取异常 - 睡眠 消息弹窗去除外部亮屏函数,统一使用UIService亮屏 - Merge branch 'sdk602patch0626' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0626 - 取消早安闹钟一直响铃 Signed-off-by: Caisking <3449750381@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/521 --- .../src/AlarmClockTimerConfig.cpp | 4 +- .../message/src/MessageControlPresenter.cpp | 28 ++++++-------- .../nativeui/message/src/MessageModel.cpp | 4 +- .../nativeui/message/src/MessagePresenter.cpp | 29 +++------------ .../message/src/MessageShowPresenter.cpp | 7 +++- .../msg_center/src/msg_center_customer.cpp | 37 +++++++++---------- .../src/notify/message_notification.cpp | 4 ++ .../src/notify/sleep_notification.cpp | 11 ++++-- 8 files changed, 57 insertions(+), 67 deletions(-) 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 cb59e2fae..908a720d6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -84,6 +84,7 @@ extern "C" sleep_time_min = sleep_time & 0x0000FFFF; wake_time_hour = (wake_up_time & 0xFFFF0000) >> 16; wake_time_min = wake_up_time & 0x0000FFFF; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleep_time_hour:%d sleep_time_min:%d wake_time_hour:%d wake_time_min:%d", sleep_time_hour, sleep_time_min, wake_time_hour,wake_time_min); } void set_sedentary_data(void) @@ -124,7 +125,7 @@ extern "C" sleep_notify_time_hour = (sleep_notify_time_hour < 0) ? 23 : sleep_notify_time_hour; // 处理从0点前20分钟的情况,变为前一天的23点40分 sleep_notify_time = (sleep_notify_time_hour << 16) | sleep_notify_time_min; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleep_time_hour:%d sleep_time_min:%d sleep_notify_time:%d", sleep_notify_time_hour, sleep_notify_time_min, sleep_notify_time); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sleep_notify_time_hour:%d sleep_notify_time_min:%d sleep_notify_time:%d", sleep_notify_time_hour, sleep_notify_time_min, sleep_notify_time); } void AlarmEventPublish(uint16_t topic, uint8_t *data, uint32_t size) { @@ -340,6 +341,7 @@ extern "C" OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::SLEPP); if (curTime.tm_hour == sleep_time_hour && curTime.tm_min == sleep_time_min && curTime.tm_sec == 0) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "要睡觉啦!"); AlarmEventPublish(TOPIC_EVENT_SLEEPNOTE, (uint8_t *)sleep_notify_time, 4); OHOS::SleepModel::GetInstance().DeleteSleepData(); // 清空前一天睡眠数据 } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp index f2b1c5526..494fd2bfb 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-22 11:36:16 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-15 16:53:35 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageControlPresenter.cpp + */ /*** * @Date: 2024-06-22 11:36:16 * @LastEditors: Caisking 3449750381@qq.com @@ -44,11 +50,6 @@ namespace OHOS { UNUSED(event); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MessageControlView::OnClick %s", view.GetViewId()); - if (strcmp(view.GetViewId(), MAINMESSAGEVIEW) != 0) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: View is not List"); - return false; - } if (!MessageModel::GetInstance().HasDataVector()) { @@ -69,18 +70,13 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error: Invalid view type."); return false; } - - int index1 = MessageCardView::GetInstance()->GetList()->GetViewIndex(); - int index2 = p_MessageItemView->GetMessageListIndex(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "index1 is %d, index2 is %d", index1, index2); - if (index2 > -1 && index2 < 11) - { - MessageModel::GetInstance().SetCurrentIndex(index2); - // 切换到详情界面 - NativeAbility::GetInstance().ChangeSlice(VIEW_MESSAGE_SHOW); - } + int index = p_MessageItemView->GetMessageListIndex(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "index is %d", index); - return true; // 返回 true 表示点击事件处理成功 + MessageModel::GetInstance().SetCurrentIndex(index); + MessageModel::GetInstance().SetMessageAsRead(); + NativeAbility::GetInstance().ChangeSlice(VIEW_MESSAGE_SHOW); // 切换到详情界面 + return true; } } // namespace OHOS \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp index 1dda147fe..f27f942e8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp @@ -212,7 +212,7 @@ namespace OHOS data.labelDetails = labelDetails->valuestring; data.labelTitle = labelTitle->valuestring; data.timestamp = timestamp->valuedouble; - + char labelTime[20]; if (uapi_get_TIME_STR(data.timestamp, labelTime, '.', ':', DATE_Y_M_D_H_M) != ERRCODE_SUCC) { @@ -309,6 +309,8 @@ namespace OHOS // 设置当前项[数组下标] void MessageModel::SetCurrentIndex(uint8_t index) { + if (index < 0 || index > MaxMessageListCount) + return; numberOfItems = MessageVector.size(); currentIndex_ = numberOfItems - index - 1; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp index 0de31f895..51924c7fd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp @@ -1,21 +1,4 @@ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-18 17:26:05 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-06-15 15:56:50 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp - */ -/*** - * @Date: 2024-04-15 10:55:58 - * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-04-23 15:38:33 - * @FilePath: /XTS_FD230/FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessagePresenter.cpp - */ + #include "AppViewIDs.h" #include "components/ui_label_ext.h" @@ -94,14 +77,12 @@ namespace OHOS { NativeAbility::GetInstance().Back(); } - if (!MessageModel::GetInstance().GetPopupViewState()) + // 向下回到主界面 + if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) { - // 向下回到主界面 - if (event.GetDragDirection() == DragEvent::DIRECTION_TOP_TO_BOTTOM) - { - NativeAbility::GetInstance().EnterSlice(VIEW_MAIN); - } + NativeAbility::GetInstance().EnterSlice(VIEW_MAIN); } + return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp index 692688cfa..25860de82 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-06-17 19:39:36 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-07-15 17:05:36 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/message/src/MessageShowPresenter.cpp + */ /*** * @Date: 2024-06-17 19:39:36 * @LastEditors: Caisking 3449750381@qq.com @@ -80,7 +86,6 @@ namespace OHOS { NativeAbility::GetInstance().ChangeSlice(VIEW_MESSAGE); } - return true; } diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index b34fcd810..8837100b3 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -270,6 +270,8 @@ static OHOS::UIViewGroup* showSleepNotify(void) { return OHOS::CreateSleepNotifyView(); } + + void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) { unused(req); @@ -286,7 +288,6 @@ void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) } } - void MsgCenterNotifyONtimeProc(const Topic topic, Request* req) { unused(req); @@ -447,7 +448,7 @@ void MsgCenterNotifyNextDayProc(const Topic topic, Request* req) if(!ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP)) { - //未设置睡眠监控 nextday进行清除消息。 + //未设置睡眠监控 nextday进行清除睡眠数据。 SleepModel::GetInstance().DeleteSleepData(); } @@ -640,15 +641,9 @@ void MsgCenterNotifyMessageProc(const Topic topic, Request* req) unused(topic); unused(req); WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyMessageProc !"); - //亮屏显示新信息弹窗 - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); - } - display_api->set_screen_set_keepon_timeout(1000*5); - // NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); - NotificationManager::GetInstance()->ShowNotify(showMessageNotify, (uint16_t)topic, true); + if (CheckPriority(topic)) { + NotificationManager::GetInstance()->ShowNotify(showMessageNotify, (uint16_t)topic, true); + } } //睡眠提醒通知 @@ -656,15 +651,17 @@ void MsgCenterNotifySleepProc(const Topic topic, Request* req) { unused(topic); unused(req); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifySleepProc !"); - //亮屏显示新信息弹窗 - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - if (display_api->get_screen_state() != SCREEN_ON) - { - display_api->turn_on_screen(); - } - display_api->set_screen_set_keepon_timeout(1000*5); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifySleepProc %d!",SleepModel::GetInstance().get_sleep_state()); + + if(SleepModel::GetInstance().get_sleep_state()==SLEEPSTATE::WAKE) + { + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + AlarmClockModel::GetInstance()->PopInterPlayMusic(); + } + else + { + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_THREE); + } NotificationManager::GetInstance()->ShowNotify(showSleepNotify, (uint16_t)topic, true); } #endif diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp index b5d24a62a..0a1f7ff5b 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp @@ -199,6 +199,9 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create MessageGroupView succeed!!"); // 震动提醒 custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); + // 亮屏操作 + int32_t timeout = -1; + SendMsgToUIService(SCREEN_TURN_ON_TO_UI, 0, &timeout, sizeof(int32_t)); return MessageGroupView; } /*释放消息弹窗视图*/ @@ -226,6 +229,7 @@ namespace OHOS MessageGroupView = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Free MessageView succeed!!"); } + SendMsgToUIService(SCREEN_TURN_OFF_TO_UI, 0, NULL, 0); return; } } \ No newline at end of file diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp index b461244d3..b465e1f16 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp @@ -78,14 +78,12 @@ namespace OHOS break; case SLEEPSTATE::SLEPP: titleStr = SleepModel::GetInstance().get_sleep_notifiy(); - textId = STR_DISTURBNOTE; + textId = STR_DISTURBNOTE; break; case SLEEPSTATE::WAKE: titleStr = SleepModel::GetInstance().get_wake_notifiy(); textId = STR_MORNNING; - SetAlarmClockView(); // 设置为早安视图 - SleepViewEventListener::GetInstance().PopInterPlayMusic(); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + SetAlarmClockView(); // 设置为早安视图 return SleepGroupView; break; default: @@ -149,6 +147,9 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!"); custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒 + // 亮屏操作 + int32_t timeout = -1; + SendMsgToUIService(SCREEN_TURN_ON_TO_UI, 0, &timeout, sizeof(int32_t)); return SleepGroupView; } @@ -236,6 +237,7 @@ namespace OHOS delete SleepGroupView; SleepGroupView = nullptr; WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Free SleepView succeed!!"); + SendMsgToUIService(SCREEN_TURN_OFF_TO_UI, 0, NULL, 0); } return; } @@ -382,6 +384,7 @@ namespace OHOS */ int SleepViewEventListener::SleepRingPlayStop(void) { + AlarmClockModel::GetInstance()->PopInterCancelMusic(); int32_t ret = 0; AudioManager &amIntance = AudioManager::GetInstance(); if (playerCtr.get() == nullptr) -- 2.17.1