-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1","enabled":true,"outputFile":"IcL02WorkService_V59_202105281829_release.apk","fullName":"IcL02WorkServiceRelease","baseName":"IcL02WorkService-release"},"path":"IcL02WorkService_V59_202105281829_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1","enabled":true,"outputFile":"IcL02WorkService_V59_202105291708_release.apk","fullName":"IcL02WorkServiceRelease","baseName":"IcL02WorkService-release"},"path":"IcL02WorkService_V59_202105291708_release.apk","properties":{}}]
\ No newline at end of file
checkCount = 0;
noWearCount = 0;
invalidateTime = 0;
- //TODO:这个是走官方API的,也得有机器再进行修改代码
- //sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_START_CHECK);
- // EventBus.getDefault().post(new BloodSensorEvent(1));
+ //加一个超时处理,如果超过30秒没有数据返回
+ //那么就会干掉当前的任务,并且取消监听,重置数据
+ //如果有数据回来,那么就重新设置下一次超时
+ ppgLooper.postDelayed(mTask, TIME_OUT_VALUE);
} else {
//这个走JNI获取数据的,完成了
checkBloodOther();
}
}
+ //10秒还没有数据回来,那么就结束测试
+ public static final int TIME_OUT_VALUE = 10 * 1000;
+
+ private final Runnable mTask = new Runnable() {
+ @Override
+ public void run() {
+ //超时了
+ //取消监听监听注册
+ mSensorManager.unregisterListener(BloodInfoHelper.this);
+ //结束任务
+ if (mListener != null) {
+ mListener.onHeartRateResult(ndkHigh, ndkLow, ndkHeart, oxygen);
+ mListener.onHeartRateTestFinished();
+ }
+ }
+ };
+
private Sensor mHeartRate = null;
private int ndkHeart = 0;
private int ndkHigh = 0;
doPPGtest();
/*[0]---心率;[1]---血压高压;[2]---血压低压;[3]---血氧;[4]---佩戴检测(1--脱手,2--上手);*/
if (checkCount > 10 || invalidateTime > 30) {
+ //结束了,干掉超时任务
+ ppgLooper.removeCallbacks(mTask);
handleResult();
+ } else {
+ ppgLooper.removeCallbacks(mTask);
+ ppgLooper.postDelayed(mTask, TIME_OUT_VALUE);
}
} else {
Log.d(TAG, "on sensor change == > PPG= " + values[0]);
--- /dev/null
+package com.ic.work.utils;
+
+import android.content.Context;
+
+public class SizeUtils {
+ public static int dip2px(Context context, float dpValue) {
+ float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (dpValue * scale + 0.5f);
+ }
+
+
+ //根据手机分辨率从px转成为dip
+ public static int px2dip(Context context, float pxValue) {
+ //获取当前手机的像素密度
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (pxValue / scale + 0.5f); //四舍五入取整
+ }
+}
\ No newline at end of file