*/
#include "thunderbird/include/ThunderBirdModel.h"
+ #include "ota/include/OtaModel.h"
#include "thunderbird/include/ThunderBirdReminderView.h"
#include "thunderbird/include/ThunderBirdLullabyView.h"
#include "thunderbird/include/ThunderBirdDialogueView.h"
#include "ai_media.h"
#include "ConfigModelC.h"
#include "ConfigModel.h"
+#include "build_version.h"
+#include <cstring>
#include "cmsis_os2.h"
#include "los_task.h"
#include "custom_runtime.h"
#define LOW_FREQUENCE 18
//最高视频帧率
#define HIGH_FREQUENCE 30
+
+namespace {
+
+/** 当前手表软件版本是否为 1.0.47(与 OTA 侧 ln_ota_target_is_1047 语义一致) */
+static bool IsSoftwareVersion_1_0_47(void)
+{
+ uint8_t major = 0;
+ uint8_t mid = 0;
+ uint8_t minor = 0;
+ if (uapi_get_fw_version(&major, &mid, &minor) == ERRCODE_SUCC && major == 1 && mid == 0 && minor == 47) {
+ return true;
+ }
+ const char *v = get_version_string();
+ if (v == nullptr || v[0] == '\0') {
+ return false;
+ }
+ if (strcmp(v, "1.0.47") == 0 || strcmp(v, "V1.0.47") == 0) {
+ return true;
+ }
+ if (strncmp(v, "1.0.47", 6) == 0 && (v[6] == '\0' || v[6] == '_')) {
+ return true;
+ }
+ if (strncmp(v, "V1.0.47", 7) == 0 && (v[7] == '\0' || v[7] == '_')) {
+ return true;
+ }
+ return false;
+}
+
+} // namespace
+
namespace OHOS
{
enum OTA_STATUS
return -1;
}
+ void ThunderBirdModel::TryEnterBootCat1OtaSliceIfNeeded()
+ {
+#ifdef SUPPORT_CAT1_SERVICE
+ if (!IsSoftwareVersion_1_0_47()) {
+ return;
+ }
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "TryEnterBootCat1OtaSliceIfNeeded: sw=1.0.47, enter OTA updating (Cat1), wait for network then upgrade");
+ m_bootCat1OtaFromVer47 = true;
+ m_bootCat1OtaAwaitNetwork = true;
+ (void)memset(g_ln_last_package_url_new1, 0, sizeof(g_ln_last_package_url_new1));
+ (void)memset(g_ln_last_package_url_new2, 0, sizeof(g_ln_last_package_url_new2));
+ m_otaStatus = OTA_UI_STATUS_CAT1_START;
+ OtaModel::GetInstance()->SetOtaStatus(OTA_UI_STATUS_CAT1_START);
+ ln_ws_send_voice_chat_interrupt("进入OTA");
+ do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_DEINIT, NULL, 0);
+ NativeAbility::GetInstance().ChangeSlice(VIEW_OTA);
+#endif
+ }
+
/*************************OTA升级进度*************************/
void ThunderBirdModel::UpdateOtaProgress(int progress)
{
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ResetOtaStatus: resetting OTA status to 0");
m_otaStatus = 0;
+ m_bootCat1OtaFromVer47 = false;
+ m_bootCat1OtaAwaitNetwork = false;
+ m_bootCat1OtaUrlsPending = false;
}
*/
void ThunderBirdModel::Cat1OtaUpgrade()
{
+ m_bootCat1OtaFromVer47 = false;
+ /* 已确认需 Cat1 并开始写模组:关闭 1.0.47 开机进 OTA 时为保活而未停的状态定时器 */
+ StopStatusTimer();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "cat1模组升级");
// LOS_Msleep(1000);
// uint32_t ret = 0;
*/
void ThunderBirdModel::StatusCallback()
{
- // 更新网络状态
- UpdateNetworkStatus();
+ // 更新网络状态
+ UpdateNetworkStatus();
// 检查网络状态是否有网
if(HasNetwork())
{
if(get_is_ln_get_device_network_success())
{
- if (init_falg == false)
+ if (m_bootCat1OtaAwaitNetwork) {
+ m_bootCat1OtaAwaitNetwork = false;
+ m_bootCat1OtaUrlsPending = true;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "Boot Cat1(sw1.0.47): network ok, request CAT1 OTA URL check");
+ do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_IS_CAT1_OTA_UPGRADE, NULL, 0);
+ }
+ if (m_bootCat1OtaUrlsPending) {
+ if (strlen(g_ln_last_package_url_new1) > 0 && strlen(g_ln_last_package_url_new2) > 0) {
+ m_bootCat1OtaUrlsPending = false;
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "Boot Cat1(sw1.0.47): package URLs ready, start Cat1OtaUpgrade");
+ GraphicService::GetInstance()->PostGraphicEvent(
+ std::bind(&OHOS::ThunderBirdModel::Cat1OtaUpgrade,
+ OHOS::ThunderBirdModel::GetInstance()));
+ }
+ }
+ if (init_falg == false && !m_bootCat1OtaFromVer47)
{
//发送获取绑定用户ID
do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_GET_USER_ID, NULL, 0);
{
ThunderBirdGuideView::GetInstance()->OnWsConnected();
}
- do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_IS_CAT1_OTA_UPGRADE, NULL, 0);
+ if (!(m_bootCat1OtaUrlsPending && m_bootCat1OtaFromVer47)) {
+ do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_IS_CAT1_OTA_UPGRADE, NULL, 0);
+ } else {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
+ "Skip duplicate IS_CAT1 (boot sw1.0.47 already requested)");
+ }
#if JUHEPINGTAI
uapi_init_all_websocket_servers();
}
}
+
+ /* OTA 独立 slice:雷鸟主页已析构,避免 CountUp/换页/视频恢复/Presenter 定时器等在无 MainView 或错误上下文下运行 */
+ if (NativeAbility::GetInstance().GetCurSliceId() == VIEW_OTA) {
+ return;
+ }
// #if JUHEPINGTAI
// if(is_all_services_ready == false)