修复密码锁通过蓝牙解锁进行状态同步 813/1
authorCaisking <3449750381@qq.com>
Wed, 28 Aug 2024 11:08:14 +0000 (19:08 +0800)
committerCaisking <3449750381@qq.com>
Wed, 28 Aug 2024 11:08:14 +0000 (19:08 +0800)
code/sdk/application/wearable/fd230app/nativeui/codedlock/include/CodedLockModel.h
code/sdk/application/wearable/fd230app/nativeui/codedlock/src/CodedLockModel.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp

index 76e12d7..995b85c 100644 (file)
@@ -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();
index 25c7d8d..40175f1 100644 (file)
@@ -1,9 +1,13 @@
 #include "codedlock/include/CodedLockModel.h"
+#include "MainViewSample.h"
+#include "codedlock/include/CodedLockView.h"
 #include <cctype>
 #include <algorithm>
 #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
index 7db379f..99d68d6 100644 (file)
@@ -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;