From 6863dc8c3e9eeec28a4419480fc3a95552d19d94 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Sat, 6 Jul 2024 18:45:42 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E7=9D=A1=E7=9C=A0=E4=B8=8E?= =?utf8?q?=E5=B0=8F=E7=9D=A1=E6=97=B6=E9=97=B4=E6=88=B3=E6=8E=A5=E6=94=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../msg_center/src/msg_center_customer.cpp | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index fc06cef0f..b4d32781d 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -424,10 +424,21 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) #endif #endif + +#ifdef FD230 +static SLEEP_T sleep_data = {0}; +static NAP_T nap_data = {0}; +static int state_num = 0; +static uint32_t day_timestamp = 0; +#endif + void MsgCenterNotifyNextDayProc(const Topic topic, Request* req) { unused(topic); unused(req); +#ifdef FD230 + day_timestamp = 0; +#endif AlarmClockModel::GetInstance()->NextDayNotify(); if(!ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP)) { @@ -998,17 +1009,24 @@ void MsgCenterNotifyActivityExtraInfoProc(const Topic topic, Request* req) { unused(topic); } -#ifdef FD230 -static SLEEP_T sleep_data = {0}; -static NAP_T nap_data = {0}; -#endif -static int state_num = 0; void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) { WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyInactivityProc !"); unused(topic); - uint32_t timestamp = 0; +#ifdef FD230 + if(day_timestamp == 0) + { + uint32_t timestamp = 0; + time_t rawtime; + struct tm* timeinfo; + time(&rawtime); + timeinfo = localtime(&rawtime); + uapi_get_timestampe_ss(×tamp); + day_timestamp = timestamp - (timeinfo->tm_hour * 60 * 60 + timeinfo->tm_min * 60 + timeinfo->tm_sec); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, ", = %d", day_timestamp); + } +#endif OHOS::SLEEP_STATE_T state_data = {0}; cywee_inactivity_result_t *cywee_Inactivity_Info = (cywee_inactivity_result_t *)malloc(req->len); if (!cywee_Inactivity_Info) @@ -1050,43 +1068,36 @@ void MsgCenterNotifyInactivityProc(const Topic topic, Request *req) //睡眠 case INACTIVITY_MODE_SLEEPING_OUTPUT: - - uapi_get_timestampe_ss(×tamp); - #ifdef FD230 - if(state_num < 20) { - sleep_data.sleep_status[state_num].timestamp = timestamp; + sleep_data.sleep_status[state_num].timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60; sleep_data.sleep_status[state_num].stat = cywee_Inactivity_Info->status; - state_num ++ ; + state_num ++; } - - if(cywee_Inactivity_Info->status == 6) //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 + if(cywee_Inactivity_Info->status == 0) //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 { - sleep_data.fall_asleep_timestamp = timestamp; + sleep_data.fall_asleep_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60; } else if(cywee_Inactivity_Info->status == 4) { - sleep_data.wake_up_timestamp = timestamp; + sleep_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60; } #endif break; //小睡 case INACTIVITY_MODE_NAP_OUTPUT: - if(cywee_Inactivity_Info->status == 6) //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 + if(cywee_Inactivity_Info->status == 0) //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 8未出睡最后一笔输出 12快速动眼 13取消入睡 { - uapi_get_timestampe_ss(×tamp); #ifdef FD230 - nap_data.fall_asleep_timestamp = timestamp; + nap_data.fall_asleep_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60; #endif } else if(cywee_Inactivity_Info->status == 14) { - uapi_get_timestampe_ss(×tamp); #ifdef FD230 - nap_data.wake_up_timestamp = timestamp; + nap_data.wake_up_timestamp = day_timestamp + cywee_Inactivity_Info->hour * 60 * 60 + cywee_Inactivity_Info->minute * 60; #endif } break; -- 2.17.1