From: TrillGates Date: Thu, 28 Oct 2021 02:04:35 +0000 (+0800) Subject: add heart rate and tempeartre test from. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=3d4c89dfdea10bd3ffff5609975a69b4a9de0281;p=protocol_srv.git add heart rate and tempeartre test from. --- diff --git a/app/release/ICProtocol81_V934_2110281000_release.apk b/app/release/ICProtocol81_V934_2110281000_release.apk new file mode 100644 index 00000000..0c42e4a5 Binary files /dev/null and b/app/release/ICProtocol81_V934_2110281000_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 1c7a2d7b..5f7177cc 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":932,"versionName":"2110030008","enabled":true,"outputFile":"ICProtocol81_V932_2110030008_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol81_V932_2110030008_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":934,"versionName":"2110281000","enabled":true,"outputFile":"ICProtocol81_V934_2110281000_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol81_V934_2110281000_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/ic/protocolSrv/service/HeartRateManager.java b/app/src/main/java/com/ic/protocolSrv/service/HeartRateManager.java index 1304b296..8f0ef5b1 100644 --- a/app/src/main/java/com/ic/protocolSrv/service/HeartRateManager.java +++ b/app/src/main/java/com/ic/protocolSrv/service/HeartRateManager.java @@ -12,6 +12,7 @@ import android.net.Uri; import android.os.Handler; import android.os.IBinder; import android.os.Message; +import android.util.Log; import com.ic.protocolSrv.Config; import com.ic.protocolSrv.Constants; @@ -262,7 +263,7 @@ public class HeartRateManager extends AbstractInvokeHandlerService { ICLogger.d("result invalidate..."); runtime.getHRS().setHeartrateStat(heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_TEST_FAILED); uploadResult(); - }else { + } else { //BY TrillGates //判断是否有超出阀值 //如果超出的话,插入一条警告通知 @@ -402,11 +403,11 @@ public class HeartRateManager extends AbstractInvokeHandlerService { } else { ICLogger.i("PPG Failed for Timeout! send 0 message to server"); if (!Runtime.practising) { - StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(runtime,0,0,0,0); + StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(runtime, 0, 0, 0, 0); //因为协议中没有时间变量,所以只能实时传输,如果恰巧没有网络也只能丢弃,有时间变量的话,可以考虑通过deliver的buffer来进行缓存发送 if (PPGDATA == null) { StringMessage ppgd = protocolAPIHelper.getPPG_MSG(0, this.runtime); - StringMessage bloodd = protocolAPIHelper.getBlood_MSG(0,0, this.runtime); + StringMessage bloodd = protocolAPIHelper.getBlood_MSG(0, 0, this.runtime); StringMessage oxd = protocolAPIHelper.getOxygen_MSG(0, this.runtime); Deliver.sendLocationMSG(ppgd); Deliver.sendLocationMSG(bloodd); @@ -493,7 +494,8 @@ public class HeartRateManager extends AbstractInvokeHandlerService { } } //开始去测试 - ICLogger.d("from == > " + from + " HeartRateManager "); + ICLogger.d("from == > " + from + " HeartRateManager " + + " " + Log.getStackTraceString(new Throwable())); new Thread(() -> { try { if (heartRateSensorService != null) { diff --git a/app/src/main/java/com/ic/protocolSrv/utils/ServiceUtil.java b/app/src/main/java/com/ic/protocolSrv/utils/ServiceUtil.java deleted file mode 100644 index b8222a63..00000000 --- a/app/src/main/java/com/ic/protocolSrv/utils/ServiceUtil.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.ic.protocolSrv.utils; - -import android.annotation.SuppressLint; - -import com.ic.protocolSrv.LocationClient; -import com.ic.protocolSrv.bean.StringMessage; -import com.ic.protocolSrv.service.Deliver; - -import java.util.concurrent.LinkedBlockingDeque; - -public class ServiceUtil { - - public static boolean offerQueue(StringMessage paramStringMessage) { - return offerQueue(paramStringMessage, false); - } - - public static boolean offerQueue(StringMessage paramStringMessage, boolean paramBoolean) { - if (paramBoolean) { - if (!Deliver.queue.offerFirst(paramStringMessage)) { -// Deliver.saveQueue(); -// Deliver.queue.offerFirst(paramStringMessage); - return false; - } - } else if (!Deliver.queue.offerLast(paramStringMessage)) { -// Deliver.saveQueue(); -// Deliver.queue.offerLast(paramStringMessage); - return false; - } - return true; - } - - - -// public static void offerVideoQueue(OssFileContent paramOssFileContent, LinkedBlockingDeque paramLinkedBlockingDeque, FileCache paramFileCache) { -// if (!paramLinkedBlockingDeque.offerLast(paramOssFileContent)) { -// (new Thread(new Runnable(paramLinkedBlockingDeque, paramFileCache) { -// public void run() { SendOssMessage.saveVideoPathQueue(queue, fileCache); } -// })).start(); -// paramLinkedBlockingDeque.offerLast(paramOssFileContent); -// } -// } -// -// public static void offerVideoQueueForThread(OssFileContent paramOssFileContent, LinkedBlockingDeque paramLinkedBlockingDeque, FileCache paramFileCache) { -// if (!paramLinkedBlockingDeque.offerLast(paramOssFileContent)) { -// SendOssMessage.saveVideoPathQueue(paramLinkedBlockingDeque, paramFileCache); -// paramLinkedBlockingDeque.offerLast(paramOssFileContent); -// } -// } -} - diff --git a/app/src/main/java/com/ic/protocolSrv/utils/TempAlgUtil.java b/app/src/main/java/com/ic/protocolSrv/utils/TempAlgUtil.java deleted file mode 100644 index af50dc99..00000000 --- a/app/src/main/java/com/ic/protocolSrv/utils/TempAlgUtil.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.ic.protocolSrv.utils; - -import android.text.TextUtils; -import android.util.Log; - -import com.ic.protocolSrv.bean.TemperatureItem; -import com.ic.jni.ICJniUtils; - -public class TempAlgUtil { - private static String TAG = "TemperatureUtil"; - - private static double temp_value_orig = 0.0f; - private static double tempOut_value = 0.0f; - - public static double get_tempOut_value_origin() { - long tmp=System.currentTimeMillis(); - tempOut_value = ICJniUtils.getTemperatureOrigin(); - long tmp1=System.currentTimeMillis()-tmp; - if (tmp1>1000) - ICLogger.i("测量环境温度 原始值 " + tempOut_value+" 超过1秒 "+tmp1); - ICLogger.i( "测量环境温度 原始值 " + tempOut_value); - return tempOut_value; - } - - public static double get_temp_value_adjusted() { - long tmp=System.currentTimeMillis(); - temp_value_orig = ICJniUtils.getTemperature(); - long tmp1=System.currentTimeMillis()-tmp; - if (tmp1>1000) - ICLogger.i("测量体温 原始值 " + temp_value_orig+" 超过1秒 "+tmp1); - ICLogger.i("测量体温 原始值 " + temp_value_orig); - return temp_value_orig; - } - - - public static void enableTemp() { - if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) { - ICJniUtils.disablePedometer(); - ICJniUtils.enableTemperature(); - mSleep(1000); - } - } - - public static void disableTemp() { - if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) { - ICJniUtils.disableTemperature(); - ICJniUtils.enablePedometer(); - } - } - - public static void mSleep(int ms) { - try { - Thread.yield(); - Thread.sleep(ms); - } catch (Exception e) { - e.printStackTrace(); - } - } - - //thermal_zone0 - public static final String CMD_CPU_TEM = "/sys/class/thermal/thermal_zone0/temp"; - public static final String CMD_CPU_TYPE = "/sys/class/thermal/thermal_zone0/type"; - //thermal_zone1 - public static final String CMD_GPU_TEM = "/sys/class/thermal/thermal_zone1/temp"; - public static final String CMD_GPU_TYPE = "/sys/class/thermal/thermal_zone1/type"; - //thermal_zone2 - public static final String CMD_CHARGE_TEM = "/sys/class/thermal/thermal_zone2/temp"; - public static final String CMD_CHARGE_TYPE = "/sys/class/thermal/thermal_zone2/type"; - //thermal_zone3 - public static final String CMD_PA_TEM = "/sys/class/thermal/thermal_zone3/temp"; - public static final String CMD_PA_TYPE = "/sys/class/thermal/thermal_zone3/type"; - //thermal_zone4 - public static final String CMD_BOARD_TEM = "/sys/class/thermal/thermal_zone4/temp"; - public static final String CMD_BOARD_TYPE = "/sys/class/thermal/thermal_zone4/type"; - - - /** - * 这里获取到CPU温度,主板温度,体温,外温的数据,然后写到log里,后面转成数据表,再转成函数表达式。 - */ - public static TemperatureItem doTempTest() { - if (ICJniUtils.isTemperatureDevAvailable() > ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) { - - double bodyTemp/*体温*/ = 0.0f; - double cpuTemp/*cpu温度*/ = 0.0f; - double evnTemp/*环境温度*/ = 0.0f; - double gpuTemp/*gpu温度*/ = 0.0f; - double chargeTemp/*充电板的温度*/ = 0.0f; - double paTemp/*射频的温度*/ = 0.0f; - double boardTemp/*主板的温度*/ = 0.0f; - try { - String cpuTempType = TempFileUtils.readFile(CMD_CPU_TYPE); - String cpuTempStr = TempFileUtils.readFile(CMD_CPU_TEM); - String gpuTempType = TempFileUtils.readFile(CMD_GPU_TYPE); - String gpuTempStr = TempFileUtils.readFile(CMD_GPU_TEM); - String chargeTempType = TempFileUtils.readFile(CMD_CHARGE_TYPE); - String chargeTempStr = TempFileUtils.readFile(CMD_CHARGE_TEM); - String paTempType = TempFileUtils.readFile(CMD_PA_TYPE); - String paTempStr = TempFileUtils.readFile(CMD_PA_TEM); - String boardTempType = TempFileUtils.readFile(CMD_BOARD_TYPE); - String boardTempStr = TempFileUtils.readFile(CMD_BOARD_TEM); - //cpuTempType == > cpu-thmzone cpuTempStr == > 45295 gpuTempType == > gpu-thmzone gpuTempStr == > 43910 - ICLogger.d( " cpuTempType == > " + cpuTempType + - " cpuTempStr == > " + cpuTempStr + - "\n | " + - " gpuTempType == > " + gpuTempType + - " gpuTempStr == > " + gpuTempStr - + "\n | " - + "chargeTempType == > " + chargeTempType + - " chargeTempStr == > " + chargeTempStr - + "\n | " - + "paTempType == > " + paTempType + - " paTempStr == > " + paTempStr - + "\n | " - + "boardTempType == > " + boardTempType + - " boardTempStr == > " + boardTempStr - ); - //数据处理一下 - cpuTemp = Integer.parseInt(cpuTempStr) / 1000.0f; - gpuTemp = Integer.parseInt(gpuTempStr) / 1000.0f; - chargeTemp = Integer.parseInt(chargeTempStr) / 1000.0f; - paTemp = Integer.parseInt(paTempStr) / 1000.0f; - boardTemp = Integer.parseInt(boardTempStr) / 1000.0f; - } catch (Exception e) { - e.printStackTrace(); - } - evnTemp = get_tempOut_value_origin(); - bodyTemp = get_temp_value_adjusted(); - //对数据进行处理=======================================================start - // 环境温度计算公式: - // Ut=St-(0.6205x-22.049),St为传感器温度,其中x主板温度,x∈[38,56] - // 体温计算公式: - // Ut = St-(Bt*0.4533-15.294) St为传感器温度,Bt为板子温度 Bt∈[38,56] - // 系数不要抽成常量,以后如果有更好的公式可以替换。 - // 以上公式通过数据分析出来的,此公式仅适用于S123的产品,公式跟产品结构有关系 - //TODO:以上重要,所以同时对外可支持配置,如果没有配置不进行数据处理,直接返回原数值 - //TODO:配置格式: - // PRODUCT_PROPERTY_OVERRIDES += persist.sys.envTempAlgSlope=系数(斜率) - // PRODUCT_PROPERTY_OVERRIDES += persist.sys.envTempAlgDy=Y轴偏移值 - //========================================================================// - //环境温度的斜率和Y轴偏移值 - String envSlope = Util.getSystemProperties("persist.sys.envAlgSlope", ""); - String envDy = Util.getSystemProperties("persist.sys.envAlgDy", ""); - ICLogger.d("envSlope == > " + envSlope + " envDy == > " + envDy); - double resultEnvTemp = evnTemp; - if (!TextUtils.isEmpty(envDy) && !TextUtils.isEmpty(envSlope) && boardTemp > 39) { - //进行换算 - ICLogger.d("env temp with board temp..."); - resultEnvTemp = evnTemp - (Float.parseFloat(envSlope) * boardTemp + Float.parseFloat(envDy)); - // resultEnvTemp = evnTemp - (0.8492 * boardTemp - 25.204); - } else if (boardTemp <= 39 && boardTemp >= 27) { - ICLogger.d("in range of 27 to 39"); - //Ut = St-(Bt*0.869-27.167) Bt∈[32,38) - resultEnvTemp = evnTemp - (0.2441 * boardTemp - 2.3248); - } else { - //TODO:主板温度低于27度的,如果测试有这样的case,再采集数据 - } - String bodySlope = Util.getSystemProperties("persist.sys.bodyAlgSlope", ""); - String bodyDy = Util.getSystemProperties("persist.sys.bodyAlgDy", ""); - ICLogger.d("bodySlope == > " + bodySlope + " bodyDy == > " + bodyDy); - double resultBodyTemp = bodyTemp; - if (!TextUtils.isEmpty(bodyDy) && !TextUtils.isEmpty(bodySlope)) { - ICLogger.d("body temp with board temp..."); - resultBodyTemp = bodyTemp - (Float.parseFloat(bodySlope) * boardTemp + Float.parseFloat(bodyDy)); - } - - //=======================================================================end - ICLogger.d("evnTemp == > " + evnTemp + " resultEnvTemp = > " + resultEnvTemp); - ICLogger.d("bodyTemp == > " + bodyTemp + " resultBodyTemp = > " + resultBodyTemp); - if (resultBodyTemp < 0) { - return null; - } - - try { - //发送消息给launcher显示 - TemperatureItem temperatureItem = new TemperatureItem( - String.format("%.01f", resultBodyTemp), - String.format("%.01f", cpuTemp), - String.format("%.01f", resultEnvTemp), - String.format("%.01f", gpuTemp), - String.format("%.01f", chargeTemp), - String.format("%.01f", boardTemp), - String.format("%.01f", paTemp)); - return temperatureItem; - } catch (Exception e) { - e.printStackTrace(); - } - } - return null; - } -} diff --git a/app/src/main/java/com/ic/protocolSrv/utils/TempFileUtils.java b/app/src/main/java/com/ic/protocolSrv/utils/TempFileUtils.java deleted file mode 100644 index d32cfe9d..00000000 --- a/app/src/main/java/com/ic/protocolSrv/utils/TempFileUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.ic.protocolSrv.utils; - -import android.text.TextUtils; - -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.InputStreamReader; - -public class TempFileUtils { - /** - * 执行命令并且输出结果 - */ - public static String readFile(String file) { - if (TextUtils.isEmpty(file)) { - return null; - } - - BufferedReader bf = null; - try { - FileInputStream fis = new FileInputStream(file); - InputStreamReader isr = new InputStreamReader(fis); - bf = new BufferedReader(isr); - String result = bf.readLine(); - return result; - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (bf != null) { - try { - bf.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - return null; - } -} diff --git a/app/src/main/java/com/ic/protocolSrv/utils/TemperatureUtil.java b/app/src/main/java/com/ic/protocolSrv/utils/TemperatureUtil.java index 70ed3e8f..e316e3f0 100644 --- a/app/src/main/java/com/ic/protocolSrv/utils/TemperatureUtil.java +++ b/app/src/main/java/com/ic/protocolSrv/utils/TemperatureUtil.java @@ -8,6 +8,7 @@ import android.content.Intent; import android.content.ServiceConnection; import android.net.Uri; import android.os.IBinder; +import android.util.Log; import com.ic.protocolSrv.Config; import com.ic.protocolSrv.Constants; @@ -210,7 +211,7 @@ public class TemperatureUtil { * @param from */ public void DoTempTest(int from) { - ICLogger.d("DoTempTest..." + from); + ICLogger.d("DoTempTest..." + from + " " + Log.getStackTraceString(new Throwable())); if (CoreService.getInstance() != null && CoreService.getInstance().getRuntime().Anti_off_flag == 1) { ICLogger.i("未佩戴,取消TempTest!" + from); return; diff --git a/app/src/main/java/com/ic/protocolSrv/utils/sysProperties.java b/app/src/main/java/com/ic/protocolSrv/utils/sysProperties.java deleted file mode 100644 index a8382dd1..00000000 --- a/app/src/main/java/com/ic/protocolSrv/utils/sysProperties.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.ic.protocolSrv.utils; - - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -public class sysProperties { - - private static Method sysPropGet; - private static Method sysPropSet; - - private sysProperties() { - } - - static { - try { - Class S = Class.forName("android.os.SystemProperties"); - Method M[] = S.getMethods(); - for (Method m : M) { - String n = m.getName(); - if (n.equals("get")) { - sysPropGet = m; - } else if (n.equals("set")) { - sysPropSet = m; - } - } - } catch (ClassNotFoundException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } - } - - public static String get(String name, String default_value) { - try { - return (String) sysPropGet.invoke(null, name, default_value); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } catch (IllegalAccessException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } catch (InvocationTargetException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } - return default_value; - } - - public static void set(String name, String value) { - try { - sysPropSet.invoke(null, name, value); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } catch (IllegalAccessException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } catch (InvocationTargetException e) { - e.printStackTrace(); - ICLogger.e(e.getMessage(),e); - } - } -} \ No newline at end of file diff --git a/app/version_code.properties b/app/version_code.properties index 6c5dbd98..ae78b942 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Sun Oct 03 00:08:26 CST 2021 -VERSION_CODE=932 +#Thu Oct 28 10:00:42 CST 2021 +VERSION_CODE=934 diff --git a/local.properties b/local.properties index c8314aa7..c04f4aee 100644 --- a/local.properties +++ b/local.properties @@ -5,4 +5,4 @@ # For customization when using a Version Control System, please read the # header note. #Mon Sep 06 17:17:01 CST 2021 -sdk.dir=C\:\\Users\\incar\\AppData\\Local\\Android\\Sdk +sdk.dir=E\:\\Android\\Sdk