From 471c4cd227f6fc129582038c220f006e34bdcdb2 Mon Sep 17 00:00:00 2001 From: Caisking Date: Sun, 21 Sep 2025 18:22:49 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E7=BB=91=E5=AE=9A=E6=A0=87?= =?utf8?q?=E5=BF=97=E4=BD=8D=E7=9A=84=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../thunderbird/include/ThunderBirdModel.h | 8 ++- .../thunderbird/src/ThunderBirdModel.cpp | 49 +++++++------------ .../thunderbird/src/ThunderBirdPresenter.cpp | 11 +++-- 3 files changed, 29 insertions(+), 39 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h index 9577ceb91..c710ed02c 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdModel.h @@ -154,6 +154,9 @@ namespace OHOS bool Get_is_all_services_ready(); void init_all_callback(void); + bool GetQrcodeChecked(); + void SetQrcodeChecked(bool checked); + private: ThunderBirdModel(); virtual ~ThunderBirdModel(); @@ -186,8 +189,8 @@ namespace OHOS int m_countUpTarget; // 计数目标值 // IMEI状态管理 - bool m_imeiValid; // IMEI是否有效标志位 - bool m_imeiChecked; // IMEI是否已检查过 + bool m_imeiValid = false; // IMEI是否有效标志位 + bool m_qrcodeChecked = false; // IMEI是否已检查过 // 网络状态管理 int m_simStatus; // SIM卡状态 @@ -200,6 +203,7 @@ namespace OHOS bool is_all_services_ready = false; bool init_falg = false; + bool bind_status = false; }; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 20270ef7b..ac414277c 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -63,7 +63,6 @@ m_reminderHideActive(false), m_reminderHideTime(0), m_otaCountdownActive(false), m_otaCountdownValue(0), m_countUpActive(false), m_countUpValue(0), m_countUpTarget(0), - m_imeiValid(false), m_imeiChecked(false), m_simStatus(0), m_cat1PowerStatus(0), m_signalStrength(0), m_networkStatus(0), m_networkType(0), m_hasNetwork(false), m_networkStatusChanged(false) @@ -71,19 +70,12 @@ // 初始化时加载提醒数据 // LoadRemindersFromFile(); //创建kv文件夹 - uapi_create_folder("/user/system/kvstore/"); // 读取绑定状态 char temp[10] = { 0 }; (void)UtilsGetValue("bind_status", temp, 10); if(strcmp(temp, "1") == 0) { - m_imeiValid = true; - m_imeiChecked = true; - } - else - { - m_imeiValid = false; - m_imeiChecked = true; + bind_status = true; } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "目前绑定状态 %s", temp); } @@ -324,16 +316,8 @@ int ThunderBirdModel::StartBootOperation() { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartBootOperation"); - //绑定设备提示 > 配置更新成功>OTA升级>其他(按触发时间先后提示) - /*************************用户是否绑定*************************/ - do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_USER_ID, nullptr, 0);//获取用户是否绑定 - if(CheckBindingStatus() != BindingStatus::BOUND)//未绑定 - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::StartBootOperation: 未绑定"); - return 0; - } - return 1; - } + return bind_status; + } //判断是否绑定 ThunderBirdModel::BindingStatus ThunderBirdModel::CheckBindingStatus() { @@ -345,6 +329,9 @@ } else if(uapi_ln_is_device_bound() == 1)//已绑定 { + //存储kv + (void)UtilsSetValue("bind_status", "1"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::CheckBindingStatus: 已绑定"); return BindingStatus::BOUND; } else if(uapi_ln_is_device_bound() == 2)//认证失败 @@ -1025,7 +1012,7 @@ { if(get_is_ln_get_device_token_success() == 0) { - do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_DEVICE_TOKEN, NULL, 0); + do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_DEVICE_TOKEN, NULL, 0); } else { @@ -1230,29 +1217,27 @@ } } - // IMEI状态管理函数实现 - bool ThunderBirdModel::IsIMEIValid() const + // 二维码是否有效更新过 + bool ThunderBirdModel::GetQrcodeChecked() const { - return m_imeiValid; + return m_qrcodeChecked; + } + void ThunderBirdModel::SetQrcodeChecked(bool checked) + { + m_qrcodeChecked = checked; } - void ThunderBirdModel::CheckIMEIStatus() + bool ThunderBirdModel::IsIMEIValid() { // 如果已经检查过,直接返回 - if (m_imeiChecked) { + if (m_qrcodeChecked) { return; } // 检查IMEI有效性 m_imeiValid = IsDeviceIdValid(); - if(m_imeiValid){ - //有效 设置标志位为true - m_imeiChecked = true; - //存储kv - (void)UtilsSetValue("bind_status", "1"); - return; - } + return m_imeiValid; WEARABLE_LOGD("IMEI status checked: valid=%d", m_imeiValid); } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index 3374801b5..28fd80494 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -619,16 +619,17 @@ namespace OHOS // 更新二维码(如果设备ID有效) void ThunderBirdPresenter::UpdateQrcodeIfValid() { - // 确保IMEI状态已检查 - ThunderBirdModel::GetInstance()->CheckIMEIStatus(); - - // 检查IMEI是否有效 - if (ThunderBirdModel::GetInstance()->IsIMEIValid()) { + + // 检查IMEI是否有效 并且 二维码是否有效更新过 + if (ThunderBirdModel::GetInstance()->IsIMEIValid() && ThunderBirdModel::GetInstance()->GetQrcodeChecked() == true) { return; } // 更新二维码 更新一次二维码 不能一直获取 ThunderBirdGuideView::GetInstance()->UpdateQrcode(); + + //设置更新 + ThunderBirdModel::GetInstance()->SetQrcodeChecked(true); } } -- 2.17.1