From a97f0b72c40abc7bc75ec83ff321c9daf69ad444 Mon Sep 17 00:00:00 2001 From: cheng Date: Tue, 27 Aug 2024 20:35:05 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E7=9D=A1=E7=9C=A0=E6=A8=A1?= =?utf8?q?=E5=BC=8F=EF=BC=9B=E6=9B=B4=E6=96=B0=E7=9D=A1=E7=9C=A0=E6=A8=A1?= =?utf8?q?=E5=BC=8F=E5=88=A4=E5=AE=9A=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../wearable/fd230app/CMakeLists.txt | 5 + .../nativelauncher/include/AppViewIDs.h | 1 + .../nativelauncher/include/NativeLauncher.h | 1 + .../include/ui_resource_string.h | 28 +-- .../nativelauncher/src/NativeLauncher.cpp | 16 ++ .../nativeui/alarm/src/AlarmClockModel.cpp | 4 +- .../nativeui/applist/src/ApplistPresenter.cpp | 2 +- .../nativeui/countdown/src/CountDownModel.cpp | 5 + .../src/DisplayBrightnessModel.cpp | 2 +- .../src/DisplayBrightnessPresent.cpp | 2 +- .../src/DisplayBrightnessView.cpp | 2 +- .../dnotdisturb/src/DnotDisturbModel.cpp | 2 +- .../heart_blood/CheckAbnormalView.cpp | 3 +- .../nativeui/heart_blood/CheckInvalidView.cpp | 3 +- .../nativeui/main/src/MainPresenterSample.cpp | 2 +- .../main/src/dropdown/DropDownCardPage1.cpp | 18 +- .../sleepmode/include/SleepModeModel.h | 25 ++ .../sleepmode/include/SleepModePresenter.h | 42 ++++ .../sleepmode/include/SleepModeView.h | 49 ++++ .../nativeui/sleepmode/src/SleepModeModel.cpp | 80 ++++++ .../sleepmode/src/SleepModePresenter.cpp | 104 ++++++++ .../nativeui/sleepmode/src/SleepModeView.cpp | 231 ++++++++++++++++++ .../nativeui/traing/src/TraingModel.cpp | 2 +- .../service/ble_service/blemoder/bletest.cpp | 2 +- .../msg_center/src/msg_center_customer.cpp | 2 +- .../src/notify/drinkReminder_notification.cpp | 3 +- .../src/notify/findwatch_notification.cpp | 5 +- .../src/notify/message_notification.cpp | 3 +- .../src/notify/sleep_notification.cpp | 5 +- .../power_manager/src/power_display_service.c | 5 + .../fs/user/res/font/ui_resource_string.h | 28 +-- .../peripheral/config/src/ConfigModel.cpp | 13 + .../drivers/peripheral/utils/custom_utils.c | 1 + tools/language_tool/font/ui_resource_string.h | 28 +-- 34 files changed, 660 insertions(+), 64 deletions(-) create mode 100644 code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeModel.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModePresenter.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeView.h create mode 100644 code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeModel.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModePresenter.cpp create mode 100644 code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeView.cpp diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 46837da2e..3f90941e9 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -133,6 +133,7 @@ set(PRIVATE_HEADER ${ROOT_DIR}/open_source/openharmony/utils/native/lite/kv_store/innerkits ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/include + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/include ) set(SOURCES @@ -757,6 +758,10 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListAdapter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/schedule/src/ScheduleListItem.cpp + #sleep mode + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/src/SleepModeView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/src/SleepModePresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleepmode/src/SleepModeModel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/calculator/src/CalculatorView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/calculator/src/CalculatorPresenter.cpp diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h index cf46569a2..74ea9c92f 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/AppViewIDs.h @@ -122,6 +122,7 @@ typedef enum : uint16_t VIEW_GOAL, // 每日目标 VIEW_CALCULATOR, // 计算器 VIEW_SCHEDULE, // schedule + VIEW_SLEEPMODE, // sleep mode /*屏蔽Slice*/ VIEW_PHONERING, // 拨号界面 VIEW_PHONECALLING, // 来电 diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h index a3fd40998..607843798 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/NativeLauncher.h @@ -121,6 +121,7 @@ namespace OHOS /* -------------------------------------------------------------------------- */ void InitCalculatorSlice(void); void InitScheduleSlice(void); + void InitSleepModeSlice(void); void InittestSlice(void); private: diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h index e6d8587e5..d67039d45 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h +++ b/code/sdk/application/wearable/fd230app/nativelauncher/include/ui_resource_string.h @@ -1,15 +1,15 @@ -/* -* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: language -* Author: Graphic develop team -* Create: 2021-07-06 -*/ - -#ifndef UI_RESOURCE_STRING_H -#define UI_RESOURCE_STRING_H -#include -namespace OHOS { -enum UIResourceTextId : uint16_t { +/* +* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. +* Description: language +* Author: Graphic develop team +* Create: 2021-07-06 +*/ + +#ifndef UI_RESOURCE_STRING_H +#define UI_RESOURCE_STRING_H +#include +namespace OHOS { +enum UIResourceTextId : uint16_t { STR_EXERCISE_OUTDOORWALKING = 0, STR_EXERCISE_OUTDOORRUNNING = 1, STR_EXERCISE_OUTDOORBIKING = 2, @@ -560,8 +560,8 @@ enum UIResourceTextId : uint16_t { STR_SLEEP_MODE_PROMPT_ON = 547, STR_MAX_ID = 548, }; // UIResourceTextId - -enum FontLanguageId : uint8_t { + +enum FontLanguageId : uint8_t { LANGUAGE_ID_ZH, LANGUAGE_ID_EN, LANGUAGE_ID_MAX diff --git a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp index e9540e53f..f88f405fa 100644 --- a/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp +++ b/code/sdk/application/wearable/fd230app/nativelauncher/src/NativeLauncher.cpp @@ -266,6 +266,7 @@ /* -------------------------------------------------------------------------- */ #include "schedule/include/SchedulePresenter.h" #include "schedule/include/ScheduleData.h" +#include "sleepmode/include/SleepModePresenter.h" #ifdef SUPPORT_ALIPAY_SEC #include "AlipayMainView.h" @@ -283,6 +284,7 @@ #include "product_adapter.h" #endif #include "bleEvent.h" +#include "../../../../../../drivers/peripheral/config/include/ConfigModelC.h" namespace OHOS { @@ -416,6 +418,7 @@ namespace OHOS /*智能助手*/ {VIEW_OFFLINEVOICE, &NativeLauncher::InitOfflineVoice}, {VIEW_SCHEDULE, &NativeLauncher::InitScheduleSlice}, + {VIEW_SLEEPMODE, &NativeLauncher::InitSleepModeSlice}, #ifdef SUPPORT_ALIPAY_SEC {VIEW_MAIN_ALIPAY, &NativeLauncher::InitMainAlipaySlice}, @@ -505,6 +508,7 @@ namespace OHOS read_jsonHistory_weather(); C_ScheduleDataReadFromFile(); + mmi_sleep_mode_switch_read(); } void NativeLauncher::InitAllNativeSlices(void) @@ -1534,4 +1538,16 @@ namespace OHOS NativeAbility::GetInstance().AddSliceProxy(VIEW_SCHEDULE, t_View); } + void NativeLauncher::InitSleepModeSlice(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NativeLauncher::InitSleepModeSlice"); + SliceProxy *t_View = new AbilitySliceProxy; + if (nullptr == t_View) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "View is nullptr"); + return; + } + NativeAbility::GetInstance().AddSliceProxy(VIEW_SLEEPMODE, t_View); + } + } diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp index 6cf0c9e31..9804b3e89 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -20,7 +20,7 @@ #include "ui_service.h" #include "notification_manager.h" #include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h" -#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h" +#include "custom_runtime.h" #ifdef __cplusplus extern "C" { @@ -692,7 +692,7 @@ void AlarmClockModel::PopInterCancelMusic() void AlarmClockModel::PopInterPlayMusic() { - if(true == ConfigModel::GetInstance()->GetDnotdisturb() && (0 == uapi_dev_runtime_get_sleep_monitoring_status())) + if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get())) { return; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp index 89278f439..564c30999 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp @@ -174,7 +174,7 @@ namespace OHOS HealthService::GetInstance()->SetHealthCurrent(highHealthState); viewId = VIEW_CHECK_INVALID; } - if(uapi_dev_runtime_get_sleep_monitoring_status()) + if(uapi_sleep_mode_flag_get()) { if(VIEW_DNOTDISTURB == viewId) return false; diff --git a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp index 3ac4f11a3..e56a8286a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/countdown/src/CountDownModel.cpp @@ -14,6 +14,7 @@ #include #include "ConfigModel.h" #include "ui_resource_string.h" +#include "custom_runtime.h" namespace OHOS { /* -------------------------------------------------------------------------- */ @@ -308,6 +309,10 @@ namespace OHOS /*触发铃声的开始*/ void CountDownModel::RequestStartRingtone(void) { + if(uapi_sleep_mode_flag_get()) + { + return; + } if (true != ConfigModel::GetInstance()->GetDnotdisturb()) { PostRingtoneEvent(&CountDownModel::StartRingtonePlayback); diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp index e8c8be662..035543200 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp @@ -36,7 +36,7 @@ namespace OHOS return false; } bool t_value = mmi_flip_wrist_switch_get(); - if(uapi_dev_runtime_get_sleep_monitoring_status()) + if(uapi_sleep_mode_flag_get()) { t_value = false; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp index 4ab35f458..819075e36 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp @@ -170,7 +170,7 @@ namespace OHOS } if (strcmp(view.GetViewId(), BRINGHTNESSCONTROLBUTTON_VIEW) == 0) { - if(uapi_dev_runtime_get_sleep_monitoring_status()) + if(uapi_sleep_mode_flag_get()) { return false; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp index dd1b552cd..437da1383 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp @@ -402,7 +402,7 @@ namespace OHOS DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessLabel); DisplayBrightnessScrollView[DISPLAYBRIGHTNESSVIEW]->Add(RaiseToBrightnessCheckBoxButton); - if(uapi_dev_runtime_get_sleep_monitoring_status()) + if(uapi_sleep_mode_flag_get()) { RaiseToBrightnessCheckBoxButton->SetTouchable(false); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp index f186f5569..1818c8faa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/dnotdisturb/src/DnotDisturbModel.cpp @@ -34,7 +34,7 @@ namespace OHOS bool DnotDisturbModel::GetDoNotDisturbModeEnabled() const { - if(uapi_dev_runtime_get_sleep_monitoring_status()) + if(uapi_sleep_mode_flag_get()) { return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp index 09ab6f0c7..1d4e6f692 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalView.cpp @@ -23,6 +23,7 @@ #include "heart_blood/CheckAbnormalView.h" #include "vibrator_service.h" +#include "custom_runtime.h" namespace OHOS { @@ -164,7 +165,7 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "CheckAbnormalView::InitBloodView fail"); } - if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { ui_api_vibrate_once_func(); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckInvalidView.cpp b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckInvalidView.cpp index 78953d59b..51a1030d2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckInvalidView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckInvalidView.cpp @@ -31,6 +31,7 @@ #include "heart_blood/health_service/health_service.h" #include "vibrator_service.h" +#include "custom_runtime.h" namespace OHOS { @@ -215,7 +216,7 @@ namespace OHOS } SetViewData(); - if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if(true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { // 震动提醒 ui_api_vibrate_once_func(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp index eb28df018..db2488651 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -134,7 +134,7 @@ namespace OHOS return true; } - if (uapi_dev_runtime_get_sleep_monitoring_status()) + if (uapi_sleep_mode_flag_get()) { if (VIEW_DNOTDISTURB == g_jumpView[curViewId]) { diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp index c7c2232f9..259de9636 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/dropdown/DropDownCardPage1.cpp @@ -12,6 +12,7 @@ #include "AppViewIDs.h" #include "NativeAbility.h" #include "dnotdisturb/include/DnotDisturbModel.h" +#include "sleepmode/include/SleepModeModel.h" #include "main/include/MainModel.h" #include #include "ConfigModel.h" @@ -113,11 +114,22 @@ namespace OHOS } else if (viewId == DROPDOWN_SLEEP_TOGGLEBUTTON_VIEWID) // 睡眠开关 { - state = toggleButton[DropDownCardPage1::toggleButton_SLEEP]->GetState(); + if (uapi_sleep_mode_flag_get()) + { + state = toggleButton[DropDownCardPage1::toggleButton_SLEEP]->GetState(); + UpdateSleepModelState(state); + SleepModeModel::GetInstance().SetSleepModeDisabled(); + // state = toggleButton[DropDownCardPage1::toggleButton_DNOTDISTURB]->GetState(); + UpdateDnotdisturbState(DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled()); + } + else + { + NativeAbility::GetInstance().EnterSlice(VIEW_SLEEPMODE); + } } else if (viewId == DROPDOWN_DNOTDISTURB_TOGGLEBUTTON_VIEWID) // 勿扰开关 { - if (uapi_dev_runtime_get_sleep_monitoring_status()) + if (uapi_sleep_mode_flag_get()) { return true; } @@ -180,7 +192,7 @@ namespace OHOS bool state_bt = ConfigModel::GetInstance()->GetClassicBlueToothState(); // 传统蓝牙开关 bool state_4g = uapi_cat1_get_power_stat(); bool state_savepower = uapi_dev_runtime_get_saveele_status(); - bool state_sleep = uapi_dev_runtime_get_sleep_monitoring_status(); + bool state_sleep = uapi_sleep_mode_flag_get(); bool state_dnotdisturb = DnotDisturbModel::GetInstance().GetDoNotDisturbModeEnabled(); ToggleButtonConfig toggleButtonConfig[] = { diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeModel.h b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeModel.h new file mode 100644 index 000000000..14cc1ac6a --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeModel.h @@ -0,0 +1,25 @@ + +#ifndef __SLEEPMODEMODEL_H__ +#define __SLEEPMODEMODEL_H__ + + +namespace OHOS +{ + class SleepModeModel + { + public: + static SleepModeModel &GetInstance(void); + // void UpdateSleepMode(void); + void SetSleepModeEnabled(void); + void SetSleepModeDisabled(void); + + private: + SleepModeModel(); + SleepModeModel(const SleepModeModel &) = delete; + SleepModeModel &operator=(const SleepModeModel &) = delete; + virtual ~SleepModeModel(); + + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModePresenter.h new file mode 100644 index 000000000..2d28b5d7c --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModePresenter.h @@ -0,0 +1,42 @@ + +#ifndef __SLEEPMODEPRESENTER_H__ +#define __SLEEPMODEPRESENTER_H__ + +#include "Presenter.h" +#include "View.h" +#include "sleepmode/include/SleepModeView.h" +#include "sleepmode/include/SleepModeModel.h" + + +namespace OHOS +{ + class SleepModeView; + class SleepModePresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener + { + public: + SleepModePresenter(); + virtual ~SleepModePresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SleepModePresenter *GetInstance(); + // virtual void Notify() override; + + private: + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool X_DRAG_FLAG{false}; + + SleepModeModel * SleepModeModel_{nullptr}; + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeView.h b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeView.h new file mode 100644 index 000000000..f4317cc2d --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/include/SleepModeView.h @@ -0,0 +1,49 @@ + +#ifndef __SLEEPMODEVIEW_H__ +#define __SLEEPMODEVIEW_H__ + +#include "BaseView.h" +#include "View.h" + +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_label_button_ext.h" + + +namespace OHOS +{ + #define SLEEPMODE_ViewId_OKButton_ "SLEEPMODE_ViewId_OKButton_" + + class SleepModePresenter; + class SleepModeView : public View + { + public: + SleepModeView(); + virtual ~SleepModeView(); + static SleepModeView * GetInstance(void); + + void OnStart() override; + void OnSetUpView() override; + void OnTearDownView() override; + void OnStop() override; + + private: + UIScrollView * InitScreen(void); + void DeinitScreen(void); + + UIScrollView * ScrollView_{nullptr}; + UILabelExt * TitleLabelExt_{nullptr}; + UIImageView * PromptImage_{nullptr}; + UILabelExt * PromptLabelExt_{nullptr}; + UILabelButtonExt * CancelButton_{nullptr}; + UILabelButtonExt * OKButton_{nullptr}; + + + #define SCREEN_WIDTH (Screen::GetInstance().GetWidth()) + #define SCREEN_HEIGHT (Screen::GetInstance().GetHeight()) + + #define SLEEP_MODE_PROMPT_IMAGE "/user/res/Sleepmode/sleepmode.bin" + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeModel.cpp new file mode 100644 index 000000000..c60aeb35b --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeModel.cpp @@ -0,0 +1,80 @@ + +#include "sleepmode/include/SleepModeModel.h" +#include "main/include/MainViewSample.h" +#include "MainModel.h" +#include "ConfigModel.h" +#include "custom_runtime.h" +#include "custom_utils.h" +#include "ui_service.h" +#include "ConfigModelC.h" +#include "power_display_service.h" + + +namespace OHOS +{ + SleepModeModel::SleepModeModel() {} + + SleepModeModel::~SleepModeModel() {} + + SleepModeModel &SleepModeModel::GetInstance() + { + static SleepModeModel instance; + return instance; + } + + void SleepModeModel::SetSleepModeEnabled(void) + { + uapi_sleep_mode_flag_set(1); + + // 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 SleepModeModel::SetSleepModeDisabled(void) + { + uapi_sleep_mode_flag_set(0); + + // 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()); + } + + // /*更新勿扰模式*/ + // void SleepModeModel::UpdateSleepMode(void) + // { + // if (PullUpDownView::GetInstance() != nullptr) + // { + // /*更新主界面下拉界面配置*/ + // if(DropDownCardPage1::GetInstance() && DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)) + // { + // DropDownCardPage1::GetInstance()->GetDropDownCardPage1_ToggleButton(DropDownCardPage1::toggleButton_DNOTDISTURB)->SetState(GetSleepModeEnabled()); + // } + // PullUpDownView::GetInstance()->UpdateSleepModeStatus(GetSleepModeEnabled()); + // /*更新主界面配置*/ + // MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB, GetSleepModeEnabled()); + // } + // return; + // } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModePresenter.cpp new file mode 100644 index 000000000..57882dc48 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModePresenter.cpp @@ -0,0 +1,104 @@ + +#include "AppViewIDs.h" +#include "NativeAbility.h" +#include "UiConfig.h" +#include "sleepmode/include/SleepModePresenter.h" +#include "common/key_code.h" +#include + + +namespace OHOS +{ + static SleepModePresenter * p_SleepModePresenterInstance = nullptr; + + SleepModePresenter::SleepModePresenter() + { + SleepModeModel_ = &SleepModeModel::GetInstance(); + p_SleepModePresenterInstance = this; + } + + SleepModePresenter::~SleepModePresenter() + { + p_SleepModePresenterInstance = nullptr; + } + + SleepModePresenter * SleepModePresenter::GetInstance() + { + return p_SleepModePresenterInstance; + } + + void SleepModePresenter::OnStart() + { + Presenter::OnStart(); + } + + void SleepModePresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void SleepModePresenter::OnResume(void) + { + Presenter::OnResume(); + } + + void SleepModePresenter::OnStop(void) + { + Presenter::OnStop(); + } + + bool SleepModePresenter::OnDrag(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepModePresenter::OnDrag"); + UNUSED(view); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SleepModePresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool SleepModePresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepModePresenter::OnDragEnd"); + UNUSED(event); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SleepModePresenter::X_DRAG_FLAG) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + SleepModePresenter::X_DRAG_FLAG = false; + } + return true; + } + + bool SleepModePresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(event); + + if(0 == strcmp(view.GetViewId(), SLEEPMODE_ViewId_OKButton_)) + { + SleepModeModel_->SetSleepModeEnabled(); + } + + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + return true; + } + + // 增加按键事件 + bool SleepModePresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SleepModePresenter::OnKeyAct"); + uint16_t keyID = event.GetKeyId(); + uint16_t keyState = event.GetState(); + // 如果是power键就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS); + } + return true; + } + + // void SleepModePresenter::Notify() + // { + // // SleepModeView::GetInstance()->UpdataTime(); + // } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeView.cpp b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeView.cpp new file mode 100644 index 000000000..987c5f215 --- /dev/null +++ b/code/sdk/application/wearable/fd230app/nativeui/sleepmode/src/SleepModeView.cpp @@ -0,0 +1,231 @@ + +#include "sleepmode/include/SleepModeView.h" +#include "sleepmode/include/SleepModePresenter.h" +#include "sleepmode/include/SleepModeModel.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "ui_resource_image.h" +#include "uicomponents/UIComponents.h" +#include "ui_resource_string.h" + + +namespace OHOS +{ + static SleepModeView * p_SleepModeViewInstance = nullptr; + + SleepModeView::SleepModeView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepModeView::SleepModeView"); + p_SleepModeViewInstance = this; + } + + SleepModeView::~SleepModeView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SleepModeView::~SleepModeView"); + p_SleepModeViewInstance = nullptr; + } + + SleepModeView * SleepModeView::GetInstance() + { + return p_SleepModeViewInstance; + } + + void SleepModeView::OnStart() + { + View::OnStart(); + + SetContainerView(new UIViewGroup()); + if (nullptr == GetContainer()) + { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[%d]", __LINE__); + return; + } + container_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + container_->SetTouchable(true); + container_->SetDraggable(true); + + ScrollView_ = InitScreen(); + + container_->Add(ScrollView_); + + RootView::GetInstance()->SetOnKeyActListener(presenter_); + } + + void SleepModeView::OnSetUpView() + { + View::OnSetUpView(); + + Draw(); + } + + void SleepModeView::OnTearDownView() + { + View::OnTearDownView(); + } + + void SleepModeView::OnStop() + { + View::OnStop(); + RootView::GetInstance()->ClearOnKeyActListener(); + + if (nullptr != container_) + { + container_->RemoveAll(); + + DeinitScreen(); + + delete container_; + container_ = nullptr; + } + + return; + } + + void SleepModeView::DeinitScreen() + { + if(nullptr != ScrollView_) + { + ScrollView_->RemoveAll(); + if(nullptr != TitleLabelExt_) + { + delete TitleLabelExt_; + TitleLabelExt_ = nullptr; + } + if(nullptr != PromptImage_) + { + delete PromptImage_; + PromptImage_ = nullptr; + } + if(nullptr != PromptLabelExt_) + { + delete PromptLabelExt_; + PromptLabelExt_ = nullptr; + } + if(nullptr != CancelButton_) + { + delete CancelButton_; + CancelButton_ = nullptr; + } + if(nullptr != OKButton_) + { + delete OKButton_; + OKButton_ = nullptr; + } + + delete ScrollView_; + ScrollView_ = nullptr; + } + } + + UIScrollView * SleepModeView::InitScreen(void) + { + if (nullptr == ScrollView_) + { + ScrollView_ = new UIScrollView(); + if (nullptr == ScrollView_) + return nullptr; + + ScrollView_->SetPosition(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + // ScrollView_->SetViewId(); + ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); + ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); + ScrollView_->SetOnDragListener(presenter_); + ScrollView_->SetTouchable(true); + ScrollView_->SetDraggable(true); + + if (nullptr == TitleLabelExt_) + { + TitleLabelExt_ = new UILabelExt(); + if (nullptr == TitleLabelExt_) + return nullptr; + + TitleLabelExt_->SetPosition(83, 50, 300, 35); + TitleLabelExt_->SetStyle(STYLE_TEXT_FONT, 30); + TitleLabelExt_->SetStyle(STYLE_LINE_HEIGHT, 35); + TitleLabelExt_->SetTextId(STR_SLEEPMODE); + TitleLabelExt_->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + TitleLabelExt_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TitleLabelExt_->SetRollSpeed(70); + TitleLabelExt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + // TitleLabelExt_->SetStyle(STYLE_TEXT_COLOR, 0xffff5a36); + } + + if (nullptr == PromptImage_) + { + PromptImage_ = new UIImageView(); + if (nullptr == PromptImage_) + return nullptr; + + PromptImage_->SetPosition(183, 107); + // PromptImage_->Resize(94, 94); + // PromptImage_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff8120e2); + // PromptImage_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + // PromptImage_->SetStyle(STYLE_BORDER_RADIUS, 100); + // PromptImage_->SetAutoEnable(false); + // PromptImage_->SetResizeMode(UIImageView::CENTER); + PromptImage_->SetSrc(SLEEP_MODE_PROMPT_IMAGE); + } + + if (nullptr == PromptLabelExt_) + { + PromptLabelExt_ = new UILabelExt(); + if (nullptr == PromptLabelExt_) + return nullptr; + + PromptLabelExt_->SetPosition(53, 230, 360, 70); + PromptLabelExt_->SetStyle(STYLE_TEXT_FONT, 30); + PromptLabelExt_->SetStyle(STYLE_LINE_HEIGHT, 35); + PromptLabelExt_->SetTextId(STR_SLEEP_MODE_PROMPT_ON); + PromptLabelExt_->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + PromptLabelExt_->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + PromptLabelExt_->SetRollSpeed(70); + PromptLabelExt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + PromptLabelExt_->SetStyle(STYLE_TEXT_COLOR, 0Xff999999); + } + + if (nullptr == CancelButton_) + { + CancelButton_ = new UILabelButtonExt(); + if (nullptr == CancelButton_) + return nullptr; + + CancelButton_->SetPosition(111, 320, 100, 100); + // CancelButton_->SetViewId(SCHEDULE_ViewId_DeleteCancelButton_); + CancelButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + CancelButton_->SetStyle(STYLE_BACKGROUND_OPA, 25); // 10% + CancelButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + CancelButton_->SetStyleForState(STYLE_BACKGROUND_OPA, 25, UIButton::PRESSED); + CancelButton_->SetStyle(STYLE_BORDER_RADIUS, 100); + CancelButton_->SetImagePosition(0, 0); + CancelButton_->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE); + CancelButton_->SetOnClickListener(presenter_); + } + + if (nullptr == OKButton_) + { + OKButton_ = new UILabelButtonExt(); + if (nullptr == OKButton_) + return nullptr; + + OKButton_->SetPosition(256, 320, 100, 100); + OKButton_->SetViewId(SLEEPMODE_ViewId_OKButton_); + OKButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + OKButton_->SetStyle(STYLE_BACKGROUND_OPA, 25); // 10% + OKButton_->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xffffffff, UIButton::PRESSED); + OKButton_->SetStyleForState(STYLE_BACKGROUND_OPA, 25, UIButton::PRESSED); + OKButton_->SetStyle(STYLE_BORDER_RADIUS, 100); + OKButton_->SetImagePosition(0, 0); + OKButton_->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE); + OKButton_->SetOnClickListener(presenter_); + } + + ScrollView_->Add(TitleLabelExt_); + ScrollView_->Add(PromptImage_); + ScrollView_->Add(PromptLabelExt_); + ScrollView_->Add(CancelButton_); + ScrollView_->Add(OKButton_); + } + + return ScrollView_; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index d13f55e88..43827fb8d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -510,7 +510,7 @@ namespace OHOS if (sportdata->heart >= maxHeartRate) { uapi_set_screen_on_api(); // 亮屏检测 - if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { ui_api_vibrate_once_func(); } diff --git a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp index 67705d48f..7db379f46 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -1880,7 +1880,7 @@ int get_ScreenDuration(void) //获取亮屏时长 } void Set_RaiseToWake(bool value) //抬婉亮屏开关 { - if(uapi_dev_runtime_get_sleep_monitoring_status()) + if(uapi_sleep_mode_flag_get()) { return; } 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 6029f6008..2cd458c82 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 @@ -782,7 +782,7 @@ void MsgCenterNotifyCatIncomingCallProc(const Topic topic, Request* req) } display_api->set_screen_set_keepon_timeout(10); - if(true != ConfigModel::GetInstance()->GetDnotdisturb()) + if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { AlarmClockModel::GetInstance()->AlarmPlayerStart(); } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp index 5e2708a32..f7db40c09 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/drinkReminder_notification.cpp @@ -15,6 +15,7 @@ #include #include #include "vibrator_service.h" +#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h" namespace OHOS { @@ -91,7 +92,7 @@ namespace OHOS { /*亮屏加震动*/ uapi_set_screen_on_api(); - if(true != ConfigModel::GetInstance()->GetDnotdisturb()) + if(true != ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { // uapi_vibrationModeSet(ConfigModel::GetInstance()->GetVibrationReminder()); ui_api_vibrate_once_func(); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp index 8681cc581..2c319dcfc 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/findwatch_notification.cpp @@ -38,6 +38,7 @@ #include #include #include "vibrator_service.h" +#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h" namespace OHOS { @@ -125,7 +126,7 @@ namespace OHOS void FindWatchViewEventListener::SetVibration(void) { - if(true == ConfigModel::GetInstance()->GetDnotdisturb()) + if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get())) { return; } @@ -314,7 +315,7 @@ namespace OHOS { ScreenTurnOn(-1); // 亮屏操作 - if(true == ConfigModel::GetInstance()->GetDnotdisturb()) + if(true == ConfigModel::GetInstance()->GetDnotdisturb() || (uapi_sleep_mode_flag_get())) { return; } diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp index 599b2cda8..d948443f2 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/message_notification.cpp @@ -14,6 +14,7 @@ #include "string" #include "vibrator_service.h" #include "../../../../../../../drivers/peripheral/config/include/ConfigModel.h" +#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h" namespace OHOS { @@ -200,7 +201,7 @@ namespace OHOS MessageGroupView->Add(messageLabel); MessageGroupView->Add(deleteButton); - if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { // 震动提醒 ui_api_vibrate_once_func(); 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 b708ae7db..cebf133cc 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 @@ -14,6 +14,7 @@ #include "UiConfig.h" #include "ConfigModel.h" #include "alarm/include/AlarmClockModel.h" +#include "../../../../../../../drivers/peripheral/utils/custom_runtime.h" namespace OHOS { @@ -150,7 +151,7 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create SleepGroupView succeed!!"); - if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb()) + if (true != OHOS::ConfigModel::GetInstance()->GetDnotdisturb() && (!uapi_sleep_mode_flag_get())) { ui_api_vibrate_once_func(); } @@ -194,7 +195,7 @@ 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() && (!uapi_sleep_mode_flag_get())) { ui_api_vibrate_once_func(); } diff --git a/code/sdk/application/wearable/service/power_manager/src/power_display_service.c b/code/sdk/application/wearable/service/power_manager/src/power_display_service.c index 10b582ee9..833d45a0f 100755 --- a/code/sdk/application/wearable/service/power_manager/src/power_display_service.c +++ b/code/sdk/application/wearable/service/power_manager/src/power_display_service.c @@ -207,6 +207,11 @@ static brightness_mode_t power_display_get_brightness_mode(void) static errcode_t power_display_set_brightness(uint8_t brightness) { + if(uapi_sleep_mode_flag_get()) // in sleep mode, cannot change brightness + { + brightness = 51; + } + message_type_t mt = SET_BRIGHTNESS_CMD; uint32_t event_info = brightness; #ifndef SUPPORT_AT_OHOSFWK diff --git a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h index e6d8587e5..d67039d45 100644 --- a/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h +++ b/code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/res/font/ui_resource_string.h @@ -1,15 +1,15 @@ -/* -* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: language -* Author: Graphic develop team -* Create: 2021-07-06 -*/ - -#ifndef UI_RESOURCE_STRING_H -#define UI_RESOURCE_STRING_H -#include -namespace OHOS { -enum UIResourceTextId : uint16_t { +/* +* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. +* Description: language +* Author: Graphic develop team +* Create: 2021-07-06 +*/ + +#ifndef UI_RESOURCE_STRING_H +#define UI_RESOURCE_STRING_H +#include +namespace OHOS { +enum UIResourceTextId : uint16_t { STR_EXERCISE_OUTDOORWALKING = 0, STR_EXERCISE_OUTDOORRUNNING = 1, STR_EXERCISE_OUTDOORBIKING = 2, @@ -560,8 +560,8 @@ enum UIResourceTextId : uint16_t { STR_SLEEP_MODE_PROMPT_ON = 547, STR_MAX_ID = 548, }; // UIResourceTextId - -enum FontLanguageId : uint8_t { + +enum FontLanguageId : uint8_t { LANGUAGE_ID_ZH, LANGUAGE_ID_EN, LANGUAGE_ID_MAX diff --git a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp index d43d0981a..7cd60976e 100644 --- a/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp +++ b/code/sdk/drivers/peripheral/config/src/ConfigModel.cpp @@ -12,6 +12,7 @@ #define CONFIG_DEBUG #endif #include "../../../../../drivers/peripheral/vibrator/service/vibrator_service.h" +#include "../../../../../application/wearable/fd230app/nativeui/sleepmode/include/SleepModeModel.h" // #define DEBUG_LINE() printf("%s %d\n",__func__,__LINE__) namespace OHOS @@ -1500,6 +1501,10 @@ 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); + if(flag) + { + OHOS::SleepModeModel::GetInstance().SetSleepModeEnabled(); + } } // sleep mode switch set @@ -1524,6 +1529,10 @@ void mmi_flip_wrist_switch_set(bool value) // play audio judgement bool mmi_play_audio_is_permitted(void) { + if(uapi_sleep_mode_flag_get()) + { + return false; + } if(true == (OHOS::ConfigModel::GetInstance()->GetDnotdisturb())) { return false; @@ -1535,6 +1544,10 @@ bool mmi_play_audio_is_permitted(void) // play vibrate judgement bool mmi_play_vibrate_is_permitted(void) { + if(uapi_sleep_mode_flag_get()) + { + return false; + } if(true == (OHOS::ConfigModel::GetInstance()->GetDnotdisturb())) { return false; diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 4352510ae..41066f444 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -183,6 +183,7 @@ void uapi_save_time_of_day(void) void shutdown_reboot_prejobs_task(void) { C_ScheduleDataWriteToFile(); + mmi_sleep_mode_switch_write(); uapi_save_time_of_day(); //保存步数 diff --git a/tools/language_tool/font/ui_resource_string.h b/tools/language_tool/font/ui_resource_string.h index e6d8587e5..d67039d45 100644 --- a/tools/language_tool/font/ui_resource_string.h +++ b/tools/language_tool/font/ui_resource_string.h @@ -1,15 +1,15 @@ -/* -* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: language -* Author: Graphic develop team -* Create: 2021-07-06 -*/ - -#ifndef UI_RESOURCE_STRING_H -#define UI_RESOURCE_STRING_H -#include -namespace OHOS { -enum UIResourceTextId : uint16_t { +/* +* Copyright (c) xxxxxxxx Technologies Co., Ltd. 2021-2021. All rights reserved. +* Description: language +* Author: Graphic develop team +* Create: 2021-07-06 +*/ + +#ifndef UI_RESOURCE_STRING_H +#define UI_RESOURCE_STRING_H +#include +namespace OHOS { +enum UIResourceTextId : uint16_t { STR_EXERCISE_OUTDOORWALKING = 0, STR_EXERCISE_OUTDOORRUNNING = 1, STR_EXERCISE_OUTDOORBIKING = 2, @@ -560,8 +560,8 @@ enum UIResourceTextId : uint16_t { STR_SLEEP_MODE_PROMPT_ON = 547, STR_MAX_ID = 548, }; // UIResourceTextId - -enum FontLanguageId : uint8_t { + +enum FontLanguageId : uint8_t { LANGUAGE_ID_ZH, LANGUAGE_ID_EN, LANGUAGE_ID_MAX -- 2.17.1