272:解决压力界面按键无法退出问题 2582/1
authorluozheng <1732036298@qq.com>
Tue, 21 Oct 2025 12:22:35 +0000 (20:22 +0800)
committerluozheng <1732036298@qq.com>
Tue, 21 Oct 2025 12:22:35 +0000 (20:22 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestModel.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/include/stressTestPresenter.h
code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestFailView.cpp
code/sdk/application/wearable/fd272/nativeapp/nativeui/stress/src/stressTestPresenter.cpp

index 98ee175..29b7ece 100644 (file)
@@ -6,8 +6,8 @@ namespace OHOS
 {
     enum FailType :uint8_t
     {
-        FAIL_TYPE_NOT_WORN = 0,//未佩戴
-        FAIL_TYPE_INVALID_DATA,//数据无效
+        FAIL_TYPE_INVALID_DATA = 0,//数据无效
+        FAIL_TYPE_NOT_WORN ,//未佩戴
         FAIL_TYPE_OTHER,//其他错误
     };
 
@@ -26,7 +26,7 @@ namespace OHOS
         StressTestModel(const StressTestModel &) = delete;
         StressTestModel &operator=(const StressTestModel &) = delete;
         uint8_t currentView{0};
-        uint8_t currentFailType{FAIL_TYPE_NOT_WORN};//当前错误类型
+        uint8_t currentFailType{FAIL_TYPE_INVALID_DATA};//当前错误类型
     };
 }
 
index 6a364da..fa01757 100644 (file)
@@ -20,6 +20,7 @@ namespace OHOS
         static StressTestPresenter *GetInstance();
 
         void OnStart() override;
+        void OnResume() override;
 
         uint8_t GetCurrentFailType(void);
 
index 4ba5779..6130887 100644 (file)
@@ -211,7 +211,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "error1DescriptionLabel new fail!!");
                 return nullptr;
             }
-            error1DescriptionLabel->SetPosition(53, 230, 360, 70);
+            error1DescriptionLabel->SetPosition(53, 210, 360, 70);
             error1DescriptionLabel->SetText("请确认已带上手表,并保持静止");
             error1DescriptionLabel->SetStyle(STYLE_TEXT_FONT, 30);
             error1DescriptionLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
@@ -229,7 +229,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "retryButton new fail!!");
                 return nullptr;
             }
-            retryButton->SetPosition(238, 328,170,90);
+            retryButton->SetPosition(238, 300,170,90);
             retryButton->SetText("重测");
             retryButton->SetAlign(TEXT_ALIGNMENT_CENTER);
             retryButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
@@ -249,7 +249,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "stopButton new fail!!");
                 return nullptr;
             }
-            stopButton->SetPosition(58, 328,170,90);
+            stopButton->SetPosition(58, 300,170,90);
             stopButton->SetText("停止");
             stopButton->SetAlign(TEXT_ALIGNMENT_CENTER);
             stopButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
index d2a6609..6325d2c 100644 (file)
@@ -41,6 +41,11 @@ namespace OHOS
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StressTestPresenter::OnStart");
     }
 
+    void StressTestPresenter::OnResume()
+    {
+        RootView::GetInstance()->SetOnKeyActListener(this);
+    }
+
 
     bool StressTestPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
@@ -109,7 +114,7 @@ namespace OHOS
         uint16_t keyID = event.GetKeyId();
         uint16_t keyState = event.GetState();
         // 如果是power键,且是亮屏状态,按键释放就返回上一级
-        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
         {
             NativeAbility::GetInstance().Back();
         }