From: snickersun Date: Mon, 29 Mar 2021 09:31:04 +0000 (+0800) Subject: release V58 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=a507611c342869780ac2845906da098b5cd1a638;p=icworkservice.git release V58 添加SensorManager的标准检测方法。 --- diff --git a/app/IcL02WorkService/release/IcL02WorkService_V58_202103291730_release.apk b/app/IcL02WorkService/release/IcL02WorkService_V58_202103291730_release.apk new file mode 100644 index 0000000..0f1643f Binary files /dev/null and b/app/IcL02WorkService/release/IcL02WorkService_V58_202103291730_release.apk differ diff --git a/app/IcL02WorkService/release/output.json b/app/IcL02WorkService/release/output.json index a195a26..1773cb6 100644 --- a/app/IcL02WorkService/release/output.json +++ b/app/IcL02WorkService/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.1","enabled":true,"outputFile":"IcL02WorkService_V57_202102011623_release.apk","fullName":"IcL02WorkServiceRelease","baseName":"IcL02WorkService-release"},"path":"IcL02WorkService_V57_202102011623_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_V58_202103291730_release.apk","fullName":"IcL02WorkServiceRelease","baseName":"IcL02WorkService-release"},"path":"IcL02WorkService_V58_202103291730_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/ic/work/hardware/BloodInfoHelper.java b/app/src/main/java/com/ic/work/hardware/BloodInfoHelper.java index 112b2ba..1320910 100644 --- a/app/src/main/java/com/ic/work/hardware/BloodInfoHelper.java +++ b/app/src/main/java/com/ic/work/hardware/BloodInfoHelper.java @@ -69,9 +69,17 @@ public class BloodInfoHelper implements SensorEventListener { ICLogger.d("deviceState[1]..." + deviceState[1]); if (deviceState[1]) { mSensorManager = (SensorManager) WorkServiceApp.sContext.getSystemService(SENSOR_SERVICE); - Sensor mHeartRate = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE); + mHeartRate = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE); boolean ret = mSensorManager.registerListener(this, mHeartRate, SensorManager.SENSOR_DELAY_FASTEST); Log.d(TAG, "ret == > " + ret); + isWear=false; + ndkHeart = 0; + ndkHigh = 0; + ndkLow = 0; + oxygen = 0; + checkCount = 0; + noWearCount = 0; + invalidateTime = 0; //TODO:这个是走官方API的,也得有机器再进行修改代码 //sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_START_CHECK); // EventBus.getDefault().post(new BloodSensorEvent(1)); @@ -80,7 +88,7 @@ public class BloodInfoHelper implements SensorEventListener { checkBloodOther(); } } - + private Sensor mHeartRate = null; private int ndkHeart = 0; private int ndkHigh = 0; private int ndkLow = 0; @@ -140,7 +148,21 @@ public class BloodInfoHelper implements SensorEventListener { } }); } - + private void doPPGtest(){ + if (ndkHeart > 0) { + if (oxygen <= 0) oxygen = randomOxygenValue(); + if (mListener != null) { + IcLog.d(TAG, "ndkHigh == > " + ndkHigh + "ndkLow == > " + ndkLow + "oxygen == > " + oxygen); + mListener.onHeartRateUpdate(ndkHigh, ndkLow, ndkHeart, oxygen); + } + checkCount++; + IcLog.d(TAG, "checkCount == > " + checkCount); + } else { + //如果为0的话,记录下来 + invalidateTime++; + IcLog.d(TAG, "invalidateTime == > " + invalidateTime); + } + } //- 数据测试结果为0,如果连续20个数据为0,那么就结束此次测试 //- 有数据以后,连续测上10次,就可以返回结果了 private void doTest() { @@ -150,45 +172,29 @@ public class BloodInfoHelper implements SensorEventListener { //这部分代码要做超时处理{ long getPPGStartTime = System.currentTimeMillis(); ndkHeart = HardwareUtils.getNdkPPGValue(); - if (ndkHeart > 0) { - ndkHigh = HardwareUtils.getNdkHighBloodValue(); - ndkLow = HardwareUtils.getNdkLowBloodValue(); - oxygen = HardwareUtils.getNdkOxygenValue(); - if (oxygen <= 0) oxygen = randomOxygenValue(); - if (mListener != null) { - IcLog.d(TAG, "ndkHigh == > " + ndkHigh + "ndkLow == > " + ndkLow + "oxygen == > " + oxygen); - mListener.onHeartRateUpdate(ndkHigh, ndkLow, ndkHeart, oxygen); - } - checkCount++; - IcLog.d(TAG, "checkCount == > " + checkCount); - if (checkCount <= 10) { - //继续测试 - ppgLooper.postDelayed(this, 1000); - } else { - handleResult(); - } - IcLog.d(TAG, "use time == > " + (System.currentTimeMillis() - getPPGStartTime)); + ndkHigh = HardwareUtils.getNdkHighBloodValue(); + ndkLow = HardwareUtils.getNdkLowBloodValue(); + oxygen = HardwareUtils.getNdkOxygenValue(); + doPPGtest(); + if ( checkCount > 10 || invalidateTime > 30) { + handleResultOtherBlood(); } else { - //如果为0的话,记录下来 - invalidateTime++; - IcLog.d(TAG, "invalidateTime == > " + invalidateTime); - if (invalidateTime <= 30) { - ppgLooper.postDelayed(this, 1000); - } else { - handleResult(); - } + //继续测试 + ppgLooper.postDelayed(this, 1000); } + IcLog.d(TAG, "use time == > " + (System.currentTimeMillis() - getPPGStartTime)); } }); } - private void handleResult() { + private void handleResultOtherBlood() { if (mListener != null) { mListener.onHeartRateResult(ndkHigh, ndkLow, ndkHeart, oxygen); } if (mListener != null) { mListener.onHeartRateTestFinished(); } + try { IcLog.d(TAG, "disable ppg.."); HardwareUtils.onNdkDisablePPG(); @@ -197,6 +203,23 @@ public class BloodInfoHelper implements SensorEventListener { } IcLog.d(TAG, "total use time == checkBloodStartTime > " + (System.currentTimeMillis() - checkBloodStartTime)); } + private void handleResult() { + if (mListener != null) { + mListener.onHeartRateResult(ndkHigh, ndkLow, ndkHeart, oxygen); + } + if (mListener != null) { + mListener.onHeartRateTestFinished(); + } + + try { + IcLog.d(TAG, "disable ppg.."); + if(mHeartRate!=null) + mSensorManager.unregisterListener(this,mHeartRate); + } catch (Exception e) { + IcLog.e(TAG, "Stop Get Heart Value", e); + } + IcLog.d(TAG, "total use time == checkBloodStartTime > " + (System.currentTimeMillis() - checkBloodStartTime)); + } private int randomOxygenValue() { @@ -224,6 +247,18 @@ public class BloodInfoHelper implements SensorEventListener { + "spo2= " + values[3] + "Weared= " + values[4] ); + + ndkHeart = (int)values[0];//调用底层函数保证状态更新。 + ndkHigh = (int)values[1]; + ndkLow = (int)values[2]; + oxygen = (int)values[3]; + isWear = ((int)values[4] == 2); + // isPPGTesting = true;// (ICJniUtils.isPPGStarted() == 1); + doPPGtest(); + /*[0]---心率;[1]---血压高压;[2]---血压低压;[3]---血氧;[4]---佩戴检测(1--脱手,2--上手);*/ + if ( checkCount > 10 || invalidateTime > 30) { + handleResult(); + } } else { Log.d(TAG, "on sensor change == > PPG= " + values[0]); } diff --git a/app/version_code.properties b/app/version_code.properties index c34b001..055f6a2 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ #Thu Jul 16 16:46:05 CST 2020 -VERSION_CODE=57 +VERSION_CODE=58