1.通话音量添加4g音量调节 925/1
authorluozheng <1732036298@qq.com>
Mon, 9 Sep 2024 13:10:30 +0000 (21:10 +0800)
committerluozheng <1732036298@qq.com>
Mon, 9 Sep 2024 13:10:30 +0000 (21:10 +0800)
2.#536,解决:闹钟响铃只有三下bug
3.闹钟弹窗UI优化

17 files changed:
code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmClockModel.h
code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmMaxClock.h
code/sdk/application/wearable/fd230app/nativeui/alarm/include/AlarmPresenter.h
code/sdk/application/wearable/fd230app/nativeui/alarm/include/MainAlarmView.h
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmMaxClock.cpp
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPopUpPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/alarm/src/MainAlarmView.cpp
code/sdk/application/wearable/fd230app/nativeui/alarmclockmanage/include/AlarmClockManage.h
code/sdk/application/wearable/fd230app/nativeui/alarmclockmanage/src/AlarmClockManage.cpp
code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
code/sdk/application/wearable/service/msg_center/include/notify/alarm_notification.h
code/sdk/application/wearable/service/msg_center/include/notify/findwatch_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
code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp

index 3ca0907..7666e1c 100644 (file)
@@ -147,7 +147,7 @@ private:
     std::shared_ptr<Player> playerCtr{nullptr};\r
     AlarmClockManagement managementAlarm;\r
     uint8_t alarmId[5]{0}; // 事件闹钟的个数是5个\r
-    uint16_t alarmSerial{0};\r
+    uint16_t alarmSerial{0};//闹钟数量\r
     uint16_t clockListener{0};\r
     uint16 preSliceId{0};\r
     uint32_t listAlarmClockNum{0};\r
index 55c020d..6fd46c5 100644 (file)
@@ -39,7 +39,7 @@ public:
     void AlarmMaxDelayExit(void);\r
 private:\r
     UIScrollView *container{nullptr};\r
-    UILabel *labelText{nullptr};\r
+    UILabelExt *labelText{nullptr};\r
 };\r
 } // namespace OHOS\r
 #endif
\ No newline at end of file
index 0bcbac2..3ce4546 100644 (file)
@@ -170,7 +170,7 @@ private:
     uint32_t timeHour{0};\r
     uint32_t timeMin{0};\r
     uint16_t setListener;\r
-    uint16_t alarmListener{0};\r
+    uint16_t alarmListener{0};//闹钟编号\r
     uint16_t clockQty{0};\r
     int16_t interListener;\r
     bool buttonStratus = true;\r
index 6deb8aa..77b9a4e 100644 (file)
@@ -35,7 +35,7 @@
 namespace OHOS {
 constexpr int16_t D_CLOCK_Y = 210;
 constexpr int16_t LABEL_ZERO_Y = 270;
-constexpr int16_t ALARM_INTER_ADD = 130; // 150;
+constexpr int16_t ALARM_INTER_ADD = 130; // 130;
 
 class AlarmPresenter;
 class MainAlarmView : public View<AlarmPresenter> {
@@ -87,8 +87,8 @@ private:
     uint8_t alarmHour, alarmMin;
     int8_t dClockNum{-1};
     int16_t weekStatus{-1};
-    int16_t alarmPositionY{D_CLOCK_Y};
-    int16_t labelPositionY{LABEL_ZERO_Y};
+    // int16_t alarmPositionY{D_CLOCK_Y};
+    // int16_t labelPositionY{LABEL_ZERO_Y};
     int16_t alarmInterval{ALARM_INTER_ADD};
     bool reflashStatus{false};
     UILabelExt * TitleLabelExt_{nullptr}; 
index 7c96b54..c7b6365 100644 (file)
 #include "samgr_lite.h"
 #include "thread_adapter.h"
 #include "UiConfig.h"
-#include "AlarmClockModel.h"
-#include "AlarmPopUpPresenter.h"
+#include "alarm/include/AlarmClockModel.h"
+#include "alarm/include/AlarmPopUpPresenter.h"
 #include "graphic_service.h"
-#include "PlayersModel.h"
-#include "PhoneService.h"
+#include "player/include/PlayersModel.h"
+#include "phoneservice/include/PhoneService.h"
 #include "ui_service.h"
 #include "notification_manager.h"
-#include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h"
+#include "ConfigModel.h"
 #include "custom_runtime.h"
 
 #ifdef __cplusplus
@@ -47,7 +47,7 @@ AlarmClockInfo g_alarmClockData[ALARM_CLOCK_MAX];
 AlarmClockModel::AlarmClockModel()
 {
     g_alarmClockDataMutex = MUTEX_InitValue();
-    InitAlarmData();
+    // InitAlarmData();
 }
 
 AlarmClockModel::~AlarmClockModel()
@@ -196,6 +196,7 @@ int32_t AlarmClockModel::InitAlarmData(void)
     return 0;
 }
 
+//获取闹钟数量
 int32_t AlarmClockModel::GetAlarmNum(void)
 {
     return alarmSerial;
@@ -331,16 +332,18 @@ bool AlarmClockModel::JudgeClockModel(uint16_t num)
     }
 }
 
+//获取一个可用的闹钟 ID
 uint8_t AlarmClockModel::GetAlarmId(void)
 {
     for (int num = 0; num < CLOCK_MAX; num++) {
-        if (alarmId[num] == 0) {
+        if (alarmId[num] == 0) { //如果某个元素的值为 0,表示这个 ID 尚未被使用
             return num;
         }
     }
     return 0;
 }
 
+//将指定id的闹钟标记为已删除状态
 void AlarmClockModel::DeleteAlarmId(uint8_t id)
 {
     for (int num = 0; num < CLOCK_MAX; num++) {
@@ -351,6 +354,7 @@ void AlarmClockModel::DeleteAlarmId(uint8_t id)
     return;
 }
 
+//将指定id的闹钟标记为已设置状态
 void AlarmClockModel::SetAlarmId(uint8_t id)
 {
     for (int num = 0; num < CLOCK_MAX; num++) {
@@ -395,7 +399,7 @@ void AlarmClockModel::SetAlarmId(uint8_t id)
 //     SetAlarmId(currentAlarm[0]->alarmClockId);
 //     return;
 // }
-
+#if 0
 void AlarmClockModel::DeleteClockModel(uint16_t num)
 {
     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel num=%d", num);
@@ -458,7 +462,77 @@ void AlarmClockModel::DeleteClockModel(uint16_t num)
     }
     currentAlarm[alarmSerial - 1] = nullptr;
 }
+#endif
+
+//删除闹钟信息
+void AlarmClockModel::DeleteClockModel(uint16_t id)
+{
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel id=%d", id);
+    if (id >= CLOCK_MAX || currentAlarm[id] == nullptr) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel delete clock error!");
+        return;
+    }
+    uint8_t clockId = currentAlarm[id]->alarmClockId;
+    int status = DeleteAlarmClock(currentAlarm[id]);
+    if (status!= 0) {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteAlarmClock delete clock error!");
+        return;
+    }
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"AlarmClockModel::DeleteAlarmClock = %d, currentAlarm[alarmListener] = %p, alarmClockId = %u!", status, currentAlarm[id],currentAlarm[id]->alarmClockId);
+    DeleteAlarmId(clockId);
+    int alarmNum = GetAlarmNum();
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel alarmNum = %u!", alarmNum);
+
+    bool isFirstAlarm = (alarmNum == 0);
+    if (isFirstAlarm) {
+        // 如果是第一个闹钟,直接处理删除,无需检查下一个闹钟状态
+        if (alarmNum > 1) {
+            // 如果有多个闹钟,将第二个闹钟赋给第一个位置,并更新索引
+            currentAlarm[0] = currentAlarm[1];
+            currentAlarm[0]->index = 0;
+            int ret = UpdataAlarmClock(currentAlarm[0]);
+            if (ret!= 0) {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel update first alarm failed!");
+                return;
+            }
+        } else {
+            // 如果只有一个闹钟,直接将其置为 nullptr
+            currentAlarm[0] = nullptr;
+        }
+    } else {
+        // 如果不是第一个闹钟,按照原逻辑处理
+        for (; id < alarmNum; id++)
+        {
+            AlarmClockInfo *tempAlarm = currentAlarm[id];
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel. current_index = %u!", currentAlarm[id]->index);
+            // 判断是否到达最后一个闹钟或者下一个闹钟为 nullptr 或无效类型
+            if ((id + 1) == alarmNum || currentAlarm[id + 1] == nullptr || currentAlarm[id + 1]->alarmType == TYPE_INVALID_ALARM_CLOCK)
+            {
+                // 如果是最后一个闹钟,直接置为 nullptr
+                if ((id + 1) == alarmNum) {
+                    currentAlarm[id] = nullptr;
+                } else {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel fail");
+                    currentAlarm[id] = tempAlarm;
+                    return;
+                }
+                break;
+            }
+            currentAlarm[id] = currentAlarm[id + 1];
+            currentAlarm[id]->index = id;
+
+            int ret = UpdataAlarmClock(currentAlarm[id]);
+            if (ret!= 0)
+            {
+                currentAlarm[id] = tempAlarm;
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DeleteClockModel [%d]", __LINE__);
+                return;
+            }
+        }
+    }
+}
 
+//切换特定闹钟的启用状态
 bool AlarmClockModel::ButtonStatusRing(int16_t num, bool alarmStatus)
 {
     if (num >= CLOCK_MAX || currentAlarm[num] == nullptr) {
@@ -472,8 +546,7 @@ bool AlarmClockModel::ButtonStatusRing(int16_t num, bool alarmStatus)
     } else if (!alarmStatus) {
         currentAlarm[num]->alarmClockEnable = 0;
     }
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ButtonStatusRing alarm[%d] status is %u", num,
-        currentAlarm[num]->alarmClockEnable);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ButtonStatusRing alarm[%d] status is %u", num, currentAlarm[num]->alarmClockEnable);
     int ret = UpdataAlarmClock(currentAlarm[num]);
     if (ret != 0) {
         currentAlarm[num]->alarmClockEnable = tempAlarmEnable;
@@ -482,6 +555,7 @@ bool AlarmClockModel::ButtonStatusRing(int16_t num, bool alarmStatus)
     return true;
 }
 
+//延迟某个闹钟
 void AlarmClockModel::SetDelayAlarm(uint8_t alarm)
 {
     AlarmClockQueueMsg *clockQueueMsg = new AlarmClockQueueMsg();
@@ -491,13 +565,13 @@ void AlarmClockModel::SetDelayAlarm(uint8_t alarm)
     }
     currentAlarm[clockListener]->delayNum++;
     clockQueueMsg->eventType = EVENT_ALARM_RING_DELAY;
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ButtonStatusRing clockQueueMsg->eventType is %u",
-        clockQueueMsg->eventType);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ButtonStatusRing clockQueueMsg->eventType is %u",clockQueueMsg->eventType);
     (clockQueueMsg->data).value = alarm;
     AlmmgrAlarmClockEventProcess(clockQueueMsg);
     return;
 }
 
+//取消某个闹钟
 void AlarmClockModel::SetCancelAlarm(uint8_t alarm)
 {
     AlarmClockQueueMsg *clockQueueMsg = new AlarmClockQueueMsg();
@@ -506,13 +580,13 @@ void AlarmClockModel::SetCancelAlarm(uint8_t alarm)
         return;
     }
     clockQueueMsg->eventType = EVENT_ALARM_RING_CANCEL;
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ButtonStatusRing clockQueueMsg->eventType is %u",
-        clockQueueMsg->eventType);
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::ButtonStatusRing clockQueueMsg->eventType is %u",clockQueueMsg->eventType);
     (clockQueueMsg->data).value = alarm;
     AlmmgrAlarmClockEventProcess(clockQueueMsg);
     return;
 }
 
+//设置闹钟时间
 void AlarmClockModel::SetAlarmTime(uint32_t time_hour, uint32_t time_min, int16_t num)
 {
     if (num >= CLOCK_MAX || currentAlarm[num] == nullptr) {
@@ -530,6 +604,7 @@ void AlarmClockModel::SetAlarmTime(uint32_t time_hour, uint32_t time_min, int16_
         currentAlarm[num]->alarmTime);
 }
 
+//设置闹钟星期
 void AlarmClockModel::SetAlarmWeek(uint8_t week, int16_t num)
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek set week!");
@@ -550,7 +625,7 @@ void AlarmClockModel::SetAlarmWeek(uint8_t week, int16_t num)
 
 void AlarmClockModel::DelAlarmDelay(int16_t num)
 {
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek set week!");
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DelAlarmDelay set week!");
     if (num >= CLOCK_MAX || currentAlarm[num] == nullptr) {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClcokModel::SetAlarmTime new alarm_clock! num = %d", num);
         return;
@@ -562,12 +637,19 @@ void AlarmClockModel::DelAlarmDelay(int16_t num)
         currentAlarm[num]->delayNum = tempAlarmDelay;
         return;
     }
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek currentAlarm[num]->delayNum = %u",
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::DelAlarmDelay currentAlarm[num]->delayNum = %u",
         currentAlarm[num]->delayNum);
 }
 
-void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_t week, uint16_t alarmListener,
-    uint16_t setListener)
+/*
+ * @brief 设置闹钟信息 
+ * @param 1 闹钟的小时数
+ * @param 2 闹钟的分钟数
+ * @param 3 表示闹钟的重复周期,按位表示一周中哪些天重复的数值
+ * @param 4 标识特定闹钟的索引
+ * @param 5 区分是新建闹钟还是修改闹钟的标志
+ */
+void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_t week, uint16_t alarmListener,uint16_t setListener)
 {
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmInfo!");
     if (currentAlarm[alarmListener] == nullptr || (currentAlarm[alarmListener]->alarmType == TYPE_INVALID_ALARM_CLOCK &&
@@ -576,9 +658,8 @@ void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClcokModel::SetAlarmTime new alarm!");
     }
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "hour = %u, minute = %u", time_hour, time_min);
-    currentAlarm[alarmListener]->alarmTime = ((time_hour << 16) | time_min); // 闹钟时间数据的小时位右边16位
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::NewAlarmTime currentAlarm[alarmListener]->alarm_time = %u",
-        currentAlarm[alarmListener]->alarmTime);
+    currentAlarm[alarmListener]->alarmTime = ((time_hour << 16) | time_min); // 闹钟时间数据:小时存储在高 16 位,分钟存储在低 16 位
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::NewAlarmTime currentAlarm[alarmListener]->alarm_time = %u",currentAlarm[alarmListener]->alarmTime);
     currentAlarm[alarmListener]->alarmClockId = GetAlarmId();
     currentAlarm[alarmListener]->alarmClockEnable = 1;
     currentAlarm[alarmListener]->alarmType = 1;
@@ -593,7 +674,7 @@ void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_
     }
     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::NewAlarmTime clock name = %s, id = %u",
         currentAlarm[alarmListener]->alarmClockName, currentAlarm[alarmListener]->alarmClockId);
-    if (setListener == 0) {
+    if (setListener == 0) { //表示新建闹钟
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek new time!");
         int ret = AddAlarmClock(currentAlarm[alarmListener]);
         if (ret != 0) {
@@ -604,7 +685,7 @@ void AlarmClockModel::SetAlarmInfo(uint32_t time_hour, uint32_t time_min, uint8_
             return;
         }
         SetAlarmId(currentAlarm[alarmListener]->alarmClockId);
-    } else {
+    } else { //表示修改闹钟
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::SetAlarmWeek modify time!");
         UpdataAlarmClock(currentAlarm[alarmListener]);
     }
@@ -722,6 +803,7 @@ void AlarmClockModel::PopInterCancelMusic()
 
 void AlarmClockModel::PopInterPlayMusic()
 {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::PopInterPlayMusic");
     if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get()))
     {
         return;
index 0fbfb13..696562c 100644 (file)
@@ -5,12 +5,13 @@
  * Create: 2021-09-11\r
  */\r
 \r
-#include "AlarmMaxClock.h"\r
+#include "alarm/include/AlarmMaxClock.h"\r
 #include "UiConfig.h"\r
 #include <string>\r
 #include "cmsis_os.h"\r
-#include "AlarmPresenter.h"\r
-#include "MainAlarmView.h"\r
+#include "alarm/include/AlarmPresenter.h"\r
+#include "alarm/include/MainAlarmView.h"\r
+#include "cmsis_os2.h"\r
 \r
 namespace OHOS {\r
 #define MAX_INETERFACES "当前闹钟个数已达上限"\r
@@ -18,7 +19,7 @@ namespace OHOS {
 \r
 osTimerId_t g_stopAlarmMaxHandle = nullptr;\r
 static AlarmMaxClock *g_AlarmMaxClock = nullptr;\r
-static constexpr uint64_t MS_THREE_SECONDS = 3000;\r
+static constexpr uint64_t MS_THREE_SECONDS = 10*1000; //10s钟无操作关闭该视图\r
 static void ScanTimerCallback(int data);\r
 static void EndScanHandle(void);\r
 \r
@@ -61,40 +62,50 @@ AlarmMaxClock *AlarmMaxClock::GetInstance(void)
 \r
 UIScrollView *AlarmMaxClock::InitAlarmMax(void)\r
 {\r
-    container = new UIScrollView();\r
     if (container == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmMaxClock:: new container fail");\r
-        return container;\r
-    }\r
-    container->SetPosition(CONTAINER_X, CONTAINER_Y);\r
-    container->SetWidth(HORIZONTAL_RESOLUTION);\r
-    container->SetHeight(VERTICAL_RESOLUTION);\r
-\r
-    labelText = new UILabel();\r
-    if (labelText == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmMaxClock:: new labelText fail");\r
-        return container;\r
-    }\r
-    labelText->SetPosition(MAX_LABEL_X_LEN, MAX_LABEL_Y_LEN, MAX_LABEL_LENGTH_LEN, MAX_LABEL_WIDTH_LEN);\r
-    labelText->SetText(MAX_INETERFACES);\r
-    labelText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MAX_LABEL_FONT_LEN);\r
-\r
-    container->SetTouchable(true);\r
-    container->SetDraggable(true);\r
-    UIView::OnDragListener *maxClockDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance();\r
-    if (maxClockDragListener == nullptr) {\r
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmMaxClock:: maxClockDragListener is nullptr");\r
-        return container;\r
+        container = new UIScrollView();\r
+        if (container == nullptr) {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmMaxClock:: new container fail");\r
+            return container;\r
+        }\r
+        container->SetPosition(CONTAINER_X, CONTAINER_Y);\r
+        container->SetWidth(HORIZONTAL_RESOLUTION);\r
+        container->SetHeight(VERTICAL_RESOLUTION);\r
+        container->SetTouchable(true);\r
+        container->SetDraggable(true);\r
+        UIView::OnDragListener *maxClockDragListener = (UIView::OnDragListener *)OHOS::AlarmPresenter::GetInstance();\r
+        if (maxClockDragListener == nullptr) {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmMaxClock:: maxClockDragListener is nullptr");\r
+            return container;\r
+        }\r
+        container->SetOnDragListener(maxClockDragListener);\r
+        /* -------------------------------------------------------------------------- */\r
+        if (labelText == nullptr)\r
+        {\r
+            labelText = new UILabelExt();\r
+            if (labelText == nullptr)\r
+            {\r
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitAlarmMax labelText is nullptr");\r
+                return nullptr;\r
+            }\r
+        }\r
+        labelText->SetPosition(83, 236, 360, 35);\r
+        labelText->SetText(MAX_INETERFACES);//当前闹钟个数已达上限\r
+        labelText->SetStyle(STYLE_TEXT_FONT, 30);\r
+        labelText->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+        labelText->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        labelText->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);\r
+        labelText->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        container->Add(labelText);\r
+        labelText->LayoutCenterOfParent();\r
     }\r
-    container->SetOnDragListener(maxClockDragListener);\r
-    container->Add(labelText);\r
-\r
     return container;\r
 }\r
 \r
 void CancelScanHandle(void)\r
 {\r
     if (g_stopAlarmMaxHandle != nullptr) {\r
+        osTimerStop(g_stopAlarmMaxHandle);\r
         osStatus_t ret = osTimerDelete(g_stopAlarmMaxHandle);\r
         if (ret != osOK) {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ScanTimerCallback osTimerDelete failed, ret = %lx!!", ret);\r
@@ -122,6 +133,7 @@ static void ScanTimerCallback(int data)
     GraphicService::GetInstance()->PostGraphicEvent(std::bind(ScanTimerCallbackProc, data));\r
 }\r
 \r
+//开启一个三秒钟关闭视图的定时器\r
 void AlarmMaxClock::AlarmMaxDelayExit(void)\r
 {\r
     g_stopAlarmMaxHandle = osTimerNew((osTimerFunc_t)ScanTimerCallback, osTimerPeriodic, nullptr, nullptr);\r
index f143d97..e61dbbc 100644 (file)
@@ -56,6 +56,7 @@ AlarmPopUpPresenter *AlarmPopUpPresenter::GetInstance()
     return g_pAlarmPresenter;\r
 }\r
 \r
+//取消闹钟响铃\r
 void AlarmPopUpPresenter::CancelAlarmRing()\r
 {\r
     uint8_t alarmId = 0;\r
@@ -70,6 +71,7 @@ void AlarmPopUpPresenter::CancelAlarmRing()
     AlarmClockModel::GetInstance()->SetCancelAlarm(alarmId);\r
 }\r
 \r
+//延迟闹钟响铃\r
 void AlarmPopUpPresenter::DelayAlarmRing()\r
 {\r
     uint8_t alarmId = 0;\r
index 22baced..a28756f 100644 (file)
@@ -188,7 +188,7 @@ void AlarmPresenter::ClickJudgeTrue(uint16_t num)
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmPresenter::ClickJudgeTrue new MainAlarmView::GetInstance() error");\r
         return;\r
     }\r
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[@CHENG][%d]:", __LINE__);\r
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clockQty = %d", clockQty);\r
     clockQty--;\r
     AlarmClockModel::GetInstance()->SetSerialRdc();\r
     MainAlarmView::GetInstance()->RefreshAlarm();\r
@@ -522,6 +522,7 @@ bool AlarmPresenter::OnClick(UIView &view, const ClickEvent &event)
 \r
 bool AlarmStatusBtnChangeListener::OnChange(UICheckBox::UICheckBoxState state)\r
 {\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmStatusBtnChangeListener::OnChange,%d",alarmStatusNum);\r
     if (MainAlarmView::GetInstance()->GetRefreshStatus()) {\r
         return true;\r
     }\r
index fceebef..4adfe64 100644 (file)
@@ -5,7 +5,7 @@
  * Create: 2021-09-11
  */
 
-#include "MainAlarmView.h"
+#include "alarm/include/MainAlarmView.h"
 #include "UiConfig.h"
 #include "ui_label_button.h"
 #include "PhoneService.h"
@@ -68,19 +68,36 @@ MainAlarmView::~MainAlarmView()
     weekStatus = 0;
     // delete addButton;
     // addButton = nullptr;
-    delete group;
-    group = nullptr;
-    delete configView;
-    configView = nullptr;
-    delete setTimeView;
-    setTimeView = nullptr;
-    delete setWeekView;
-    setWeekView = nullptr;
-    delete judgeView;
-    judgeView = nullptr;
-    delete newTimeView;
-    newTimeView = nullptr;
-
+    if(group)
+    {
+        delete group;
+        group = nullptr;
+    }
+    if(configView)
+    {
+        delete configView;
+        configView = nullptr;
+    }
+    if(setTimeView)
+    {
+        delete setTimeView;
+        setTimeView = nullptr;
+    }
+    if(setWeekView)
+    {
+        delete setWeekView;
+        setWeekView = nullptr;
+    }
+    if(judgeView)
+    {
+        delete judgeView;
+        judgeView = nullptr;
+    }
+    if(newTimeView)
+    {
+        delete newTimeView;
+        newTimeView = nullptr;
+    }
     if(nullptr != TitleLabelExt_)
     {
         delete TitleLabelExt_;
@@ -204,6 +221,10 @@ void MainAlarmView::AlarmAddButtonUpdate(uint8_t count)
 
     // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: 0_y=%d", __LINE__, SwipeView_[0]->GetY());
     AddButton_->SetY((0 == count) ? (Screen::GetInstance().GetHeight() / 2 - 50) : (SwipeView_[0]->GetY() + (alarmInterval * count)));
+    // if(group) {
+    //     group->ScrollBy(0, ADD_BUTTON_Y - AddButton_->GetY());
+    // }
+    RootView::GetInstance()->Invalidate();
 }
 
 UIViewGroup * MainAlarmView::NewClockCtlExt(int16_t alarmNum, uint8_t index)
@@ -492,37 +513,55 @@ void MainAlarmView::RefreshAlarm(void)
         RefreshAlarmStatus(alarmEnable, i);
         dClock[i]->SetTime24Hour(refreshHour, refreshMin, 0);
     }
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]: dClockNum = %d", __LINE__, dClockNum);
     // group->ScrollBy(0, ADD_BUTTON_Y - addButton->GetY());
     if (dClockNum > (i - 1))
     {
+        if(group)
+        {
+            if(SwipeView_[dClockNum])
+            {   
+        group->Remove(SwipeView_[dClockNum]);
         group->Remove(SwipeView_[dClockNum]);
 
         // 0
-        SwipeView_[dClockNum]->RemoveAll();
+                group->Remove(SwipeView_[dClockNum]);
 
-        SwipeViewItem_[dClockNum][0]->RemoveAll();
-        delete dClock[dClockNum];
-        dClock[dClockNum] = nullptr;
+        // 0
+                SwipeView_[dClockNum]->RemoveAll();
+                // 0
+                if(SwipeViewItem_[dClockNum][0])
+                {
+                    SwipeViewItem_[dClockNum][0]->RemoveAll();
 
-        delete statusButton[dClockNum];
-        statusButton[dClockNum] = nullptr;
+                    delete dClock[dClockNum];
+                    dClock[dClockNum] = nullptr;
 
-        delete dLabel[dClockNum];
-        dLabel[dClockNum] = nullptr;
+                    delete dLabel[dClockNum];
+                    dLabel[dClockNum] = nullptr;
 
-        delete SwipeViewItem_[dClockNum][0];
-        SwipeViewItem_[dClockNum][0] = nullptr;
+                    delete statusButton[dClockNum];
+                    statusButton[dClockNum] = nullptr;
 
-        // 1
-        SwipeViewItem_[dClockNum][1]->RemoveAll();
-        delete DeleteButton_[dClockNum];
-        DeleteButton_[dClockNum] = nullptr;
+                    delete SwipeViewItem_[dClockNum][0];
+                    SwipeViewItem_[dClockNum][0] = nullptr;
+                }
+                /* -------------------------------------------------------------------------- */
+                // 1
+                if(SwipeViewItem_[dClockNum][1])
+                {
+                    SwipeViewItem_[dClockNum][1]->RemoveAll();
 
-        delete SwipeViewItem_[dClockNum][1];
-        SwipeViewItem_[dClockNum][1] = nullptr;
+                    delete DeleteButton_[dClockNum];
+                    DeleteButton_[dClockNum] = nullptr;
 
-        delete SwipeView_[dClockNum];
-        SwipeView_[dClockNum] = nullptr;
+                    delete SwipeViewItem_[dClockNum][1];
+                    SwipeViewItem_[dClockNum][1] = nullptr;
+                }
+                delete SwipeView_[dClockNum];
+                SwipeView_[dClockNum] = nullptr;
+            }
+        }
     }
     dClockNum = i - 1;
 
index 869857e..07cecb7 100644 (file)
@@ -47,8 +47,8 @@ typedef enum {
 \r
 typedef enum {\r
     TYPE_INVALID_ALARM_CLOCK = 0,\r
-    TYPE_EVENT_ALARM_CLOCK = 1,\r
-    TYPE_SMART_ALARM_CLOCK,\r
+    TYPE_EVENT_ALARM_CLOCK = 1, // 事件闹钟\r
+    TYPE_SMART_ALARM_CLOCK,     // 智能闹钟\r
 } AlarmClockType;\r
 \r
 typedef enum {\r
index 7f3e656..6342f91 100644 (file)
@@ -20,7 +20,7 @@
 #include "samgr_lite.h"
 
 #include "RtcService.h"
-#include "AlarmClockTimerConfig.h"
+#include "alarmclocktimerconfig/include/AlarmClockTimerConfig.h"
 #include "AlarmClockManage.h"
 
 #ifdef __cplusplus
@@ -323,7 +323,13 @@ static int32 UpdataListAlarmToday(const AlarmClockInfo *alarmInfo)
 
 static int32 DeleteAndUpdataListAlarmToday(uint8 id)
 {
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_alarmTodayList size = %d!!", g_alarmTodayList.size());
     std::list< AlarmClockInfoToday>::iterator node;
+    for (node = g_alarmTodayList.begin(); node != g_alarmTodayList.end(); node++) {
+        if (node->alarmClockId == id) {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "g_alarmTodayList size = %d!!", node->alarmClockId);
+        }
+    }
     /* 将指定闹钟信息删除 */
     for (node = g_alarmTodayList.begin(); node != g_alarmTodayList.end(); node++) {
         if (node->alarmClockId == id) {
index ce41565..0769e3f 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-04-19 10:08:31
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-06 15:29:47
+ * @LastEditTime: 2024-09-09 20:56:39
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/soundandvibration/src/SoundAndVibrationVolumeSettingPresenter.cpp
  */
 #include "soundandvibration/include/SoundAndVibrationVolumeSettingPresenter.h"
@@ -229,7 +229,8 @@ extern "C"
     void CallVolumeSet(int32_t sounding)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CallVolumeSet %d", sounding);
-        Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 系统音量设置
+        Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_BT_SCO, sounding); // 通话音量设置
+        Audio::AudioManager::GetInstance().SetVolume(AUDIO_STREAM_VOICE_CALL_VOLTE, sounding); // 通话音量设置
     }
 
     int CallVolumeGet(void)
index ef3a483..7fe7435 100755 (executable)
@@ -8,17 +8,17 @@
 #ifndef ALARM_NOTIFICATION_H
 #define ALARM_NOTIFICATION_H
 
-constexpr char* ALARM_IMAGE_DELETE = "alarm_delete";
+constexpr char* ALARM_IMAGE_STOP = "alarm_stop"; //闹钟停止
 constexpr char* ALARM_IMAGE_CLOCK = "alarm_clock";
 constexpr char* ALARM_VIEW_CLOSE = "alarm_close";
 constexpr char* ALARM_VIEW_DELAY = "alarm_delay";
-constexpr char* ALARM_VIEW_POPUP = "alarm_popup";
+constexpr char* ALARM_VIEW_POPUP = "alarm_popup"; //闹钟弹窗
 
 enum class AlarmTimerType {
-    NOTIFY_ALARM_CLOSE = 0,
-    NOTIFY_ALARM_DELAY = 1,
-    NOTIFY_ALARM_RING = 2,
-    NOTIFY_ALARM_UNKNOWN = 10,
+    NOTIFY_ALARM_CLOSE = 0, //关闭闹钟
+    NOTIFY_ALARM_DELAY = 1, //延迟闹钟
+    NOTIFY_ALARM_RING = 2, //响铃闹钟
+    NOTIFY_ALARM_UNKNOWN = 10, //无效闹钟类型
 };
 
 namespace OHOS {
index 952a266..c54e251 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-25 17:31:19
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-01 14:22:04
+ * @LastEditTime: 2024-09-09 20:34:46
  * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/include/notify/findwatch_notification.h
  */
 #ifndef FIND_WATCH_NOTIFICATION_H
@@ -85,6 +85,8 @@ 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;
+        
+        const char *GetPath();
 
     private:
         FindWatchViewEventListener();
@@ -100,6 +102,7 @@ namespace OHOS
         AudioSession sessionId;
         AudioInterrupt interrupt;
         const char *RingMusicName = "/music/ring/findwatch.mp3";
+        const char * path_{nullptr};
         bool FindWatchNotifyFlag{false}; // 判断是查找手表, 由notify生成界面
         bool X_DRAG_FLAG{false};
     };
index e22e786..fce8c8d 100644 (file)
@@ -314,7 +314,8 @@ void MsgCenterNotifyAlarmProc(const Topic topic, Request* req)
     unused(req);
     // The alarm notification is not displayed if the incoming call notification is already being processed
     if (CheckPriority(topic)) {
-        AlarmClockModel::GetInstance()->PopInterPlayMusic();
+        // AlarmClockModel::GetInstance()->PopInterPlayMusic();
+        FindWatchViewEventListener::GetInstance().PopInterPlayMusic("/music/ring/alarm.mp3");//播放铃声
         NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
         NotificationManager::GetInstance()->ShowNotify(ShowAlarmNotify, static_cast<uint16_t>(topic), true);
     } else {
index 359d90a..4258294 100755 (executable)
 #include "notification_manager.h"
 #include "wearable_log.h"
 #include "UiConfig.h"
-#include "AlarmPopUpPresenter.h"
+#include "alarm/include/AlarmPopUpPresenter.h"
 #include "components/ui_image_view.h"
 #include "components/ui_label_ext.h"
 #include "components/ui_label_button_ext.h"
-namespace OHOS {
-static constexpr const char* RING_AGAIN = "响铃将在十分钟后再次响起";
-constexpr int32_t NOTIFY_THREE_SECONDS = 3000;
-constexpr int32_t NOTIFY_ONE_SECOND = 1000;
-constexpr int32_t NOTIFY_THIRTY_SECONDS = 30000;
-constexpr int32_t NOTIFY_ONE_MINUTE = 60000;
-constexpr int32_t NOTOFY_NO_OPERATE_TIME = 35000;
-osTimerId_t g_notifyStopHandle = nullptr; // timer of close view and alarm ring view
-osTimerId_t g_alarmRing = nullptr; // timer of alarm view
-
-UIViewGroup* g_alarmView = nullptr;
-UIViewGroup* g_closeView = nullptr;
-UIViewGroup* g_ringView = nullptr;
-UIImageView* g_imageClose = nullptr;
-UIImageView* g_imageRing = nullptr;
-UIImageView* g_imageDelete = nullptr;
-UILabelButtonExt * g_StopBtn = nullptr;
-UIImageView * g_ClockPrompt = nullptr;
-UIImageView* g_imageClock = nullptr;
-UILabel* g_closeLable = nullptr;
-UILabel* g_ringLable = nullptr;
-UILabelExt* g_mainLable = nullptr;
-UIDigitalClock* g_dClock = nullptr;
-
-// alarm close view
-constexpr int16_t MAX_SET_ZERO_LEN = 0;
-constexpr int16_t MAX_SET_SRC_LEN = 90;
-constexpr int16_t MAX_IMAGE_X_LEN = 165;
-constexpr int16_t MAX_IMAGE_Y_LEN = 150;
-constexpr int16_t MAX_LABEL_X_LEN = 187;
-constexpr int16_t MAX_LABEL_Y_LEN = 300;
-constexpr int16_t MAX_LABEL_LENGTH_LEN = 350;
-constexpr int16_t MAX_LABEL_HEIGHT_LEN = 40;
-constexpr int16_t MAX_LABEL_FONT_LEN = 35;
-
-// alarm main view
-constexpr int16_t CONTAINER_X = 0;
-constexpr int16_t CONTAINER_Y = 0;
-constexpr int16_t LABEL_X = 185;
-constexpr int16_t LABEL_Y = 100;
-constexpr int16_t LABEL_WIDTH = 250;
-constexpr int16_t LABEL_HEIGHT = 45;
-constexpr int16_t LABEL_FONT = 40;
-constexpr int16_t CLOCK_FONT = 70;
-constexpr int16_t CLOCK_X = 140;
-constexpr int16_t CLOCK_Y = 170;
-constexpr int16_t IMAGE_DELETE_X = 85;
-constexpr int16_t IMAGE_DELETE_Y = 300;
-constexpr int16_t IMAGE_CLOCK_X = 275;
-constexpr int16_t IMAGE_CLOCK_Y = 300;
-constexpr int16_t DIGITAL_CLOCK_WIDTH = 350;
-constexpr int16_t DIGITAL_CLOCK_HEIGHT = 75;
-
-// alarm delay view
-constexpr int16_t SET_ZERO = 0;
-constexpr int16_t SET_SRC = 150;
-constexpr int16_t DELAY_IMAGE_X = 150;
-constexpr int16_t DELAY_IMAGE_Y = 140;
-constexpr int16_t DELAY_LABEL_X = 80;
-constexpr int16_t DELAY_LABEL_Y = 300;
-constexpr int16_t DELAY_LABEL_LENGTH = 350;
-constexpr int16_t DELAY_LABEL_HEIGHT = 35;
-constexpr int16_t DELAY_LABEL_FONT = 25;
-
-void StopNotifyCallback()
+#include "components/ui_digital_clock.h"
+#include "time.h"
+#include "cmsis_os2.h"
+#include <service/graphic_service.h>
+#include "ConfigModel.h"
+#include <custom_runtime.h>
+#include "../../../../../../drivers/peripheral/vibrator/service/vibrator_service.h"
+namespace OHOS
 {
-    NotificationManager::GetInstance()->StopNotify();
-}
+    static constexpr const char *RING_AGAIN = "响铃将在十分钟后再次响起";
+    constexpr int32_t NOTIFY_THREE_SECONDS = 3000;
+    constexpr int32_t NOTIFY_ONE_SECOND = 1000;
+    constexpr int32_t NOTIFY_THIRTY_SECONDS = 30 * 1000; // 30秒
+    constexpr int32_t NOTIFY_ONE_MINUTE = 60 * 1000;
+    static int popalarm_time = 60;
+    constexpr int32_t NOTOFY_NO_OPERATE_TIME = 30 * 1000; // 无操作30s超时时间
+    osTimerId_t g_notifyStopHandle = nullptr;             // timer of close view and alarm ring view
+    osTimerId_t g_alarmRing = nullptr;                    // timer of alarm view
+
+    UIViewGroup *g_alarmView = nullptr;
+    UIViewGroup *g_closeView = nullptr;
+    UIViewGroup *g_ringView = nullptr;
+    UIImageView *g_imageClose = nullptr;
+    UIImageView *g_imageRing = nullptr;
+    UIImageView *g_imageDelete = nullptr;
+    UILabelButtonExt *g_StopBtn = nullptr;
+    UIImageView *g_ClockPrompt = nullptr;
+    UIImageView *g_imageClock = nullptr;
+    UILabel *g_closeLable = nullptr;
+    UILabel *g_ringLable = nullptr;
+    UILabelExt *g_mainLable = nullptr;
+    UILabelExt *g_popTime = nullptr;
+    UIDigitalClock *g_dClock = nullptr;
+
+    // alarm close view
+    constexpr int16_t MAX_SET_ZERO_LEN = 0;
+    constexpr int16_t MAX_SET_SRC_LEN = 90;
+    constexpr int16_t MAX_IMAGE_X_LEN = 165;
+    constexpr int16_t MAX_IMAGE_Y_LEN = 150;
+    constexpr int16_t MAX_LABEL_X_LEN = 187;
+    constexpr int16_t MAX_LABEL_Y_LEN = 300;
+    constexpr int16_t MAX_LABEL_LENGTH_LEN = 350;
+    constexpr int16_t MAX_LABEL_HEIGHT_LEN = 40;
+    constexpr int16_t MAX_LABEL_FONT_LEN = 35;
+
+    // alarm main view
+    constexpr int16_t CONTAINER_X = 0;
+    constexpr int16_t CONTAINER_Y = 0;
+    constexpr int16_t LABEL_X = 185;
+    constexpr int16_t LABEL_Y = 100;
+    constexpr int16_t LABEL_WIDTH = 250;
+    constexpr int16_t LABEL_HEIGHT = 45;
+    constexpr int16_t LABEL_FONT = 40;
+    constexpr int16_t CLOCK_FONT = 70;
+    constexpr int16_t CLOCK_X = 140;
+    constexpr int16_t CLOCK_Y = 170;
+    constexpr int16_t IMAGE_DELETE_X = 85;
+    constexpr int16_t IMAGE_DELETE_Y = 300;
+    constexpr int16_t IMAGE_CLOCK_X = 275;
+    constexpr int16_t IMAGE_CLOCK_Y = 300;
+    constexpr int16_t DIGITAL_CLOCK_WIDTH = 350;
+    constexpr int16_t DIGITAL_CLOCK_HEIGHT = 75;
+
+    // alarm delay view
+    constexpr int16_t SET_ZERO = 0;
+    constexpr int16_t SET_SRC = 150;
+    constexpr int16_t DELAY_IMAGE_X = 150;
+    constexpr int16_t DELAY_IMAGE_Y = 140;
+    constexpr int16_t DELAY_LABEL_X = 80;
+    constexpr int16_t DELAY_LABEL_Y = 300;
+    constexpr int16_t DELAY_LABEL_LENGTH = 350;
+    constexpr int16_t DELAY_LABEL_HEIGHT = 35;
+    constexpr int16_t DELAY_LABEL_FONT = 25;
+
+    void StopNotifyCallback()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopNotifyCallback");
+        NotificationManager::GetInstance()->StopNotify();
+    }
 
-void NoOperateCallback()
-{
-    NotificationManager::GetInstance()->StopNotify();
-}
+    static void NoOperateCallbackProc(int data)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NoOperateCallback");
+        popalarm_time--;
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NoOperateCallback popalarm_time = %d",popalarm_time);
+        if (popalarm_time <= 0)
+        {
+            DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+            // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
+            FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
+            NotificationManager::GetInstance()->StopNotify();
+        }
+        else
+        {
+            if (true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get()))
+            {
+                return;
+            }
+            if (g_alarmView)
+            {
+                ui_api_vibrate_once_func();
+            }
+        }
+    }
 
-void StartAlarmTimer(AlarmTimerType type, int32_t interval)
-{
-    uint32_t tick;
-    osStatus_t retTimer;
-    if (type >= AlarmTimerType::NOTIFY_ALARM_UNKNOWN) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartAlarmTimer type:%d invalid!!", type);
-        return;
+    static void NoOperateCallback(int data)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(NoOperateCallbackProc, data));
     }
-    switch (type) {
+
+    /*
+     * @brief 启动特定类型的闹钟定时器
+     * @param 1 闹钟定时器的类型
+     * @param 2 时间间隔,以毫秒为单位
+     */
+    void StartAlarmTimer(AlarmTimerType type, int32_t interval)
+    {
+        uint32_t tick;
+        osStatus_t retTimer;
+        // 1.检查传入的闹钟类型是否有效
+        if (type >= AlarmTimerType::NOTIFY_ALARM_UNKNOWN)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartAlarmTimer type:%d invalid!!", type);
+            return;
+        }
+        switch (type)
+        {
         case AlarmTimerType::NOTIFY_ALARM_CLOSE:
         case AlarmTimerType::NOTIFY_ALARM_DELAY:
-            g_notifyStopHandle = osTimerNew((osTimerFunc_t)StopNotifyCallback, osTimerPeriodic, nullptr, nullptr);
-            tick = osMs2Tick(interval);
-            retTimer = osTimerStart(g_notifyStopHandle, tick);
-            if (retTimer != osOK && g_notifyStopHandle != nullptr) {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
-                    "StartAlarmTimer osTimerStart failed, type= %d ret = %lx!!", type, retTimer);
-                osTimerDelete(g_notifyStopHandle);
-                g_notifyStopHandle = nullptr;
-                return;
+            if (g_notifyStopHandle == nullptr)
+            {
+                g_notifyStopHandle = osTimerNew((osTimerFunc_t)StopNotifyCallback, osTimerPeriodic, nullptr, nullptr);
+                tick = osMs2Tick(interval);
+                retTimer = osTimerStart(g_notifyStopHandle, tick);
+                if (retTimer != osOK && g_notifyStopHandle != nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartAlarmTimer osTimerStart failed, type= %d ret = %lx!!", type, retTimer);
+                    osTimerDelete(g_notifyStopHandle);
+                    g_notifyStopHandle = nullptr;
+                    return;
+                }
             }
             break;
         case AlarmTimerType::NOTIFY_ALARM_RING:
-            g_alarmRing = osTimerNew((osTimerFunc_t)NoOperateCallback, osTimerPeriodic, nullptr, nullptr);
-            tick = osMs2Tick(interval);
-            retTimer = osTimerStart(g_alarmRing, tick);
-            if (retTimer != osOK && g_alarmRing != nullptr) {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
-                    "StartAlarmTimer osTimerStart failed, type= %d ret = %lx!!", type, retTimer);
-                osTimerDelete(g_alarmRing);
-                g_alarmRing = nullptr;
-                return;
+            if (g_alarmRing == nullptr)
+            {
+                g_alarmRing = osTimerNew((osTimerFunc_t)NoOperateCallback, osTimerPeriodic, nullptr, nullptr);
+                tick = osMs2Tick(interval);
+                retTimer = osTimerStart(g_alarmRing, tick);
+                if (retTimer != osOK && g_alarmRing != nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StartAlarmTimer osTimerStart failed, type= %d ret = %lx!!", type, retTimer);
+                    osTimerDelete(g_alarmRing);
+                    g_alarmRing = nullptr;
+                    return;
+                }
             }
             break;
         default:
             break;
+        }
     }
-}
 
-void DisableAlarmTimer(AlarmTimerType type)
-{
-    if (type >= AlarmTimerType::NOTIFY_ALARM_UNKNOWN) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableAlarmTimer type:%d invalid!!", type);
-        return;
-    }
-    osStatus_t ret;
-    switch (type) {
+    /*
+     * @brief 取消特定类型的闹钟定时器
+     * @param 闹钟定时器的类型
+     */
+    void DisableAlarmTimer(AlarmTimerType type)
+    {
+        if (type >= AlarmTimerType::NOTIFY_ALARM_UNKNOWN)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableAlarmTimer type:%d invalid!!", type);
+            return;
+        }
+        osStatus_t ret;
+        switch (type)
+        {
         case AlarmTimerType::NOTIFY_ALARM_CLOSE:
         case AlarmTimerType::NOTIFY_ALARM_DELAY:
-            if (g_notifyStopHandle != nullptr) {
+            if (g_notifyStopHandle != nullptr)
+            {
+                osTimerStop(g_notifyStopHandle);
                 ret = osTimerDelete(g_notifyStopHandle);
-                if (ret != osOK) {
+                if (ret != osOK)
+                {
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableAlarmTimer failed, type= %d ret = %lx!", type, ret);
                     return;
                 }
@@ -145,380 +204,441 @@ void DisableAlarmTimer(AlarmTimerType type)
             }
             break;
         case AlarmTimerType::NOTIFY_ALARM_RING:
-            if (g_alarmRing != nullptr) {
+            if (g_alarmRing != nullptr)
+            {
+                osTimerStop(g_alarmRing);
                 ret = osTimerDelete(g_alarmRing);
-                if (ret != osOK) {
+                if (ret != osOK)
+                {
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisableAlarmTimer failed, type= %d ret = %lx!", type, ret);
                     return;
                 }
                 g_alarmRing = nullptr;
+                popalarm_time = 60;
             }
             break;
         default:
             break;
+        }
     }
-}
-
-UIViewGroup *CreateAlarmCloseView()
-{
-    g_closeView = new UIViewGroup();
-    if (g_closeView == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView g_closeView null!");
-        return nullptr;
-    }
-    g_closeView->SetPosition(MAX_SET_ZERO_LEN, MAX_SET_ZERO_LEN);
-    g_closeView->SetWidth(Screen::GetInstance().GetWidth());
-    g_closeView->SetHeight(Screen::GetInstance().GetHeight());
-    g_imageClose = new UIImageView();
-    if (g_imageClose == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView g_imageClose null!");
-        delete g_closeView;
-        g_closeView = nullptr;
-        return nullptr;
-    }
-    g_imageClose->SetPosition(MAX_IMAGE_X_LEN, MAX_IMAGE_Y_LEN);
-    g_imageClose->SetWidth(MAX_SET_SRC_LEN);
-    g_imageClose->SetHeight(MAX_SET_SRC_LEN);
-    g_imageClose->SetSrc(ALARM_CLOCK_CLOSE_ADD_PATH);
-    g_imageClose->SetTouchable(true);
-    g_closeView->Add(g_imageClose);
-
-    g_closeLable = new UILabel();
-    if (g_closeLable == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView g_closeLable null!");
-        delete g_closeView;
-        g_closeView = nullptr;
-        delete g_imageClose;
-        g_imageClose = nullptr;
-        return nullptr;
-    }
-    g_closeLable->SetPosition(MAX_LABEL_X_LEN, MAX_LABEL_Y_LEN, MAX_LABEL_LENGTH_LEN, MAX_LABEL_HEIGHT_LEN);
-    g_closeLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MAX_LABEL_FONT_LEN);
-    g_closeLable->SetText("CLOSE");
-    g_closeView->Add(g_closeLable);
-    g_closeView->SetViewId(ALARM_VIEW_CLOSE);
-    UIView::OnDragListener *listener = static_cast<UIView::OnDragListener*>(AlarmViewEventListener::GetInstance());
-    g_closeView->SetOnDragListener(listener);
-    g_closeView->SetDraggable(true);
-    g_closeView->SetTouchable(true);
-    NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeAlarmCloseView);
-    return g_closeView;
-}
 
-void FreeAlarmCloseView(void)
-{
-    if (g_closeView != nullptr) {
-        DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_CLOSE);
-        g_closeView->RemoveAll();
-        delete g_imageClose;
-        g_imageClose = nullptr;
-        delete g_closeLable;
-        g_closeLable = nullptr;
-        RootView::GetInstance()->Remove(g_closeView);
-        delete g_closeView;
-        g_closeView = nullptr;
+    UIViewGroup *CreateAlarmCloseView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView");
+        g_closeView = new UIViewGroup();
+        if (g_closeView == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView g_closeView null!");
+            return nullptr;
+        }
+        g_closeView->SetPosition(MAX_SET_ZERO_LEN, MAX_SET_ZERO_LEN);
+        g_closeView->SetWidth(Screen::GetInstance().GetWidth());
+        g_closeView->SetHeight(Screen::GetInstance().GetHeight());
+        g_imageClose = new UIImageView();
+        if (g_imageClose == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView g_imageClose null!");
+            delete g_closeView;
+            g_closeView = nullptr;
+            return nullptr;
+        }
+        g_imageClose->SetPosition(MAX_IMAGE_X_LEN, MAX_IMAGE_Y_LEN);
+        g_imageClose->SetWidth(MAX_SET_SRC_LEN);
+        g_imageClose->SetHeight(MAX_SET_SRC_LEN);
+        g_imageClose->SetSrc(ALARM_CLOCK_CLOSE_ADD_PATH);
+        g_imageClose->SetTouchable(true);
+        g_closeView->Add(g_imageClose);
+
+        g_closeLable = new UILabel();
+        if (g_closeLable == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmCloseView g_closeLable null!");
+            delete g_closeView;
+            g_closeView = nullptr;
+            delete g_imageClose;
+            g_imageClose = nullptr;
+            return nullptr;
+        }
+        g_closeLable->SetPosition(MAX_LABEL_X_LEN, MAX_LABEL_Y_LEN, MAX_LABEL_LENGTH_LEN, MAX_LABEL_HEIGHT_LEN);
+        g_closeLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, MAX_LABEL_FONT_LEN);
+        g_closeLable->SetText("CLOSE");
+        g_closeView->Add(g_closeLable);
+        g_closeView->SetViewId(ALARM_VIEW_CLOSE);
+        UIView::OnDragListener *listener = static_cast<UIView::OnDragListener *>(AlarmViewEventListener::GetInstance());
+        g_closeView->SetOnDragListener(listener);
+        g_closeView->SetDraggable(true);
+        g_closeView->SetTouchable(true);
+        NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeAlarmCloseView);
+        return g_closeView;
     }
-}
 
-UIViewGroup *CreateAlarmRingView()
-{
-    g_ringView = new UIViewGroup();
-    if (g_ringView == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmRingView g_ringView null!");
-        return nullptr;
-    }
-    g_ringView->SetPosition(SET_ZERO, SET_ZERO);
-    g_ringView->SetWidth(Screen::GetInstance().GetWidth());
-    g_ringView->SetHeight(Screen::GetInstance().GetHeight());
-    g_imageRing = new UIImageView();
-    if (g_imageRing == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmRingView g_imageRing null!");
-        delete g_ringView;
-        g_ringView = nullptr;
-        return nullptr;
-    }
-    g_imageRing->SetPosition(DELAY_IMAGE_X, DELAY_IMAGE_Y);
-    g_imageRing->SetWidth(SET_SRC);
-    g_imageRing->SetHeight(SET_SRC);
-    g_imageRing->SetSrc(ALARM_CLOCK_POP_ADD_PATH);
-    g_ringView->Add(g_imageRing);
-    g_ringLable = new UILabel();
-    if (g_ringLable == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmRingView::g_ringLable null!");
-        delete g_ringView;
-        g_ringView = nullptr;
-        delete g_imageRing;
-        return nullptr;
+    void FreeAlarmCloseView(void)
+    {
+        if (g_closeView != nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeAlarmCloseView");
+            DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_CLOSE);
+            g_closeView->RemoveAll();
+            delete g_imageClose;
+            g_imageClose = nullptr;
+            delete g_closeLable;
+            g_closeLable = nullptr;
+            RootView::GetInstance()->Remove(g_closeView);
+            delete g_closeView;
+            g_closeView = nullptr;
+        }
     }
-    g_ringLable->SetPosition(DELAY_LABEL_X, DELAY_LABEL_Y, DELAY_LABEL_LENGTH, DELAY_LABEL_HEIGHT);
-    g_ringLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, DELAY_LABEL_FONT);
-    g_ringLable->SetText(RING_AGAIN);
-    g_ringView->Add(g_ringLable);
-    g_ringView->SetViewId(ALARM_VIEW_DELAY);
-    UIView::OnDragListener *listener = static_cast<UIView::OnDragListener*>(AlarmViewEventListener::GetInstance());
-    g_ringView->SetOnDragListener(listener);
-    g_ringView->SetDraggable(true);
-    g_ringView->SetTouchable(true);
-    NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeAlarmRingView);
-    return g_ringView;
-}
 
-void FreeAlarmRingView(void)
-{
-    if (g_ringView != nullptr) {
-        DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_DELAY);
-        g_ringView->RemoveAll();
-        delete g_imageRing;
-        g_imageRing = nullptr;
-        delete g_ringLable;
-        g_ringLable = nullptr;
-        RootView::GetInstance()->Remove(g_ringView);
-        delete g_ringView;
-        g_ringView = nullptr;
+    /*创建一个响铃闹钟视图*/
+    UIViewGroup *CreateAlarmRingView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmRingView");
+        if (g_ringView == nullptr)
+        {
+            g_ringView = new UIViewGroup();
+            if (g_ringView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmRingView g_ringView null!");
+                return nullptr;
+            }
+            g_ringView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            g_ringView->SetViewId(ALARM_VIEW_DELAY);
+            UIView::OnDragListener *listener = static_cast<UIView::OnDragListener *>(AlarmViewEventListener::GetInstance());
+            if (listener == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmViewEventListener::GetInstance fail!!");
+                return nullptr;
+            }
+            g_ringView->SetOnDragListener(listener);
+            g_ringView->SetDraggable(true);
+            g_ringView->SetTouchable(true);
+            /* -------------------------------------------------------------------------- */
+            if (g_imageRing == nullptr)
+            {
+                g_imageRing = new UIImageView();
+                if (g_imageRing == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmRingView g_imageRing null!");
+                    return nullptr;
+                }
+            }
+            g_imageRing->SetPosition(DELAY_IMAGE_X, DELAY_IMAGE_Y);
+            g_imageRing->SetWidth(SET_SRC);
+            g_imageRing->SetHeight(SET_SRC);
+            g_imageRing->SetSrc(ALARM_CLOCK_POP_ADD_PATH);
+            /* -------------------------------------------------------------------------- */
+            if (g_ringLable == nullptr)
+            {
+                g_ringLable = new UILabel();
+                if (g_ringLable == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmRingView::g_ringLable null!");
+                    return nullptr;
+                }
+            }
+            g_ringLable->SetPosition(DELAY_LABEL_X, DELAY_LABEL_Y, DELAY_LABEL_LENGTH, DELAY_LABEL_HEIGHT);
+            g_ringLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, DELAY_LABEL_FONT);
+            g_ringLable->SetText("响铃将在十分钟后再次响起");
+            /* ----------------------------------- Add ---------------------------------- */
+            g_ringView->Add(g_imageRing);
+            g_ringView->Add(g_ringLable);
+        }
+        NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeAlarmRingView);
+        return g_ringView;
     }
-}
 
-static bool CreateAlarmViewImage(void)
-{
-    g_imageDelete = new UIImageView();
-    if (g_imageDelete == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showAlarmNotify g_imageDelete null!");
-        return false;
+    // 析构一个响铃闹钟视图
+    void FreeAlarmRingView(void)
+    {
+        if (g_ringView != nullptr)
+        {
+            DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_DELAY);
+            g_ringView->RemoveAll();
+            if (g_imageRing)
+            {
+                delete g_imageRing;
+                g_imageRing = nullptr;
+            }
+            if (g_ringLable)
+            {
+                delete g_ringLable;
+                g_ringLable = nullptr;
+            }
+            RootView::GetInstance()->Remove(g_ringView);
+            delete g_ringView;
+            g_ringView = nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeAlarmRingView over!!");
+        }
     }
-    g_imageDelete->SetPosition(IMAGE_DELETE_X, IMAGE_DELETE_Y);
-    g_imageDelete->SetWidth(MAX_SET_SRC_LEN);
-    g_imageDelete->SetHeight(MAX_SET_SRC_LEN);
-    g_imageDelete->SetViewId(ALARM_IMAGE_DELETE);
-    g_imageDelete->SetSrc(ALARM_DELETE_ADD_PATH);
-    g_imageDelete->SetTouchable(true);
-    UIView::OnClickListener *closeListener = static_cast<UIView::OnClickListener *>\
-        (AlarmViewEventListener::GetInstance());
-    g_imageDelete->SetOnClickListener(closeListener);
-    g_imageDelete->SetVisible(false);
 
-    g_imageClock = new UIImageView();
-    if (g_imageClock == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showAlarmNotify g_imageClock null!");
-        delete g_imageDelete;
-        return false;
+    // 创建一个闹钟弹窗视图
+    UIViewGroup *CreateAlarmView(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView");
+        AlarmClockModel::GetInstance()->AlarmGetClockNum();
+        if (g_alarmView == nullptr)
+        {
+            g_alarmView = new UIViewGroup();
+            if (g_alarmView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView g_alarmView null!");
+                return nullptr;
+            }
+            g_alarmView->SetPosition(CONTAINER_X, CONTAINER_Y, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            g_alarmView->SetViewId(ALARM_VIEW_POPUP);
+            g_alarmView->SetDraggable(true);
+            g_alarmView->SetTouchable(true);
+            UIView::OnDragListener *listener = static_cast<UIView::OnDragListener *>(AlarmViewEventListener::GetInstance());
+            if (nullptr == listener)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmViewEventListener::GetInstance fail!!");
+                return nullptr;
+            }
+            g_alarmView->SetOnDragListener(listener);
+            /* -------------------------------------------------------------------------- */
+            if (g_mainLable == nullptr)
+            {
+                g_mainLable = new UILabelExt();
+                if (g_mainLable == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView g_mainLable is nullptr");
+                    return nullptr;
+                }
+            }
+            g_mainLable->SetPosition(83, 50, 300, 35);
+            g_mainLable->SetTextId(STR_ALARM); // 闹钟
+            g_mainLable->SetStyle(STYLE_TEXT_FONT, 30);
+            g_mainLable->SetStyle(STYLE_LINE_HEIGHT, 35);
+            g_mainLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            g_mainLable->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+            g_mainLable->SetRollSpeed(70);
+            g_mainLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            g_alarmView->Add(g_mainLable);
+            /* -------------------------------------------------------------------------- */
+            if (g_ClockPrompt == nullptr)
+            {
+                g_ClockPrompt = new UIImageView();
+                if (g_ClockPrompt == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView g_ClockPrompt is nullptr");
+                    return nullptr;
+                }
+            }
+            g_ClockPrompt->SetPosition(184, 129, 100, 100);
+            g_ClockPrompt->SetSrc("/user/res/Alarm/alarm_prompt.bin");
+            g_alarmView->Add(g_ClockPrompt);
+            /* -------------------------------------------------------------------------- */
+            struct tm localTime;
+            int16 thisHour;
+            int16 thisMin;
+            if (g_dClock == nullptr)
+            {
+                g_dClock = new UIDigitalClock();
+                if (g_dClock == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmViewLabel g_dClock is nullptr");
+                    return nullptr;
+                }
+            }
+            g_dClock->SetPosition((g_alarmView->GetWidth() - 200) / 2, 236, 200, 70);
+            g_dClock->SetStyle(STYLE_TEXT_FONT, 60);
+            g_dClock->SetStyle(STYLE_LINE_HEIGHT, 69);
+            g_dClock->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 60);
+            time_t seconds = time(nullptr);
+            if (localtime_r(&seconds, &localTime) == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmViewLabel get localtime error!");
+                return nullptr;
+            }
+            AlarmClockModel::GetInstance()->GetPopTimeData(&thisHour, &thisMin);
+            g_dClock->SetDisplayMode(UIDigitalClock::DISPLAY_24_HOUR_NO_SECONDS);
+            g_dClock->SetTime24Hour(thisHour, thisMin, 0);
+            g_dClock->SetVisible(false);
+            g_alarmView->Add(g_dClock);
+            /* -------------------------------- g_popTime ------------------------------- */
+            if (g_popTime == nullptr)
+            {
+                g_popTime = new UILabelExt();
+                if (g_popTime == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView g_popTime is nullptr");
+                    return nullptr;
+                }
+            }
+            g_popTime->SetPosition(83, 236, 200, 70);
+            // std::string poptime = std::to_string(thisHour) + ":" + std::to_string(thisMin);
+            char poptime[12] = {0};
+            sprintf(poptime, "%02d:%02d", thisHour, thisMin);
+            g_popTime->SetText(poptime);
+            g_popTime->SetStyle(STYLE_TEXT_FONT, 60);
+            g_popTime->SetStyle(STYLE_LINE_HEIGHT, 70);
+            g_popTime->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 60);
+            g_popTime->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);
+            g_popTime->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+            g_alarmView->Add(g_popTime);
+            g_popTime->SetPosition((g_alarmView->GetWidth() - g_popTime->GetTextWidth()) / 2, 236);
+            /* -------------------------------------------------------------------------- */
+            if (g_StopBtn == nullptr)
+            {
+                g_StopBtn = new UILabelButtonExt();
+                if (g_StopBtn == nullptr)
+                {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView g_StopBtn is nullptr");
+                    return nullptr;
+                }
+            }
+            g_StopBtn->SetPosition(0, 366, 466, 100);
+            g_StopBtn->SetViewId(ALARM_IMAGE_STOP);
+            g_StopBtn->SetTextId(STR_STOP); // 停止
+            g_StopBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+            g_StopBtn->SetTextColor(Color::GetColorFromRGBA(0xff, 0x5a, 0x36, 0xff));
+            g_StopBtn->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
+            g_StopBtn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED);
+            g_StopBtn->SetTouchable(true);
+            UIView::OnClickListener *closeListener = static_cast<UIView::OnClickListener *>(AlarmViewEventListener::GetInstance());
+            if (nullptr == closeListener)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmViewEventListener::GetInstance fail!!");
+                return nullptr;
+            }
+            g_StopBtn->SetOnClickListener(closeListener);
+            g_alarmView->Add(g_StopBtn);
+            /* -------------------------------------------------------------------------- */
+            StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING, NOTIFY_ONE_SECOND);
+        }
+        NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeAlarmView);
+        return g_alarmView;
     }
-    g_imageClock->SetPosition(IMAGE_CLOCK_X, IMAGE_CLOCK_Y);
-    g_imageClock->SetWidth(MAX_SET_SRC_LEN);
-    g_imageClock->SetHeight(MAX_SET_SRC_LEN);
-    g_imageClock->SetViewId(ALARM_IMAGE_CLOCK);
-    g_imageClock->SetSrc(ALARM_CLOCK_ADD_PATH);
-    g_imageClock->SetTouchable(true);
-    g_imageClock->SetTouchable(true);
-    UIView::OnClickListener *clockListener = static_cast<UIView::OnClickListener *>\
-        (OHOS::AlarmViewEventListener::GetInstance());
-    g_imageClock->SetOnClickListener(clockListener);
-    g_imageClock->SetVisible(false);
-
-
-    g_ClockPrompt = new UIImageView();
-    if (g_ClockPrompt == nullptr)
-        return false;
-    
-    g_ClockPrompt->SetPosition(184, 129, 100, 100);
-    g_ClockPrompt->SetSrc("/user/res/Alarm/alarm_prompt.bin");
-
-
-    g_StopBtn = new UILabelButtonExt();
-    if (g_StopBtn == nullptr)
-        return false;
-
-    g_StopBtn->SetPosition(0, 366, 466, 100);
-    g_StopBtn->SetViewId(ALARM_IMAGE_DELETE);
-    g_StopBtn->SetTextId(STR_STOP);
-    g_StopBtn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
-    g_StopBtn->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0x5A, 0x36));
-    g_StopBtn->SetImageSrc(PNG_BUTTON_466x100_IMAGE, PNG_BUTTON_466x100_IMAGE);
-    g_StopBtn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0x00, UIButton::PRESSED);
-    g_StopBtn->SetTouchable(true);
-    // closeListener = static_cast<UIView::OnClickListener *>(AlarmViewEventListener::GetInstance());
-    g_StopBtn->SetOnClickListener(closeListener);
-
-    return true;
-}
-
-static void FreeAlarmViewImage(void)
-{
-    delete g_imageDelete;
-    g_imageDelete = nullptr;
-    delete g_imageClock;
-    g_imageClock = nullptr;
-
-    delete g_StopBtn;
-    g_StopBtn = nullptr;
-    delete g_ClockPrompt;
-    g_ClockPrompt = nullptr;    
-}
-
-static bool CreateAlarmViewLabel(void)
-{
-    struct tm localTime;
-    int16 thisHour;
-    int16 thisMin;
-
-    g_mainLable = new UILabelExt(); // UILabel();
-    if (g_mainLable == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmViewLabel g_mainLable is nullptr");
-        return false;
+    // 释放闹钟视图
+    void FreeAlarmView(void)
+    {
+        if (g_alarmView != nullptr)
+        {
+            DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+            g_alarmView->RemoveAll();
+            if (g_mainLable != nullptr)
+            {
+                delete g_mainLable;
+                g_mainLable = nullptr;
+            }
+            if (g_dClock != nullptr)
+            {
+                delete g_dClock;
+                g_dClock = nullptr;
+            }
+            if (g_popTime != nullptr)
+            {
+                delete g_popTime;
+                g_popTime = nullptr;
+            }
+            if (g_ClockPrompt != nullptr)
+            {
+                delete g_ClockPrompt;
+                g_ClockPrompt = nullptr;
+            }
+            if (g_StopBtn != nullptr)
+            {
+                delete g_StopBtn;
+                g_StopBtn = nullptr;
+            }
+            RootView::GetInstance()->Remove(g_alarmView);
+            delete g_alarmView;
+            g_alarmView = nullptr;
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FreeAlarmView over!!");
+        }
     }
-    g_mainLable->SetPosition(83, 50, 300, 35); // (LABEL_X, LABEL_Y, LABEL_WIDTH, LABEL_HEIGHT);
-    // g_mainLable->SetText("闹钟");
-    g_mainLable->SetTextId(STR_ALARM);
-    g_mainLable->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); // LABEL_FONT);
-    g_mainLable->SetStyle(STYLE_TEXT_FONT, 30);
-    g_mainLable->SetStyle(STYLE_LINE_HEIGHT, 35);
-    g_mainLable->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
-    g_mainLable->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
-    g_mainLable->SetRollSpeed(70);
 
-    g_dClock = new UIDigitalClock();
-    if (g_dClock == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmViewLabel g_dClock is nullptr");
-        delete g_mainLable;
-        return false;
+    AlarmViewEventListener::AlarmViewEventListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmViewEventListener :%p", this);
     }
-    g_dClock->SetPosition(155, 236, 156, 70); // (CLOCK_X, CLOCK_Y);
-    // g_dClock->Resize(DIGITAL_CLOCK_WIDTH, DIGITAL_CLOCK_HEIGHT);
-    g_dClock->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 60); // CLOCK_FONT);
-    time_t seconds = time(nullptr);
-    if (localtime_r(&seconds, &localTime) == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmViewLabel get localtime error!");
-        delete g_mainLable;
-        delete g_dClock;
-        return false;
-    }
-    AlarmClockModel::GetInstance()->GetPopTimeData(&thisHour, &thisMin);
-    g_dClock->SetDisplayMode(UIDigitalClock::DISPLAY_24_HOUR_NO_SECONDS);
-    g_dClock->SetTime24Hour(thisHour, thisMin, 0);
-    return true;
-}
-
-static void FreeAlarmViewLabel(void)
-{
-    delete g_mainLable;
-    g_mainLable = nullptr;
-    delete g_dClock;
-    g_dClock = nullptr;
-}
 
-UIViewGroup* CreateAlarmView(void)
-{
-    AlarmClockModel::GetInstance()->AlarmGetClockNum();
-    g_alarmView = new UIViewGroup();
-    if (g_alarmView == nullptr) {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CreateAlarmView g_alarmView null!");
-        return nullptr;
+    AlarmViewEventListener::~AlarmViewEventListener()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~AlarmViewEventListener");
     }
-    g_alarmView->SetPosition(CONTAINER_X, CONTAINER_Y,
-                             Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
-    g_alarmView->SetViewId(ALARM_VIEW_POPUP);
 
-    if (!CreateAlarmViewLabel()) {
-        delete g_alarmView;
-        g_alarmView = nullptr;
-        return nullptr;
+    AlarmViewEventListener *AlarmViewEventListener::GetInstance(void)
+    {
+        static AlarmViewEventListener alarmViewEventListener;
+        return &alarmViewEventListener;
     }
 
-    if (!CreateAlarmViewImage()) {
-        delete g_alarmView;
-        g_alarmView = nullptr;
-        FreeAlarmViewLabel();
-        return nullptr;
+    bool AlarmViewEventListener::OnDrag(UIView &view, const DragEvent &event)
+    {
+        return true;
     }
-    g_alarmView->Add(g_mainLable);
-    g_alarmView->Add(g_dClock);
-    g_alarmView->Add(g_imageDelete);
-    g_alarmView->Add(g_imageClock);
-    g_alarmView->Add(g_ClockPrompt);
-    g_alarmView->Add(g_StopBtn);
 
-    g_alarmView->SetDraggable(true);
-    g_alarmView->SetTouchable(true);
-    UIView::OnDragListener *listener = static_cast<UIView::OnDragListener*>(AlarmViewEventListener::GetInstance());
-    g_alarmView->SetOnDragListener(listener);
-    StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING, NOTOFY_NO_OPERATE_TIME);
-    NotificationManager::GetInstance()->RegisterNotifyCleanupFunction(FreeAlarmView);
-    return g_alarmView;
-}
-void FreeAlarmView(void)
-{
-    if (g_alarmView != nullptr) {
-        DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
-        g_alarmView->RemoveAll();
-        FreeAlarmViewLabel();
-        FreeAlarmViewImage();
-        RootView::GetInstance()->Remove(g_alarmView);
-        delete g_alarmView;
-        g_alarmView = nullptr;
+    bool AlarmViewEventListener::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        // if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        // {
+        //     if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0)
+        //     {
+        //         DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+        //         AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+        //         UIViewGroup *alarmRingView = CreateAlarmRingView();
+        //         NotificationManager::GetInstance()->screenContainer_->SetVisible(false);
+        //         RootView::GetInstance()->Add(alarmRingView);
+        //         alarmRingView->SetVisible(true);
+        //         StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_DELAY, NOTIFY_THREE_SECONDS);
+        //     }
+        //     else if (strcmp(view.GetViewId(), ALARM_VIEW_CLOSE) == 0 ||
+        //              strcmp(view.GetViewId(), ALARM_VIEW_DELAY) == 0)
+        //     {
+        //         NotificationManager::GetInstance()->StopNotify();
+        //     }
+        // }
+        // return true;
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT)
+        {
+            if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0)
+            {
+                DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+                // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
+                FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
+                NotificationManager::GetInstance()->StopNotify();
+            }
+        }
+        return true;
     }
-}
-
-AlarmViewEventListener::AlarmViewEventListener()
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmViewEventListener :%p", this);
-}
-
-AlarmViewEventListener::~AlarmViewEventListener()
-{
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "~AlarmViewEventListener");
-}
-
-AlarmViewEventListener *AlarmViewEventListener::GetInstance(void)
-{
-    static AlarmViewEventListener alarmViewEventListener;
-    return &alarmViewEventListener;
-}
-
-bool AlarmViewEventListener::OnDrag(UIView& view, const DragEvent& event)
-{
-    return true;
-}
 
-bool AlarmViewEventListener::OnDragEnd(UIView& view, const DragEvent& event)
-{
-    if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) {
-        if (strcmp(view.GetViewId(), ALARM_VIEW_POPUP) == 0) {
+    bool AlarmViewEventListener::OnClick(UIView &view, const ClickEvent &event)
+    {
+        // UNUSED(event);
+        // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlamNotify ClickListener %s", view.GetViewId());
+        // if (strcmp(view.GetViewId(), ALARM_IMAGE_DELETE) == 0)
+        // {
+        //     DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+        //     AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
+        //     UIViewGroup *alarmCloseView = CreateAlarmCloseView();
+        //     NotificationManager::GetInstance()->screenContainer_->SetVisible(false);
+        //     RootView::GetInstance()->Add(alarmCloseView);
+        //     alarmCloseView->SetVisible(true);
+        //     StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_CLOSE, NOTIFY_THREE_SECONDS);
+        //     return true;
+        // }
+        // else if (strcmp(view.GetViewId(), ALARM_IMAGE_CLOCK) == 0)
+        // {
+        //     DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
+        //     AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
+        //     UIViewGroup *alarmRingView = CreateAlarmRingView();
+        //     NotificationManager::GetInstance()->screenContainer_->SetVisible(false);
+        //     RootView::GetInstance()->Add(alarmRingView);
+        //     alarmRingView->SetVisible(true);
+        //     StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_DELAY, NOTIFY_THREE_SECONDS);
+        // }
+        // return true;
+
+        UNUSED(event);
+        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()->DelayAlarmRing();
-            UIViewGroup* alarmRingView = CreateAlarmRingView();
-            NotificationManager::GetInstance()->screenContainer_->SetVisible(false);
-            RootView::GetInstance()->Add(alarmRingView);
-            alarmRingView->SetVisible(true);
-            StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_DELAY, NOTIFY_THREE_SECONDS);
-        } else if (strcmp(view.GetViewId(), ALARM_VIEW_CLOSE) == 0 ||
-                   strcmp(view.GetViewId(), ALARM_VIEW_DELAY) == 0) {
+            // AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
+            FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
             NotificationManager::GetInstance()->StopNotify();
         }
-    }
-    return true;
-}
-
-bool AlarmViewEventListener::OnClick(UIView& view, const ClickEvent& event)
-{
-    UNUSED(event);
-    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlamNotify ClickListener %s", view.GetViewId());
-    if (strcmp(view.GetViewId(), ALARM_IMAGE_DELETE) == 0) {
-        DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
-        AlarmPopUpPresenter::GetInstance()->CancelAlarmRing();
-        UIViewGroup* alarmCloseView = CreateAlarmCloseView();
-        NotificationManager::GetInstance()->screenContainer_->SetVisible(false);
-        RootView::GetInstance()->Add(alarmCloseView);
-        alarmCloseView->SetVisible(true);
-        StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_CLOSE, NOTIFY_THREE_SECONDS);
         return true;
-    } else if (strcmp(view.GetViewId(), ALARM_IMAGE_CLOCK) == 0) {
-        DisableAlarmTimer(AlarmTimerType::NOTIFY_ALARM_RING);
-        AlarmPopUpPresenter::GetInstance()->DelayAlarmRing();
-        UIViewGroup* alarmRingView = CreateAlarmRingView();
-        NotificationManager::GetInstance()->screenContainer_->SetVisible(false);
-        RootView::GetInstance()->Add(alarmRingView);
-        alarmRingView->SetVisible(true);
-        StartAlarmTimer(AlarmTimerType::NOTIFY_ALARM_DELAY, NOTIFY_THREE_SECONDS);
     }
-    return true;
-}
-}  // namespace OHOS
+} // namespace OHOS
index 9077bed..be9adac 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-03-25 17:33:47
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-07 17:27:45
+ * @LastEditTime: 2024-09-09 20:43:23
  * @FilePath: /FD230/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp
  * @details:实现查找手表的功能一般需要手表和智能手机之间的配合,通常是通过手机上的应用(App)或其他设备发送指令给手表,触发手表的查找功能。
  * 以下是基本的实现步骤:
@@ -105,6 +105,11 @@ namespace OHOS
         return true;
     }
 
+    const char *FindWatchViewEventListener::GetPath()
+    {
+        return path_;
+    }
+
     void FindWatchViewEventListener::SetFindWatchNotifyFlag(bool flag)
     {
         FindWatchNotifyFlag = flag;
@@ -313,6 +318,7 @@ namespace OHOS
      */
     void FindWatchViewEventListener::PopInterPlayMusic(const char *path)
     {
+        path_ = path;
         ScreenTurnOn(-1); // 亮屏操作
 
         if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get()))
@@ -322,7 +328,7 @@ namespace OHOS
 
         // 将"开启查找手表铃声"任务发布到异步线程
         GraphicService::GetInstance()->PostGraphicEvent(
-            std::bind(&FindWatchViewEventListener::FindWatchRingPlayStart, &FindWatchViewEventListener::GetInstance(), path));
+            std::bind(&FindWatchViewEventListener::FindWatchRingPlayStart, &FindWatchViewEventListener::GetInstance(), path_));
     }
 
     // 声明定时器变量
@@ -573,7 +579,8 @@ namespace OHOS
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnPlaybackComplete");
         FindWatchViewEventListener::GetInstance().PopInterCancelMusic();
-        FindWatchViewEventListener::GetInstance().PopInterPlayMusic(nullptr);
+        const char *path = FindWatchViewEventListener::GetInstance().GetPath();
+        FindWatchViewEventListener::GetInstance().PopInterPlayMusic((path != nullptr) ? path : nullptr);
     }
 
     void FindWatchRingPlayerCallbackImpl::OnError(int32_t errorType, int32_t errorCode)