同步applsit更新;配置充电不能进行检测
authorCaisking <3449750381@qq.com>
Fri, 16 Aug 2024 08:51:42 +0000 (16:51 +0800)
committerCaisking <3449750381@qq.com>
Fri, 16 Aug 2024 08:51:42 +0000 (16:51 +0800)
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistModel.cpp
code/sdk/application/wearable/fd230app/nativeui/applist/src/ApplistPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenModel.cpp
code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.cpp

index f3caa03..d9bdc48 100644 (file)
@@ -21,7 +21,7 @@
 #include "applist/include/ApplistModel.h"
 #include "themestyle/include/ThemeStyleModel.h"
 
-#define HEART_APPLIST 0
+#define HEART_APPLIST 1
 namespace OHOS
 {
     /**- APPLSIT
@@ -57,7 +57,7 @@ namespace OHOS
 #endif
         {VIEW_MAIN_PHONE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_CALLER_IMAGE, PNG_APPLIST_DEFAULT_IMG, "手机", STR_PHONE, nullptr},
 #if HEART_APPLIST
-        {VIEW_HEART_RESULT, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_DEFAULT_IMG, "心率", STR_HEART_RATE, nullptr},
+        {VIEW_HEART_CHART, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_HEART_IMAGE, PNG_APPLIST_DEFAULT_IMG, "心率", STR_HEART_RATE, nullptr},
 #endif
         {VIEW_BLOOD_RESULT, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_SPO2_IMAGE, PNG_APPLIST_DEFAULT_IMG, "血氧", STR_BLOOD_OXYGEN, nullptr},
         {VIEW_TRAINING, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_TRAINING_IMAGE, PNG_APPLIST_DEFAULT_IMG, "训练", STR_TRAINING, nullptr},
index 6929aa7..01821c2 100644 (file)
 #include "ConfigModel.h"
 #include "traing/include/TraingModel.h"
 #include <ThemeStyleModel.h>
-namespace OHOS {
+#include "heart_blood/health_service/health_service.h"
+#include "battery_hal.h"
+
+namespace OHOS
+{
     ApplistPresenter::ApplistPresenter()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::ApplistPresenter()");
@@ -25,7 +29,8 @@ namespace OHOS {
 
     ApplistPresenter::~ApplistPresenter()
     {
-        if (keyActListenr != nullptr) {
+        if (keyActListenr != nullptr)
+        {
             delete keyActListenr;
             keyActListenr = nullptr;
         }
@@ -36,11 +41,15 @@ namespace OHOS {
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStart()");
         Presenter<ApplistView>::OnStart();
-        if (keyActListenr == nullptr) {
+        if (keyActListenr == nullptr)
+        {
             keyActListenr = new KeyInputListener();
-            if (keyActListenr != nullptr) {
+            if (keyActListenr != nullptr)
+            {
                 RootView::GetInstance()->SetOnKeyActListener(keyActListenr);
-            } else {
+            }
+            else
+            {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnStart: new KeyInputListener fail");
             }
         }
@@ -50,11 +59,13 @@ namespace OHOS {
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnResume()");
         Presenter<ApplistView>::OnResume();
-        if (view_ == nullptr) {
+        if (view_ == nullptr)
+        {
             return;
         }
         const AppItem *itemInfo = model->GetApplistItems();
-        for (uint8 i = 0; i < model->GetAppListNum(); i++) {
+        for (uint8 i = 0; i < model->GetAppListNum(); i++)
+        {
             view_->AddAppItemToList(itemInfo[i]);
         }
         view_->RefreshAppList();
@@ -72,25 +83,28 @@ namespace OHOS {
         Presenter<ApplistView>::OnStop();
     }
 
-    bool ApplistPresenter::OnRotate(UIView& view, const RotateEvent& event)
+    bool ApplistPresenter::OnRotate(UIView &view, const RotateEvent &event)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnRotate");
-        UICustomHexagonsList* hexagonsView = dynamic_cast<UICustomHexagonsList *>(&view);
-        if (hexagonsView == nullptr) {
+        UICustomHexagonsList *hexagonsView = dynamic_cast<UICustomHexagonsList *>(&view);
+        if (hexagonsView == nullptr)
+        {
             return false;
         }
-        
+
         int8_t index = hexagonsView->GetFocusedImgIndex();
         uint8_t focusIndex_ = 0;
-        if (index >= 0) {
+        if (index >= 0)
+        {
             focusIndex_ = static_cast<uint8_t>(index);
         }
-        
+
         HexagonsItemView *itemView = dynamic_cast<HexagonsItemView *>(hexagonsView->GetViewByIndex(focusIndex_));
         AppViewId viewId = itemView->GetViewId();
-        if (FloatMore(hexagonsView->GetGlobalScale(), 2.0f)) { // 2.0 threshold for beginning transition
+        if (FloatMore(hexagonsView->GetGlobalScale(), 2.0f))
+        { // 2.0 threshold for beginning transition
             hexagonsView->StopRotateAnimator();
-            //NativeAbility::GetInstance().ChangeSlice(viewId, TransitionType::TRANSITION_HEXAGONS);
+            // NativeAbility::GetInstance().ChangeSlice(viewId, TransitionType::TRANSITION_HEXAGONS);
             NativeAbility::GetInstance().EnterSlice(viewId, TransitionType::TRANSITION_HEXAGONS);
             hexagonsView->ClearFocus();
         }
@@ -101,17 +115,21 @@ namespace OHOS {
     {
         UNUSED(event);
         AppViewId viewId = VIEW_INVALID;
-        char *uid =  nullptr;
+        char *uid = nullptr;
         TransitionType type = TransitionType::TRANSITION_INVALID;
         AppListStyle style = GetCurrentStyle();
-        if (style == AppListStyle::FOOTBALL_STYLE) {
+        if (style == AppListStyle::FOOTBALL_STYLE)
+        {
             FootballItemView *itemView = dynamic_cast<FootballItemView *>(&view);
             viewId = itemView->GetViewId();
             uid = (char *)itemView->GetAppUid();
-        } else if (style == AppListStyle::HEXAGONS_STYLE) {
+        }
+        else if (style == AppListStyle::HEXAGONS_STYLE)
+        {
             HexagonsItemView *itemView = dynamic_cast<HexagonsItemView *>(&view);
-            UIHexagonsList* hexagonsView = dynamic_cast<UIHexagonsList *>(itemView->GetParent());
-            if (hexagonsView == nullptr || itemView == nullptr) {
+            UIHexagonsList *hexagonsView = dynamic_cast<UIHexagonsList *>(itemView->GetParent());
+            if (hexagonsView == nullptr || itemView == nullptr)
+            {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hexagonsView or itemView is nullptr");
                 return false;
             }
@@ -120,32 +138,45 @@ namespace OHOS {
             hexagonsView->SetDraggable(false);
             hexagonsView->Scale(1.0f, itemView->GetViewIndex()); // switch focus to click view
             type = TransitionType::TRANSITION_HEXAGONS;
-        } 
-        else if(AppListStyle::ARC_SCALE_LIST_STYLE == style)
+        }
+        else if (AppListStyle::ARC_SCALE_LIST_STYLE == style)
         {
-            ArcScaleListItemView * itemView = dynamic_cast<ArcScaleListItemView *>(&view);
-            if(nullptr == itemView)
+            ArcScaleListItemView *itemView = dynamic_cast<ArcScaleListItemView *>(&view);
+            if (nullptr == itemView)
             {
                 return false;
             }
             viewId = itemView->GetViewId();
             uid = (char *)itemView->GetAppUid();
         }
-        else {
+        else
+        {
             AppItemView *itemView = dynamic_cast<AppItemView *>(&view);
-            if (itemView == nullptr) {
+            if (itemView == nullptr)
+            {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "itemView is nullptr", viewId);
                 return false;
             }
             viewId = itemView->GetViewId();
             uid = (char *)itemView->GetAppUid();
         }
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d type = %d", viewId,type);
-        if (viewId < VIEW_MAX_INTER_APP) {
-            //NativeAbility::GetInstance().ChangeSlice(viewId, type);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick viewid = %d type = %d", viewId, type);
+        if (viewId < VIEW_MAX_INTER_APP)
+        {
+            /*心率Slice需要增加特殊配置*/
+            bool isCharging = get_charge_stat(); // 获取充电状态
+            if (isCharging && viewId == VIEW_HEART_CHART)
+            {
+                HealthState highHealthState;
+                highHealthState.checkType = CHARGE;
+                HealthService::GetInstance()->SetHealthCurrent(highHealthState);
+                viewId = VIEW_CHECK_INVALID;
+            }
             NativeAbility::GetInstance().EnterSlice(viewId, type);
             return true;
-        } else if (viewId == VIEW_EXTERN_APP) {
+        }
+        else if (viewId == VIEW_EXTERN_APP)
+        {
 #ifdef JS_ENABLE
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ApplistPresenter::OnClick bundleName = %s", uid);
             Want *want = new Want();
@@ -167,11 +198,13 @@ namespace OHOS {
     void ApplistPresenter::OnItemSelected(int16 index, UIView *view)
     {
         UNUSED(index);
-        if (view != nullptr) {
+        if (view != nullptr)
+        {
             itemViewSele = static_cast<AppItemView *>(view);
             itemViewSele->SelectedChange();
 
-            if (preItemViewSele != nullptr && preItemViewSele != itemViewSele) {
+            if (preItemViewSele != nullptr && preItemViewSele != itemViewSele)
+            {
                 preItemViewSele->Reset();
             }
             preItemViewSele = itemViewSele;
@@ -209,7 +242,7 @@ namespace OHOS {
         return model->GetCurrentStyle();
     }
 
-    ApplistView* ApplistPresenter::GetAppListView()
+    ApplistView *ApplistPresenter::GetAppListView()
     {
         return view_;
     }
index 105c0fe..25ff1c4 100644 (file)
@@ -12,8 +12,9 @@ extern "C" errcode_t uapi_get_timestamp_ms(uint32_t *tm);
 #include "ConfigModel.h"
 #include "AppViewIDs.h"
 #include "NativeAbility.h"
+#include "battery_hal.h"
 
-#define MAX_UNWARE_COUNT 30
+#define MAX_UNWARE_COUNT 20
 #define MAX_VALID_SPO2_COUNT 30
 #define MAX_DISVALID_SPO2_COUNT 100
 namespace OHOS
@@ -64,6 +65,13 @@ namespace OHOS
         }
         else if (state == BloodState::Start && startspo2 == false)
         {
+            /*充电状态下不进行检测*/
+            bool isCharging = get_charge_stat(); // 获取充电状态
+            if (isCharging)
+            {
+                WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "充电不能检测");
+                return;
+            }
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "startspo2 Start");
             uint16_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST;
             send_ppg_cmd_msg(md);
index ea61a6c..2597ad3 100644 (file)
@@ -1,3 +1,9 @@
+/***
+ * @Date: 2024-07-30 11:22:00
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-16 15:59:09
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/heart_blood/CheckAbnormalPresenter.cpp
+ */
 /*
  * Copyright (c) CompanyNameMagicTag 2021-2021. All rights reserved.
  * Description: bloodOxygen view
@@ -39,7 +45,8 @@
 #include "cywee_service.h"
 
 #include "MainModel.h"
-
+#include "heart_blood/health_service/health_service.h"
+#include "battery_hal.h"
 namespace OHOS
 {
 
@@ -79,7 +86,19 @@ namespace OHOS
         }
         if (strcmp(view.GetViewId(), CLICK_BLOOD_RE) == 0)
         {
-            NativeAbility::GetInstance().ChangeSlice(VIEW_BLOOD_CHECK, TransitionType::TRANSITION_ZOOM);
+            // 检测过程中充电 失败可以弹窗
+            bool isCharging = get_charge_stat(); // 获取充电状态
+            if (isCharging)
+            {
+                HealthState highHealthState;
+                highHealthState.checkType = CHARGE;
+                HealthService::GetInstance()->SetHealthCurrent(highHealthState);
+                NativeAbility::GetInstance().ChangeSlice(VIEW_CHECK_INVALID, TransitionType::TRANSITION_ZOOM);
+                return true;
+            }
+            // 回到上一个检测界面
+            uint16 preSlice = NativeAbility::GetInstance().GetPreSliceId();
+            NativeAbility::GetInstance().ChangeSlice(preSlice, TransitionType::TRANSITION_ZOOM);
         }
         return true;
     }