From 724b566a1e564b04109c4b13fdce16f8b86e0285 Mon Sep 17 00:00:00 2001 From: cheng Date: Tue, 27 Aug 2024 15:50:01 +0800 Subject: [PATCH] =?utf8?q?=E7=A7=BB=E9=99=A4=E7=9D=A1=E7=9C=A0=E7=9B=91?= =?utf8?q?=E6=B5=8B=E8=A7=A6=E5=8F=91=E7=9D=A1=E7=9C=A0=E6=A8=A1=E5=BC=8F?= =?utf8?q?=EF=BC=9B=E9=85=8D=E7=BD=AE=E7=9D=A1=E7=9C=A0=E6=A8=A1=E5=BC=8Fc?= =?utf8?q?onfig=20value=20&=20runtime=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/AlarmClockTimerConfig.cpp | 14 ------- .../nativeui/sleep/include/SleepModel.h | 4 -- .../nativeui/sleep/src/SleepModel.cpp | 38 ------------------- .../peripheral/config/include/ConfigModel.h | 2 + .../peripheral/config/include/ConfigModelC.h | 4 ++ .../peripheral/config/src/ConfigModel.cpp | 14 +++++++ .../drivers/peripheral/utils/custom_runtime.c | 12 ++++++ .../drivers/peripheral/utils/custom_runtime.h | 3 ++ 8 files changed, 35 insertions(+), 56 deletions(-) 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 9fd0b3fde..f1c8935bf 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -325,16 +325,6 @@ extern "C" std::bind(AlarmTimerEventPublish, TOPIC_EVENT_ON_TIME, unuse)); } - static void _ExitSleepModeAction(void) - { - OHOS::SleepModel::GetInstance().ExitSleepModeAction(); - } - - static void _EnterSleepModeAction(void) - { - OHOS::SleepModel::GetInstance().EnterSleepModeAction(); - } - void AlarmScan(void *arg) { struct tm curTime; @@ -416,8 +406,6 @@ extern "C" OHOS::SleepModel::GetInstance().ReInitData(); // 更新睡眠数据 SendMsgToUIService(UI_UPDATE_SLEEP_DATA, 0, nullptr, 0); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL);//算法底层切换小睡监测模式 - - GraphicService::GetInstance()->PostGraphicEvent(_ExitSleepModeAction); } } // 进入睡眠检测模式并退出小睡检测模式 @@ -440,8 +428,6 @@ extern "C" //LOS_Msleep(1000); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SLEEPING_MODE, NULL);//算法底层切换睡眠监测模式 - - GraphicService::GetInstance()->PostGraphicEvent(_EnterSleepModeAction); } } // 久坐提醒 diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h index 44554c4b5..88c848f37 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/include/SleepModel.h @@ -119,10 +119,6 @@ namespace OHOS void Sleep_StartTimer(uint32_t interval); void Sleep_StopTimer(void); - // - void EnterSleepModeAction(void); - void ExitSleepModeAction(void); - private: SleepModel(); SleepModel(const SleepModel &); diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp index c8d9912d5..b86e0e83a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp @@ -749,42 +749,4 @@ namespace OHOS } } /* -------------------------------------------------------------------------- */ - void SleepModel::EnterSleepModeAction(void) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]:EnterSleepModeAction]", __LINE__); - - // update donotdisturb - SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0); - - /*更新主界面配置*/ - MainModel::GetInstance().setDialState(DialState::SLEEP, true); - - // disable flip wrist - uapi_take_to_wake(0); - - // 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__); - - // update donotdisturb - SendMsgToUIService(UI_UPDATE_DNOTDISTURB_MODE, 0, nullptr, 0); - - /*更新主界面配置*/ - MainModel::GetInstance().setDialState(DialState::SLEEP, false); - - // enable flip wrist - if(true == mmi_flip_wrist_switch_get()) - { - uapi_take_to_wake(1); - } - - // 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 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModel.h b/code/sdk/drivers/peripheral/config/include/ConfigModel.h index 2527a92e7..b27ad3216 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModel.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModel.h @@ -104,6 +104,7 @@ namespace OHOS CONFIGMODEL_ITEM_SLEEP_BEDTIME,//就寝时间 CONFIGMODEL_ITEM_SLEEP_GET_UP,//起床时间 CONFIGMODEL_ITEM_SLEEP_REMIND,//提前20分钟提醒开关 + CONFIGMODEL_ITEM_SLEEP_MODE_SWITCH, // sleep mode //久坐提醒相关 CONFIGMODEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔(单位小时) @@ -358,6 +359,7 @@ namespace OHOS {ConfigDataType::DATATYPE_INT, "sleep_bedtime", "1310720" }, //CONFIGMODEL_ITEM_SLEEP_BEDTIME,就寝时间 1310720 : 20 << 16 ,前16位为小时,后16位为分钟 {ConfigDataType::DATATYPE_INT, "sleep_getup", "589824" }, // CONFIGMODEL_ITEM_SLEEP_GET_UP,起床时间,589824 : 9 << 16 ,前16位为小时,后16位为分钟 {ConfigDataType::DATATYPE_INT, "sleep_remide", "0" }, // CONFIGMODEL_ITEM_SLEEP_REMIND,//提前20分钟提醒开关 + {ConfigDataType::DATATYPE_INT, "sleep_mode", "0" }, // CONFIGMODEL_ITEM_SLEEP_MODE_SWITCH, // sleep mode {ConfigDataType::DATATYPE_INT, "sedentary_switch", "0" }, // CONFIGMODEL_ITEM_SEDENTARY_SWITCH,//久坐提醒开关 {ConfigDataType::DATATYPE_INT, "sedentary_interval", "1" }, // CONFIGMODEL_ITEM_SEDENTARY_INTERVAL,//久坐提醒时间间隔 {ConfigDataType::DATATYPE_INT, "sedentary_remindertime", "0" }, // CONFIGMODEL_ITEM_SEDENTARY_REMINDERTIME,//久坐提醒时间段 前16位是开始时间 前8 为小时 后8为分钟 后16位为结束时间规则同前 例: 1600 0B00 11点开始到 22点结束 diff --git a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h index b0b962354..2a0a6dd44 100644 --- a/code/sdk/drivers/peripheral/config/include/ConfigModelC.h +++ b/code/sdk/drivers/peripheral/config/include/ConfigModelC.h @@ -106,6 +106,10 @@ int get_config_heart_from_config_model(void); //设置睡眠频率 void set_config_heart(int heartRateDetectionFreq); +// sleep mode switch +void mmi_sleep_mode_switch_read(void); +void mmi_sleep_mode_switch_write(void); + // for c file bool mmi_flip_wrist_switch_get(void); diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index 16de7a0de..f66f1211f 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -1530,6 +1530,20 @@ bool get_motion_recognition_from_config_model(void) return flag; } +// sleep mode switch get +void mmi_sleep_mode_switch_read(void) +{ + uint8_t flag = (OHOS::ConfigModel::GetInstance()->get_configData_int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_MODE_SWITCH)); + uapi_sleep_mode_flag_set(flag); +} + +// sleep mode switch set +void mmi_sleep_mode_switch_write(void) +{ + uint8_t flag = uapi_sleep_mode_flag_get(); + OHOS::ConfigModel::GetInstance()->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SLEEP_MODE_SWITCH, flag); +} + // get flip wrist switch for c file bool mmi_flip_wrist_switch_get(void) { diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index 5d05fd128..c93c616ae 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -79,6 +79,7 @@ typedef struct uint8_t saveele_status;//省电模式状态 uint8_t lock_status;//密码锁状态 uint8_t motion_recognition_status;//运动识别开关状态 + uint8_t sleep_mode_flag; // sleep mode flag } runtime_status_t; @@ -379,4 +380,15 @@ void uapi_dev_runtime_set_motion_recognition_status(uint8_t status) uint8_t uapi_dev_runtime_get_motion_recognition_status(void) { return g_runtime.motion_recognition_status; +} + +// sleep mode flag +void uapi_sleep_mode_flag_set(uint8_t flag) +{ + g_runtime.sleep_mode_flag = flag; +} + +uint8_t uapi_sleep_mode_flag_get(void) +{ + return g_runtime.sleep_mode_flag; } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index 38ed9784c..f36c53997 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -184,6 +184,9 @@ void uapi_dev_runtime_set_ancs_clientid(uint16_t clientid); uint16_t uapi_dev_runtime_get_ancs_clientid(void); +// sleep mode flag +void uapi_sleep_mode_flag_set(uint8_t flag); +uint8_t uapi_sleep_mode_flag_get(void); #ifdef __cplusplus #if __cplusplus -- 2.17.1