From 3013c53d2515f3ac3c214f051f9f6ea963ec47ae Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 24 Dec 2024 20:42:05 +0800 Subject: [PATCH] =?utf8?q?1.=E8=A7=A3=E5=86=B3=EF=BC=9A#1261=E9=97=B9?= =?utf8?q?=E9=92=9F=E5=93=8D=E8=B5=B7=E6=97=B6=E6=9D=A5=E6=97=A5=E5=B8=B8?= =?utf8?q?=E6=B4=BB=E5=8A=A8=E7=9B=AE=E6=A0=87=E8=BE=BE=E6=88=90=E6=8F=90?= =?utf8?q?=E9=86=92=EF=BC=88=E6=AF=94=E5=A6=82=E6=AD=A5=E6=95=B0=E8=BE=BE?= =?utf8?q?=E6=A0=87=E6=8F=90=E9=86=92=EF=BC=89=EF=BC=8C=E6=8F=90=E9=86=92?= =?utf8?q?=E7=95=8C=E9=9D=A2=E8=87=AA=E5=8A=A8=E6=B6=88=E5=90=8E=EF=BC=8C?= =?utf8?q?=E9=97=B9=E9=92=9F=E7=95=8C=E9=9D=A2=E4=B9=9F=E6=B6=88=E5=A4=B1?= =?utf8?q?=EF=BC=8C=E4=BD=86=E9=97=B9=E9=92=9F=E4=B8=80=E7=9B=B4=E5=93=8D?= =?utf8?q?=E9=93=83=EF=BC=88=E6=97=A0=E6=B3=95=E5=85=B3=E9=97=AD=EF=BC=89b?= =?utf8?q?ug=202.=E6=9F=A5=E6=89=BE=E6=89=8B=E8=A1=A8=E5=92=8C=E9=97=B9?= =?utf8?q?=E9=92=9F=E5=BC=B9=E7=AA=97=E5=B1=8F=E8=94=BD=E6=8C=89=E9=94=AE?= =?utf8?q?=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/RebootAndShutdownModel.cpp | 23 +++++++++++++++++-- .../include/notify/alarm_notification.h | 6 ++++- .../include/notify/findwatch_notification.h | 8 +++++-- .../msg_center/src/msg_center_customer.cpp | 6 ++--- .../src/notify/alarm_notification.cpp | 22 ++++++++++++------ .../src/notify/findwatch_notification.cpp | 7 +++++- 6 files changed, 56 insertions(+), 16 deletions(-) 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; -- 2.17.1