Merge #1867 into sdk602patch0911 from refs/changes/1867/head 1869/target/1
authoraliyun3243248791 <accounts_67aaf52ad497cd558d73ac32@mail.teambition.com>
Thu, 19 Jun 2025 06:45:27 +0000 (06:45 +0000)
committer袁清梦 <3449750381@qq.com>
Thu, 19 Jun 2025 06:45:27 +0000 (06:45 +0000)
Code review from aliyun3243248791

* refs/changes/1867/head: (3 commits squashed)

  - 修复界面切换bug

  - 修复内存泄漏

  - 增加血压设置区间

Signed-off-by: 薛文强 <accounts_67aaf52ad497cd558d73ac32@mail.teambition.com>
Reviewed-by: Caisking <3449750381@qq.com>
Reviewed-by: 罗正 <1732036298@qq.com>
Reviewed-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Reviewed-by: aliyun6865282430 <1624952103@qq.com>
Merged-by: Caisking <3449750381@qq.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1867
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/include/BPMainPresenter.h
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPMainView.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPModel.cpp
code/sdk/application/wearable/fd230app/nativeui/bloodpressure/src/BPValueView.cpp
code/sdk/application/wearable/fd230app/nativeui/settings/src/SettingModel.cpp

index ac164ff..da1a32f 100644 (file)
@@ -25,7 +25,7 @@ namespace OHOS
         BPMainPresenter();
         virtual ~BPMainPresenter();
         static BPMainPresenter *GetInstance(void);
-        void ReSetPassflag();
+        void SetPassflag(int value);
 
         void OnStart() override;
         void OnPause() override;
index 571c575..3b50d46 100644 (file)
@@ -73,9 +73,9 @@ namespace OHOS
     {
         return g_pBPMainPresenter;
     }
-    void BPMainPresenter::ReSetPassflag()
+    void BPMainPresenter::SetPassflag(int value)
     {
-        passflag = 0;
+        passflag = value;
     }
     void BPMainPresenter::OnStart()
     {
@@ -166,7 +166,8 @@ namespace OHOS
             else
             {
                 // 退出
-                // passflag = 0;
+                NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+                passflag = 0;
             }
         }
         else if (strcmp(view.GetViewId(), "SBPLeft") == 0)
@@ -209,6 +210,7 @@ namespace OHOS
         {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CALIBRATIONLATTERBUTTON");
             // 退出
+            NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
         }
         return true;
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BPPresenter::OnClick");
index e16dca5..09a3c21 100644 (file)
@@ -111,12 +111,15 @@ namespace OHOS
 
         if (BPModel::GetInstance()->GetCalibrationFlag() == 0)
         {
-            ChangeView(MAX_BPVIEW, BPCALPOSREQVIEW);// 切换到第一个界面
-            BPMainPresenter::GetInstance()->ReSetPassflag();//重置校准成功按钮标志位
-        } 
+            ChangeView(MAX_BPVIEW, BPCALPOSREQVIEW);         // 切换到第一个界面
+            BPMainPresenter::GetInstance()->SetPassflag(0); // 重置校准成功按钮标志位
+        }
 
         else
+        {
             ChangeView(MAX_BPVIEW, BPLASTCALIBRATIONTIME);
+            BPMainPresenter::GetInstance()->SetPassflag(1); // 校准成功按钮标志位
+        }
 
         // 增加按键监听
         RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::BPMainPresenter::GetInstance();
index 94d45d4..36e4378 100644 (file)
@@ -45,7 +45,7 @@ namespace OHOS
 #define MAX_UNWARE_COUNT 10
 #define MAX_VALID_SPO2_COUNT 30
 #define MAX_DISVALID_SPO2_COUNT 100
-static uint16 CalibrationFlag = 0;
+  static uint16 CalibrationFlag = 0;
 
   // 声明定时器变量
   static osTimerId_t g_timer = nullptr;
@@ -58,9 +58,9 @@ static uint16 CalibrationFlag = 0;
     static BPModel instance;
     return &instance;
   }
-   int16_t BPModel::GetCalibrationFlag()
+  int16_t BPModel::GetCalibrationFlag()
   {
-    
+
     return CalibrationFlag;
   }
 
@@ -163,16 +163,18 @@ static uint16 CalibrationFlag = 0;
     if (set_value)
     {
       if (type == BP_VALUE_TYPE::SBP)
-        custom_sbp++;
-      else
-        custom_dbp++;
+        if (custom_sbp < 250)
+          custom_sbp++;
+        else if (custom_dbp < 150)
+          custom_dbp++;
     }
     else
     {
       if (type == BP_VALUE_TYPE::SBP)
-        custom_sbp--;
-      else
-        custom_dbp--;
+        if (custom_sbp > 50)
+          custom_sbp--;
+        else if (custom_dbp > 30)
+          custom_dbp--;
     }
   }
   int16_t BPModel::GetValue(BP_VALUE_TYPE type)
@@ -187,7 +189,6 @@ static uint16 CalibrationFlag = 0;
   /*定时器到期时的处理*/
   static void BP_TimerCallbackProc(int data)
   {
-    
 
     // 倒计时
     Time--;
@@ -201,7 +202,7 @@ static uint16 CalibrationFlag = 0;
         BPMainView::GetInstance()->ChangeView(BPUNDERCALIBRATIONVIEW, BPCALIBRATIONMINDVIEW);
         CalibrationFlag++;
       }
-      else if (BPMainView::GetInstance() && ( CalibrationFlag == 1 || CalibrationFlag == 3)) // 分析完
+      else if (BPMainView::GetInstance() && (CalibrationFlag == 1 || CalibrationFlag == 3)) // 分析完
       {
         // 校准成功
         BPMainView::GetInstance()->ChangeView(BPRESULTANALYSISVIEW, BPCALIBRATIONPASSVIEW);
index 2bb2fe5..4cb5ea0 100644 (file)
@@ -17,8 +17,6 @@ namespace OHOS
     static const char *BPBACKPATH = "/user/res/BPCalibration/W.bin";
     static const char *LEFTPATH = "/user/res/BPCalibration/decrease_button.bin";
     static const char *RIGHTPATH = "/user/res/BPCalibration/increase_button.bin";
-    
-    
 
     BPValueView::BPValueView()
     {
@@ -37,8 +35,12 @@ namespace OHOS
     }
     void BPValueView::DeInit()
     {
-        if(group)
+        if (group)
         {
+            group->RemoveAll();
+            delete group;
+            group = nullptr;
+        }
         if (background != nullptr)
         {
             delete background;
@@ -64,22 +66,22 @@ namespace OHOS
             delete valuecheckButton;
             valuecheckButton = nullptr;
         }
-         if (SBPLeft != nullptr)
+        if (SBPLeft != nullptr)
         {
             delete SBPLeft;
             SBPLeft = nullptr;
         }
-         if (SBPRight != nullptr)
+        if (SBPRight != nullptr)
         {
             delete SBPRight;
             SBPRight = nullptr;
         }
-         if (DBPLeft != nullptr)
+        if (DBPLeft != nullptr)
         {
             delete DBPLeft;
             DBPLeft = nullptr;
         }
-         if (DBPRight != nullptr)
+        if (DBPRight != nullptr)
         {
             delete DBPRight;
             DBPRight = nullptr;
@@ -94,10 +96,6 @@ namespace OHOS
             delete DBPValue;
             DBPValue = nullptr;
         }
-            group->RemoveAll();
-            delete group;
-            group = nullptr;
-        }
     }
 
     /***
@@ -123,7 +121,7 @@ namespace OHOS
      */
     bool BPValueView::InitLable()
     {
-        
+
         InitLabel(titleLabel, 109, 38, 239, 35, "title", "请输入血压计量", DEFAULT_VECTOR_FONT_FILENAME, 30);
         InitLabel(SBPLabel, 63, 170, 100, 29, "SBP", "收缩压", DEFAULT_VECTOR_FONT_FILENAME, 30);
         InitLabel(DBPLabel, 63, 270, 100, 29, "DBP", "舒张压", DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -133,7 +131,6 @@ namespace OHOS
         SBPValue->SetTextColor(Color::Red());
         DBPValue->SetTextColor(Color::Red());
 
-
         /*初始化检测时间*/
         group->Add(titleLabel);
         group->Add(SBPLabel);
@@ -147,7 +144,7 @@ namespace OHOS
 
     void BPValueView::UpDateVauleText(BP_VALUE_TYPE type)
     {
-        if(SBPValue == nullptr || DBPValue == nullptr)
+        if (SBPValue == nullptr || DBPValue == nullptr)
         {
             return;
         }
@@ -172,37 +169,36 @@ namespace OHOS
     bool BPValueView::Initbackground()
     {
         background = new UIImageView();
-        background->SetPosition(0, 62, 466,342);
+        background->SetPosition(0, 62, 466, 342);
         background->SetSrc(BPBACKPATH);
 
         SBPLeft = new UIImageView();
         SBPLeft->SetPosition(199, 160, 31, 35);
-        SBPLeft->SetSrc(LEFTPATH);        
-        SBPLeft->SetViewId("SBPLeft");   
+        SBPLeft->SetSrc(LEFTPATH);
+        SBPLeft->SetViewId("SBPLeft");
         SBPLeft->SetTouchable(true);
         UIView::OnClickListener *clickListener_SBPLeft = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance();
-        SBPLeft->SetOnClickListener(clickListener_SBPLeft);   
-
+        SBPLeft->SetOnClickListener(clickListener_SBPLeft);
 
         SBPRight = new UIImageView();
         SBPRight->SetPosition(385, 160, 31, 35);
-        SBPRight->SetSrc(RIGHTPATH);        
-        SBPRight->SetViewId("SBPRight");   
+        SBPRight->SetSrc(RIGHTPATH);
+        SBPRight->SetViewId("SBPRight");
         SBPRight->SetTouchable(true);
         UIView::OnClickListener *clickListener_SBPRight = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance();
-        SBPRight->SetOnClickListener(clickListener_SBPRight);             
+        SBPRight->SetOnClickListener(clickListener_SBPRight);
 
         DBPLeft = new UIImageView();
-        DBPLeft->SetPosition(199, 278, 31, 35);   
-        DBPLeft->SetSrc(LEFTPATH);         
-        DBPLeft->SetViewId("DBPLeft");      
+        DBPLeft->SetPosition(199, 278, 31, 35);
+        DBPLeft->SetSrc(LEFTPATH);
+        DBPLeft->SetViewId("DBPLeft");
         DBPLeft->SetTouchable(true);
         UIView::OnClickListener *clickListener_DBPLeft = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance();
         DBPLeft->SetOnClickListener(clickListener_DBPLeft);
 
         DBPRight = new UIImageView();
-        DBPRight->SetPosition(385, 278, 31, 35); 
-        DBPRight->SetSrc(RIGHTPATH);    
+        DBPRight->SetPosition(385, 278, 31, 35);
+        DBPRight->SetSrc(RIGHTPATH);
         DBPRight->SetViewId("DBPRight");
         DBPRight->SetTouchable(true);
         UIView::OnClickListener *clickListener_DBPRight = (UIView::OnClickListener *)OHOS::BPMainPresenter::GetInstance();
@@ -232,20 +228,20 @@ namespace OHOS
         if (!Initbackground())
         {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Initbackground error!");
-              return nullptr;
+            return nullptr;
         };
         if (!InitLable())
         {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "InitLable error!");
-              return nullptr;
+            return nullptr;
         };
         if (!AddButton())
         {
             WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AddButton error!");
-              return nullptr;
+            return nullptr;
         };
-        
+
         return group;
     }
-    
+
 }
index 98467b2..5d7bff0 100644 (file)
@@ -35,7 +35,7 @@ namespace OHOS
     {
         int index = 0;
         settings[index++] = {VIEW_SETTING, nullptr, STR_SETTINGS, false};//标题:设置
-        #if defined(BOARD_W9) || defined(BOARD_N9) || 1
+        #if defined(BOARD_W9) || defined(BOARD_N9)
         settings[index++] = {VIEW_BLOOD_PRESSURE_CALIBRATION, PNG_APPLIST_BP_IMAGE, STR_BP_CALIBRATE, true};//血压检测
         #endif
         settings[index++] = {VIEW_DISPLAY_BRIGHTNESS, PNG_SETTINGS_DISPLAY_BRIGHTNESS, STR_SCREEN_AND_BRIGHTNESS, true};