From: Caisking <3449750381@qq.com> Date: Wed, 28 Aug 2024 11:08:14 +0000 (+0800) Subject: 修复密码锁通过蓝牙解锁进行状态同步 X-Git-Tag: release_V1.2.70_20241020_135402~575 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F813%2F1;p=mirrors%2FFD230.git 修复密码锁通过蓝牙解锁进行状态同步 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h b/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h index 76e12d73e..995b85ccd 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h @@ -1,3 +1,9 @@ +/*** + * @Date: 2024-08-21 15:27:38 + * @LastEditors: Caisking 3449750381@qq.com + * @LastEditTime: 2024-08-28 18:32:09 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h + */ #ifndef CODEDLOCKMODEL_H #define CODEDLOCKMODEL_H @@ -33,6 +39,8 @@ namespace OHOS uint8_t GetPointNum(); // 配置用户密码 void SetUserPassWord(const std::string &password); + // ble进行解锁 + void BleUnlock(); private: CodedLockModel(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp index 25c7d8d25..40175f14a 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp @@ -1,9 +1,13 @@ #include "codedlock/include/CodedLockModel.h" +#include "MainViewSample.h" +#include "codedlock/include/CodedLockView.h" #include #include #include "wearable_log.h" #include "string.h" #include "ConfigModel.h" + +extern "C" void uapi_dev_runtime_set_lock_status(uint8_t status); namespace OHOS { /** @@ -185,4 +189,26 @@ namespace OHOS WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "密码为空"); } } + + /** + * @brief 更新用户状态 + */ + void CodedLockModel::BleUnlock() + { + // 先进行解锁 + uapi_dev_runtime_set_lock_status(0); + /*设置表盘状态*/ + MainModel::GetInstance().setDialState(DialState::LOCK, false); + + // 获取当前活动视图的实例 + auto mainViewInstance = MainViewSample::GetInstance(); + auto codedLockViewInstance = CodedLockView::GetInstance(); + + // 如果是在主界面或密码锁界面,重新进入主界面 + if (mainViewInstance != nullptr || codedLockViewInstance != nullptr) + { + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + } + } + } \ No newline at end of file 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 7db379f46..99d68d6db 100644 --- a/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp +++ b/code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp @@ -615,6 +615,12 @@ void ble_set_password(uint8_t falg, char * data) printf("设置手表密码 %d %s \r\n",falg, data); /*更新model密码配置*/ + if(falg == 0) + { + //更新手表状态 + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::CodedLockModel::BleUnlock, OHOS::CodedLockModel::GetInstance())); + } OHOS::CodedLockModel::GetInstance()->SetUserPassWord(data); return;