// uapi_dev_runtime_set_sleep_status(0);\r
// do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, NULL);\r
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "起床啦!");\r
+ if (OHOS::ConfigModel::GetInstance()->GetDnotdisturb())\r
+ {\r
+ OHOS::ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰\r
+ SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0);\r
+ }\r
if (curTime.tm_hour == wake_time_hour && curTime.tm_min == wake_time_min && curTime.tm_sec == 0)\r
{\r
OHOS::SleepModel::GetInstance().set_sleep_state(OHOS::SLEEPSTATE::WAKE);\r
OHOS::SleepModel::GetInstance().ReInitData(); // 更新睡眠数据\r
SendMsgToUIService(UI_UPDATE_SLEEP_DATA, 0, nullptr, 0);\r
}\r
- if (OHOS::ConfigModel::GetInstance()->GetDnotdisturb())\r
- {\r
- OHOS::ConfigModel::GetInstance()->SetDnotdisturb(false); // 关闭勿扰\r
- SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0);\r
- }\r
{\r
mmi_sleep_mode_flag_set(false); // switch off\r
\r
namespace OHOS
{
+#define MAX_SLEEP_RING 8
UIViewGroup *SleepGroupView{nullptr};
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;
}
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)
/*关闭闹钟*/
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();
}
{
// 如果是早安闹钟需要关闭闹钟
if (SLEEPSTATE::WAKE == SleepModel::GetInstance().get_sleep_state())
- AlarmClockModel::GetInstance()->PopInterCancelMusic();
+ SleepViewEventListener::GetInstance().PopInterCancelMusic();
NotificationManager::GetInstance()->StopNotify();
}
return true;
*/
void SleepViewEventListener::PopInterPlayMusic(void)
{
- ScreenTurnOn(15000); // 亮屏操作 15000ms 15秒关闭
// 将"开启闹铃铃声"任务发布到异步线程
GraphicService::GetInstance()->PostGraphicEvent(
std::bind(&SleepViewEventListener::SleepRingPlayStart, &SleepViewEventListener::GetInstance()));
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_)
{
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)