From 025651289376b2ea694e200048d203421b0a5717 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Thu, 22 Aug 2024 18:27:56 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E5=AF=86=E7=A0=81=E9=94=81?= =?utf8?q?=E7=95=8C=E9=9D=A2=E5=9B=9E=E9=80=80=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?utf8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../codedlock/src/CodedLockPresenter.cpp | 10 ++++----- .../fd230app/nativeui/main/src/MainModel.cpp | 21 ++++++++++++------- .../screennotify/src/ui_screennotify.cpp | 6 ++++++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp index 616ebd1b3..ed91c90b3 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockPresenter.cpp @@ -62,10 +62,6 @@ namespace OHOS void CodedLockPresenter::OnStop(void) { - /*关锁*/ - uapi_dev_runtime_set_lock_status(0); - /*设置表盘状态*/ - MainModel::GetInstance().setDialState(DialState::LOCK, false); Presenter::OnStop(); } void CodedLockPresenter::JudgeMatch() @@ -81,8 +77,12 @@ namespace OHOS /*每次点击完成判断 是否 完成密码匹配*/ if (CodedLockModel::GetInstance()->IsLockState()) { - NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "回到主界面"); + /*关锁*/ + uapi_dev_runtime_set_lock_status(0); + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + /*设置表盘状态*/ + MainModel::GetInstance().setDialState(DialState::LOCK, false); } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JudgeMatch is Ok"); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp index 674e135e7..0cd452184 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainModel.cpp @@ -47,7 +47,7 @@ namespace OHOS #ifdef CUSTOM_Z1 {DIAL_CLOCK, "Z1", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD}, #else - {DIAL_CLOCK, "KUMI", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD}, // 默认表盘 Id 0 + {DIAL_CLOCK, "KUMI", DEFAULT_DIALPER_PATH, DEFAULT_TASK_PERIOD}, // 默认表盘 Id 0 #endif {DIAL_CLOCK_1, "Custom_1", CUSTOM_CLOCK1_DIALPER_PATH, DEFAULT_TASK_PERIOD}, // 表盘 Id 1 {DIAL_CLOCK_2, "Custom_2", CUSTOM_CLOCK2_DIALPER_PATH, DEFAULT_TASK_PERIOD}, // 表盘 Id 2 @@ -492,17 +492,24 @@ namespace OHOS { // 将 state 转换为整数以进行比较 int stateIndex = static_cast(state); - if (stateIndex >= 0 && stateIndex < STATE_COUNT) - { // 确保 index 在有效范围 - dialstateInfo[stateIndex].active = value; // 使用转换后的索引 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set dialstateInfo[%d].active = %d", stateIndex, value); + if (stateIndex >= 0 && stateIndex < STATE_COUNT) // 确保 index 在有效范围 + { + // 检查当前状态是否与要设置的状态一致 + if (dialstateInfo[stateIndex].active != value) + { + dialstateInfo[stateIndex].active = value; // 使用转换后的索引 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Set dialstateInfo[%d].active = %d", stateIndex, value); + SendMsgToUIService(UI_UPDATE_DIALSTATE_DATA, 0, nullptr, 0); // 发送更新消息 + } + else + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "State %d is unchanged, no update needed.", stateIndex); + } } else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "state %d is error", stateIndex); } - - SendMsgToUIService(UI_UPDATE_DIALSTATE_DATA, 0, nullptr, 0); } // 接口 2: 获取最高优先级为 true 的状态 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 138b98b60..deac43619 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 @@ -34,6 +34,7 @@ extern "C" { 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) @@ -79,6 +80,11 @@ extern "C" /*设置表盘状态*/ OHOS::MainModel::GetInstance().setDialState(OHOS::DialState::LOCK, true); } + if (uapi_dev_runtime_get_lock_status() == 1 && (current_slice_id == VIEW_CODED_LOCK)) + { + /*重新进入一次主界面*/ + OHOS::NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + } } } } -- 2.17.1