1.取消测试时候的按键事件;2.保持血氧测试常亮
authorCaisking <3449750381@qq.com>
Wed, 28 Feb 2024 12:18:27 +0000 (20:18 +0800)
committerCaisking <3449750381@qq.com>
Wed, 28 Feb 2024 12:18:27 +0000 (20:18 +0800)
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/include/BloodOxygenPresenter.h
code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp

index 0164c1a..ecdfc36 100644 (file)
 #include "ohos_types.h"
 #include "KeyInputListener.h"
 #include "common/key_code.h"
+#include "power_display_service.h"
+namespace OHOS
+{
+    class BloodOxygenView;
+    class BloodOxygenPresenter : public Presenter<BloodOxygenView>,
+                                 public UIView::OnClickListener,
+                                 public RootView::OnKeyActListener,
+                                 public ModelListenerSample,
+                                 public UIView::OnDragListener
+    {
+    public:
+        BloodOxygenPresenter();
+        virtual ~BloodOxygenPresenter();
 
-namespace OHOS {
-class BloodOxygenView;
-class BloodOxygenPresenter : public Presenter<BloodOxygenView>,
-                            public UIView::OnClickListener,
-                            public RootView::OnKeyActListener,
-                            public ModelListenerSample,
-                            public UIView::OnDragListener {
-public:
-    BloodOxygenPresenter();
-    virtual ~BloodOxygenPresenter();
+        void OnStart() override;
+        void OnPause() override;
+        void OnResume() override;
+        void OnStop() override;
+        virtual void Notify() override;
+        static BloodOxygenPresenter *GetInstance(void);
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
 
-    void OnStart() override;
-    void OnPause() override;
-    void OnResume() override;
-    void OnStop() override;
-    virtual void Notify() override;
-    static BloodOxygenPresenter *GetInstance(void);
-    bool OnDrag(UIView& view, const DragEvent& event) override;
-    bool OnClick(UIView& view, const ClickEvent& event) override;
-    bool OnKeyAct(UIView& view, const KeyEvent& event) override;//增加按键事件
-
-private:
-    bool CheckPointersValue(void);
-    void ReturnInterface(void);
-    void ProgressNotify(void);
-    int count;
-    KeyInputListener *keyActListenr{nullptr};
-};
+    private:
+        bool CheckPointersValue(void);
+        void ReturnInterface(void);
+        void ProgressNotify(void);
+        int count;
+        KeyInputListener *keyActListenr{nullptr};
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        int display_time;
+    };
 }
 
 #endif
index 89007d2..787c6fe 100644 (file)
@@ -27,7 +27,8 @@
 #include <chrono>
 #include <thread>
 #include "ppg_service.h"
-
+#include "displaybrightness/include/DisplayBrightnessModel.h"
+#include "power_display_service.h"
 namespace OHOS
 {
     static BloodOxygenPresenter *g_pMainView = nullptr;
@@ -41,11 +42,6 @@ namespace OHOS
         g_pMainView = this;
     }
 
-    BloodOxygenPresenter::~BloodOxygenPresenter()
-    {
-        g_pMainView = nullptr;
-    }
-
     BloodOxygenPresenter::~BloodOxygenPresenter()
     {
         if (keyActListenr != nullptr)
@@ -55,12 +51,16 @@ namespace OHOS
         }
         g_pMainView = nullptr;
     }
+    BloodOxygenPresenter *BloodOxygenPresenter::GetInstance()
+    {
+        return g_pMainView;
+    }
 
     void BloodOxygenPresenter::OnStart()
     {
         Presenter<BloodOxygenView>::OnStart();
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::On Start ");
-
+#if 0
         if (keyActListenr == nullptr)
         {
             keyActListenr = new KeyInputListener();
@@ -73,6 +73,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnStart: new KeyInputListener fail");
             }
         }
+#endif
     }
 
     void BloodOxygenPresenter::OnPause(void) {}
@@ -114,6 +115,8 @@ namespace OHOS
 
     bool BloodOxygenPresenter::OnClick(UIView &view, const ClickEvent &event)
     {
+        display_time = DisplayBrightnessModel::GetInstance()->GetScreenDurationTime();
+        display_api->set_screen_auto_off_timeout(30 * 1000);
         UNUSED(view);
         UNUSED(event);
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnClick");
@@ -143,6 +146,7 @@ namespace OHOS
     // 增加按键事件
     bool BloodOxygenPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
     {
+#if 0
         WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name());
         uint16 keyID = event.GetKeyId();
         WEARABLE_LOGD("", "into key! keyID %u\n", keyID);
@@ -152,6 +156,7 @@ namespace OHOS
             // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
             NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
         }
+#endif
         return true;
     }
     void BloodOxygenPresenter::ProgressNotify(void)
@@ -191,6 +196,7 @@ namespace OHOS
                 uint32_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST;
                 send_ppg_cmd_msg(md);
 #endif
+                display_api->set_screen_auto_off_timeout(display_time); // 复原
             }
         }
     }