From: luozheng <1732036298@qq.com> Date: Tue, 28 May 2024 12:30:14 +0000 (+0800) Subject: screennotify 文件夹更新 X-Git-Tag: release_V1.2.70_20241020_135402~1092 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=efd66b7e4f638313bf610b526c0e793938004421;p=mirrors%2FFD230.git screennotify 文件夹更新 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/screennotify/include/ui_screennotify.h b/code/sdk/application/wearable/fd230app/nativeui/screennotify/include/ui_screennotify.h index 6b673ba8a..4d202759a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/screennotify/include/ui_screennotify.h +++ b/code/sdk/application/wearable/fd230app/nativeui/screennotify/include/ui_screennotify.h @@ -44,9 +44,3 @@ uint32_t get_back_to_home_interval(void); #endif #endif // OHOS_UI_SCREENNOTIFY_H - - - - - - diff --git a/code/sdk/application/wearable/fd230app/nativeui/screennotify/src/ui_screennotify.cpp b/code/sdk/application/wearable/fd230app/nativeui/screennotify/src/ui_screennotify.cpp index fa29ba864..564409805 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/screennotify/src/ui_screennotify.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/screennotify/src/ui_screennotify.cpp @@ -1,5 +1,5 @@ #include -#include "stdio.h" +#include #include "ability_state.h" #include "cmsis_os2.h" #include "common_def.h" @@ -9,111 +9,103 @@ #include "power_display_service.h" #include "NativeAbility.h" #include "AppViewIDs.h" -#include "components/ui_label_ext.h" -#include "language/font/ui_resource_string.h" #include "MainViewSample.h" #include "ui_screennotify.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif - static uint32_t g_back_to_home_interval = 5; +static uint32_t g_back_to_home_interval = 5; // 需要屏蔽掉的slice,ignore_slice_ids数组中的slice灭屏超时后不会调转到默认界面 - uint16_t ignore_slice_ids[] = { - VIEW_INVALID, - VIEW_SETTING, - VIEW_UISAMPLE, - VIEW_BLOODOXY, // 血氧功能 - VIEW_HEART, // 心率检测 - VIEW_SAVEBAT, // 省电模式 - VIEW_TEST, +uint16_t ignore_slice_ids[] = { +VIEW_INVALID, +VIEW_SETTING, +VIEW_UISAMPLE, +VIEW_BLOODOXY, // 血氧功能 +VIEW_HEART, // 心率检测 +VIEW_SAVEBAT, // 省电模式 +VIEW_TEST, #ifdef SUPPORT_ALIPAY_SEC - VIEW_MAIN_ALIPAY, + VIEW_MAIN_ALIPAY, #endif }; - static std::list g_callback; +static std::list g_callback; - static void ChangeToHomeView(void) - { +static void ChangeToHomeView(void) +{ #if 0 - screen_context_t *sc = power_display_get_screen_context(); - uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId(); - for (uint16_t i = 0; i < sizeof(ignore_slice_ids) / sizeof(uint16_t); i++) - { - if (ignore_slice_ids[i] == current_slice_id) - { - return; - } + screen_context_t *sc = power_display_get_screen_context(); + uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId(); + for (uint16_t i = 0; i < sizeof(ignore_slice_ids) / sizeof(uint16_t); i++) { + if (ignore_slice_ids[i] == current_slice_id) { + return; } - if (sc->screen_off_time_interval > g_back_to_home_interval) - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "screen off time = %u", - sc->screen_off_time_interval); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetNativeAbilityState = %u", - OHOS::NativeAbility::GetInstance().GetNativeAbilityState()); - if (OHOS::NativeAbility::GetInstance().GetNativeAbilityState() == STATE_ACTIVE) - { - if (current_slice_id != VIEW_MAIN) - { // 主表盘 - OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - } - else - { - // if (!OHOS::MainViewSample::GetInstance()->IsMainClockPage()) { + } + if (sc->screen_off_time_interval > g_back_to_home_interval) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "screen off time = %u", + sc->screen_off_time_interval); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GetNativeAbilityState = %u", + OHOS::NativeAbility::GetInstance().GetNativeAbilityState()); + if (OHOS::NativeAbility::GetInstance().GetNativeAbilityState() == STATE_ACTIVE) { + if (current_slice_id != VIEW_MAIN_SAMPLE) { // 主表盘 + OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN_SAMPLE); + } else { + if (!OHOS::MainViewSample::GetInstance()->IsMainClockPage()) { // 当前页面为主表盘的其他页面时,切换回主表盘页面 - // OHOS::MainViewSample::GetInstance()->SwitchToClockPage(); - // } + OHOS::MainViewSample::GetInstance()->SwitchToClockPage(); } } } -#endif } +#endif +} - void notify_screen_on_event(void) - { - for (auto callback : g_callback) - { - callback(SCREEN_STATUS_ON); - } - GraphicService::GetInstance()->PostGraphicEvent(ChangeToHomeView); - } +void notify_screen_on_event(void) +{ + GraphicService::GetInstance()->PostGraphicEvent( + [&] { + for (auto callback : g_callback) { + callback(SCREEN_STATUS_ON); + } + ChangeToHomeView(); + }); +} - void notify_screen_off_event(void) - { - for (auto callback : g_callback) - { - callback(SCREEN_STATUS_OFF); - } - } +void notify_screen_off_event(void) +{ + GraphicService::GetInstance()->PostGraphicEvent( + [&] { + for (auto callback : g_callback) { + callback(SCREEN_STATUS_OFF); + } + }); +} - void set_back_to_home_interval(uint32_t time_sec) - { - g_back_to_home_interval = time_sec; - } +void set_back_to_home_interval(uint32_t time_sec) +{ + g_back_to_home_interval = time_sec; +} - uint32_t get_back_to_home_interval(void) - { - return g_back_to_home_interval; - } +uint32_t get_back_to_home_interval(void) +{ + return g_back_to_home_interval; +} - void registerNotifyScreenStatus(ScreenStatusNotifyCallback callback) - { - if (callback != nullptr) - { - g_callback.push_back(callback); - } +void registerNotifyScreenStatus(ScreenStatusNotifyCallback callback) +{ + if (callback != nullptr) { + g_callback.push_back(callback); } +} - void deregisterNotifyScreenStatus(ScreenStatusNotifyCallback callback) - { - if (callback != nullptr) - { - g_callback.remove(callback); - } +void deregisterNotifyScreenStatus(ScreenStatusNotifyCallback callback) +{ + if (callback != nullptr) { + g_callback.remove(callback); } +} #ifdef __cplusplus }