#include "cywee_service.h"
#include "custom_utils.h"
-#define HEARTKEYABLE 0
+#define HEARTKEYABLE 1
namespace OHOS
{
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp");
return 0;
}
-
+
return time;
}
// 秒级时间戳的差
int time_diff_seconds = new_time - old_time;
// 转换为分钟的差值
- int time_diff_minutes = time_diff_seconds / 60;
+ int time_diff_minutes = time_diff_seconds / 60;
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "time_diff_seconds is %d time_diff_minute is %d", time_diff_seconds, time_diff_minutes);
return time_diff_minutes;
}
HeartPresenter::~HeartPresenter()
{
-#if HEARTKEYABLE
- if (keyActListenr != nullptr)
- {
- delete keyActListenr;
- keyActListenr = nullptr;
- }
-#endif
g_pMainView = nullptr;
}
{
Presenter<HeartView>::OnStart();
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HeartPresenter::On Start ");
-#if HEARTKEYABLE
- if (keyActListenr == nullptr)
- {
- keyActListenr = new KeyInputListener();
- if (keyActListenr != nullptr)
- {
- RootView::GetInstance()->SetOnKeyActListener(keyActListenr);
- }
- else
- {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HeartPresenter::OnStart: new KeyInputListener fail");
- }
- }
-#endif
}
void HeartPresenter::OnPause(void) {}
bool HeartPresenter::OnKeyAct(UIView &view, const KeyEvent &event)
{
#if HEARTKEYABLE
- WEARABLE_LOGD("", "into the view is: %s\n", typeid(view).name());
- uint16 keyID = event.GetKeyId();
- WEARABLE_LOGD("", "into key! keyID %u\n", keyID);
- // 如果是power键就返回上一级
- if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER))
+ unsigned short keyID = event.GetKeyId();
+ unsigned short keyState = event.GetState();
+ // 如果是power键,且是亮屏状态,按键释放就返回上一级
+ if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 0 && uapi_get_screen_state() == 0)
{
- // uint16_t preSlice = NativeAbility::GetInstance().GetPreSliceId();
- NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+ // 关闭心率检测
+ HeartModel::GetInstance()->Heart_Control(HeartState::End);
+ // 回退
+ NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST, TransitionType::TRANSITION_ZOOM);
}
+ return true;
#endif
return true;
}
if (startheart == false)
{
HeartCheckView::GetInstance()->GetImageAnimator()->Stop();
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : false");
- uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST;
- send_ppg_cmd_msg(md);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus false");
+ // 关闭心率检测
+ HeartModel::GetInstance()->Heart_Control(HeartState::End);
startheart = true;
}
}
HeartCheckView::GetInstance()->UpShowHeartText(); // 更新检测界面
if (startheart == true)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true");
- uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST;
- send_ppg_cmd_msg(md);
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus true");
+ // 开启心率检测
+ HeartModel::GetInstance()->Heart_Control(HeartState::Start);
startheart = false;
}
}
{
if (HeartModel::GetInstance()->GetHeartCheckViewStatus() == true)
{
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetWearStatus : false");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetWearStatus false");
HeartCheckView::GetInstance()->GetImageAnimator()->Stop();
// 跳转到异常检测界面
HeartView::GetInstance()->ChangeView(HEARTCHECKVIEW, HEARTRESULT);