From 2f712e597bd6525ddb40703a39bb5332b7cbe656 Mon Sep 17 00:00:00 2001 From: kfl_614 Date: Thu, 3 Dec 2020 16:15:12 +0800 Subject: [PATCH] format codes. --- app/src/main/java/com/ic/jni/ICJniUtils.java | 87 ++++++++++--------- .../com/ic/work/hardware/BloodRunnable.java | 16 ++-- .../java/com/ic/work/utils/HardwareUtils.java | 73 ++++++++-------- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 90 insertions(+), 88 deletions(-) diff --git a/app/src/main/java/com/ic/jni/ICJniUtils.java b/app/src/main/java/com/ic/jni/ICJniUtils.java index 9062096..23de3d0 100644 --- a/app/src/main/java/com/ic/jni/ICJniUtils.java +++ b/app/src/main/java/com/ic/jni/ICJniUtils.java @@ -2,25 +2,22 @@ package com.ic.jni; public class ICJniUtils { - public enum GSensorType - { + public enum GSensorType { GSENSOR_TYPE_NONE, GSENSOR_TYPE_QMA7981, GSENSOR_TYPE_SC7A21, GSENSOR_TYPE_MAX - }; + } - public enum TempSensorType - { + public enum TempSensorType { TEMPSENSOR_TYPE_NONE, TEMPSENSOR_TYPE_NST175, TEMPSENSOR_TYPE_IC68, TEMPSENSOR_TYPE_EM7068, TEMPSENSOR_TYPE_MAX - }; + } - public enum PPG_EGC_SensorType - { + public enum PPG_EGC_SensorType { PPG_EGC_TYPE_NONE, PPG_EGC_TYPE_EM7028, PPG_EGC_TYPE_EM7068, @@ -29,11 +26,12 @@ public class ICJniUtils { PPG_EGC_TYPE_IC66, PPG_EGC_TYPE_PAH8002, PPG_EGC_TYPE_MAX - }; + } - public ICJniUtils(){ + public ICJniUtils() { } + static { // build.gradle里面 android\defaultConfig\ndk\moduleName 的名称 // Android.mk, LOCAL_MODULE 的名称 @@ -81,38 +79,42 @@ public class ICJniUtils { public static native int getGsensorType(); /*保存当前步数(getStepCount取得的值)到磁盘 不必判断返回值 - * 为了兼容,已经不再使用 - * */ + * 为了兼容,已经不再使用 + * */ public static native int saveStepCount(); /*恢复保存时的步数数据,下次getStepCount会在恢复的值上增加 不必判断返回值 - * * 为了兼容,已经不再使用 - * */ + * * 为了兼容,已经不再使用 + * */ public static native int recoverStepCount(); /******心率,血压****************************************/ - /*** + /*** * 检查 PPG硬件是否存在,返回PPG_EGC_SensorType * @return - * 返回PPG_EGC_TYPE_NONE代表不存在,否则返回 传感器类型 + * 返回PPG_EGC_TYPE_NONE代表不存在,否则返回 传感器类型 */ public static native int isPPGavailable(); - /** - * 开启心率血压检测 + /** + * 开启心率血压检测 + * * @return - */ + */ public static native int enablePPG(); /*** * 停止心率血压检测 + * * @return */ public static native int disablePPG(); /*** + * * 返回PPG 运行状态, 0 停止, 1,运行中 + * * @return */ public static native int isPPGStarted(); @@ -145,11 +147,11 @@ public class ICJniUtils { */ public static native int getLowBloodPressure(); - /*** - * 获取血氧值 + /*** + * 获取血氧值 * 请注意,此数据必须在执行 getPPG() 后才有效,否则一直为上一次的值。 * @return - */ + */ public static native int getSPO2(); @@ -157,19 +159,20 @@ public class ICJniUtils { * 开始温度检测,有些sensor不需要,为了兼容,请开始前执行一次,并且sleep 1秒钟 * @return */ - public static native int enableTemperature(); + public static native int enableTemperature(); /*** * 停止温度检测,有些sensor不需要,为了兼容请结束后还是要执行一次。 - * @return 返回值<0 表示失败 =>0表示成功 + * @return 返回值<0 表示失败 =>0表示成功 */ public static native int disableTemperature(); /*** * 检查体温检测设备是否开启 - * @return 返回0 未开启 1 开启 + * @return 返回0 未开启 1 开启 */ public static native int isTemperatureDevOpened(); + /*** * 执行温度校准操作,一版在整机生产时的恒温箱中执行 * @param refTemp 恒温箱的温度 @@ -179,7 +182,7 @@ public class ICJniUtils { /*** * 获取温度 校准后数据 单位摄氏度 - * @return 返回值<=0 表示失败 >0表示成功 + * @return 返回值<= 0 表示失败>0表示成功 */ public static native double getTemperature(); @@ -197,11 +200,11 @@ public class ICJniUtils { */ public static native int setTemperatureValidFlag(int flag); - /*** - * 此操作仅仅为了检查标志状态设置成功与否,标志已经在内部被使用 - * 注:暂时未启用,预留 + /*** + * 此操作仅仅为了检查标志状态设置成功与否,标志已经在内部被使用 + * 注:暂时未启用,预留 * @return - */ + */ public static native int getTemperatureValidFlag(); /*** @@ -211,31 +214,31 @@ public class ICJniUtils { * 腕温 * @param ref_temp * 室外参考温度 - * @return 返回值<=0 表示失败 >0表示成功 + * @return 返回值<= 0 表示失败>0表示成功 */ - public static native double getBodyTempFromWristTemp(double wrist_temp,double ref_temp); + public static native double getBodyTempFromWristTemp(double wrist_temp, double ref_temp); - /*** - * 有体温检测功能则返回 TempSensorType - * TempSensor_NONE 就表示没有体温检测功能,否则返回温度传感器类型 + /*** + * 有体温检测功能则返回 TempSensorType + * TempSensor_NONE 就表示没有体温检测功能,否则返回温度传感器类型 * @return - */ + */ public static native int isTemperatureDevAvailable(); /*获取温度校准前 - * 为了兼容已经不用 - * */ + * 为了兼容已经不用 + * */ public static native double getTemperatureOrigin(); /*设置校准参数 - * * 为了兼容已经不用 - * */ + * * 为了兼容已经不用 + * */ public static native int setTemperatureAdjustValue(double value); /*设置校准参数 - * * 为了兼容已经不用 - * */ + * * 为了兼容已经不用 + * */ public static native double getTemperatureAdjustValue(); } 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 50b7758..ebd22d3 100644 --- a/app/src/main/java/com/ic/work/hardware/BloodRunnable.java +++ b/app/src/main/java/com/ic/work/hardware/BloodRunnable.java @@ -36,7 +36,6 @@ public class BloodRunnable implements Runnable { @Override public void run() { - boolean[] deviceState = HardwareUtils.isPPGavailableIc66(); if (!deviceState[0]) { @@ -80,9 +79,6 @@ public class BloodRunnable implements Runnable { try { while (!Thread.currentThread().isInterrupted()) { - - - ndkHeart = HardwareUtils.getNdkPPGValue(); isWeared = HardwareUtils.isWeared(); @@ -92,15 +88,15 @@ public class BloodRunnable implements Runnable { //超过10连续未佩戴则认为没有佩戴 if (noWearCount > 10) break; noWearCount++; - }else{ + } else { //已佩戴则noWearCount 清零重新计数 - noWearCount=0; + noWearCount = 0; if (ndkHeart > 0) { ndkHigh = HardwareUtils.getNdkHighBloodValue(); ndkLow = HardwareUtils.getNdkLowBloodValue(); oxygen = HardwareUtils.getNdkOxygenValue(); - if (oxygen<=0) oxygen=randomOxygenValue(); - EventBus.getDefault().post(new BloodCheckTempEvent(ndkHigh, ndkLow, ndkHeart,oxygen)); + if (oxygen <= 0) oxygen = randomOxygenValue(); + EventBus.getDefault().post(new BloodCheckTempEvent(ndkHigh, ndkLow, ndkHeart, oxygen)); //测试到数据30秒后停止测量 if (checkCount >= 30) { @@ -117,11 +113,10 @@ public class BloodRunnable implements Runnable { } - Thread.sleep(1000); } - if (noWearCount >=5) { + if (noWearCount >= 5) { sendTipsEventBus(BLOOD_NULL_TIPS, BLOOD_NOT_WEAR); } else if (ndkHeart == 0) { sendTipsEventBus(BLOOD_STOP_CHECK, BLOOD_NOT_DATA_CHECK); @@ -138,6 +133,7 @@ public class BloodRunnable implements Runnable { HardwareUtils.onNdkDisablePPG(); } } + public int randomOxygenValue() throws Exception { int min = 95; int max = 100; 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 e103f60..6ecf0c7 100644 --- a/app/src/main/java/com/ic/work/utils/HardwareUtils.java +++ b/app/src/main/java/com/ic/work/utils/HardwareUtils.java @@ -7,16 +7,16 @@ public class HardwareUtils { private static final String TAG = "HardwareUtils"; - public static boolean[] isPPGavailableIc66(){ + public static boolean[] isPPGavailableIc66() { try { int value = ICJniUtils.isPPGavailable(); return new boolean[]{ value > ICJniUtils.PPG_EGC_SensorType.PPG_EGC_TYPE_NONE.ordinal(), value == ICJniUtils.PPG_EGC_SensorType.PPG_EGC_TYPE_IC66.ordinal() }; - }catch (Exception e) { - IcLog.e(TAG, "",e); - return new boolean[]{false,false}; + } catch (Exception e) { + IcLog.e(TAG, "", e); + return new boolean[]{false, false}; } } @@ -25,7 +25,7 @@ public class HardwareUtils { int value = ICJniUtils.isPPGavailable(); return value == 0; } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return true; } } @@ -34,7 +34,7 @@ public class HardwareUtils { try { ICJniUtils.enablePPG(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); } } @@ -42,7 +42,7 @@ public class HardwareUtils { try { ICJniUtils.disablePPG(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); } } @@ -50,13 +50,13 @@ public class HardwareUtils { try { int value = ICJniUtils.isWeared(); // if(BuildConfig.productType == 1002){ - return value == 1; + return value == 1; // }else{ // return value == 0; // } } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return true; } } @@ -65,7 +65,7 @@ public class HardwareUtils { try { return ICJniUtils.getPPG(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } @@ -74,7 +74,7 @@ public class HardwareUtils { try { return ICJniUtils.getHighBloodPressure(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } @@ -83,7 +83,7 @@ public class HardwareUtils { try { return ICJniUtils.getLowBloodPressure(); } catch (Exception e) { - IcLog.e(TAG,"",e); + IcLog.e(TAG, "", e); return 0; } } @@ -92,7 +92,7 @@ public class HardwareUtils { try { return ICJniUtils.getSPO2(); } catch (Exception e) { - IcLog.e(TAG,"",e); + IcLog.e(TAG, "", e); return 0; } } @@ -101,7 +101,7 @@ public class HardwareUtils { try { return ICJniUtils.getStepCount(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } @@ -110,39 +110,41 @@ public class HardwareUtils { try { return ICJniUtils.resetStepCount(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } - public static int enablePedometer(){ + + public static int enablePedometer() { try { return ICJniUtils.enablePedometer(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } - public static int disablePedometer(){ + + public static int disablePedometer() { try { return ICJniUtils.disablePedometer(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } public static boolean[] isTemperatureDevAvailable() { - boolean[] temp = new boolean[]{false,false}; + boolean[] temp = new boolean[]{false, false}; try { int type = ICJniUtils.isTemperatureDevAvailable(); temp[0] = type > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal(); - if(temp[0]){ + if (temp[0]) { temp[1] = type == ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal(); } return temp; } catch (Exception e) { - IcLog.e(TAG, "",e); + e.printStackTrace(); return temp; } } @@ -151,23 +153,25 @@ public class HardwareUtils { try { return ICJniUtils.getTemperature(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } + public static double getNdkTemperatureOutValue() { try { return ICJniUtils.getTemperatureOrigin(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } - public static double getBodyTempFromWristTemp(double wrist_temp,double ref_temp) { + + public static double getBodyTempFromWristTemp(double wrist_temp, double ref_temp) { try { - return ICJniUtils.getBodyTempFromWristTemp(wrist_temp,ref_temp); + return ICJniUtils.getBodyTempFromWristTemp(wrist_temp, ref_temp); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return 0; } } @@ -176,19 +180,19 @@ public class HardwareUtils { try { return ICJniUtils.isTemperatureDevOpened() == 0; } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return false; } } public static boolean enableTemperature() { - int ret=0; + int ret = 0; try { - ret=ICJniUtils.enableTemperature(); - IcLog.d(TAG,"enableTemperature ret "+ret); - return ret>0; + ret = ICJniUtils.enableTemperature(); + IcLog.d(TAG, "enableTemperature ret " + ret); + return ret > 0; } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); return false; } } @@ -197,10 +201,9 @@ public class HardwareUtils { try { ICJniUtils.disableTemperature(); } catch (Exception e) { - IcLog.e(TAG, "",e); + IcLog.e(TAG, "", e); } } - } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 830e3aa..dbd189e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip \ No newline at end of file -- 2.17.1