From: Caisking <3449750381@qq.com> Date: Thu, 22 Aug 2024 08:05:48 +0000 (+0800) Subject: 增加密码锁的锁屏逻辑 X-Git-Tag: release_V1.2.70_20241020_135402~606^2~11 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=6e28e375bd581853edb4368342d67ca0c4470d50;p=mirrors%2FFD230.git 增加密码锁的锁屏逻辑 --- diff --git a/code/sdk/application/wearable/fd230app/CMakeLists.txt b/code/sdk/application/wearable/fd230app/CMakeLists.txt index 04d9dc4b7..7d20554ff 100644 --- a/code/sdk/application/wearable/fd230app/CMakeLists.txt +++ b/code/sdk/application/wearable/fd230app/CMakeLists.txt @@ -695,6 +695,11 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepControlPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/sleep/src/SleepModel.cpp + #密码锁 + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/codedlock/src/CodedLockView.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/codedlock/src/CodedLockPresenter.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/codedlock/src/CodedLockModel.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneCallPresenter.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nativeui/phone/src/PhoneDirView.cpp diff --git a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp index 73f90f766..49dab4d82 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/key/src/KeyInputListener.cpp @@ -21,6 +21,7 @@ #include "MainCallingPresenter.h" #include "secondaryfunction/include/SecondaryFunctionModel.h" #include "DialViewGroup.h" +#include "ui_service.h" namespace OHOS { static bool IsNotifyCallStatus() @@ -125,13 +126,14 @@ namespace OHOS uint32_t mcu_pm_lcd_on(uint8_t *para, uint32_t para_len); uint32_t mcu_pm_lcd_off(uint8_t *para, uint32_t para_len); uint8_t mcu_pms_is_screen_on(void); + uint8_t uapi_dev_runtime_get_lock_status(void); } void KeyInputListener::OnKeyRelease(const KeyEvent &event) { uint16_t currentViewId = NativeAbility::GetInstance().GetCurSliceId(); uint16 keyID = event.GetKeyId(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyRelease keyID %d , longPressFlag = %d , pressFlag = %d ",keyID,longPressFlag,pressFlag); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnKeyRelease keyID %d , longPressFlag = %d , pressFlag = %d ", keyID, longPressFlag, pressFlag); if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) // 如果按下的按键是电源键 { @@ -165,11 +167,22 @@ namespace OHOS } else { - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + /*密码锁上锁*/ + if (uapi_dev_runtime_get_lock_status()) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK); + } + else + { + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + // NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); // NativeAbility::GetInstance().EnterSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM); } - }else{ + } + else + { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " mcu_pms_is_screen_on = off "); } } 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 285daa121..dc366ab3b 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainPresenterSample.cpp @@ -124,9 +124,18 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "health model nullptr"); return false; } - if(uapi_dev_runtime_get_sleep_monitoring_status()) + + /*发生点击进入密码锁*/ + if (uapi_dev_runtime_get_lock_status()) + { + /*进入密码锁*/ + NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK); + return true; + } + + if (uapi_dev_runtime_get_sleep_monitoring_status()) { - if(VIEW_DNOTDISTURB == g_jumpView[curViewId]) + if (VIEW_DNOTDISTURB == g_jumpView[curViewId]) { return true; } @@ -194,7 +203,7 @@ namespace OHOS PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(false); DnotDisturbModel::GetInstance().SetDoNotDisturbModeEnabled(false); /*更新主界面配置*/ - MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB,false); + MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB, false); return true; } if (g_jumpView.count(curViewId) != 0) @@ -210,14 +219,26 @@ namespace OHOS UNUSED(view); WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "MainPresenterSample OnLongPress"); uint8_t cardId = view_->GetHorCurrentCard(); - if (cardId != WATCH_FACE) - { - SetCardModel::GetInstance().SetSelectedCard(cardId); - // NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD); - } - else + /* + 卡片进入管理卡片界面 + if (cardId != WATCH_FACE) + { + SetCardModel::GetInstance().SetSelectedCard(cardId); + NativeAbility::GetInstance().ChangeSlice(VIEW_ADD_CARD); + } + */ + if (cardId == WATCH_FACE) { - NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL); + if (uapi_dev_runtime_get_lock_status()) + { + /*进入密码锁*/ + NativeAbility::GetInstance().ChangeSlice(VIEW_CODED_LOCK); + } + else + { + /*进入表盘设置*/ + NativeAbility::GetInstance().ChangeSlice(VIEW_SET_DIAL); + } } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp index d2076360f..288512711 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/main/src/MainViewSample.cpp @@ -9,7 +9,11 @@ #include "graphic_service.h" #include "dialupdate/include/DialUpdateModel.h" #include "uicomponents/UIComponents.h" +#include "ui_service.h" extern DialInfo_1 dialInfo_1[MAX_DIALNUM_1]; + +extern "C" uint8_t uapi_dev_runtime_get_lock_status(void); + namespace OHOS { static constexpr const char *DISTURBICON = "user/res/dial_state/disturbicon.bin"; @@ -191,7 +195,7 @@ namespace OHOS { if (messageicon_ == nullptr || dialstateicon_ == nullptr) return; - + /*配置未读状态*/ messageicon_->SetVisible(MainModel::GetInstance().getMessageActiveState()); /*配置表盘状态*/ @@ -253,19 +257,34 @@ namespace OHOS mainSwipeGroup->SetLoopState(false); // 主界面循环 mainSwipeGroup->EnableScreenCap(true); // 主界面截屏滑动 mainSwipeGroup->RegisterSwipeCallback(callback); // 主界面动画回调 - // 判断是否为从主界面前往的其他Slice - if (presenter_->IsFromSetCardView()) + /*密码锁上锁*/ + if (uapi_dev_runtime_get_lock_status()) { - // 回退标志位 - presenter_->SetFromSetCardView(false); - // 设置Id为主界面显示索引 - SwitchToCard(presenter_->GetFromCardId()); + // 回到表盘 + SwitchToClockPage(); + printf("密码锁\r\n"); + mainClockView->SetIntercept(true); + mainSwipeGroup->SetDraggable(false); + mainSwipeGroup->SetOnSwipeListener(nullptr); + mainSwipeGroup->SetOnClickListener(presenter_); } else { - // 回到表盘 - SwitchToClockPage(); + // 判断是否为从主界面前往的其他Slice + if (presenter_->IsFromSetCardView()) + { + // 回退标志位 + presenter_->SetFromSetCardView(false); + // 设置Id为主界面显示索引 + SwitchToCard(presenter_->GetFromCardId()); + } + else + { + // 回到表盘 + SwitchToClockPage(); + } } + #if DIALSTATE /*增加勿扰图标*/ @@ -360,7 +379,7 @@ namespace OHOS messageView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); messageView->PreLoad(); messageView->SetDraggable(false); - messageView->SetIntercept(true); + // messageView->SetIntercept(true); messageView->SetStyle(STYLE_BACKGROUND_OPA, OPA_TRANSPARENT); #endif } @@ -436,6 +455,8 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "MainClockView new fail"); return nullptr; } + + mainClockView->SetViewId("mainClockView"); return mainClockView; } // 指南针卡片 diff --git a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp index b24f0ba03..cad9b24a5 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/rebootdevice/src/RebootModel.cpp @@ -15,7 +15,8 @@ #include "power_display_service.h" #include "aimodels/include/AiModelsModel.h" #include "themestyle/include/ThemeStyleModel.h" - +#include "ui_service.h" +extern "C" uint8_t uapi_dev_runtime_get_lock_status(void); namespace OHOS { RebootModel::RebootModel() {} @@ -185,6 +186,16 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VIEW_AI_VOICE is not switched"); return; } + /*处于主界面*/ + if (curSliceId == VIEW_MAIN) + { + /*被锁*/ + if (uapi_dev_runtime_get_lock_status()) + { + NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK); + } + return; + } // 全局切换到Ai语音界面 NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp index dba03e3ee..e83142710 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp @@ -1,7 +1,7 @@ /*** * @Date: 2024-08-16 09:26:06 * @LastEditors: Caisking 3449750381@qq.com - * @LastEditTime: 2024-08-20 16:59:59 + * @LastEditTime: 2024-08-21 17:03:11 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/saveele/src/SaveElePresenter.cpp */ /*** diff --git a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h index f09fd1382..7a4174bce 100755 --- a/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h +++ b/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-05-30 15:59:37 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-22 14:47:49 + * @FilePath: /FD230/code/sdk/application/wearable/nativeapp/nativeui/main/include/MainViewSample.h + */ /* * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved. * Description: MainViewSample