#656,解决,手表,闹钟偶现0000闹钟提醒bug
authorluozheng <1732036298@qq.com>
Sat, 14 Sep 2024 03:10:01 +0000 (11:10 +0800)
committerluozheng <1732036298@qq.com>
Sat, 14 Sep 2024 03:10:01 +0000 (11:10 +0800)
code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp
code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp
code/sdk/application/wearable/service/msg_center/include/notify/alarm_notification.h
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/alarm_notification.cpp

index 6bb071b..5361975 100644 (file)
@@ -124,6 +124,7 @@ public:
 \r
     void UpdateAlarmInfoByAppSet(void);\r
     void CancelAlarmRing();\r
+    void DelayAlarmRing();\r
 \r
 private:\r
     void SetAlarmId(uint8_t id);\r
index c0cb884..d3387cb 100644 (file)
@@ -1097,6 +1097,18 @@ void AlarmClockModel::CancelAlarmRing()
     }
 }
 
+void AlarmClockModel::DelayAlarmRing()
+{
+    uint8_t alarmId = 0;
+    bool alarmStatus;
+    alarmStatus = AlarmClockModel::GetInstance()->GetListenClockId(&alarmId);
+    if (!alarmStatus) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DelayAlarmRing get alarm Id false!");
+        return;
+    }
+    AlarmClockModel::GetInstance()->SetDelayAlarm(alarmId);
+}
+
 bool AlarmPlayerListener::IsPaused()
 {
     return isPaused_;
index 7b8214e..8a3f4ff 100644 (file)
@@ -46,9 +46,10 @@ namespace OHOS
         uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
         if (NotificationManager::GetInstance()->HasNotifyShowing() && notifyId == TOPIC_EVENT_ALARM_RING)
         {
-            AlarmClockModel::GetInstance()->AlarmGetClockNum();
-            AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
-            NotificationManager::GetInstance()->StopNotify();
+            // AlarmClockModel::GetInstance()->AlarmGetClockNum();
+            // AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+            // NotificationManager::GetInstance()->StopNotify();
+            return;
         }
     }
 
index 7fe7435..48a98bd 100755 (executable)
@@ -39,6 +39,9 @@ public:
     AlarmViewEventListener();
     virtual ~AlarmViewEventListener();
     static AlarmViewEventListener *GetInstance(void);
+    void PopAlarmRing();
+    void CancelAlarmRing();
+    void DelayAlarmRing();
     bool OnDrag(UIView& view, const DragEvent& event) override;
     bool OnDragEnd(OHOS::UIView& view, const OHOS::DragEvent& event) override;
     bool OnClick(OHOS::UIView& view, const OHOS::ClickEvent& event) override;
index aa954be..4ee3333 100644 (file)
@@ -316,14 +316,15 @@ 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();
-        FindWatchViewEventListener::GetInstance().PopInterPlayMusic("/music/ring/alarm.mp3");//播放铃声
+        AlarmViewEventListener::GetInstance()->PopAlarmRing();
         NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
         NotificationManager::GetInstance()->ShowNotify(ShowAlarmNotify, static_cast<uint16_t>(topic), true);
     } else {
         // just delay the alarm
         WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "just delay the alarm");
-        AlarmClockModel::GetInstance()->AlarmGetClockNum();
-        AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+        // AlarmClockModel::GetInstance()->AlarmGetClockNum();
+        // AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+        AlarmViewEventListener::GetInstance()->DelayAlarmRing();
     }
 }
 
@@ -880,7 +881,8 @@ void MsgCenterNotifyCat1CallConnectedProc(const Topic topic, Request* req)
         return;
     }
     SetMicMute(false);
-    AlarmClockModel::GetInstance()->AlarmPlayerStop();
+    // AlarmClockModel::GetInstance()->AlarmPlayerStop()
+    AlarmViewEventListener::GetInstance()->CancelAlarmRing();
     NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
     cat1_phone_state_change_cb(OPERATE_WATCH_ACTIVE);
     CallerLogModel::GetInstance()->SetCallSource(CallerLogModel::CallSource::CallSourceCat1);
@@ -928,7 +930,8 @@ void MsgCenterNotifyCat1CallEndedProc(const Topic topic, Request* req)
     unused(topic);
     unused(req);
     // just stop the notify
-    AlarmClockModel::GetInstance()->AlarmPlayerStop();
+    // AlarmClockModel::GetInstance()->AlarmPlayerStop();
+    AlarmViewEventListener::GetInstance()->CancelAlarmRing();
     if(!NotificationManager::GetInstance()->GetWatchCallStatus())
     {
         return;
index db4838d..d1585d6 100755 (executable)
@@ -99,11 +99,7 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NoOperateCallback popalarm_time = %d",popalarm_time);
         if (popalarm_time <= 0)
         {
-            DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
-            // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
-            AlarmClockModel::GetInstance()->CancelAlarmRing();
-            FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
-            NotificationManager::GetInstance()->StopNotify();
+            AlarmViewEventListener::GetInstance()->CancelAlarmRing();
         }
         else
         {
@@ -594,11 +590,8 @@ namespace OHOS
         if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
         {
             if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0)
-            {
-                DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
-                AlarmClockModel::GetInstance()->CancelAlarmRing();
-                FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
-                NotificationManager::GetInstance()->StopNotify();
+            {   
+                CancelAlarmRing();
             }
         }
         return true;
@@ -635,12 +628,29 @@ namespace OHOS
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlamNotify ClickListener %s", view.GetViewId());
         if (strcmp(view.GetViewId(), ALARM_IMAGE_STOP) == 0) // 点击停止闹钟响铃
         {
-            DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
             // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
-            AlarmClockModel::GetInstance()->CancelAlarmRing();
-            FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
-            NotificationManager::GetInstance()->StopNotify();
+            CancelAlarmRing();
         }
         return true;
     }
+
+    void AlarmViewEventListener::PopAlarmRing()
+    {
+        FindWatchViewEventListener::GetInstance().PopInterPlayMusic("/music/ring/alarm.mp3");//播放铃声
+    }
+
+    void AlarmViewEventListener::CancelAlarmRing()
+    {
+        DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+        FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
+        AlarmClockModel::GetInstance()->CancelAlarmRing();
+        NotificationManager::GetInstance()->StopNotify();
+    }
+
+    void AlarmViewEventListener::DelayAlarmRing()
+    {
+        CancelAlarmRing();//先取消闹铃
+        AlarmClockModel::GetInstance()->AlarmGetClockNum();
+        AlarmClockModel::GetInstance()->DelayAlarmRing();
+    }
 } // namespace OHOS