void SleepModel::Sleep_StartTimer(uint32_t interval)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepModel::Sleep_StartTimer");
- /* -------------------------- 1.检查定时器是否已经存在,如果存在则返回 ------------------------- */
if (g_timer != NULL)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer already exists!!");
return;
}
-
- /* --------------------------------- 2.创建定时器 -------------------------------- */
g_timer = osTimerNew((osTimerFunc_t)Sleep_TimerCallback, osTimerOnce, NULL, NULL);
- // 检查定时器创建是否成功
if (g_timer == NULL)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CountDownModel::CountDown_StartTimer Timer create failed!!");
return;
}
-
- /* ----------------------------- 3.将毫秒转换为系统时钟节拍数 ---------------------------- */
int tick = osMs2Tick(interval);
-
- /* --------------------------------- 4.启动定时器 -------------------------------- */
osStatus_t ret = osTimerStart(g_timer, tick);
- /* -------------------- 5.检查定时器启动是否成功,如果启动失败,删除定时器并置为 NULL -------------------- */
if (ret != osOK)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[CountDown_StartTimer] osTimerDelete failed, ret = %lx!!", ret);
g_timer = NULL;
}
}
-
+ /* -------------------------------------------------------------------------- */
void SleepModel::EnterSleepModeAction(void)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:EnterSleepModeAction]", __LINE__);
// switch on
- mmi_sleep_mode_flag_set(true);
-
+ // mmi_sleep_mode_flag_set(true);
+
// switch on donotdisturb
DeviceStateBeforeSleep_.DnotdisturbFlag = OHOS::ConfigModel::GetInstance()->GetDnotdisturb();
OHOS::ConfigModel::GetInstance()->SetDnotdisturb(true); // 开启勿扰
// turn down brightness
const power_display_svr_api_t *display_api = power_display_svr_get_api();
display_api->set_brightness(51);
-
}
void SleepModel::ExitSleepModeAction(void)
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:ExitSleepModeAction]", __LINE__);
// switch off
- mmi_sleep_mode_flag_set(false);
+ // mmi_sleep_mode_flag_set(false);
// reset donotdisturb
bool DnotdisturbFlag = DeviceStateBeforeSleep_.DnotdisturbFlag;
// reset brightness
const power_display_svr_api_t *display_api = power_display_svr_get_api();
display_api->set_brightness(OHOS::ConfigModel::GetInstance()->GetBrightness());
-
}
}
\ No newline at end of file