From b01521ed1c6b44b0880030c37466272c50742e92 Mon Sep 17 00:00:00 2001 From: Caisking Date: Fri, 27 Jun 2025 14:57:40 +0800 Subject: [PATCH] =?utf8?q?=E9=80=82=E9=85=8DAOD=E9=BB=98=E8=AE=A4=E8=A1=A8?= =?utf8?q?=E7=9B=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aod_view/src/AodView.cpp | 10 +- .../nativeui/clock/include/AmbientClockView.h | 1 + .../nativeui/clock/src/AmbientClockView.cpp | 106 +++++---- .../nativeui/clock/src/MainClockView.cpp | 2 - .../dnotdisturb/src/DnotDisturbModel.cpp | 4 - .../main/include/dial/DialViewGroup.h | 1 + .../nativeapp/nativeui/main/src/MainModel.cpp | 4 +- .../nativeui/main/src/dial/DialViewGroup.cpp | 46 +++- .../screennotify/src/ui_screennotify.cpp | 2 + .../nativeui/set_dial/include/SetDialInfo.h | 2 + .../nativeui/set_dial/include/SetDialModel.h | 7 +- .../nativeui/set_dial/src/SetDialModel.cpp | 225 ++++++++++-------- .../set_dial/src/SetDialPresenter.cpp | 1 + 13 files changed, 243 insertions(+), 168 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aod_view/src/AodView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aod_view/src/AodView.cpp index 90405196d..7943c5a98 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/aod_view/src/AodView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/aod_view/src/AodView.cpp @@ -25,13 +25,17 @@ AodView::~AodView() void AodView::OnStart() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AodView::OnStart: Start to generate the AOD watch face.\n"); DialSetting &setting = MainModel::GetInstance().GetDialSetting(); if (setting.dialFlag == 0) { // 在线表盘 + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "online dial"); clockDial_ = InitAodDial(setting); } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "offline dial"); clockDial_ = InitAodOffDial(setting); } if (clockDial_ == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "clockDial_ init failed."); clockDial_ = InitDefaultAod(); } if (clockDial_ == nullptr) { @@ -80,13 +84,16 @@ UIViewGroup *AodView::InitAodOffDial(DialSetting &setting) { DialPreviewInfo preview; memset_s(&preview, sizeof(preview), 0, sizeof(preview)); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "dialFullName: %s", setting.dialFullName.c_str()); FILE *fp = fopen(setting.dialFullName.c_str(), "rb"); if (fp == nullptr) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AodView::InitAodOffDial: Failed to open the dial file.\n"); return nullptr; } bool ret = DialBinParserManager::GetInstance()->GetDialPreviewInfo(fp, &preview); fclose(fp); if (!ret) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AodView::InitAodOffDial: Failed to get the dial preview info.\n"); return nullptr; } if (preview.capability == DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY || @@ -94,7 +101,8 @@ UIViewGroup *AodView::InitAodOffDial(DialSetting &setting) DialViewGroup *dial = new DialViewGroup; dial->SetDial(setting.dialFullName, DisplayState::AOD); return dial; - } + } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AodView::InitAodOffDial: The dial does not support AOD.\n"); return nullptr; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/include/AmbientClockView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/include/AmbientClockView.h index 2d02ca41e..44e9f36cc 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/include/AmbientClockView.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/include/AmbientClockView.h @@ -58,6 +58,7 @@ private: Image *bigCircle_{nullptr}; Image *medCircle_{nullptr}; Image *smallCircle_{nullptr}; + UILabel *timerlabel{nullptr}; bool viewiInitStatus_{false}; }; // class AmbientClockView } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/AmbientClockView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/AmbientClockView.cpp index d9aaac648..0a64ad021 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/AmbientClockView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/AmbientClockView.cpp @@ -11,7 +11,10 @@ #include "wearable_log.h" #include "ui_resource_image.h" #include "common/image_cache_manager.h" - +#include "uicomponents/UIComponents.h" +#include "ui_resource_image.h" +#include +#include namespace OHOS { static constexpr uint16_t POINT_POSITION_X = 202; static constexpr uint16_t POINT_POSITION_Y = 16; @@ -40,24 +43,27 @@ AmbientClockView::~AmbientClockView() { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AmbientClockView::~AmbientClockView"); if (viewiInitStatus_) { - mainSweepClock_->RemoveAll(); - delete secondHand_; - secondHand_ = nullptr; - delete minuteHand_; - minuteHand_ = nullptr; - delete hourHand_; - hourHand_ = nullptr; - delete hand24Hour_; - hand24Hour_ = nullptr; - delete bigCircle_; - bigCircle_ = nullptr; - delete medCircle_; - medCircle_ = nullptr; - delete smallCircle_; - smallCircle_ = nullptr; - Remove(mainSweepClock_); - delete mainSweepClock_; - mainSweepClock_ = nullptr; + // mainSweepClock_->RemoveAll(); + // delete secondHand_; + // secondHand_ = nullptr; + // delete minuteHand_; + // minuteHand_ = nullptr; + // delete hourHand_; + // hourHand_ = nullptr; + // delete hand24Hour_; + // hand24Hour_ = nullptr; + // delete bigCircle_; + // bigCircle_ = nullptr; + // delete medCircle_; + // medCircle_ = nullptr; + // delete smallCircle_; + // smallCircle_ = nullptr; + // Remove(mainSweepClock_); + // delete mainSweepClock_; + // mainSweepClock_ = nullptr; + + delete timerlabel; + timerlabel = nullptr; } } @@ -172,40 +178,27 @@ void AmbientClockView::PreLoad(void) bool AmbientClockView::InitView(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AmbientClockView::InitView"); - - mainSweepClock_ = new UISweepClock(); - if (mainSweepClock_ == nullptr) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "mainSweepClock new fail"); - return false; + //只显示时间 使用数字 + if (timerlabel == nullptr) { + timerlabel = new UILabel(); } - if (!InitSweepClock()) { - return false; - } - - Add(mainSweepClock_); + timerlabel->SetPosition(58, 108); // widget's left position and top position + timerlabel->Resize(350, 250); // widget's width and height + timerlabel->SetViewId("label1");// Set style + timerlabel->SetStyle(STYLE_TEXT_FONT, 130); - mainSweepClock_->SetDragParentInstead(true); - mainSweepClock_->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION); + // Set additional property + timerlabel->SetText("12:00"); + timerlabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + timerlabel->SetTextColor(Color::GetColorFromRGBA(0x69, 0x69, 0x69, 0xff)); + timerlabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + timerlabel->SetRollSpeed(0); + timerlabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 130); - // {214, 3}: position x, y {14, 223}: center x, y - mainSweepClock_->SetHandImage(UISweepClock::HandType::SECOND_HAND, *secondHand_, - { POINT_POSITION_X, SECOND_POINT_POSITION_Y }, { POINT_CENTER_X, POINT_CENTER_Y }); - mainSweepClock_->SetHandImage(UISweepClock::HandType::MINUTE_HAND, *minuteHand_, - { POINT_POSITION_X, POINT_POSITION_Y }, { POINT_CENTER_X, POINT_CENTER_Y }); - mainSweepClock_->SetHandImage(UISweepClock::HandType::HOUR_HAND, *hourHand_, { POINT_POSITION_X, POINT_POSITION_Y }, - { POINT_CENTER_X, POINT_CENTER_Y }); - mainSweepClock_->SetHandCircleImage(UISweepClock::HandType::SECOND_HAND, *smallCircle_, - { SMALLCIRCLE_POSITION_X, SMALLCIRCLE_POSITION_Y }); - mainSweepClock_->SetHandCircleImage(UISweepClock::HandType::MINUTE_HAND, *medCircle_, - { MEDCIRCLE_POSITION_X, MEDCIRCLE_POSITION_Y }); - mainSweepClock_->SetHandCircleImage(UISweepClock::HandType::HOUR_HAND, *bigCircle_, - { BIGCIRCLE_POSITION_X, BIGCIRCLE_POSITION_Y }); + Add(timerlabel); - mainSweepClock_->SetInitTime24Hour(0, 0, 0); - mainSweepClock_->SetWorkMode(UISweepClock::WorkMode::NORMAL); - InitDateTime(); SetCoverable(true); + return true; } @@ -215,7 +208,7 @@ void AmbientClockView::InitDateTime(void) time_t seconds; time(&seconds); localtime_r(&seconds, &pTM); - mainSweepClock_->SetTime24Hour(pTM.tm_hour, pTM.tm_min, pTM.tm_sec); + // mainSweepClock_->SetTime24Hour(pTM.tm_hour, pTM.tm_min, pTM.tm_sec); } void AmbientClockView::UpdateTime(void) @@ -230,7 +223,20 @@ void AmbientClockView::UpdateTime(void) uint8_t realMinute = static_cast(minute % MIN_TO_HOUR); uint16_t realMilliSecond = static_cast((second % MIN_TO_HOUR) * SEC_TO_MILLI + uSecond / USEC_TO_MILLI); - mainSweepClock_->SetSweepTime12Hour(realHour, realMinute, realMilliSecond, 1); + + // if (timerlabel != nullptr) { + // std::stringstream ss; + // ss.fill('0'); + + // ss << std::setw(2) << realHour << ":"; + // ss << std::setw(2) << realMinute; + + // timerlabel->SetText(ss.str().c_str()); + // } + if(timerlabel == nullptr) + return; + + timerlabel->SetText((std::to_string(realHour) + ":" + std::to_string(realMinute)).c_str()); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/MainClockView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/MainClockView.cpp index 4138c95b2..7ac83e00a 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/MainClockView.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/clock/src/MainClockView.cpp @@ -596,7 +596,6 @@ void MainClockView::UpdateBatteryColor(void) { -#ifdef FD230_650 bool isCharging = get_charge_stat(); // 获取充电状态 if (isCharging) @@ -637,7 +636,6 @@ } } } -#endif } void MainClockView::SetViewColor(int64_t color) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/dnotdisturb/src/DnotDisturbModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/dnotdisturb/src/DnotDisturbModel.cpp index d8728a090..ed646eaca 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/dnotdisturb/src/DnotDisturbModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/dnotdisturb/src/DnotDisturbModel.cpp @@ -28,10 +28,8 @@ namespace OHOS void DnotDisturbModel::SetDoNotDisturbModeEnabled(bool enabled) { ConfigModel::GetInstance()->SetDnotdisturb(enabled); - #ifdef FD230_650 /*更新主界面配置*/ MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB, enabled); - #endif } bool DnotDisturbModel::GetDoNotDisturbModeEnabled() const @@ -56,10 +54,8 @@ namespace OHOS DropDownCardPage1::GetInstance()->UpdateDnotdisturbState(GetDoNotDisturbModeEnabled()); } PullUpDownView::GetInstance()->UpdateDnotDisturbStatus(GetDoNotDisturbModeEnabled()); - #ifdef FD230_650 /*更新主界面配置*/ MainModel::GetInstance().setDialState(DialState::DO_NOT_DISTURB, GetDoNotDisturbModeEnabled()); - #endif } return; } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h index 3b4aec3c7..3b5c15f94 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/include/dial/DialViewGroup.h @@ -147,6 +147,7 @@ public: private: bool resLoadStatus{false}; + bool videoPlaying_{false}; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp index c39fb43da..c9943f4e7 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/MainModel.cpp @@ -85,7 +85,9 @@ namespace OHOS {DialState::SLEEP, false}, {DialState::LOCK, false}, }}; - MainModel::MainModel() {} + MainModel::MainModel() { + power_display_gui_enable_aod(IsAodEnabled()); + } MainModel::~MainModel() {} MainModel &MainModel::GetInstance() { diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp index 9225077ca..f172246b7 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/main/src/dial/DialViewGroup.cpp @@ -261,6 +261,46 @@ void DialViewGroup::DoPause(void) video_->PausePlay(); } } +void DialViewGroup::StopDial() +{ + if(videoPlaying_ == false) + return; + + SetLableAnimatorState(Animator::PAUSE); + SetImgAnimatorState(Animator::PAUSE); + if (kaleidoscope_ != nullptr) { + kaleidoscope_->StopRotateAnimator(); + kaleidoscope_->ClearFocus(); + } + if (video_ != nullptr) { + video_->PausePlay(); + } + + videoPlaying_ = false; +} +void DialViewGroup::StartDial() +{ + if(videoPlaying_ == true) + return; + + SetLableAnimatorState(Animator::START); + if (isSeqImgLoaded_) { + SetImgAnimatorState(Animator::START); + } + if (video_ != nullptr) { + if (video_->IsPaused()) { + video_->ResumePlay(); + } else if (!video_->IsPlayed()) { + video_->StartPlay(); + } + } + if (kaleidoscope_ != nullptr) { + kaleidoscope_->RequestFocus(); + kaleidoscope_->StartRotateAnimator(); + } + + videoPlaying_ = true; +} void DialViewGroup::RecordSpecial(UIView *view) { @@ -403,15 +443,15 @@ void DialViewGroup::AddView(DialDataType type, DialView* view, bool isPeriodic) Invalidate(); } // ota进行视频暂停 - if (uapi_dev_runtime_get_transmitting_status() == 1 || uapi_dev_runtime_get_restore_factory_status() == 1) + if (uapi_dev_runtime_get_transmitting_status()|| uapi_dev_runtime_get_restore_factory_status()) { // 暂停视频 - DoPause(); + StopDial(); } else { // 获取视频 - DoStart(); + StartDial(); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/screennotify/src/ui_screennotify.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/screennotify/src/ui_screennotify.cpp index fe79bf6ec..784c4c4a6 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/screennotify/src/ui_screennotify.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/screennotify/src/ui_screennotify.cpp @@ -72,8 +72,10 @@ static void GuiEnterAod(bool entry) } if (NativeAbility::GetInstance().GetNativeAbilityState() == STATE_ACTIVE) { if (newState == DisplayState::AOD) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "enter aod"); NativeAbility::GetInstance().ChangeSlice(VIEW_AOD); } else { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "exit aod"); NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); } } diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialInfo.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialInfo.h index 158370c9c..9b16a4d1f 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialInfo.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialInfo.h @@ -17,11 +17,13 @@ namespace OHOS { uint8_t dialFlag; // 表盘标志 1:离线表盘 0:预制表盘 uint8_t id; // 表盘Id 仅预制表盘使用 + uint32_t resId; /* 仅离线表盘使用 */ std::string dialFullName; // 表盘路径 仅离线表盘使用 std::string imageFullName; // 表盘缩约图 仅预制表盘使用 std::string dialName; // 表盘名 std::string description; // 表盘描述 仅离线表盘使用 ImageInfo *preImageInfo; + uint8_t capability; } SetDialInfo; } #endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h index 043f27d34..d7d55a7a6 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/include/SetDialModel.h @@ -65,6 +65,7 @@ namespace OHOS void LoadAllDial(void); size_t GetDialCount(void); std::vector &GetDialInfo(void); + std::vector& GetAmbientDialInfo(void); void SaveDialSetting(uint8_t pageIndex); uint8_t GetPageIndex(void); void RegisterDial(uint16_t ID, const char *dialname); @@ -102,7 +103,7 @@ namespace OHOS //判断是否可以继续下载表盘 bool CheckDialDownload(uint16_t ID,uint32_t dial_size); void CheckDialSpace(); - + void ClearDialInfo(void); private: void LoadAllDialFromRam(void); void LoadAllDialFromFs(void); @@ -112,9 +113,11 @@ namespace OHOS SetDialModel &operator=(const SetDialModel &); virtual ~SetDialModel(); int32_t ParseDialHeader(int type, const std::string &dialFileName, SetDialInfo &dialInfo); + std::vector dialInfoList; - uint16_t currentDialID = 114; // 设置表盘默认值 + std::vector aodDialInfoList; + uint16_t currentDialID = 114; // 设置表盘默认值 uint16_t download_DialID = 1028; uint32_t download_dialSize = 0; bool downloadstate = false; diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp index 17be6291a..b4a31e5af 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialModel.cpp @@ -14,6 +14,7 @@ #include "securec.h" #include "set_dial/include/SetDialModelC.h" // #include "system/include/SystemLogModel.h" +#include "graphic_service.h" #include "wearable_log.h" #include #include @@ -27,7 +28,6 @@ #include #include #include -#include "graphic_service.h" extern "C" { void check_dial_space() { OHOS::SetDialModel::GetInstance().CheckDialSpace(); } } @@ -493,6 +493,7 @@ void SetDialModel::UpdateDialSetting(uint16_t ID) { void SetDialModel::LoadAllDial() { dialInfoList.clear(); size_t dialSize = dialInfoList.size(); + size_t aodSize = aodDialInfoList.size(); // 加载默认表盘 LoadAllDialFromDefult(); // 加载自定义表盘 @@ -509,6 +510,10 @@ void SetDialModel::LoadAllDial() { char dialId[128]; GetAllDialIDs(dialId, 128); PrintRegisteredDials(registeredDials); + + std::sort(aodDialInfoList.begin() + aodSize, + aodDialInfoList.end(), + [](const SetDialInfo &f, const SetDialInfo &n) { return f.dialName < n.dialName; }); } /*加载离线表盘*/ void SetDialModel::LoadAllDialFromFs() { @@ -523,7 +528,15 @@ void SetDialModel::LoadAllDialFromFs() { SetDialInfo dialInfo{0}; int ret = ParseDialHeader(DOWNLOADDIAL, direntp->d_name, dialInfo); if (ret == 0) { - dialInfoList.push_back(dialInfo); + if (dialInfo.capability == DIAL_DISPLAY_CAPABILITY_NORMAL_ONLY) { + dialInfoList.push_back(dialInfo); + } else if (dialInfo.capability == + DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY) { + aodDialInfoList.push_back(dialInfo); + } else { + dialInfoList.push_back(dialInfo); + aodDialInfoList.push_back(dialInfo); + } downloadnum++; } } @@ -571,7 +584,15 @@ void SetDialModel::LoadAllDialFromDefult(void) { if (ret == 0) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Adding dial %s", fullDialName.c_str()); - dialInfoList.push_back(dialInfo); + if (dialInfo.capability == DIAL_DISPLAY_CAPABILITY_NORMAL_ONLY) { + dialInfoList.push_back(dialInfo); + } else if (dialInfo.capability == + DIAL_DISPLAY_CAPABILITY_AMBITIENT_ONLY) { + aodDialInfoList.push_back(dialInfo); + } else { + dialInfoList.push_back(dialInfo); + aodDialInfoList.push_back(dialInfo); + } } else { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ParseDialHeader is error for file %s", @@ -630,10 +651,12 @@ int32_t SetDialModel::ParseDialHeader(int type, const std::string &dialFileName, dialInfo.dialFlag = 1; dialInfo.id = 0; + dialInfo.resId = preInfo.imgId; dialInfo.dialFullName = dialFullName; dialInfo.dialName = preInfo.dialName; dialInfo.description = preInfo.description; dialInfo.preImageInfo = info; + dialInfo.capability = preInfo.capability; fclose(fp); return 0; @@ -684,6 +707,22 @@ size_t SetDialModel::GetDialCount(void) { std::vector &SetDialModel::GetDialInfo(void) { return dialInfoList; } +std::vector& SetDialModel::GetAmbientDialInfo(void) +{ + return aodDialInfoList; +} +void SetDialModel::ClearDialInfo(void) +{ + for (auto iter : dialInfoList) { + if (iter.dialFlag) { + ImageCacheManager::GetInstance().UnloadOneInMultiRes(iter.resId, iter.dialFullName); + } else { + ImageCacheManager::GetInstance().UnloadSingleRes(iter.imageFullName); + } + } + dialInfoList.clear(); + aodDialInfoList.clear(); +} uint8_t SetDialModel::GetPageIndex(void) { uint8_t index = 0; @@ -752,7 +791,6 @@ void SetDialModel::LoadAllDialFromRam() { // 设置图像信息 dialInfo.preImageInfo = imageInfo; - // 添加到表盘列表 dialInfoList.push_back(dialInfo); // 注册到map @@ -1013,145 +1051,123 @@ extern "C" { #endif /* __cplusplus */ #endif /* __cplusplus */ - -uint8_t get_dial_num_() -{ - return OHOS::SetDialModel::GetInstance().GetDialCount(); +uint8_t get_dial_num_() { + return OHOS::SetDialModel::GetInstance().GetDialCount(); } -bool check_dial_freespace_(uint16_t id,uint32_t dial_size) { - return OHOS::SetDialModel::GetInstance().CheckDialDownload(id,dial_size); +bool check_dial_freespace_(uint16_t id, uint32_t dial_size) { + return OHOS::SetDialModel::GetInstance().CheckDialDownload(id, dial_size); } -void ble_get_dial_path_(char * buf,uint16_t id) -{ - char *path= (char*)OHOS::SetDialModel::GetInstance().GetSaveDir(id,0).c_str(); - memcpy(buf,path,strlen(path)+1); - return; +void ble_get_dial_path_(char *buf, uint16_t id) { + char *path = + (char *)OHOS::SetDialModel::GetInstance().GetSaveDir(id, 0).c_str(); + memcpy(buf, path, strlen(path) + 1); + return; } -void ble_save_dial_custom_(msg_recv_custom_dial_info_t *data) -{ - OHOS:: DialLayout info; - info.dialId=data->dial_uid; - info.batteryDisplay=data->battery; - info.timeDisplay=data->time; - info.colorTypeSet=data->time_font; - OHOS::SetDialModel::GetInstance().saveDialConfig(info); +void ble_save_dial_custom_(msg_recv_custom_dial_info_t *data) { + OHOS::DialLayout info; + info.dialId = data->dial_uid; + info.batteryDisplay = data->battery; + info.timeDisplay = data->time; + info.colorTypeSet = data->time_font; + OHOS::SetDialModel::GetInstance().saveDialConfig(info); } -void ble_set_dial_by_id__(uint16_t id) -{ - // printf("ble_set_dial_by_id_ %d\n",id); - OHOS::SetDialModel::GetInstance().UpdateDialSetting(id); - +void ble_set_dial_by_id__(uint16_t id) { + // printf("ble_set_dial_by_id_ %d\n",id); + OHOS::SetDialModel::GetInstance().UpdateDialSetting(id); } -void ble_set_dial_by_id_(uint16_t id) -{ - // printf("ble_set_dial_by_id %d\n",id); - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(ble_set_dial_by_id__ ,id)); +void ble_set_dial_by_id_(uint16_t id) { + // printf("ble_set_dial_by_id %d\n",id); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(ble_set_dial_by_id__, id)); } -void ble_get_custom_dial_(uint16_t id,char *buf) -{ - const char *name=OHOS::SetDialModel::GetInstance().GetCustomName(id).c_str(); - memset_s(buf,32,0,32); - memcpy_s(buf,32,name,strlen(name)); +void ble_get_custom_dial_(uint16_t id, char *buf) { + const char *name = + OHOS::SetDialModel::GetInstance().GetCustomName(id).c_str(); + memset_s(buf, 32, 0, 32); + memcpy_s(buf, 32, name, strlen(name)); } -uint16_t ble_get_dial_id_(void) -{ - uint16_t id= OHOS::SetDialModel::GetInstance().GetCurrentDialID(); - return id; +uint16_t ble_get_dial_id_(void) { + uint16_t id = OHOS::SetDialModel::GetInstance().GetCurrentDialID(); + return id; } -bool ble_is_dial_install_by_id_(uint16_t id) -{ - return OHOS::SetDialModel::GetInstance().IsDialInstalled(id); +bool ble_is_dial_install_by_id_(uint16_t id) { + return OHOS::SetDialModel::GetInstance().IsDialInstalled(id); } //////////////////////////////////////////////////////// -int ble_get_dial_num_(void) -{ - return OHOS::SetDialModel::GetInstance().GetDialCount(); +int ble_get_dial_num_(void) { + return OHOS::SetDialModel::GetInstance().GetDialCount(); } -void ble_delete_dial__(uint16_t id) -{ - OHOS::SetDialModel::GetInstance().UninstallDial(id); +void ble_delete_dial__(uint16_t id) { + OHOS::SetDialModel::GetInstance().UninstallDial(id); } -bool ble_delete_dial_(uint16_t id) -{ +bool ble_delete_dial_(uint16_t id) { - if(id==OHOS::SetDialModel::GetInstance().GetCurrentDialID()) + if (id == OHOS::SetDialModel::GetInstance().GetCurrentDialID()) return false; - else - { - switch (id) { - case OHOS::DEFAULT_DIAL_ID: - case OHOS::MAX_DEFAULT_DIAL_ID: - case OHOS::DEFAULT_DIAL_ID_0: - case OHOS::DEFAULT_DIAL_ID_1: - case OHOS::DEFAULT_DIAL_ID_2: - case OHOS::DEFAULT_DIAL_ID_3: - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, - "UninstallDial: Default dial %d cannot be uninstalled", id); - return false; - } - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(ble_delete_dial__,id)); - return true; + else { + switch (id) { + case OHOS::DEFAULT_DIAL_ID: + case OHOS::MAX_DEFAULT_DIAL_ID: + case OHOS::DEFAULT_DIAL_ID_0: + case OHOS::DEFAULT_DIAL_ID_1: + case OHOS::DEFAULT_DIAL_ID_2: + case OHOS::DEFAULT_DIAL_ID_3: + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "UninstallDial: Default dial %d cannot be uninstalled", id); + return false; } - + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(ble_delete_dial__, id)); + return true; + } } -int get_all_dial_id_( char * buf,uint16_t MAX_LEN) -{ - return OHOS::SetDialModel::GetInstance().GetAllDialIDs(buf,MAX_LEN); +int get_all_dial_id_(char *buf, uint16_t MAX_LEN) { + return OHOS::SetDialModel::GetInstance().GetAllDialIDs(buf, MAX_LEN); } -bool dial_file_save_(void ) -{ - return OHOS::SetDialModel::GetInstance().saveDialfile(); +bool dial_file_save_(void) { + return OHOS::SetDialModel::GetInstance().saveDialfile(); } -void install_Register_dial__( char * name,uint16_t id) -{ - OHOS::SetDialModel::GetInstance().RegisterDial(id,name,0); - +void install_Register_dial__(char *name, uint16_t id) { + OHOS::SetDialModel::GetInstance().RegisterDial(id, name, 0); } -void install_Register_dial_( char * name,uint16_t id) -{ - GraphicService::GetInstance()->PostGraphicEvent( - std::bind(install_Register_dial__,name ,id)); - return ; - +void install_Register_dial_(char *name, uint16_t id) { + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(install_Register_dial__, name, id)); + return; } extern bleInstruct_t_ bleInstruct_t; -void ble_dial_init(void) -{ - bleInstruct_t.get_dial_num_cb= get_dial_num_; - bleInstruct_t.check_dial_freespace= check_dial_freespace_; - bleInstruct_t.ble_get_dial_path= ble_get_dial_path_; - bleInstruct_t. ble_save_dial_custom=ble_save_dial_custom_; - - bleInstruct_t. ble_set_dial_by_id=ble_set_dial_by_id_; +void ble_dial_init(void) { + bleInstruct_t.get_dial_num_cb = get_dial_num_; + bleInstruct_t.check_dial_freespace = check_dial_freespace_; + bleInstruct_t.ble_get_dial_path = ble_get_dial_path_; + bleInstruct_t.ble_save_dial_custom = ble_save_dial_custom_; + bleInstruct_t.ble_set_dial_by_id = ble_set_dial_by_id_; - bleInstruct_t. ble_get_custom_dial= ble_get_custom_dial_; - bleInstruct_t. ble_get_dial_id = ble_get_dial_id_; - bleInstruct_t. ble_is_dial_install_by_id =ble_is_dial_install_by_id_; + bleInstruct_t.ble_get_custom_dial = ble_get_custom_dial_; + bleInstruct_t.ble_get_dial_id = ble_get_dial_id_; + bleInstruct_t.ble_is_dial_install_by_id = ble_is_dial_install_by_id_; //////////////////////////////////////////////////////// - bleInstruct_t. ble_get_dial_num=ble_get_dial_num_; - bleInstruct_t. ble_delete_dial=ble_delete_dial_; - bleInstruct_t. get_all_dial_id=get_all_dial_id_; - bleInstruct_t. dial_file_save=dial_file_save_; - bleInstruct_t.install_Register_dial= install_Register_dial_; - + bleInstruct_t.ble_get_dial_num = ble_get_dial_num_; + bleInstruct_t.ble_delete_dial = ble_delete_dial_; + bleInstruct_t.get_all_dial_id = get_all_dial_id_; + bleInstruct_t.dial_file_save = dial_file_save_; + bleInstruct_t.install_Register_dial = install_Register_dial_; } #ifdef __cplusplus @@ -1160,7 +1176,6 @@ void ble_dial_init(void) #endif /* __cplusplus */ #endif /* __cplusplus */ - #endif } // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp index 3d1a2ad6b..a23202462 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/set_dial/src/SetDialPresenter.cpp @@ -51,6 +51,7 @@ namespace OHOS void SetDialPresenter::OnStop(void) { + model->ClearDialInfo(); } void SetDialPresenter::OnClickAction(void) -- 2.17.1