From a5f061a9a5651ee154ff099e54d84d9246fe5328 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Wed, 29 Apr 2026 22:26:42 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E5=8D=87=E7=BA=A7=E5=88=B034?= =?utf8?q?=E7=9A=84=E6=A0=87=E5=BF=97=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeapp/nativeui/ota/src/OtaModel.cpp | 8 ++++++ .../thunderbird/src/ThunderBirdModel.cpp | 13 +++++++-- code/sdk/zhihui/leiniao/imsl_ln/ln_api.c | 28 +++++++++++++++++++ code/sdk/zhihui/leiniao/imsl_ln/ln_api.h | 2 ++ 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp index b84cc7873..e2131f1ef 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp @@ -326,6 +326,14 @@ namespace OHOS if (OtaSuccessView::GetInstance()) { OtaSuccessView::GetInstance()->UpdateDownloadSuccess("模组升级成功"); } +#ifdef SUPPORT_CAT1_SERVICE + /* 以 g_ln_last_package_url_new2/new1(getTask 写入)中的 PY_SRV_Vxx 为准 */ + if (status == 4 && ln_cat1_last_package_urls_target_py() == 34) { + (void)UtilsSetValue("cat1_py34_upgrade_done", "1"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "CheckOtaResult: Cat1 success, URL target py=34, KV cat1_py34_upgrade_done=1"); + } +#endif } SetOtaStatus(OTA_UI_STATUS_NOT_START); ThunderBirdModel::GetInstance()->ResetOtaStatus(); 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 e1a4ba546..40cb8a10d 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 @@ -92,14 +92,21 @@ extern "C" { namespace { -/** 当前手表软件版本是否为 1.0.47(仅用 uapi_get_fw_version,避免链接 build_version 的 get_version_string) */ +/** KV:Cat1 已成功升到 py34,开机不再直进 1.0.47 升级中(离线读 py 不准,以 KV 为准) */ +static constexpr const char *kKvCat1Py34UpgradeDone = "cat1_py34_upgrade_done"; + +/** 是否满足「1.0.47 开机可直进 Cat1」的软件条件(KV 已标记 py34 升级成功则视为 false) */ static bool IsSoftwareVersion_1_0_47(void) { + char mark[8] = {0}; + (void)UtilsGetValue(kKvCat1Py34UpgradeDone, mark, sizeof(mark)); + if (strcmp(mark, "1") == 0) { + return false; + } uint8_t major = 0; uint8_t mid = 0; uint8_t minor = 0; - uint8_t py = uapi_get_py_ver(); - return uapi_get_fw_version(&major, &mid, &minor) == ERRCODE_SUCC && major == 1 && mid == 0 && minor == 47 && py!=34; + return uapi_get_fw_version(&major, &mid, &minor) == ERRCODE_SUCC && major == 1 && mid == 0 && minor == 47; } } // namespace diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c index 56c7b35a9..f26a51976 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -14,6 +14,8 @@ #include #include #include "stdio.h" +#include +#include #include "custom_utils.h" #include "ai_media.h" /* for DNS resolution */ @@ -60,6 +62,32 @@ static int g_ln_is_ota_downloading = 0; // 是否正在下载OTA升级包 char g_ln_last_package_url_new1[256] = {0}; char g_ln_last_package_url_new2[256] = {0}; +static int ln_cat1_parse_py_srv_v_from_url(const char *url) +{ + if (url == NULL || url[0] == '\0') { + return -1; + } + const char *p = strstr(url, "PY_SRV_V"); + if (p == NULL) { + return -1; + } + char *end = NULL; + long v = strtol(p + 8, &end, 10); + if (end == p + 8 || v <= 0L || v > 255L) { + return -1; + } + return (int)v; +} + +int ln_cat1_last_package_urls_target_py(void) +{ + int v = ln_cat1_parse_py_srv_v_from_url(g_ln_last_package_url_new2); + if (v < 0) { + v = ln_cat1_parse_py_srv_v_from_url(g_ln_last_package_url_new1); + } + return v; +} + /* 简单的字符串读写(以.bin形式读写原始字节,末尾补'\0')*/ static int ln_read_string_file(const char *file_path, char **out_str) { diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h index a1057030d..6d8c6b074 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.h @@ -155,6 +155,8 @@ typedef struct /* -------------------------------------------------------------------------- */ extern char g_ln_last_package_url_new1[256]; extern char g_ln_last_package_url_new2[256]; +/** 从最近一次 Cat1 双包 URL 解析目标 py(路径中含 PY_SRV_Vxx,优先 new2)。失败返回 -1 */ +int ln_cat1_last_package_urls_target_py(void); #define LN_HTTP_SERVICE_CMD_OTA_GET_TASK_NEW 0x1018 #define LN_HTTP_SERVICE_CMD_OTA_GET_TASK_CAT1_RUN 0x1019 uint32_t ln_ota_get_task_http_CAT1(const char *device_id, -- 2.17.1