From: Caisking <3449750381@qq.com> Date: Wed, 28 Feb 2024 11:01:40 +0000 (+0800) Subject: Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230... X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~50^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=21a9c6f8ac2309ef1e2539a90d44e56c6145d4dd;p=mirrors%2FFD230.git Merge branch 'xts_origin' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into xts_origin --- 21a9c6f8ac2309ef1e2539a90d44e56c6145d4dd diff --cc code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index fd3303f3c,34ff7f2c3..89007d2de --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@@ -12,174 -12,155 +12,192 @@@ #include "components/ui_label.h" #include "BloodBandoffView.h" #include "ChangeSliceListener.h" - -namespace OHOS { -static BloodOxygenPresenter *g_pMainView = nullptr; -static constexpr uint16_t PROGRESS_VALUE_MIN = 0; -static constexpr uint16_t PROGRESS_VALUE_MAX = 100; - -BloodOxygenPresenter::BloodOxygenPresenter() +#include "broadcast_service.h" +#include +#include "iostream" +#include +#include +#include +#include +#include "wearable_log.h" +#include "cmsis_os.h" +#include "securec.h" +#include "broadcast_service.h" +#include "graphic_service.h" +#include +#include +#include "ppg_service.h" + +namespace OHOS { - count = PROGRESS_VALUE_MAX; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::new BloodOxygenPresenter"); - g_pMainView = this; -} + static BloodOxygenPresenter *g_pMainView = nullptr; + static constexpr uint16_t PROGRESS_VALUE_MIN = 0; + static constexpr uint16_t PROGRESS_VALUE_MAX = 100; -BloodOxygenPresenter::~BloodOxygenPresenter() -{ - if (keyActListenr != nullptr) + BloodOxygenPresenter::BloodOxygenPresenter() { - delete keyActListenr; - keyActListenr = nullptr; + count = PROGRESS_VALUE_MAX; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::new BloodOxygenPresenter"); + g_pMainView = this; } - g_pMainView = nullptr; -} -BloodOxygenPresenter* BloodOxygenPresenter::GetInstance() -{ - return g_pMainView; -} + BloodOxygenPresenter::~BloodOxygenPresenter() + { + g_pMainView = nullptr; + } - BloodOxygenPresenter *BloodOxygenPresenter::GetInstance() -void BloodOxygenPresenter::OnStart() -{ - Presenter::OnStart(); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::On Start "); ++ BloodOxygenPresenter::~BloodOxygenPresenter() + { - return g_pMainView; ++ if (keyActListenr != nullptr) ++ { ++ delete keyActListenr; ++ keyActListenr = nullptr; ++ } ++ g_pMainView = nullptr; + } - if (keyActListenr == nullptr) + void BloodOxygenPresenter::OnStart() { - keyActListenr = new KeyInputListener(); - if (keyActListenr != nullptr) { + Presenter::OnStart(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::On Start "); ++ ++ if (keyActListenr == nullptr) ++ { ++ keyActListenr = new KeyInputListener(); ++ if (keyActListenr != nullptr) ++ { + RootView::GetInstance()->SetOnKeyActListener(keyActListenr); - } else { ++ } ++ else ++ { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnStart: new KeyInputListener fail"); ++ } + } } -} -void BloodOxygenPresenter::OnPause(void) {} + void BloodOxygenPresenter::OnPause(void) {} -void BloodOxygenPresenter::OnResume(void) {} + void BloodOxygenPresenter::OnResume(void) {} -void BloodOxygenPresenter::OnStop(void) {} + void BloodOxygenPresenter::OnStop(void) {} -bool BloodOxygenPresenter::CheckPointersValue() -{ - if (BloodOxygenView::GetInstance() == nullptr) { - return false; - } + bool BloodOxygenPresenter::CheckPointersValue() + { + if (BloodOxygenView::GetInstance() == nullptr) + { + return false; + } - if (BloodBandoffView::GetInstance() == nullptr) { - return false; + if (BloodBandoffView::GetInstance() == nullptr) + { + return false; + } + + if (BloodOxygenModel::GetInstance() == nullptr) + { + return false; + } + return true; } - if (BloodOxygenModel::GetInstance() == nullptr) { + bool BloodOxygenPresenter::OnDrag(UIView &view, const DragEvent &event) + { + UNUSED(view); + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) + { + BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(false); + BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(true); + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } return false; } - return true; -} - -bool BloodOxygenPresenter::OnDrag(UIView& view, const DragEvent& event) -{ - UNUSED(view); - if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT) { - BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(false); - BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(true); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + bool BloodOxygenPresenter::OnClick(UIView &view, const ClickEvent &event) + { + UNUSED(view); + UNUSED(event); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnClick"); + if (CheckPointersValue() == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::Pointers is empty"); + return false; + } + BloodOxygenView::GetInstance()->GetPercent()->SetText(""); + BloodOxygenView::GetInstance()->GetBloodOxygenGroup()->SetVisible(false); + BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(true); + BloodBandoffView::GetInstance()->GetImageAnimator()->Stop(); +#ifdef SUPPORT_SPO2_NOTIFICATION + uint32_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; + send_ppg_cmd_msg(md); + // 增加测试时间,大概20秒,测试期间,循环播放 + BloodBandoffView::GetInstance()->GetImageAnimator()->SetRepeatTimes(20); +#else + BloodBandoffView::GetInstance()->GetImageAnimator()->SetRepeatTimes(1); +#endif + BloodBandoffView::GetInstance()->GetImageAnimator()->Start(); + BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(true); + BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(false); + return true; } - return false; -} - -bool BloodOxygenPresenter::OnClick(UIView& view, const ClickEvent& event) -{ - UNUSED(view); - UNUSED(event); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnClick"); - if (CheckPointersValue() == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::Pointers is empty"); - return false; - } - BloodOxygenView::GetInstance()->GetPercent()->SetText(""); - BloodOxygenView::GetInstance()->GetBloodOxygenGroup()->SetVisible(false); - BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(true); - BloodBandoffView::GetInstance()->GetImageAnimator()->Stop(); - BloodBandoffView::GetInstance()->GetImageAnimator()->SetRepeat(false); - BloodBandoffView::GetInstance()->GetImageAnimator()->Start(); - BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(true); - BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(false); - return true; -} - -//增加按键事件 -bool BloodOxygenPresenter::OnKeyAct(UIView& view, const KeyEvent& event) -{ - WEARABLE_LOGD("","into the view is: %s\n", typeid(view).name()); - uint16 keyID = event.GetKeyId(); - WEARABLE_LOGD("","into key! keyID %u\n",keyID); - //如果是power键就返回上一级 - if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + // 增加按键事件 + bool BloodOxygenPresenter::OnKeyAct(UIView &view, const KeyEvent &event) { - //uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); - NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); - } - return true; -} -void BloodOxygenPresenter::ProgressNotify(void) -{ - if (CheckPointersValue() == false) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::Pointers is empty"); - return; + WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name()); + uint16 keyID = event.GetKeyId(); + WEARABLE_LOGD("", "into key! keyID %u\n", keyID); + // 如果是power键就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) + { + // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId(); + NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST); + } + return true; } - - if (BloodOxygenModel::GetInstance()->GetBloodOxygenViewStatus() == true) { - count--; - BloodOxygenView::GetInstance()->GetCircleProgress()->SetValue(count); - if (count == PROGRESS_VALUE_MIN) { - BloodOxygenView::GetInstance()->GetPercent()->SetText("98%"); - BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(false); - count = PROGRESS_VALUE_MAX; + void BloodOxygenPresenter::ProgressNotify(void) + { + if (CheckPointersValue() == false) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::Pointers is empty"); + return; + } + if (BloodOxygenModel::GetInstance()->GetBloodOxygenViewStatus() == true) + { + count--; BloodOxygenView::GetInstance()->GetCircleProgress()->SetValue(count); - BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(true); + if (count == PROGRESS_VALUE_MIN) + { + BloodOxygenView::GetInstance()->GetPercent()->SetText("98%"); + BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(false); + count = PROGRESS_VALUE_MAX; + BloodOxygenView::GetInstance()->GetCircleProgress()->SetValue(count); + BloodOxygenView::GetInstance()->GetTestButton()->SetTouchable(true); + } } } -} -void BloodOxygenPresenter::ReturnInterface() -{ - if (BloodOxygenModel::GetInstance()->GetBloodBandoffViewStatus() == true) { - if (BloodBandoffView::GetInstance()->GetImageAnimator()->GetState() == false) { - BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(false); - BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(true); - - BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(false); - BloodOxygenView::GetInstance()->GetBloodOxygenGroup()->SetVisible(true); + void BloodOxygenPresenter::ReturnInterface() + { + if (BloodOxygenModel::GetInstance()->GetBloodBandoffViewStatus() == true) + { + if (BloodBandoffView::GetInstance()->GetImageAnimator()->GetState() == false) + { + BloodOxygenModel::GetInstance()->SetBloodBandoffViewStatus(false); + BloodOxygenModel::GetInstance()->SetBloodOxygenViewStatus(true); + + BloodBandoffView::GetInstance()->GetBandoffViewGroup()->SetVisible(false); + BloodOxygenView::GetInstance()->GetBloodOxygenGroup()->SetVisible(true); +#ifdef SUPPORT_SPO2_NOTIFICATION + uint32_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; + send_ppg_cmd_msg(md); +#endif + } } } -} -void BloodOxygenPresenter::Notify(void) -{ - ProgressNotify(); - ReturnInterface(); -} + void BloodOxygenPresenter::Notify(void) + { + ProgressNotify(); + ReturnInterface(); + } }