format codes.
authorkfl_614 <kfl_614@163.com>
Thu, 3 Dec 2020 08:15:12 +0000 (16:15 +0800)
committerkfl_614 <kfl_614@163.com>
Thu, 3 Dec 2020 08:15:12 +0000 (16:15 +0800)
app/src/main/java/com/ic/jni/ICJniUtils.java
app/src/main/java/com/ic/work/hardware/BloodRunnable.java
app/src/main/java/com/ic/work/utils/HardwareUtils.java
gradle/wrapper/gradle-wrapper.properties

index 9062096..23de3d0 100644 (file)
@@ -2,25 +2,22 @@ package com.ic.jni;
 \r
 public class ICJniUtils {\r
 \r
-    public enum GSensorType\r
-    {\r
+    public enum GSensorType {\r
         GSENSOR_TYPE_NONE,\r
         GSENSOR_TYPE_QMA7981,\r
         GSENSOR_TYPE_SC7A21,\r
         GSENSOR_TYPE_MAX\r
-    };\r
+    }\r
 \r
-    public enum TempSensorType\r
-    {\r
+    public enum TempSensorType {\r
         TEMPSENSOR_TYPE_NONE,\r
         TEMPSENSOR_TYPE_NST175,\r
         TEMPSENSOR_TYPE_IC68,\r
         TEMPSENSOR_TYPE_EM7068,\r
         TEMPSENSOR_TYPE_MAX\r
-    };\r
+    }\r
 \r
-    public enum PPG_EGC_SensorType\r
-    {\r
+    public enum PPG_EGC_SensorType {\r
         PPG_EGC_TYPE_NONE,\r
         PPG_EGC_TYPE_EM7028,\r
         PPG_EGC_TYPE_EM7068,\r
@@ -29,11 +26,12 @@ public class ICJniUtils {
         PPG_EGC_TYPE_IC66,\r
         PPG_EGC_TYPE_PAH8002,\r
         PPG_EGC_TYPE_MAX\r
-    };\r
+    }\r
 \r
-    public ICJniUtils(){\r
+    public ICJniUtils() {\r
 \r
     }\r
+\r
     static {\r
         // build.gradle里面 android\defaultConfig\ndk\moduleName 的名称\r
         // Android.mk, LOCAL_MODULE 的名称\r
@@ -81,38 +79,42 @@ public class ICJniUtils {
     public static native int getGsensorType();\r
 \r
     /*保存当前步数(getStepCount取得的值)到磁盘 不必判断返回值\r
-    * 为了兼容,已经不再使用\r
-    * */\r
+     * 为了兼容,已经不再使用\r
+     * */\r
     public static native int saveStepCount();\r
 \r
     /*恢复保存时的步数数据,下次getStepCount会在恢复的值上增加 不必判断返回值\r
-    * * 为了兼容,已经不再使用\r
-    * */\r
+     * * 为了兼容,已经不再使用\r
+     * */\r
     public static native int recoverStepCount();\r
 \r
     /******心率,血压****************************************/\r
-     /***\r
+    /***\r
      * 检查 PPG硬件是否存在,返回PPG_EGC_SensorType\r
      * @return\r
-      * 返回PPG_EGC_TYPE_NONE代表不存在,否则返回 传感器类型\r
+     * 返回PPG_EGC_TYPE_NONE代表不存在,否则返回 传感器类型\r
      */\r
     public static native int isPPGavailable();\r
 \r
-     /**\r
-      * 开启心率血压检测\r
+    /**\r
+     * 开启心率血压检测\r
+     *\r
      * @return\r
-      */\r
+     */\r
     public static native int enablePPG();\r
 \r
     /***\r
      * 停止心率血压检测\r
+     *\r
      * @return\r
      */\r
     public static native int disablePPG();\r
 \r
 \r
     /***\r
+     *\r
      * 返回PPG 运行状态, 0 停止, 1,运行中\r
+     *\r
      * @return\r
      */\r
     public static native int isPPGStarted();\r
@@ -145,11 +147,11 @@ public class ICJniUtils {
      */\r
     public static native int getLowBloodPressure();\r
 \r
-      /***\r
-       * 获取血氧值\r
+    /***\r
+     * 获取血氧值\r
      *  请注意,此数据必须在执行 getPPG() 后才有效,否则一直为上一次的值。\r
      * @return\r
-       */\r
+     */\r
     public static native int getSPO2();\r
 \r
 \r
@@ -157,19 +159,20 @@ public class ICJniUtils {
      * 开始温度检测,有些sensor不需要,为了兼容,请开始前执行一次,并且sleep 1秒钟\r
      * @return\r
      */\r
-    public static native  int enableTemperature();\r
+    public static native int enableTemperature();\r
 \r
     /***\r
      * 停止温度检测,有些sensor不需要,为了兼容请结束后还是要执行一次。\r
-     * @return  返回值<0 表示失败 =>0表示成功\r
+     * @return 返回值<0 表示失败 =>0表示成功\r
      */\r
     public static native int disableTemperature();\r
 \r
     /***\r
      * 检查体温检测设备是否开启\r
-     * @return  返回0 未开启 1 开启\r
+     * @return 返回0 未开启 1 开启\r
      */\r
     public static native int isTemperatureDevOpened();\r
+\r
     /***\r
      * 执行温度校准操作,一版在整机生产时的恒温箱中执行\r
      * @param refTemp  恒温箱的温度\r
@@ -179,7 +182,7 @@ public class ICJniUtils {
 \r
     /***\r
      *  获取温度 校准后数据 单位摄氏度\r
-     * @return 返回值<=0 表示失败 >0表示成功\r
+     * @return 返回值<= 0 表示失败>0表示成功\r
      */\r
     public static native double getTemperature();\r
 \r
@@ -197,11 +200,11 @@ public class ICJniUtils {
      */\r
     public static native int setTemperatureValidFlag(int flag);\r
 \r
-     /***\r
-      * 此操作仅仅为了检查标志状态设置成功与否,标志已经在内部被使用\r
-      * 注:暂时未启用,预留\r
+    /***\r
+     * 此操作仅仅为了检查标志状态设置成功与否,标志已经在内部被使用\r
+     * 注:暂时未启用,预留\r
      * @return\r
-      */\r
+     */\r
     public static native int getTemperatureValidFlag();\r
 \r
     /***\r
@@ -211,31 +214,31 @@ public class ICJniUtils {
      * 腕温\r
      * @param ref_temp\r
      * 室外参考温度\r
-     * @return 返回值<=0 表示失败 >0表示成功\r
+     * @return 返回值<= 0 表示失败>0表示成功\r
      */\r
-    public static native double getBodyTempFromWristTemp(double wrist_temp,double ref_temp);\r
+    public static native double getBodyTempFromWristTemp(double wrist_temp, double ref_temp);\r
 \r
 \r
-     /***\r
-      * 有体温检测功能则返回 TempSensorType\r
-      * TempSensor_NONE 就表示没有体温检测功能,否则返回温度传感器类型\r
+    /***\r
+     * 有体温检测功能则返回 TempSensorType\r
+     * TempSensor_NONE 就表示没有体温检测功能,否则返回温度传感器类型\r
      * @return\r
-      */\r
+     */\r
     public static native int isTemperatureDevAvailable();\r
 \r
 \r
     /*获取温度校准前\r
-    * 为了兼容已经不用\r
-    * */\r
+     * 为了兼容已经不用\r
+     * */\r
     public static native double getTemperatureOrigin();\r
 \r
     /*设置校准参数\r
-    *  * 为了兼容已经不用\r
-    * */\r
+     *  * 为了兼容已经不用\r
+     * */\r
     public static native int setTemperatureAdjustValue(double value);\r
 \r
     /*设置校准参数\r
-    *  * 为了兼容已经不用\r
-    * */\r
+     *  * 为了兼容已经不用\r
+     * */\r
     public static native double getTemperatureAdjustValue();\r
 }\r
index 50b7758..ebd22d3 100644 (file)
@@ -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;
index e103f60..6ecf0c7 100644 (file)
@@ -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);
         }
     }
 
 
-
 }
index 830e3aa..dbd189e 100644 (file)
@@ -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