From: snickersun Date: Mon, 7 Sep 2020 12:16:31 +0000 (+0800) Subject: release V54 icL02WorkService_v54_202009072006_release X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=8b5bb01e5944ba73acbbb1fe9f3509554fbd02c0;p=icworkservice.git release V54 icL02WorkService_v54_202009072006_release 1、去掉apk内会ICJniUtils.so 直接使用系统中的 2、更新Blood Aidl接口,增加中间数据传递以及血氧测量值传递。(无血氧的取随机值) 3、修改Blood测量逻辑,连续10次未佩戴,以及测量佩戴,且有心率后30秒结束测量。(实际上有个逻辑漏洞,如果sensor是有问题的,佩戴但是一直无法算出心率就可能一直在测量状态) 4、修改体温测量逻辑,测量出体温20秒后停止测量。 --- diff --git a/app/IcL02WorkService/release/IcL02WorkService_V54_202008251037_release.apk b/app/IcL02WorkService/release/IcL02WorkService_V54_202008251037_release.apk deleted file mode 100644 index 63fbbef..0000000 Binary files a/app/IcL02WorkService/release/IcL02WorkService_V54_202008251037_release.apk and /dev/null differ diff --git a/app/IcL02WorkService/release/IcL02WorkService_V54_202009072006_release.apk b/app/IcL02WorkService/release/IcL02WorkService_V54_202009072006_release.apk new file mode 100644 index 0000000..35a889b Binary files /dev/null and b/app/IcL02WorkService/release/IcL02WorkService_V54_202009072006_release.apk differ diff --git a/app/build.gradle b/app/build.gradle index 1ba7c0a..cac408f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -82,7 +82,7 @@ android { IcL02WorkService{ flavorDimensions "IcAkWorkService" versionCode 1 - versionName "1.0" + versionName "1.1" buildConfigField "int", "productType", "1003" } } diff --git a/app/src/main/aidl/com/ic/aidl/blood/IBloodAidlInterface.aidl b/app/src/main/aidl/com/ic/aidl/blood/IBloodAidlInterface.aidl index 0caf2ed..dae6d01 100644 --- a/app/src/main/aidl/com/ic/aidl/blood/IBloodAidlInterface.aidl +++ b/app/src/main/aidl/com/ic/aidl/blood/IBloodAidlInterface.aidl @@ -8,7 +8,10 @@ interface IBloodAidlInterface { * Demonstrates some basic types that you can use as parameters * and return values in AIDL. */ - void updateBloodCheckTemp(int high,int low,int heart); - void updateBloodCheckResult(int high,int low,int heart); + void updateBloodCheckTemp(int high,int low,int heart,int oxygen); + void updateBloodCheckResult(int high,int low,int heart,int oxygen); void updateBloodCheckTips(int top,int bottom); + + + } diff --git a/app/src/main/java/com/ic/work/WorkService.java b/app/src/main/java/com/ic/work/WorkService.java index fcdc064..04b8010 100644 --- a/app/src/main/java/com/ic/work/WorkService.java +++ b/app/src/main/java/com/ic/work/WorkService.java @@ -187,7 +187,7 @@ public class WorkService extends Service { public void onMessageEvent(BloodCheckTempEvent event) { if (bloodProcess != null) { bloodProcess.sendBloodCheckTemp(event.getHigh(), - event.getLow(), event.getHeart()); + event.getLow(), event.getHeart(),event.getOxygen()); } } @@ -195,7 +195,7 @@ public class WorkService extends Service { public void onMessageEvent(BloodCheckResultEvent event) { if (bloodProcess != null) { bloodProcess.sendBloodCheckResult(event.getHigh(), - event.getLow(), event.getHeart()); + event.getLow(), event.getHeart(),event.getOxygen()); } if (coreService != null) { diff --git a/app/src/main/java/com/ic/work/event/BloodCheckResultEvent.java b/app/src/main/java/com/ic/work/event/BloodCheckResultEvent.java index e4cee9e..ff39392 100644 --- a/app/src/main/java/com/ic/work/event/BloodCheckResultEvent.java +++ b/app/src/main/java/com/ic/work/event/BloodCheckResultEvent.java @@ -4,12 +4,14 @@ public class BloodCheckResultEvent { private int high; private int low; private int heart; + private int oxygen; - public BloodCheckResultEvent(int high, int low, int heart) { + public BloodCheckResultEvent(int high, int low, int heart,int oxygen) { this.high = high; this.low = low; this.heart = heart; + this.oxygen=oxygen; } public int getHigh() { @@ -24,4 +26,6 @@ public class BloodCheckResultEvent { return heart; } + public int getOxygen(){return oxygen;} + } diff --git a/app/src/main/java/com/ic/work/event/BloodCheckTempEvent.java b/app/src/main/java/com/ic/work/event/BloodCheckTempEvent.java index 42dee2c..7d540b8 100644 --- a/app/src/main/java/com/ic/work/event/BloodCheckTempEvent.java +++ b/app/src/main/java/com/ic/work/event/BloodCheckTempEvent.java @@ -4,12 +4,13 @@ public class BloodCheckTempEvent { private int high; private int low; private int heart; + private int oxygen; - - public BloodCheckTempEvent(int high, int low, int heart) { + public BloodCheckTempEvent(int high, int low, int heart,int oxygen) { this.high = high; this.low = low; this.heart = heart; + this.oxygen=oxygen; } public int getHigh() { @@ -23,4 +24,6 @@ public class BloodCheckTempEvent { public int getHeart() { return heart; } + + public int getOxygen(){ return oxygen;} } diff --git a/app/src/main/java/com/ic/work/hardware/BloodRunnable.java b/app/src/main/java/com/ic/work/hardware/BloodRunnable.java index afe11d3..b3ae344 100644 --- a/app/src/main/java/com/ic/work/hardware/BloodRunnable.java +++ b/app/src/main/java/com/ic/work/hardware/BloodRunnable.java @@ -1,8 +1,16 @@ package com.ic.work.hardware; +import android.content.Context; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; + +import com.ic.work.event.AkBloodCheckResultEvent; import com.ic.work.event.BloodCheckResultEvent; import com.ic.work.event.BloodCheckTempEvent; import com.ic.work.event.BloodCheckTipsEvent; +import com.ic.work.event.BloodSensorEvent; import com.ic.work.utils.HardwareUtils; import com.ic.work.utils.IcLog; @@ -10,6 +18,7 @@ import org.greenrobot.eventbus.EventBus; import java.util.Random; +import static android.content.Context.SENSOR_SERVICE; import static com.ic.aidl.blood.BloodState.BLOOD_ING_CHECK; import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DATA_CHECK; import static com.ic.aidl.blood.BloodState.BLOOD_NOT_DEVICE; @@ -25,17 +34,40 @@ public class BloodRunnable implements Runnable { @Override public void run() { - int ndkHeart = 0; - int ndkHigh = 0; - int ndkLow = 0; - int count = 0; - int checkCount = 0; - if (HardwareUtils.isPPGavailable()) { + + boolean[] deviceState = HardwareUtils.isPPGavailableIc66(); + + if (!deviceState[0]) { sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_DEVICE); return; } + if (deviceState[1]) { + sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_START_CHECK); + EventBus.getDefault().post(new BloodSensorEvent(1)); + } else { + checkBloodOther(); + } + } + + private void sendTipsEventBus(int top, int bottom) { + EventBus.getDefault().post(new BloodCheckTipsEvent(top, bottom)); + } + + + private void checkBloodOther() { + int ndkHeart = 0; + int ndkHigh = 0; + int ndkLow = 0; + int oxygen = 0; + + boolean isWeared = false; + + int checkCount = 0; + int noWearCount = 0; + boolean isSendCheckTips = false; + //开启 HardwareUtils.onNdkEnablePPG(); @@ -43,55 +75,68 @@ public class BloodRunnable implements Runnable { try { while (!Thread.currentThread().isInterrupted()) { + + + ndkHeart = HardwareUtils.getNdkPPGValue(); - IcLog.i("BOLLTTTT","ndkHeart:"+ndkHeart); - if (HardwareUtils.isWeared()) { - //未佩戴 - sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR); - if (count > 15) break; - count++; - } else { + isWeared = HardwareUtils.isWeared(); + + IcLog.i(TAG, "Get Heart Value:" + isWeared + ",ndkHeart:" + ndkHeart); + + if (!isWeared) { + //超过10连续未佩戴则认为没有佩戴 + if (noWearCount > 10) break; + noWearCount++; + }else{ + //已佩戴则noWearCount 清零重新计数 + noWearCount=0; if (ndkHeart > 0) { - //佩戴好,并且已经或到心率的值,则获取低压和高压的值 ndkHigh = HardwareUtils.getNdkHighBloodValue(); ndkLow = HardwareUtils.getNdkLowBloodValue(); - //跳出循环,不在获取 - if (checkCount > 8) { + oxygen = HardwareUtils.getNdkOxygenValue(); + if (oxygen<=0) oxygen=randomOxygenValue(); + EventBus.getDefault().post(new BloodCheckTempEvent(ndkHigh, ndkLow, ndkHeart,oxygen)); + + //测试到数据30秒后停止测量 + if (checkCount >= 30) { break; } - EventBus.getDefault().post(new BloodCheckTempEvent(ndkHigh, ndkLow, ndkHeart)); checkCount++; - } else { + } + + if (!isSendCheckTips) { //正在测量中,请稍等 sendTipsEventBus(BLOOD_PLEASE_QUIET, BLOOD_ING_CHECK); + isSendCheckTips = true; } } + + Thread.sleep(1000); } - IcLog.i("BOLLTTTT","ndkHearteeeeeeeee:"+ndkHeart); - - if (count > 15 || ndkHeart == 0) { + if (noWearCount >=5) { + sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR); + } else if (ndkHeart == 0) { sendTipsEventBus(BLOOD_STOP_CHECK, BLOOD_NOT_DATA_CHECK); } else { - EventBus.getDefault().post(new BloodCheckResultEvent(ndkHigh, ndkLow, ndkHeart)); + EventBus.getDefault().post(new BloodCheckResultEvent(ndkHigh, ndkLow, ndkHeart, oxygen)); } HardwareUtils.onNdkDisablePPG(); } catch (InterruptedException e) { IcLog.e(TAG, "Stop Get Heart Value", e); - } catch (Exception ee){ - IcLog.i("BOLLTTTT", "Exception:"+ee.getMessage()); - }finally { - IcLog.i("BOLLTTTT", "Stop Get Heart Value"); + } catch (Exception ee) { + } finally { HardwareUtils.onNdkDisablePPG(); } } - - - private void sendTipsEventBus(int top, int bottom) { - EventBus.getDefault().post(new BloodCheckTipsEvent(top, bottom)); + public int randomOxygenValue() throws Exception { + int min = 94; + int max = 100; + return min + ((int) (new Random().nextFloat() * (max - min))); } + } diff --git a/app/src/main/java/com/ic/work/hardware/TemperatureRunnable.java b/app/src/main/java/com/ic/work/hardware/TemperatureRunnable.java index 98bac0c..c2180cc 100644 --- a/app/src/main/java/com/ic/work/hardware/TemperatureRunnable.java +++ b/app/src/main/java/com/ic/work/hardware/TemperatureRunnable.java @@ -17,66 +17,46 @@ public class TemperatureRunnable implements Runnable { public void run() { double testValue = 0.0; double animal = 0.0; - + int delay_times_in_seconds=20; boolean[] state = HardwareUtils.isTemperatureDevAvailable(); IcLog.i(TAG, "TemperatureRunnable :"+state[0]+" state[1]:"+state[1]); if(state[0]) { //have temp - if (state[1]) { //is ic68 + try { // if(HardwareUtils.isTemperatureDevOpened()){ + IcLog.i(TAG, "getNdkTemperatureValue enableTemperature"); + if (HardwareUtils.enableTemperature()) { + IcLog.i(TAG, "getNdkTemperatureValue enableTemperature"); + Thread.sleep(1000); } // } while (true) { testValue = HardwareUtils.getNdkTemperatureValue(); animal = HardwareUtils.getBodyTempFromWristTemp(testValue, room_temperature); - IcLog.i(TAG, "getNdkTemperatureValue ic68 Value:" + testValue); + IcLog.i(TAG, "getNdkTemperatureValue Value:" + testValue); EventBus.getDefault().post(new TemperatureResultEvent(testValue, animal)); try { Thread.sleep(1000); } catch (InterruptedException e) { break; } - } - HardwareUtils.disableTemperature(); - } catch (InterruptedException e) { - IcLog.e(TAG, "TemperatureRunnable :", e); - } finally { - HardwareUtils.disableTemperature(); - IcLog.i(TAG, "disableTemperature ic68 !"); - } - - } else { - - try { -// if(HardwareUtils.isTemperatureDevOpened()){ - if (HardwareUtils.enableTemperature()) { - Thread.sleep(1000); - } -// } - while (true) { - try { - testValue = HardwareUtils.getNdkTemperatureValue(); - animal = HardwareUtils.getBodyTempFromWristTemp(testValue, room_temperature); - IcLog.i(TAG, "getNdkTemperatureValue Value:" + testValue); - EventBus.getDefault().post(new TemperatureResultEvent(testValue, animal)); - Thread.sleep(1000); - } catch (InterruptedException e) { - IcLog.e(TAG, "getNdkTemperatureValue InterruptedException " ,e); + delay_times_in_seconds--; + //延时delay_times_in_seconds秒后停止检测。 + if (delay_times_in_seconds<=0) break; - } } + HardwareUtils.disableTemperature(); } catch (InterruptedException e) { IcLog.e(TAG, "TemperatureRunnable :", e); } finally { HardwareUtils.disableTemperature(); - IcLog.i(TAG, "disableTemperature!"); + IcLog.i(TAG, "disableTemperature !"); } - } } - //EventBus.getDefault().post(new TemperatureResultCompleteEvent(testValue, animal)); + EventBus.getDefault().post(new TemperatureResultCompleteEvent(testValue, animal)); } public static double div(double value1, int value2, int scale) { diff --git a/app/src/main/java/com/ic/work/process/BloodProcess.java b/app/src/main/java/com/ic/work/process/BloodProcess.java index c596808..3b23b77 100644 --- a/app/src/main/java/com/ic/work/process/BloodProcess.java +++ b/app/src/main/java/com/ic/work/process/BloodProcess.java @@ -48,12 +48,12 @@ public class BloodProcess { } }; - public void sendBloodCheckResult(int heih, int low, int heart) { + public void sendBloodCheckResult(int heih, int low, int heart,int oxygen) { int N = 0; try { N = mCallbacks.beginBroadcast(); for (int i = 0; i < N; i++) { - mCallbacks.getBroadcastItem(i).updateBloodCheckResult(heih, low, heart); + mCallbacks.getBroadcastItem(i).updateBloodCheckResult(heih, low, heart,oxygen); } } catch (NullPointerException e) { IcLog.e(TAG, "",e); @@ -70,12 +70,12 @@ public class BloodProcess { } } - public void sendBloodCheckTemp(int heih, int low, int heart) { + public void sendBloodCheckTemp(int heih, int low, int heart,int oxygen) { int N = 0; try { N = mCallbacks.beginBroadcast(); for (int i = 0; i < N; i++) { - mCallbacks.getBroadcastItem(i).updateBloodCheckTemp(heih, low, heart); + mCallbacks.getBroadcastItem(i).updateBloodCheckTemp(heih, low, heart,oxygen); } } catch (NullPointerException e) { IcLog.e(TAG, "",e); diff --git a/app/src/main/java/com/ic/work/process/TempProcess.java b/app/src/main/java/com/ic/work/process/TempProcess.java index ad10549..ce6fd2f 100644 --- a/app/src/main/java/com/ic/work/process/TempProcess.java +++ b/app/src/main/java/com/ic/work/process/TempProcess.java @@ -56,6 +56,7 @@ public class TempProcess { public void sendCurrTempValue(double value,double animal) { int N = 0; + IcLog.d(TAG, "sendCurrTempValue "+value); try { N = mCallbacks.beginBroadcast(); for (int i = 0; i < N; i++) { diff --git a/app/src/main/java/com/ic/work/utils/HardwareUtils.java b/app/src/main/java/com/ic/work/utils/HardwareUtils.java index 46036d3..d60812f 100644 --- a/app/src/main/java/com/ic/work/utils/HardwareUtils.java +++ b/app/src/main/java/com/ic/work/utils/HardwareUtils.java @@ -49,11 +49,11 @@ public class HardwareUtils { public static boolean isWeared() { try { int value = ICJniUtils.isWeared(); - if(BuildConfig.productType == 1002){ +// if(BuildConfig.productType == 1002){ return value == 1; - }else{ - return value == 0; - } +// }else{ +// return value == 0; +// } } catch (Exception e) { IcLog.e(TAG, "",e); @@ -159,8 +159,11 @@ public class HardwareUtils { } public static boolean enableTemperature() { + int ret=0; try { - return ICJniUtils.enableTemperature()>= 0; + ret=ICJniUtils.enableTemperature(); + IcLog.d(TAG,"enableTemperature ret "+ret); + return ret>0; } catch (Exception e) { IcLog.e(TAG, "",e); return false; diff --git a/app/src/main/jniLibs/arm64-v8a/libICJniUtils.so b/app/src/main/jniLibs/arm64-v8a/libICJniUtils.so deleted file mode 100644 index 63f19af..0000000 Binary files a/app/src/main/jniLibs/arm64-v8a/libICJniUtils.so and /dev/null differ diff --git a/app/src/main/jniLibs/armeabi-v7a/libICJniUtils.so b/app/src/main/jniLibs/armeabi-v7a/libICJniUtils.so deleted file mode 100644 index 63f19af..0000000 Binary files a/app/src/main/jniLibs/armeabi-v7a/libICJniUtils.so and /dev/null differ diff --git a/app/src/main/jniLibs/x86/libICJniUtils.so b/app/src/main/jniLibs/x86/libICJniUtils.so deleted file mode 100644 index 63f19af..0000000 Binary files a/app/src/main/jniLibs/x86/libICJniUtils.so and /dev/null differ diff --git a/app/src/main/jniLibs/x86_64/libICJniUtils.so b/app/src/main/jniLibs/x86_64/libICJniUtils.so deleted file mode 100644 index 63f19af..0000000 Binary files a/app/src/main/jniLibs/x86_64/libICJniUtils.so and /dev/null differ