// 供Model调用的回调函数
void UpdateDownloadStatus();
+
+ // 在 ChangeSlice 前调用,提前切到主界面,避免跳转时闪一下等待页
+ void SwitchToMainViewBeforeShow();
private:
int16_t currentView_{0}; // EPHEMERIS_VIEW_MAIN or EPHEMERIS_VIEW_BT_DISCONNECT
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;
}
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) {
EphemerisDownloadView::EPHEMERIS_VIEW_MAIN);
currentView_ = EphemerisDownloadView::EPHEMERIS_VIEW_MAIN;
}
- } else {
+ } else if (dir == DragEvent::DIRECTION_LEFT_TO_RIGHT) {
NativeAbility::GetInstance().Back();
}
}
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:
#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"
delete labelNote_;
labelNote_ = nullptr;
}
- // 蓝牙未连接页容器及子控件
+ // 等待页容器及子控件
if (container_[EPHEMERIS_VIEW_BT_DISCONNECT] != nullptr) {
container_[EPHEMERIS_VIEW_BT_DISCONNECT]->RemoveAll();
if (labelTitleBt_ != nullptr) { delete labelTitleBt_; labelTitleBt_ = nullptr; }
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);
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);
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);
// 更新下载状态显示
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())
{
#include "ConfigModelC.h"
#include "ConfigModel.h"
#include "transmitting.h"
+#include "ephemeris_download/include/EphemerisDownloadPresenter.h"
#ifdef SUPPORT_CYWEE_SERVICE
#include "cywee_service.h"
#endif
}
static uint8_t epo_timer_falg=20;
+ static bool epo_success_handled = false;
void epo_timerCallBack(int data)
{
//给15s时间,等待EPO文件解压完成,超过15s不管成功与否,都停止通知
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--;
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);