From: xue <2144439972@qq.com> Date: Mon, 23 Mar 2026 11:22:59 +0000 (+0800) Subject: 优化定位优化流程 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=69b8e6ab8ceaa4ddecd831b8888623dd0f5b52b4;p=mirrors%2FFD230.git 优化定位优化流程 --- diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h index 4cebce437..4bfafe465 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/include/EphemerisDownloadPresenter.h @@ -40,6 +40,9 @@ namespace OHOS // 供Model调用的回调函数 void UpdateDownloadStatus(); + + // 在 ChangeSlice 前调用,提前切到主界面,避免跳转时闪一下等待页 + void SwitchToMainViewBeforeShow(); private: int16_t currentView_{0}; // EPHEMERIS_VIEW_MAIN or EPHEMERIS_VIEW_BT_DISCONNECT diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp index 9abe000e0..017719032 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadPresenter.cpp @@ -42,23 +42,65 @@ void EphemerisDownloadPresenter::OnStop() { void EphemerisDownloadPresenter::OnResume() { RootView::GetInstance()->SetOnKeyActListener(this); + // 从 transmitting 等通知切回时,直接显示主界面并刷新状态 + if (currentView_ == EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT) { + uint8_t epo_status = uapi_dev_runtime_get_epo_file_extracted_status(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OnResume: uapi_dev_runtime_get_epo_file_extracted_status() = %d", epo_status); + if (epo_status == 1 && + EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus() != EphemerisDownloadStatus::DOWNLOADED) { + EphemerisDownloadModel::GetInstance().SetEphemerisDownloadStatus(EphemerisDownloadStatus::DOWNLOADED); + } + EphemerisDownloadView *v = EphemerisDownloadView::GetInstance(); + if (v != nullptr) { + v->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT, + EphemerisDownloadView::EPHEMERIS_VIEW_MAIN); + currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN; + UpdateDownloadStatus(); + v->UpdateValidityPeriod(); + v->UpdateDownloadButton(); + } + } } EphemerisDownloadPresenter* EphemerisDownloadPresenter::GetInstance() { return g_instance; } +void EphemerisDownloadPresenter::SwitchToMainViewBeforeShow() { + if (GetInstance() == nullptr) return; + EphemerisDownloadView *v = EphemerisDownloadView::GetInstance(); + if (v == nullptr) return; + if (currentView_ != EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT) return; + v->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT, + EphemerisDownloadView::EPHEMERIS_VIEW_MAIN); + currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN; + uint8_t epo_status = uapi_dev_runtime_get_epo_file_extracted_status(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SwitchToMainViewBeforeShow: uapi_dev_runtime_get_epo_file_extracted_status() = %d", epo_status); + if (epo_status == 1 && + EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus() != EphemerisDownloadStatus::DOWNLOADED) { + EphemerisDownloadModel::GetInstance().SetEphemerisDownloadStatus(EphemerisDownloadStatus::DOWNLOADED); + } + UpdateDownloadStatus(); +} + bool EphemerisDownloadPresenter::OnClick(UIView &view, const ClickEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadPresenter::OnClick"); UNUSED(event); - // 蓝牙未连接页的关闭按钮:切回主界面 + // 等待页的关闭按钮:切回主界面 if (strcmp(view.GetViewId(), EphemerisDownloadView::EPHEMERIS_BT_DISCONNECT_CLOSE_ID) == 0) { EphemerisDownloadView *v = EphemerisDownloadView::GetInstance(); if (v != nullptr) { + if (uapi_dev_runtime_get_epo_file_extracted_status() == 1 && + EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus() != EphemerisDownloadStatus::DOWNLOADED) { + EphemerisDownloadModel::GetInstance().SetEphemerisDownloadStatus(EphemerisDownloadStatus::DOWNLOADED); + } v->ChangeView(EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT, EphemerisDownloadView::EPHEMERIS_VIEW_MAIN); currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN; + UpdateDownloadStatus(); + v->UpdateValidityPeriod(); + v->UpdateDownloadButton(); } return true; } @@ -109,9 +151,12 @@ bool EphemerisDownloadPresenter::OnClick(UIView &view, bool EphemerisDownloadPresenter::OnDrag(UIView &view, const DragEvent &event) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "EphemerisDownloadPresenter::OnDrag"); UNUSED(view); - if ((event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) && - (event.GetDeltaX() > X_DRAG_OFFSET) && - (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) { + uint8_t dir = event.GetDragDirection(); + int16_t deltaX = event.GetDeltaX(); + bool horizontalSwipe = (MATH_ABS(deltaX) > X_DRAG_OFFSET) && + (MATH_ABS(deltaX) > (DOUBLES * MATH_ABS(event.GetDeltaY()))); + // 右滑(LEFT_TO_RIGHT)或左滑(RIGHT_TO_LEFT)时:在等待页则切回主界面,在主界面则右滑退出 + if (horizontalSwipe) { if (currentView_ == EphemerisDownloadView::EPHEMERIS_VIEW_BT_DISCONNECT) { EphemerisDownloadView *v = EphemerisDownloadView::GetInstance(); if (v != nullptr) { @@ -119,7 +164,7 @@ bool EphemerisDownloadPresenter::OnDrag(UIView &view, const DragEvent &event) { EphemerisDownloadView::EPHEMERIS_VIEW_MAIN); currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN; } - } else { + } else if (dir == DragEvent::DIRECTION_LEFT_TO_RIGHT) { NativeAbility::GetInstance().Back(); } } @@ -150,6 +195,11 @@ bool EphemerisDownloadPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { void EphemerisDownloadPresenter::UpdateDownloadStatus() { RootView::GetInstance()->SetOnKeyActListener(this); + // BLE EPO:用户提前关闭通知后,解压可能在后台完成,epo 定时器已停止,需依赖 ephemeris_data_timer 轮询检测 + if (uapi_dev_runtime_get_epo_file_extracted_status() == 1 && + EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus() != EphemerisDownloadStatus::DOWNLOADED) { + EphemerisDownloadModel::GetInstance().SetEphemerisDownloadStatus(EphemerisDownloadStatus::DOWNLOADED); + } //根据下载状态更新视图 switch (EphemerisDownloadModel::GetInstance().GetEphemerisDownloadStatus()) { case EphemerisDownloadStatus::DOWNLOADING: diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp index 9211f1692..6b9db55a4 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/ephemeris_download/src/EphemerisDownloadView.cpp @@ -2,6 +2,7 @@ #include "ephemeris_download/include/EphemerisDownloadModel.h" #include "ephemeris_download/include/EphemerisDownloadPresenter.h" +#include "custom_runtime.h" #include "UiConfig.h" #include "ui_resource_string.h" #include "components/ui_scroll_view.h" @@ -70,7 +71,7 @@ EphemerisDownloadView::~EphemerisDownloadView() { delete labelNote_; labelNote_ = nullptr; } - // 蓝牙未连接页容器及子控件 + // 等待页容器及子控件 if (container_[EPHEMERIS_VIEW_BT_DISCONNECT] != nullptr) { container_[EPHEMERIS_VIEW_BT_DISCONNECT]->RemoveAll(); if (labelTitleBt_ != nullptr) { delete labelTitleBt_; labelTitleBt_ = nullptr; } @@ -244,7 +245,6 @@ bool EphemerisDownloadView::InitBtDisconnectView() { container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetDraggable(true); container_[EPHEMERIS_VIEW_BT_DISCONNECT]->SetOnDragListener(presenter_); - // 标题 - 与 FindPhone 未连接页排版一致(83, 50, 300, 35) labelTitleBt_ = new UILabelExt(); if (labelTitleBt_ == nullptr) return false; labelTitleBt_->SetPosition(83, 50, 300, 35); @@ -261,14 +261,12 @@ bool EphemerisDownloadView::InitBtDisconnectView() { labelTitleBt_->SetTextColor(Color::White()); container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(labelTitleBt_); - // 图标 - 与「正在优化定位速度」界面的下载动图第一张一致(transmitting 使用 /user/res/down/ 24 帧) imageViewBt_ = new UIImageView(); if (imageViewBt_ == nullptr) return false; imageViewBt_->SetPosition(183, 140, 100, 100); imageViewBt_->SetSrc("/user/res/down/23.bin"); container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(imageViewBt_); - // 提示文案 - 蓝牙未连接(83, 270, 300, 35) labelHintBt_ = new UILabelExt(); if (labelHintBt_ == nullptr) return false; labelHintBt_->SetPosition(83, 270, 300, 35); @@ -285,7 +283,6 @@ bool EphemerisDownloadView::InitBtDisconnectView() { labelHintBt_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); container_[EPHEMERIS_VIEW_BT_DISCONNECT]->Add(labelHintBt_); - // 关闭按钮 - 与 FindPhone 未连接页一致(0, 366, 466, 100) btnCloseBt_ = new UILabelButtonExt(); if (btnCloseBt_ == nullptr) return false; btnCloseBt_->SetPosition(0, 366, 466, 100); @@ -325,7 +322,17 @@ UILabelExt *EphemerisDownloadView::GetValidityPeriodLabel() { // 更新下载状态显示 void EphemerisDownloadView::UpdateDownloadStatus() { if (labelStatusValue_ == nullptr) return; - +#if defined(SUPPORT_GNSS) + // BLE EPO 解压成功时,gnss_check_agnss_status 可能尚未更新,以 EPO 解压状态优先 + if (uapi_dev_runtime_get_epo_file_extracted_status() == 1) { + EphemerisDownloadModel::GetInstance().SetEphemerisDownloadStatus(EphemerisDownloadStatus::DOWNLOADED); + if(ConfigModel::GetInstance()->GetLanguage() == 0) + labelStatusValue_->SetText("已优化"); + else + labelStatusValue_->SetText("Optimized"); + return; + } +#endif // 先同步状态:如果有效期有效,确保状态为已下载 if(EphemerisDownloadModel::GetInstance().GetValidityPeriod()) { diff --git a/code/sdk/application/wearable/fd272/service/msg_center/src/notify/transmitting.cpp b/code/sdk/application/wearable/fd272/service/msg_center/src/notify/transmitting.cpp index db5ef3dec..d52a76e7b 100644 --- a/code/sdk/application/wearable/fd272/service/msg_center/src/notify/transmitting.cpp +++ b/code/sdk/application/wearable/fd272/service/msg_center/src/notify/transmitting.cpp @@ -23,6 +23,7 @@ #include "ConfigModelC.h" #include "ConfigModel.h" #include "transmitting.h" +#include "ephemeris_download/include/EphemerisDownloadPresenter.h" #ifdef SUPPORT_CYWEE_SERVICE #include "cywee_service.h" #endif @@ -242,6 +243,7 @@ namespace OHOS } static uint8_t epo_timer_falg=20; + static bool epo_success_handled = false; void epo_timerCallBack(int data) { //给15s时间,等待EPO文件解压完成,超过15s不管成功与否,都停止通知 @@ -254,10 +256,25 @@ namespace OHOS else { //如果EPO文件解压成功,停止通知 - if(uapi_dev_runtime_get_epo_file_extracted_status() == 1) + uint8_t epo_status = uapi_dev_runtime_get_epo_file_extracted_status(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "epo_timerCallBack: uapi_dev_runtime_get_epo_file_extracted_status() = %d", epo_status); + if(epo_status == 1 && !epo_success_handled) { - NativeAbility::GetInstance().ChangeSlice(VIEW_EPHEMERIS_DOWNLOAD); - NotificationManager::GetInstance()->StopNotify(); + epo_success_handled = true; + // 立即停止定时器,防止重复触发 + if (transmitting_timer != NULL) { + osTimerStop(transmitting_timer); + osTimerDelete(transmitting_timer); + transmitting_timer = NULL; + } + // 投递到图形线程执行,确保 UI 操作和状态更新正确 + GraphicService::GetInstance()->PostGraphicEvent([]() { + if (EphemerisDownloadPresenter::GetInstance() != nullptr) { + EphemerisDownloadPresenter::GetInstance()->SwitchToMainViewBeforeShow(); + } + NativeAbility::GetInstance().ChangeSlice(VIEW_EPHEMERIS_DOWNLOAD); + NotificationManager::GetInstance()->StopNotify(); + }); } } epo_timer_falg--; @@ -1371,6 +1388,7 @@ namespace OHOS transmitting_timer = NULL; epo_timer_falg=20; } + epo_success_handled = false; transmitting_timer = osTimerNew((osTimerFunc_t)epo_timerCallBack, osTimerPeriodic, NULL, NULL); tick =1000;// osMs2Tick(1000); retTimer = osTimerStart(transmitting_timer, tick);