#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
#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;
g_pMainView = this;
}
- BloodOxygenPresenter::~BloodOxygenPresenter()
- {
- g_pMainView = nullptr;
- }
-
BloodOxygenPresenter::~BloodOxygenPresenter()
{
if (keyActListenr != nullptr)
}
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();
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BloodOxygenPresenter::OnStart: new KeyInputListener fail");
}
}
+#endif
}
void BloodOxygenPresenter::OnPause(void) {}
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");
// 增加按键事件
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);
// uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
}
+#endif
return true;
}
void BloodOxygenPresenter::ProgressNotify(void)
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); // 复原
}
}
}