From: luozheng <1732036298@qq.com> Date: Wed, 17 Apr 2024 07:26:42 +0000 (+0800) Subject: 1.优化NativeAbility::GetInstance().Back();函数在后退栈为空时退到主界面 X-Git-Tag: release_V1.2.70_20241020_135402~1162^2~16^2~3 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=70d0cbcb11038379c02ee2ca5b625d6400cdc1f6;p=mirrors%2FFD230.git 1.优化NativeAbility::GetInstance().Back();函数在后退栈为空时退到主界面 2.添加根据ConfigModel开机设置屏幕亮度和亮屏时间函数 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h index 845fb9e82..9589a2997 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h +++ b/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h @@ -1,3 +1,10 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-04-17 09:32:03 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-04-17 14:52:37 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModelC.h + */ #ifndef _CONFIG_MODEL_C_H_ #define _CONFIG_MODEL_C_H_ @@ -24,6 +31,16 @@ bool poweron_cat1_on_bootup_flag(void); void sync_all_config_to_disk(void); + +/* + * @brief 初始化屏幕亮度 + */ +void initScreenBrightness(void); +/* + * @brief 初始化亮屏时间 + */ +void initializeScreenDuration(void); + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp index cf734c4ef..87c02022b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp @@ -1,6 +1,6 @@ #include "config/include/ConfigModel.h" #include "config/include/ConfigModelC.h" - +#include "custom_utils.h" namespace OHOS { ConfigModel::ConfigModel() @@ -736,6 +736,20 @@ void sync_all_config_to_disk(void) OHOS::ConfigModel::GetInstance()->sync_all_to_disk(); } + +void initScreenBrightness(void) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "initScreenBrightness"); + int brightness = OHOS::ConfigModel::GetInstance()->GetBrightness(); + uapi_setScreenBrightness(brightness); +} + +void initializeScreenDuration(void) +{ + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "initializeScreenDuration"); + unsigned int time = OHOS::ConfigModel::GetInstance()->GetScreenDuration(); + uapi_setScreenDuration(time); +} #ifdef __cplusplus #if __cplusplus } 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 570a00ea2..135a2ad8a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -147,7 +147,8 @@ namespace OHOS if (g_jumpView.count(curViewId) != 0) { - NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]); + //NativeAbility::GetInstance().ChangeSlice(g_jumpView[curViewId]); + NativeAbility::GetInstance().EnterSlice(g_jumpView[curViewId]); } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp index 24bcea2f0..bebac1aa3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingPresenter.cpp @@ -89,15 +89,16 @@ namespace OHOS // 如果是power键就返回上一级 if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0) { - uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - if (preSlice == VIEW_APPLIST) - { - NativeAbility::GetInstance().ChangeSlice(preSlice); - } - else - { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); - } + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + // if (preSlice == VIEW_APPLIST) + // { + // NativeAbility::GetInstance().ChangeSlice(preSlice); + // } + // else + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + // } + NativeAbility::GetInstance().Back(); } return true; } diff --git a/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h b/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h index 7f7e851fc..5da276391 100755 --- a/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h +++ b/code/sdk/application/wearable/nativeabilityfwk/include/Ability.h @@ -89,7 +89,12 @@ public: ChangeSlice(preSlice,transitionId,priority); return true; } - return false; // 没有更多的Slice可以后退 + else + { + // 当backStack为空时,退回到defaultSliceId_ + ChangeSlice(defaultSliceId_, transitionId, priority); + return false; // 返回false表示无前一个slice,退回到默认slice + } } protected: struct ProxyStruct { diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 945168641..7127f5db3 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -215,6 +215,9 @@ void startup_post_init_task(void) start_custom_ble_service(); } + initScreenBrightness(); + initializeScreenDuration(); + LOS_Msleep(5000); if ( poweron_cat1_on_bootup_flag() ) { @@ -557,6 +560,15 @@ void ScreenAlwaysOnCtr(uint8_t turnOnFlag) } } +/* + * @brief 应用设置自定义亮度值. 应用设置的亮度值会覆盖系统默认亮度设置. + */ +void uapi_setScreenBrightness(int value) +{ + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + display_api->set_brightness(value); +} + /* * @brief 设置某个Slice亮屏时间,超过时间后屏幕息屏,单位ms */ diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 9de742cc3..80420bc82 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -49,6 +49,8 @@ char *uapi_get_local_yyyymmdd_date(void); void ScreenAlwaysOnCtr(uint8_t turnOnFlag); +void uapi_setScreenBrightness(int value); + void uapi_setScreenDuration(int32_t time); int32_t uapi_get_screen_state(void);