From: Caisking <3449750381@qq.com> Date: Fri, 16 Aug 2024 10:20:18 +0000 (+0800) Subject: 配置睡眠提醒闹铃为一分钟 X-Git-Tag: release_V1.2.70_20241020_135402~652 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=f7af0c18ce72ccf432711c6aa64997b6e0fcc66c;p=mirrors%2FFD230.git 配置睡眠提醒闹铃为一分钟 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 9b96853a7..239c9f10c 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -383,6 +383,11 @@ extern "C" // uapi_dev_runtime_set_sleep_status(0); // do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "起床啦!"); + if (OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + { + OHOS::ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰 + SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0); + } if (curTime.tm_hour == wake_time_hour && curTime.tm_min == wake_time_min && curTime.tm_sec == 0) { OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WAKE); @@ -391,11 +396,6 @@ extern "C" OHOS::SleepModel::GetInstance().ReInitData(); // 更新睡眠数据 SendMsgToUIService(UI_UPDATE_SLEEP_DATA, 0, nullptr, 0); } - if (OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) - { - OHOS::ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰 - SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0); - } { mmi_sleep_mode_flag_set(false); // switch off diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp index 04f34fedf..10c4f2832 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/sleep_notification.cpp @@ -17,6 +17,7 @@ namespace OHOS { +#define MAX_SLEEP_RING 8 UIViewGroup *SleepGroupView{nullptr}; @@ -147,13 +148,13 @@ namespace OHOS SleepGroupView->Add(sleepbutton); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!"); - - if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) { ui_api_vibrate_once_func(); } - ScreenTurnOn(5000); // 亮屏操作 5000ms 5秒关闭 + ScreenTurnOn(100000); // 亮屏操作 100000ms 10秒关闭 return SleepGroupView; } @@ -192,10 +193,12 @@ namespace OHOS SleepGroupView->Add(closebutton); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!"); - if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) { ui_api_vibrate_once_func(); } + + ScreenTurnOn(600000); // 亮屏操作 600000ms 60秒关闭 } /*释放消息弹窗视图*/ void FreeSleepView(void) @@ -279,13 +282,13 @@ namespace OHOS /*关闭闹钟*/ if (strcmp(view.GetViewId(), CLOSEBUTTON) == 0) { - AlarmClockModel::GetInstance()->PopInterCancelMusic(); + SleepViewEventListener::GetInstance().PopInterCancelMusic(); NotificationManager::GetInstance()->StopNotify(); } /*小睡按键*/ if (strcmp(view.GetViewId(), NOPBUTTON) == 0) { - AlarmClockModel::GetInstance()->PopInterCancelMusic(); + SleepViewEventListener::GetInstance().PopInterCancelMusic(); SleepModel::GetInstance().Sleep_StartTimer(300000); // 开启一个5分钟的定时器 NotificationManager::GetInstance()->StopNotify(); } @@ -306,7 +309,7 @@ namespace OHOS { // 如果是早安闹钟需要关闭闹钟 if (SLEEPSTATE::WAKE == SleepModel::GetInstance().get_sleep_state()) - AlarmClockModel::GetInstance()->PopInterCancelMusic(); + SleepViewEventListener::GetInstance().PopInterCancelMusic(); NotificationManager::GetInstance()->StopNotify(); } return true; @@ -447,7 +450,6 @@ namespace OHOS */ void SleepViewEventListener::PopInterPlayMusic(void) { - ScreenTurnOn(15000); // 亮屏操作 15000ms 15秒关闭 // 将"开启闹铃铃声"任务发布到异步线程 GraphicService::GetInstance()->PostGraphicEvent( std::bind(&SleepViewEventListener::SleepRingPlayStart, &SleepViewEventListener::GetInstance())); @@ -514,18 +516,22 @@ namespace OHOS GraphicService::GetInstance()->PostGraphicEvent(Stop); } - /*响应外部的音频中断事件*/ + /* 响应外部的音频中断事件 */ void SleepRingPlayerListener::OnInterrupt(int32_t type, int32_t hint) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnInterrupt go in, type %d, hint %d.", type, hint); - if (type == INTERRUPT_TYPE_BEGIN && hint == INTERRUPT_HINT_PAUSE) - { - isDelayed_ = true; - } - if (type == INTERRUPT_TYPE_BEGIN && hint == INTERRUPT_HINT_STOP) + // 处理外部中断 + if (type == INTERRUPT_TYPE_BEGIN) { - StopSleepRing(); + if (hint == INTERRUPT_HINT_PAUSE) + { + isDelayed_ = true; + } + else if (hint == INTERRUPT_HINT_STOP) + { + StopSleepRing(); + } } else if (type == INTERRUPT_TYPE_END && isDelayed_) { @@ -533,15 +539,21 @@ namespace OHOS StartSleepRing(); isDelayed_ = false; } - return; } /* --------------------- SleepRingPlayerCallbackImpl -------------------- */ void SleepRingPlayerCallbackImpl::OnPlaybackComplete(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OnPlaybackComplete"); + static int countsleep = 0; SleepViewEventListener::GetInstance().PopInterCancelMusic(); - SleepViewEventListener::GetInstance().PopInterPlayMusic(); + /*达到最大次数不再播放*/ + if (countsleep <= MAX_SLEEP_RING) + { + SleepViewEventListener::GetInstance().PopInterPlayMusic(); + countsleep++; + printf("countsleep: %d\n", countsleep); + } } void SleepRingPlayerCallbackImpl::OnError(int32_t errorType, int32_t errorCode)