From: luozheng <1732036298@qq.com> Date: Tue, 24 Dec 2024 12:42:05 +0000 (+0800) Subject: 1.解决:#1261闹钟响起时来日常活动目标达成提醒(比如步数达标提醒),提醒界面自动消后,闹钟界面也消失,但闹钟一直响铃(无法关闭)bug X-Git-Tag: v1.3.113-repair_tp~65^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1564%2Fhead;p=mirrors%2FFD230.git 1.解决:#1261闹钟响起时来日常活动目标达成提醒(比如步数达标提醒),提醒界面自动消后,闹钟界面也消失,但闹钟一直响铃(无法关闭)bug 2.查找手表和闹钟弹窗屏蔽按键事件 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp index 5f2bbcae4..f8a5d39fe 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-07-18 14:55:27 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-12-06 17:26:44 + * @LastEditTime: 2024-12-24 18:54:47 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp */ @@ -22,6 +22,7 @@ #include "ui_service.h" #include "dial_sos_c.h" #include "broadcast_feature.h" +#include "notification_manager.h" #define SAVEMODE 0 #define DEBUGOUTPUT 1 @@ -74,6 +75,18 @@ namespace OHOS #define VOLUME_50 50 #define VOLUME_100 100 + //处理闹钟或者查找手表通知 + static bool HandleAlarmOrFindWatchNotify() + { + uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId(); + if (NotificationManager::GetInstance()->HasNotifyShowing() && (notifyId == TOPIC_EVENT_ALARM_RING || notifyId == TOPIC_EVENT_FIND_WATCH)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleAlarmOrFindWatchNotify:notifyId = %d", notifyId); + return true; + } + return false; + } + RebootAndShutdownModel::RebootAndShutdownModel() {} RebootAndShutdownModel::~RebootAndShutdownModel() {} @@ -142,6 +155,8 @@ namespace OHOS static void HandlePowerKeyLongPress(void) { + if (HandleAlarmOrFindWatchNotify()) + return; GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerKeyLongPressCallBack)); } @@ -323,6 +338,8 @@ namespace OHOS static void HandFuncKeyOnLongPress(void) { + if (HandleAlarmOrFindWatchNotify()) + return; // GraphicService::GetInstance()->PostGraphicEvent(std::bind(SOSKeyLongPress)); SOSKeyLongPress(); } @@ -331,7 +348,7 @@ namespace OHOS bool RebootAndShutdownModel::RegisterFuncKeyLongPressEvent(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyLongPressEvent"); - int32_t ret = uapi_button_register_event_cb(SOSKeyLongPress, BUTTON1_LONGPRESS_2S); + int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnLongPress, BUTTON1_LONGPRESS_2S); if (ret != ERRCODE_SUCC) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret); @@ -473,6 +490,8 @@ namespace OHOS static void HandleFuncKeyDoubleClick(void) { + if (HandleAlarmOrFindWatchNotify()) + return; GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyDoubleClickCallBack)); } diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/alarm_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/alarm_notification.h index 79f8828d2..8998d6e66 100755 --- a/code/sdk/application/wearable/service/msg_center/include/notify/alarm_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/alarm_notification.h @@ -34,6 +34,7 @@ void DisableAlarmTimer(AlarmTimerType type); class AlarmViewEventListener : public OHOS::UIView::OnClickListener, public OHOS::UIView::OnLongPressListener, public OHOS::UIView::OnTouchListener, + public RootView::OnKeyActListener, public OHOS::UIView::OnDragListener { public: AlarmViewEventListener(); @@ -62,7 +63,10 @@ public: { return true; } - + bool OnKeyAct(UIView &view, const KeyEvent &event) override + { + return true; + } static uint8_t pre_screen_status; }; }; // namespace OHOS diff --git a/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h b/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h index 9fc0eeb8c..057b350cd 100644 --- a/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h +++ b/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-25 17:31:19 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-12-18 15:22:38 + * @LastEditTime: 2024-12-24 17:51:31 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h */ #ifndef FIND_WATCH_NOTIFICATION_H @@ -62,7 +62,7 @@ namespace OHOS void OnRewindToComplete(); }; - class FindWatchViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener + class FindWatchViewEventListener : public UIView::OnTouchListener, public UIView::OnDragListener,public RootView::OnKeyActListener { public: static FindWatchViewEventListener &GetInstance(void); @@ -87,6 +87,10 @@ namespace OHOS bool OnRelease(UIView &view, const ReleaseEvent &event) override; bool OnDrag(UIView &view, const DragEvent &event); bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override + { + return true; + } const char *GetPath(); 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 992590383..6c61dbfa2 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 @@ -99,7 +99,7 @@ extern "C" { /* 订阅事件设定优先级 */ const PriorityMapper PRI_MAPPER[] = { - {TOPIC_EVENT_ALARM_RING, PRIORITY_TWO}, + {TOPIC_EVENT_ALARM_RING, PRIORITY_ONE}, {TOPIC_EVENT_ON_TIME,PRIORITY_TWO}, {TOPIC_EVENT_NEXTDAY_UPDATE, PRIORITY_TWO}, {TOPIC_EVENT_ACTIVITY_UPDATE,PRIORITY_TWO}, @@ -375,8 +375,8 @@ void MsgCenterNotifyAlarmProc(const Topic topic, Request* req) // The alarm notification is not displayed if the incoming call notification is already being processed if (CheckPriority(topic)) { // AlarmClockModel::GetInstance()->PopInterPlayMusic(); - AlarmViewEventListener::GetInstance()->PopAlarmRing(); - NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO); + // AlarmViewEventListener::GetInstance()->PopAlarmRing(); + NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE); NotificationManager::GetInstance()->ShowNotify(ShowAlarmNotify, static_cast(topic), true); } else { // just delay the alarm diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp index 937abc949..b9730c68f 100755 --- a/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp @@ -89,6 +89,7 @@ namespace OHOS constexpr int16_t DELAY_LABEL_FONT = 25; uint8_t AlarmViewEventListener::pre_screen_status = 0;//屏幕之前的状态 + static OHOS::RootView::OnKeyActListener *g_onKeyActListener = nullptr; void StopNotifyCallback() { @@ -103,7 +104,8 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NoOperateCallback popalarm_time = %d",popalarm_time); if (popalarm_time <= 0) { - AlarmViewEventListener::GetInstance()->CancelAlarmRing(); + // AlarmViewEventListener::GetInstance()->CancelAlarmRing(); + NotificationManager::GetInstance()->StopNotify(); } else { @@ -507,7 +509,10 @@ namespace OHOS g_alarmView->Add(g_StopBtn); /* -------------------------------------------------------------------------- */ StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING, NOTIFY_ONE_SECOND); - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); + + AlarmViewEventListener::GetInstance()->PopAlarmRing(); //闹钟响铃 + g_onKeyActListener = RootView::GetInstance()->GetOnKeyActListener(); + RootView::GetInstance()->SetOnKeyActListener(AlarmViewEventListener::GetInstance()); AlarmViewEventListener::pre_screen_status = uapi_dev_runtime_get_screen_always_on_status();//获取闹钟弹窗之前是否是长亮屏状态 if(!AlarmViewEventListener::pre_screen_status) @@ -523,7 +528,7 @@ namespace OHOS { if (g_alarmView != nullptr) { - DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING); + AlarmViewEventListener::GetInstance()->CancelAlarmRing();//取消闹钟响铃 g_alarmView->RemoveAll(); if (g_mainLable != nullptr) { @@ -550,8 +555,9 @@ namespace OHOS delete g_StopBtn; g_StopBtn = nullptr; } + RootView::GetInstance()->SetOnKeyActListener(g_onKeyActListener); RootView::GetInstance()->Remove(g_alarmView); - delete g_alarmView; + delete g_alarmView; g_alarmView = nullptr; if(!AlarmViewEventListener::pre_screen_status) //如果闹钟弹窗之前不是长亮屏状态,就取消闹钟弹窗设置的常亮屏 { @@ -607,7 +613,8 @@ namespace OHOS { if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0) { - CancelAlarmRing(); + // CancelAlarmRing(); + NotificationManager::GetInstance()->StopNotify(); } } return true; @@ -645,7 +652,8 @@ namespace OHOS if (strcmp(view.GetViewId(), ALARM_IMAGE_STOP) == 0) // 点击停止闹钟响铃 { // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing(); - CancelAlarmRing(); + // CancelAlarmRing(); + NotificationManager::GetInstance()->StopNotify(); } return true; } @@ -666,7 +674,7 @@ namespace OHOS DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING); FindWatchViewEventListener::GetInstance().PopInterCancelMusic(); AlarmClockModel::GetInstance()->CancelAlarmRing(); - NotificationManager::GetInstance()->StopNotify(); + // NotificationManager::GetInstance()->StopNotify(); //如果闹钟铃声停止播放成功,记录该事件 uapi_save_runtime_log(RUNTIME_LOG_RING_PLAY_STOP_ALARM);//TOOD* diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp index e8209845c..7d7100634 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-03-25 17:33:47 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-12-18 15:23:13 + * @LastEditTime: 2024-12-24 18:09:10 * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp * @details:实现查找手表的功能一般需要手表和智能手机之间的配合,通常是通过手机上的应用(App)或其他设备发送指令给手表,触发手表的查找功能。 * 以下是基本的实现步骤: @@ -48,6 +48,7 @@ namespace OHOS UIViewGroup *FindWatchGroupView{nullptr}; UIButton *FindWatchButton{nullptr}; uint8_t FindWatchViewEventListener::pre_screen_status = 0;//屏幕之前的状态 + static OHOS::RootView::OnKeyActListener *g_onKeyActListener = nullptr; FindWatchViewEventListener::FindWatchViewEventListener() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FindWatchViewEventListener::FindWatchViewEventListener"); @@ -475,6 +476,9 @@ namespace OHOS FindWatchViewEventListener::GetInstance().FindWatch_StartTimer(700); FindWatchViewEventListener::GetInstance().SetScreenBrightness(); + g_onKeyActListener = RootView::GetInstance()->GetOnKeyActListener(); + RootView::GetInstance()->SetOnKeyActListener(&FindWatchViewEventListener::GetInstance()); + FindWatchViewEventListener::pre_screen_status = uapi_dev_runtime_get_screen_always_on_status();//获取查找手表之前是否是长亮屏状态 if(!FindWatchViewEventListener::pre_screen_status) { @@ -497,6 +501,7 @@ namespace OHOS delete FindWatchButton; FindWatchButton = nullptr; + RootView::GetInstance()->SetOnKeyActListener(g_onKeyActListener); RootView::GetInstance()->Remove(FindWatchGroupView); delete FindWatchGroupView;