release V618
authorsnickersun <scy@incartech.cn>
Thu, 17 Sep 2020 09:26:26 +0000 (17:26 +0800)
committersnickersun <scy@incartech.cn>
Thu, 17 Sep 2020 09:26:26 +0000 (17:26 +0800)
protocol_fzd 添加自定义协议PRACTICE
是H88A 项目的 自由锻炼 需求,开始锻炼后1分钟记录一次步数,心率,血压,血氧,体温,30分钟上传一次 PRACTICE

20 files changed:
app/app.iml
app/release/ICSer_V618_2009171715_release.apk [moved from app/release/ICSer_V616_2009151746_release.apk with 78% similarity]
app/release/output.json
app/src/main/AndroidManifest.xml
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/Constants.java
app/src/main/java/com/enqualcomm/support/CoreService.java
app/src/main/java/com/enqualcomm/support/LocationClient.java
app/src/main/java/com/enqualcomm/support/MainActivity.java
app/src/main/java/com/enqualcomm/support/bean/HealthInfo.java [new file with mode: 0644]
app/src/main/java/com/enqualcomm/support/bean/Runtime.java
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/service/HeartRateManager.java
app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java
app/src/main/java/com/enqualcomm/support/utils/ICHttpUtil.java
app/src/main/java/com/enqualcomm/support/utils/SharPreferenceUtil.java
app/src/main/java/com/enqualcomm/support/utils/TemperatureUtil.java
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_fzd.java
app/version_code.properties

index df83372..e442beb 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?><module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">\r
+<?xml version="1.0" encoding="UTF-8"?><module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="icsupport" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">\r
   <component name="FacetManager">\r
     <facet type="android-gradle" name="Android-Gradle">\r
       <configuration>\r
@@ -18,8 +18,8 @@
         <option name="ALLOW_USER_CONFIGURATION" value="false"/>\r
         <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml"/>\r
         <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res"/>\r
-        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res"/>\r
-        <option name="TEST_RES_FOLDERS_RELATIVE_PATH" value=""/>\r
+        <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/debug/res;file://$MODULE_DIR$/build/generated/res/rs/debug;file://$MODULE_DIR$/build/generated/res/resValues/debug"/>\r
+        <option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/androidTest/res;file://$MODULE_DIR$/src/test/res;file://$MODULE_DIR$/src/androidTestDebug/res;file://$MODULE_DIR$/src/testDebug/res;file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug;file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug"/>\r
         <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets"/>\r
       </configuration>\r
     </facet>\r
     <orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner:0.5@aar" level="project"/>\r
     <orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:exposed-instrumentation-api-publish:0.5@aar" level="project"/>\r
     <orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource:2.2.2@aar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\android-logging-log4j-1.0.3.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\ftp4j-1.7.2.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\log4j-1.2.17.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\okio-2.4.3.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\mail.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\activation.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\additionnal.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\frameworks-full-debug.jar:unspecified@jar" level="project"/>\r
-    <orderEntry type="library" name="Gradle: __local_aars__:D.\Snicker\icsupport\app\libs\telephony_common-full-debug.jar:unspecified@jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/android-logging-log4j-1.0.3.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/ftp4j-1.7.2.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/log4j-1.2.17.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/okio-2.4.3.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/mail.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/activation.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/additionnal.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/frameworks-full-debug.jar" level="project"/>\r
+    <orderEntry type="library" name="Gradle: ./app/libs/telephony_common-full-debug.jar" level="project"/>\r
     <orderEntry type="library" name="Gradle: com.android.support.constraint:constraint-layout-solver:1.1.3@jar" level="project"/>\r
     <orderEntry type="library" name="Gradle: com.android.support:support-annotations:25.1.0@jar" level="project"/>\r
     <orderEntry type="library" name="Gradle: io.reactivex:rxjava:1.1.0@jar" level="project"/>\r
similarity index 78%
rename from app/release/ICSer_V616_2009151746_release.apk
rename to app/release/ICSer_V618_2009171715_release.apk
index 711bc17..57404bc 100644 (file)
Binary files a/app/release/ICSer_V616_2009151746_release.apk and b/app/release/ICSer_V618_2009171715_release.apk differ
index a07cd8e..1a4c58a 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":617,"versionName":"2009160733","enabled":true,"outputFile":"ICSer_V617_2009160733_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V617_2009160733_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":618,"versionName":"2009171715","enabled":true,"outputFile":"ICSer_V618_2009171715_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V618_2009171715_release.apk","properties":{}}]
\ No newline at end of file
index 549c310..b716572 100644 (file)
                 <action android:name="com.enqualcomm.support.HEART_ALARM" />
                 <action android:name="com.enqualcomm.support.ANTI_ALARM" />
                 <action android:name="com.enqualcomm.support.TEMP_ALARM" />
+                <action android:name="com.enqualcomm.support.PRACTICE_ALARM" />
                 <action android:name="com.ic.action.CHECK_ANTIOFF_EVENT"/>
             </intent-filter>
         </service>
index 4d6968e..6633aa3 100644 (file)
@@ -105,7 +105,9 @@ public class Config {
 \r
   final static String  KeyContactsList="ContactsList";\r
   final static String  KeySOSNumbersList="SOSNumbersList";\r
-  final static String KeyIMEI="IMEI";\r
+\r
+  final static String KeyIMEI = "persist.sys.protocol_IMEI";\r
+  final static String KeyPractiseState = "persist.sys.practising";\r
 \r
   final static String KeyHeartBeatCycle="ServerHeartBeatCycle";\r
 \r
@@ -234,13 +236,11 @@ public class Config {
   }\r
 \r
   public static void setIMEI(Context context, String imei){\r
-//    SharPreferenceUtil.setPrefString(context,KeyIMEI,imei);\r
-    SharPreferenceUtil.setPrefStringPublic(context,KeyIMEI,imei);\r
+    Util.setSystemProperties(KeyIMEI,imei);\r
   }\r
 \r
   public static String getIMEI(Context context){\r
-//    return SharPreferenceUtil.getPrefString(context,KeyIMEI,"");\r
-    return SharPreferenceUtil.getPrefStringPublic(context,KeyIMEI,"");\r
+    return Util.getSystemProperties(KeyIMEI,"");\r
   }\r
 \r
   public static String getProtocolServerHost(Context context){\r
index 72efe0f..eed0c6c 100644 (file)
@@ -107,7 +107,12 @@ public interface Constants {
   public static final String ACTION_WAKEUP_ALARM = "com.eqc.deliverWakeupAlarm.action";\r
   \r
   public static final String ACTION_YUN_ALARM_CHANGE = "com.eqc.deskclock.YUN_ALARM_CHANGE";\r
-  \r
+\r
+  public static final String ACTION_PRACTICE_REPORT_ALARM = "com.enqualcomm.support.PRACTICE_ALARM";\r
+\r
+  public final static String ACTION_START_PRACTISE = "com.ic.action_start_practice";\r
+  public final static String KeyPractice = "cmd";\r
+\r
   public static final int ALARM_UPDATE_NOTICE = 206;\r
   \r
   public static final int CALL_RECORD_CHANGED = 103;\r
index 6789d04..c87a031 100644 (file)
@@ -4,6 +4,7 @@ import android.app.AlarmManager;
 import android.app.Notification;\r
 import android.app.PendingIntent;\r
 import android.app.Service;\r
+import android.content.IClipboard;\r
 import android.content.Intent;\r
 import android.media.AudioManager;\r
 import android.os.Handler;\r
@@ -23,6 +24,7 @@ import com.enqualcomm.support.service.AntiMonitorService;
 import com.enqualcomm.support.utils.CellInfoUtil;\r
 import com.enqualcomm.support.utils.Connection;\r
 import com.enqualcomm.support.utils.DeviceInfoUtil;\r
+import com.enqualcomm.support.utils.ICHttpUtil;\r
 import com.enqualcomm.support.utils.LedUtil;\r
 import com.enqualcomm.support.utils.StorageUtils;\r
 import com.enqualcomm.support.utils.TemperatureUtil;\r
@@ -77,6 +79,7 @@ import static com.enqualcomm.support.Constants.ACTION_EQC_ALARM;
 import static com.enqualcomm.support.Constants.ACTION_HEATR_RATE_START;\r
 import static com.enqualcomm.support.Constants.ACTION_LOCAL_SOS_ACTION;\r
 import static com.enqualcomm.support.Constants.ACTION_LOCATION_ALARM;\r
+import static com.enqualcomm.support.Constants.ACTION_PRACTICE_REPORT_ALARM;\r
 import static com.enqualcomm.support.Constants.ACTION_SEND_EMEGENCY_LOCATION_START;\r
 import static com.enqualcomm.support.Constants.ACTION_SEND_EMEGENCY_LOCATION_STOP;\r
 import static com.enqualcomm.support.Constants.ANTI_ALARM;\r
@@ -240,6 +243,49 @@ public class CoreService extends Service {
             e.printStackTrace();\r
         }\r
     }\r
+\r
+    private BroadcastReceiver broadcastPracticeCMDReceiver = new BroadcastReceiver() {\r
+        public void onReceive(Context param1Context, Intent param1Intent) {\r
+            if(param1Intent.getAction().equals(Constants.ACTION_START_PRACTISE))\r
+            {\r
+                int cmd=param1Intent.getIntExtra(Constants.KeyPractice,0);\r
+                if (cmd==1){\r
+                    //开始自由锻炼\r
+                    Runtime.practising=true;\r
+                    Util.setSystemProperties( Config.KeyPractiseState,"true");\r
+                    Runtime.healthInfo.reset();\r
+                    Runtime.healthInfo.resetBuffer();\r
+                    setPracticeAlarm();\r
+\r
+                }else{\r
+                    //停止自由锻炼,恢复正常\r
+                    Runtime.practising=false;\r
+                    Util.setSystemProperties( Config.KeyPractiseState,"false");\r
+                    HeartRateManager.stopPPGtest();\r
+\r
+                    //最后检测是否还有数据需要发送\r
+                    if(Runtime.healthInfo.check_info_item_finished()){\r
+                        Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString());\r
+                        Runtime.healthInfo.reset();\r
+                     }\r
+                    if(Runtime.healthInfo.getInfoCount()>=0){\r
+                        //超过30次发送数据给服务器\r
+                        ICLogger.i("自由锻炼结束,发送数据给服务器 "+Runtime.healthInfo.getBufferData().length);\r
+                        new Handler().post(new Runnable() {\r
+                            @Override\r
+                            public void run() {\r
+                                //ICHttpUtil.uploadData(Runtime.healthInfo.getBufferDataStr(),runtime,TimeUtil.getSystemTime2(),null);\r
+                                Deliver.sendLocationMSG(protocolAPIHelper.getPRACTICE());\r
+                                //发送过后重置\r
+                                Runtime.healthInfo.resetBuffer();\r
+                            }\r
+                        });\r
+                    }\r
+\r
+                }\r
+            }\r
+        }\r
+    };\r
     private static class ServerHandler implements ConnectionListener {\r
         private final WeakReference<CoreService> mReference;\r
 \r
@@ -355,6 +401,7 @@ public class CoreService extends Service {
         }\r
     };\r
 \r
+\r
     private int startAlarmCount = 0;\r
 \r
     UpLoadDataPoints upLoadDataPoints;\r
@@ -449,6 +496,34 @@ public class CoreService extends Service {
 //        AlarmHelper.setTimeAlarm(this, 6, (new Random()).nextInt(40) + 20, WEATHER_ALARM);\r
     }\r
 \r
+\r
+    private void setPracticeAlarm() {\r
+\r
+        ICLogger.i("setPracticeAlarm "+Runtime.practice_cycle+ " seconds!");\r
+        //只有周期大于1才有效,否则就等于单次测量\r
+        if (Runtime.practice_cycle>1)\r
+            AlarmHelper.setRealTimeAlarmInSeconds(runtime.getContextProxy().context,Runtime.practice_cycle,Constants.ACTION_PRACTICE_REPORT_ALARM);\r
+\r
+        new Thread(new Runnable() {\r
+            @Override\r
+            public void run() {\r
+                //获取并设置当前步数\r
+                ICLogger.i("自由锻炼中,设置步数 "+runtime.getTotalStepCount());\r
+                Runtime.healthInfo.setStepCount(runtime.getTotalStepCount());\r
+                //开启定位\r
+                //        locationClient.triggerLocationProcess();\r
+                //开启测温\r
+                TemperatureUtil.DoTempTest();\r
+\r
+                //开启测量PPG\r
+                HeartRateManager.triggerPPGtest();\r
+\r
+\r
+            }\r
+        }).start();\r
+\r
+\r
+    }\r
     private void checkconnection(){\r
 \r
         if (!this.connection.isServerConnected())\r
@@ -664,6 +739,10 @@ public class CoreService extends Service {
         intentFilter.addAction(ACTION_LOCAL_SOS_ACTION);\r
         registerReceiver(broadcastSOSReceiver,intentFilter);\r
 \r
+        //添加自由锻炼 接收\r
+        intentFilter = new IntentFilter();\r
+        intentFilter.addAction(Constants.ACTION_START_PRACTISE);\r
+        registerReceiver(broadcastPracticeCMDReceiver,intentFilter);\r
 \r
         //初始化Sim信号\r
         this.mSignalUtil = SimSignalUtil.getInstance(this);\r
@@ -693,6 +772,7 @@ public class CoreService extends Service {
 \r
         batteryUtil.registerBroadReceiver();\r
 \r
+\r
         //设置计步清零时间。\r
         setCleanStepCountAlarm();\r
 \r
@@ -918,6 +998,12 @@ public class CoreService extends Service {
                 if (Config.LOG_TOFILE) ICLogger.logToFile("alarmCycle", stringBuilder1.toString());\r
 //                this.locationClient.triggerLocationProcess();\r
 \r
+            }else if (Constants.ACTION_PRACTICE_REPORT_ALARM.equals(paramIntent.getAction())) {\r
+                //alarm是延迟的,所以这个判断主要是给最后一次可能无效的测量\r
+                if (Runtime.practising==true) {\r
+                    //开始下一轮健康测量\r
+                    setPracticeAlarm();\r
+                }\r
             }else if (Constants.ACTION_CHECK_SERVER_RESPONSE.equals(paramIntent.getAction())) {\r
                 //暂时还使用 ScheduledThreadPoolExecutor , 时间要求不是那么的严格\r
             }else if (Constants.ACTION_RETRY_SERVER_CONNECT.equals(paramIntent.getAction())) {\r
@@ -971,7 +1057,12 @@ public class CoreService extends Service {
                 if (this.mKeepAlive != null) {\r
                     if (connection.isServerConnected() && runtime.isServerProtocolConnected()) {\r
                         //测试温度并上报\r
-                        TemperatureUtil.doTempTestInThread();\r
+\r
+                        if (Runtime.practising==true) {\r
+                            ICLogger.i("自由锻炼中,跳过原有的循环温度检测!");\r
+                        }else {\r
+                            TemperatureUtil.doTempTestInThread();\r
+                        }\r
 //                        double wrist_temp=TemperatureUtil.get_temp_value_adjusted();\r
 //                        double body_temp=TemperatureUtil.getBodyTemp(wrist_temp,26.0f);\r
 //                        String temperatureMsg=getTemperatureMSG(wrist_temp,body_temp);\r
@@ -1099,6 +1190,11 @@ public class CoreService extends Service {
         sb.append(" setLocationAlarm  "+ACTION_LOCATION_ALARM+" mod "+mod+", cycle in Seconds "+cycle);\r
         ICLogger.i(sb.toString());\r
         if (Config.LOG_TOFILE) FileOutputUtil.fileOutput(runtime.getCacheDir(),"alarmCycle",sb.toString());\r
+\r
+//        if (Runtime.practising==true) {\r
+//            ICLogger.i("自由锻炼中,跳过原有的循环定位!");\r
+//            return;\r
+//        }\r
         locationClient.triggerLocationProcess();\r
 \r
     }\r
index 16a6cdc..27a9c7b 100644 (file)
@@ -147,7 +147,7 @@ public class LocationClient {
             if ( runtime.bleInfo.last_is_in_area==true) {\r
               //只有上一次在区域内,这次出区域才需要报警\r
               StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime);\r
-              Deliver.sendLocationMSG(AL_CMD);\r
+              DeliverMessage(AL_CMD);\r
             }\r
           }\r
         }else {\r
@@ -158,7 +158,7 @@ public class LocationClient {
             ICLogger.i("BT 在区域内,直接发送区域坐标即可!");\r
             runtime.updateFZDDevStatusEscape(false);\r
             StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);\r
-            Deliver.sendLocationMSG(AP01_CMD);\r
+            DeliverMessage(AP01_CMD);\r
           }\r
         }\r
 \r
@@ -427,16 +427,16 @@ public class LocationClient {
             ){\r
               if (startSOSLocation==true){\r
                 StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);\r
-                Deliver.sendLocationMSG(AP10_CMD);\r
+                DeliverMessage(AP10_CMD);\r
                 startSOSLocation=false;\r
               }else {\r
 \r
                 if (gps_ok) {\r
                   StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime);\r
-                  Deliver.sendLocationMSG(AP01_CMD);\r
+                  DeliverMessage(AP01_CMD);\r
                 }else{\r
                   StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime);\r
-                  Deliver.sendLocationMSG(AP02_CMD);\r
+                  DeliverMessage(AP02_CMD);\r
                 }\r
 \r
               }\r
@@ -501,12 +501,12 @@ public class LocationClient {
 \r
               if (startSOSLocation==true){\r
                 StringMessage AP10_CMD = protocolAPIHelper.getWarningMSG(runtime);\r
-                Deliver.sendLocationMSG(AP10_CMD);\r
+                DeliverMessage(AP10_CMD);\r
                 startSOSLocation=false;\r
 \r
               }else {\r
                 StringMessage AP02_CMD = protocolAPIHelper.getLBSLocationMSG(runtime);\r
-                Deliver.sendLocationMSG(AP02_CMD);\r
+                DeliverMessage(AP02_CMD);\r
               }\r
 \r
               stopCheckLocationResult();\r
@@ -542,6 +542,30 @@ public class LocationClient {
         }\r
   }\r
 \r
+  private void DeliverMessage(StringMessage msg){\r
+\r
+//    if(Runtime.practising==true){\r
+//      if(msg==null){\r
+//        ICLogger.i("msg is null skip!");\r
+//      }\r
+//      ICLogger.i("自由锻炼中,定位缓存再发送!");\r
+//      Runtime.healthInfo.setLocationData(msg.isFromCache());\r
+//\r
+//      //因为心率和定位用时都比温度多,但是定位和心率不一定谁用时多,所以两个都需要检测是否结束\r
+//      if(Runtime.healthInfo.check_info_item_finished()){\r
+//        Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString());\r
+//        Runtime.healthInfo.reset();\r
+//      }\r
+//      if(Runtime.healthInfo.getInfoCount()>=(30-1)){\r
+//        //超过30次发送数据给服务器\r
+//        ICLogger.i("发送数据给服务器 "+Runtime.healthInfo.getBufferData().length);\r
+//        //发送过后重置\r
+//        Runtime.healthInfo.resetBuffer();\r
+//      }\r
+//    }else {\r
+      Deliver.sendLocationMSG(msg);\r
+//    }\r
+  }\r
   public void stopCheckLocationResult(){\r
     ICLogger.i("stopCheckLocationResult!");\r
 //    if (mTimer!=null){\r
index 69d1ce1..a20bb6e 100644 (file)
@@ -259,15 +259,15 @@ public class MainActivity extends Activity {
     };
 
 
-    public void tesetSharedKey(){
-            Config.setSleepScore(this,344);
-            Config.setSleepDate(this,TimeUtil.getSystemTime3());
-            Config.setKeepSitRangeInMinutes(this,3);
-        ICLogger.d("SHAREKEY_SETTING_SLEEP_SCORE_DATE "+ SharPreferenceUtil.getPrefStringPublic(this,Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE,""));
-        ICLogger.d("SHAREKEY_SETTING_SLEEP_SCORE "+ SharPreferenceUtil.getPrefIntPublic(this,Constants.SHAREKEY_SETTING_SLEEP_SCORE,0));
-        ICLogger.d("SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES "+ SharPreferenceUtil.getPrefIntPublic(this,Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES,0));
-
-    }
+//    public void tesetSharedKey(){
+//            Config.setSleepScore(this,344);
+//            Config.setSleepDate(this,TimeUtil.getSystemTime3());
+//            Config.setKeepSitRangeInMinutes(this,3);
+//        ICLogger.d("SHAREKEY_SETTING_SLEEP_SCORE_DATE "+ SharPreferenceUtil.getPrefStringPublic(this,Constants.SHAREKEY_SETTING_SLEEP_SCORE_DATE,""));
+//        ICLogger.d("SHAREKEY_SETTING_SLEEP_SCORE "+ SharPreferenceUtil.getPrefIntPublic(this,Constants.SHAREKEY_SETTING_SLEEP_SCORE,0));
+//        ICLogger.d("SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES "+ SharPreferenceUtil.getPrefIntPublic(this,Constants.SHAREKEY_SETTING_SIT_ALARM_RANGE_IN_MINUTES,0));
+//
+//    }
 
 
 
diff --git a/app/src/main/java/com/enqualcomm/support/bean/HealthInfo.java b/app/src/main/java/com/enqualcomm/support/bean/HealthInfo.java
new file mode 100644 (file)
index 0000000..da2fad0
--- /dev/null
@@ -0,0 +1,85 @@
+package com.enqualcomm.support.bean;\r
+\r
+import com.enqualcomm.support.utils.TimeUtil;\r
+\r
+public class HealthInfo {\r
+    private String LocationState="";\r
+    private String PPG_ECG_State="";\r
+    private String Temperature_State="";\r
+    private String StepCount_Stat="";\r
+    private StringBuffer infoBuffer=new StringBuffer();\r
+    private int infoCount=0;\r
+    public void reset(){\r
+        StepCount_Stat=LocationState=PPG_ECG_State=Temperature_State="";\r
+    }\r
+    public void resetBuffer(){\r
+        infoBuffer.delete(0,infoBuffer.length());\r
+        infoCount=0;\r
+    }\r
+    public int getInfoCount(){\r
+        return infoCount;\r
+    }\r
+    public void setLocationData(String location){\r
+        LocationState=location;\r
+    }\r
+\r
+    public void setPPGECGData(String ppg,String bph,String bpl, String spo2){\r
+//        PPG_ECG_State="ppg="+ppg+",bph="+bph+",bpl="+bpl+",spo2="+spo2;\r
+        PPG_ECG_State=ppg+","+bph+","+bpl+","+spo2;\r
+    }\r
+    public void setPPGECGData(int ppg,int bph,int bpl, int spo2){\r
+//        PPG_ECG_State="ppg="+ppg+",bph="+bph+",bpl="+bpl+",spo2="+spo2;\r
+        PPG_ECG_State=ppg+","+bph+","+bpl+","+spo2;\r
+    }\r
+    public void setTemperatureData(double temp){\r
+//        Temperature_State="temp="+String.format("%.1f",temp);\r
+        Temperature_State=String.format("%.1f",temp);\r
+    }\r
+\r
+    public void setStepCount(int stepcount){\r
+//        StepCount_Stat="stepcount="+stepcount;\r
+        StepCount_Stat=String.valueOf(stepcount);\r
+    }\r
+\r
+    public boolean check_info_item_finished(){\r
+//        if (!LocationState.trim().isEmpty() && !PPG_ECG_State.trim().isEmpty() && !Temperature_State.trim().isEmpty()|!StepCount_Stat.trim().isEmpty())\r
+         if ( !PPG_ECG_State.trim().isEmpty() && !Temperature_State.trim().isEmpty()|!StepCount_Stat.trim().isEmpty())\r
+         {\r
+            return true;\r
+        }else\r
+            return false;\r
+    }\r
+\r
+    public void appendBuffer(String data){\r
+        if(infoCount>0){\r
+            //第二个起,要添加分隔符 |\r
+            infoBuffer.append("|").append(data);\r
+        }else {\r
+            //第一个直接添加到后面\r
+            infoBuffer.append(data);\r
+        }\r
+        infoCount++;\r
+    }\r
+\r
+    public String getBufferDataStr(){\r
+        return new StringBuilder().append(infoCount).append(",").append(infoBuffer.toString()).toString();\r
+//        return infoBuffer.toString();\r
+    }\r
+    public byte[] getBufferData(){\r
+        return new StringBuilder().append(infoCount).append(",").append(infoBuffer.toString()).toString().getBytes();\r
+//        return infoBuffer.toString().getBytes();\r
+    }\r
+    public String getHealthInfoString(){\r
+        if (check_info_item_finished()==true){\r
+            return new StringBuilder()\r
+                    .append("").append(TimeUtil.getSystemTime3()).append(",")\r
+//                    .append(LocationState.trim()).append(";")\r
+                    .append(PPG_ECG_State.trim()).append(",")\r
+                    .append(Temperature_State.trim()).append(",")\r
+                    .append(StepCount_Stat.trim())\r
+                    .toString();\r
+        }else{\r
+            return "";\r
+        }\r
+    }\r
+}\r
index 1015ce3..f9847fa 100644 (file)
@@ -2,6 +2,7 @@ package com.enqualcomm.support.bean;
 \r
 \r
 import android.content.Context;\r
+import android.support.constraint.solver.widgets.Helper;\r
 \r
 import com.enqualcomm.support.adapter.LBSHelper;\r
 import com.enqualcomm.support.utils.ContextProxy;\r
@@ -931,6 +932,14 @@ public class Runtime {
     public static String lastSitCheckTiimeyyyyMMddHHmmss="";\r
     public static long lastSitCheckStepCount=-1;\r
 \r
+    public static HealthInfo healthInfo=null;\r
+    static {\r
+        healthInfo=new HealthInfo();\r
+        healthInfo.reset();\r
+    }\r
+\r
+    public static boolean practising=false;\r
+    public static int practice_cycle=60;\r
 \r
 }\r
 \r
index d1bedaa..8d793f0 100644 (file)
@@ -265,6 +265,8 @@ public class Deliver extends AbstractConnectionService {
       if(!ServiceUtil.offerQueue(Msg)) {\r
         ICLogger.i(" MessageQueue 已满,数据将被丢弃," + Msg.cmd()+" "+Msg.isFromCache());\r
         if (Config.LOG_TOFILE)ICLogger.logToFile( "APILog", " queueFullskip  " + Msg.cmd()+" "+Msg.isFromCache());\r
+      }else{\r
+        if (Config.LOG_TOFILE)ICLogger.logToFile( "APILog", " queueCMD  " + Msg.cmd()+" "+Msg.isFromCache());\r
       }\r
 //      if(queue.size()>5) //测试queue 发送逻辑用\r
         triggerSendThread();\r
index f901c65..0142d80 100644 (file)
@@ -18,6 +18,7 @@ import com.enqualcomm.support.Config;
 import com.enqualcomm.support.Constants;\r
 import com.enqualcomm.support.CoreService;\r
 import com.enqualcomm.support.bean.StringMessage;\r
+import com.enqualcomm.support.utils.ICHttpUtil;\r
 import com.enqualcomm.support.utils.Util;\r
 import com.ic.jni.ICJniUtils;\r
 import com.ic.protocols.protocolAPIHelper;\r
@@ -113,25 +114,50 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
             //只有检测PPG成功,且网络连接中才发送数据\r
             if (runtime.getHRS().getHeartrateWorkingStat() == heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_TEST_SUCCESS) {\r
               runtime.getHRS().setLastTestTime(TimeUtil.getSystemTime3());\r
-              StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(runtime);\r
-              sendBroadcastPPGResult();\r
-              //因为协议中没有时间变量,所以只能实时传输,如果恰巧没有网络也只能丢弃,有时间变量的话,可以考虑通过deliver的buffer来进行缓存发送\r
-                if(PPGDATA==null){\r
-                  StringMessage ppgd=protocolAPIHelper.getPPG_MSG(runtime.getHRS().getPPG(),runtime);\r
-                  StringMessage bloodd=protocolAPIHelper.getBlood_MSG( runtime.getHRS().getBPH(), runtime.getHRS().getBPL(),runtime);\r
-                  StringMessage oxd=protocolAPIHelper.getOxygen_MSG(runtime.getHRS().getSpo2(),runtime);\r
-                  Deliver.sendLocationMSG( ppgd);\r
+\r
+              if(Runtime.practising==true){\r
+                ICLogger.i("自由锻炼中,设置测量心率! "+runtime.getHRS().getPPG()+","+runtime.getHRS().getBPH()+","+runtime.getHRS().getBPL()+","+runtime.getHRS().getSpo2());\r
+                Runtime.healthInfo.setPPGECGData(runtime.getHRS().getPPG(),runtime.getHRS().getBPH(),runtime.getHRS().getBPL(),runtime.getHRS().getSpo2());\r
+\r
+                //因为心率和定位用时都比温度多,但是定位和心率不一定谁用时多,所以两个都需要检测是否结束\r
+                if(Runtime.healthInfo.check_info_item_finished()){\r
+                  Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString());\r
+                  ICLogger.i("自由锻炼中,测量完成,添加一条记录! 当前条数 "+Runtime.healthInfo.getInfoCount());\r
+                  Runtime.healthInfo.reset();\r
+                }\r
+                if(Runtime.healthInfo.getInfoCount()>=(30-1)){\r
+                  //超过30次发送数据给服务器\r
+                  ICLogger.i("自由锻炼中,发送数据给服务器 "+Runtime.healthInfo.getBufferData().length);\r
+                  mHandler.post(new Runnable() {\r
+                    @Override\r
+                    public void run() {\r
+//                      ICHttpUtil.uploadData(Runtime.healthInfo.getBufferDataStr(),runtime,TimeUtil.getSystemTime2(),null);\r
+                      Deliver.sendLocationMSG(protocolAPIHelper.getPRACTICE());\r
+                      //发送过后重置\r
+                      Runtime.healthInfo.resetBuffer();\r
+                    }\r
+                  });\r
+                }\r
+              }else {\r
+                StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(runtime);\r
+                sendBroadcastPPGResult();\r
+                //因为协议中没有时间变量,所以只能实时传输,如果恰巧没有网络也只能丢弃,有时间变量的话,可以考虑通过deliver的buffer来进行缓存发送\r
+                if (PPGDATA == null) {\r
+                  StringMessage ppgd = protocolAPIHelper.getPPG_MSG(runtime.getHRS().getPPG(), runtime);\r
+                  StringMessage bloodd = protocolAPIHelper.getBlood_MSG(runtime.getHRS().getBPH(), runtime.getHRS().getBPL(), runtime);\r
+                  StringMessage oxd = protocolAPIHelper.getOxygen_MSG(runtime.getHRS().getSpo2(), runtime);\r
+                  Deliver.sendLocationMSG(ppgd);\r
                   Deliver.sendLocationMSG(bloodd);\r
-                  Deliver.sendLocationMSG( oxd);\r
+                  Deliver.sendLocationMSG(oxd);\r
 \r
                   checkWarning();\r
 \r
-                }else {\r
-                  Deliver.sendLocationMSG( PPGDATA);\r
+                } else {\r
+                  Deliver.sendLocationMSG(PPGDATA);\r
                   ICLogger.i("Send PPG " + PPGDATA.isFromCache());\r
                   checkWarning();\r
                 }\r
-\r
+              }\r
 \r
             } else {\r
               ICLogger.i("PPG Failed for Timeout!");\r
@@ -203,10 +229,11 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
   boolean isWared ;\r
   boolean isPPGTesting ;\r
   static boolean isTimerStarted;\r
-  static heartRateStatus.HEARTRATE_WORKINGSTAT currentStat;\r
+  public static heartRateStatus.HEARTRATE_WORKINGSTAT currentStat;\r
   static int delayCount;\r
   static int testCount;\r
   static int notWaredCount;\r
+  static int noPPGCount;\r
   private final int MAX_TESTTIMES=30000;//最大延迟测试时间为30秒\r
 \r
 \r
@@ -245,8 +272,15 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
         ICLogger.i("HEARTRATE_NOTWARED 超过时限,取消检测报告!");\r
         stopPPG();\r
       }\r
+    }else if (currentStat== heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_WARED_AND_TESTING){\r
+      noPPGCount--;\r
+      if( noPPGCount <0){ //没有佩戴次数到限制后,停止检测\r
+        ICLogger.i("HEARTRATE WARED And Testing (Wared=1 PPG=0)超过时限,取消检测报告!");\r
+        stopPPG();\r
+      }\r
     }\r
 \r
+\r
     if (currentStat==heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_TEST_SUCCESS){\r
       runtime.getHRS().setLastHeartrate(PPG,BPH,BPL,SPo2);\r
       delayCount--;\r
@@ -294,6 +328,7 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
       currentStat = heartRateStatus.HEARTRATE_WORKINGSTAT.HEARTRATE_OPEN;\r
       delayCount = 4;//检测成功后4秒发送数据\r
       notWaredCount = 5; //初始化没有佩戴的检测次数5,连续5秒没有佩戴则取消检测\r
+      noPPGCount = 30;//即使佩戴了,但是30秒没有出结果,也认为无效\r
       testCount = MAX_TESTTIMES;//测试MAX_TESTTIMES后没有结果也要强制退出\r
       isTimerStarted = true;\r
       getPPGWakeLock();\r
@@ -304,7 +339,8 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
 \r
       } else {\r
 \r
-        ICJniUtils.enablePPG();\r
+        int ret=ICJniUtils.enablePPG();\r
+        ICLogger.i("Start PPG test ret="+ret);\r
         timerPPG = new ScheduledThreadPoolExecutor(10);\r
         timerPPG.scheduleAtFixedRate(new Runnable() {\r
           @Override\r
@@ -372,7 +408,11 @@ public class HeartRateManager extends AbstractInvokeHandlerService implements Se
 //        stringBuilder.append("number == ");\r
 //        stringBuilder.append(str1);\r
       ICLogger.i(stringBuilder.toString());\r
-      //do something\r
+      //周期测量执行\r
+      if (Runtime.practising==true) {\r
+        ICLogger.i("自由锻炼中,跳过原有的循环心率检测!");\r
+        return false;\r
+      }\r
       startPPG();\r
     }\r
     return false;\r
@@ -382,7 +422,9 @@ public static void triggerPPGtest(){
    if (mHandler !=null) mHandler.sendEmptyMessage(200);\r
 }\r
 \r
-\r
+  public static void stopPPGtest(){\r
+    if (mHandler !=null) mHandler.sendEmptyMessage(300);\r
+  }\r
 \r
   public boolean onUserRequest(Message message, Connection connection, final Runtime runtime) {\r
 \r
@@ -412,23 +454,45 @@ public static void triggerPPGtest(){
           }\r
 \r
 \r
+        if(Runtime.practising==true){\r
+          ICLogger.i("自由锻炼中,设置测量心率!");\r
+          Runtime.healthInfo.setPPGECGData(ppg,bph,bpl,spo2);\r
 \r
-              StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(Integer.parseInt(ppg), Integer.parseInt(bph), Integer.parseInt(bpl), Integer.parseInt(spo2),runtime);\r
-              if(PPGDATA==null){\r
-                StringMessage ppgd=protocolAPIHelper.getPPG_MSG(Integer.parseInt(ppg),runtime);\r
-                StringMessage bloodd=protocolAPIHelper.getBlood_MSG( Integer.parseInt(bph), Integer.parseInt(bpl),runtime);\r
-                StringMessage oxd=protocolAPIHelper.getOxygen_MSG(Integer.parseInt(spo2),runtime);\r
-                Deliver.sendLocationMSG(ppgd);\r
-                Deliver.sendLocationMSG(bloodd);\r
-                Deliver.sendLocationMSG( oxd);\r
-\r
-              }else {\r
-                Deliver.sendLocationMSG( PPGDATA);\r
-                ICLogger.i("Send PPG " + PPGDATA.isFromCache());\r
+          //因为心率和定位用时都比温度多,但是定位和心率不一定谁用时多,所以两个都需要检测是否结束\r
+          if(Runtime.healthInfo.check_info_item_finished()){\r
+            Runtime.healthInfo.appendBuffer(Runtime.healthInfo.getHealthInfoString());\r
+            Runtime.healthInfo.reset();\r
+          }\r
+          if(Runtime.healthInfo.getInfoCount()>=(30-1)){\r
+            //超过30次发送数据给服务器\r
+            ICLogger.i("发送数据给服务器 "+Runtime.healthInfo.getBufferData().length);\r
+            mHandler.post(new Runnable() {\r
+              @Override\r
+              public void run() {\r
+//                ICHttpUtil.uploadData(Runtime.healthInfo.getBufferDataStr(),runtime,TimeUtil.getSystemTime2(),null);\r
+                Deliver.sendLocationMSG(protocolAPIHelper.getPRACTICE());\r
+                //发送过后重置\r
+                Runtime.healthInfo.resetBuffer();\r
               }\r
+            });\r
 \r
 \r
-         callback(message.replyTo, Constants.RESULT_OK);\r
+          }\r
+        }else {\r
+          StringMessage PPGDATA = protocolAPIHelper.getPPG_ECG_MSG(Integer.parseInt(ppg), Integer.parseInt(bph), Integer.parseInt(bpl), Integer.parseInt(spo2), runtime);\r
+          if (PPGDATA == null) {\r
+            StringMessage ppgd = protocolAPIHelper.getPPG_MSG(Integer.parseInt(ppg), runtime);\r
+            StringMessage bloodd = protocolAPIHelper.getBlood_MSG(Integer.parseInt(bph), Integer.parseInt(bpl), runtime);\r
+            StringMessage oxd = protocolAPIHelper.getOxygen_MSG(Integer.parseInt(spo2), runtime);\r
+            Deliver.sendLocationMSG(ppgd);\r
+            Deliver.sendLocationMSG(bloodd);\r
+            Deliver.sendLocationMSG(oxd);\r
+          } else {\r
+            Deliver.sendLocationMSG(PPGDATA);\r
+            ICLogger.i("Send PPG " + PPGDATA.isFromCache());\r
+          }\r
+        }\r
+        callback(message.replyTo, Constants.RESULT_OK);\r
 \r
       default:\r
         break;\r
index 2fcbcbc..d812954 100644 (file)
@@ -11,6 +11,7 @@ import android.os.Build;
 import android.os.Environment;\r
 import android.os.PowerManager;\r
 import android.provider.Settings;\r
+import android.telephony.PhoneNumberUtils;\r
 import android.telephony.TelephonyManager;\r
 \r
 import com.enqualcomm.support.Config;\r
@@ -51,16 +52,20 @@ public class DeviceInfoUtil {
   public static boolean updateImei(Runtime runtime){\r
 \r
     String imei= Config.getIMEI(runtime.getContextProxy().context);\r
+    String cellphoneNumb= DeviceInfoUtil.getNumber(runtime.getContextProxy().context);\r
+    ICLogger.i("get CellPhoneNumber "+cellphoneNumb);\r
+    String cid="";\r
     if (imei.isEmpty()){\r
       //如果配置里有IMEI,优先选配置里的,没有则选择系统的\r
       imei= PhoneUtils.getIMEI(runtime.getContextProxy().context);\r
+      cid=PhoneUtils.getIMSI(runtime.getContextProxy().context);\r
       if(imei==null) {\r
         return false;\r
       }else{\r
-        runtime.setImeiAndCid(imei, "");\r
+        runtime.setImeiAndCid(imei, cid);\r
       }\r
     }  else{\r
-      runtime.setImeiAndCid(imei,"");\r
+      runtime.setImeiAndCid(imei,cid);\r
     }\r
 \r
     return true;\r
index 3dcb7c2..0e0e0ab 100644 (file)
@@ -24,7 +24,52 @@ import java.util.zip.ZipOutputStream;
 import static android.content.ContentValues.TAG;\r
 \r
 public class ICHttpUtil {\r
+    public static boolean uploadData(String filebuf, Runtime runtime, String logtime, Handler mhandler)  {\r
+        String sdcard= Environment.getExternalStorageDirectory().getAbsolutePath();\r
+        String filename=sdcard+File.separator+"tmp.txt";\r
+        String zipfile=sdcard+File.separator+"tmp.zip";\r
+        boolean compressSuccess=false;\r
+        try {\r
+\r
+            CheckedOutputStream out=new CheckedOutputStream(new FileOutputStream(filename),new CRC32());\r
+            out.write(filebuf.getBytes());\r
+            out.close();\r
+\r
+            File srcfile=new File(filename);\r
+            if (Util.zipFile(srcfile, "",\r
+                    new ZipOutputStream(new CheckedOutputStream(new FileOutputStream(zipfile),new CRC32()))\r
+                    , filename)) {\r
+                compressSuccess=true;\r
+            }\r
+            srcfile.delete();\r
+        }catch (Exception e){\r
+            e.printStackTrace();\r
+            compressSuccess=false;\r
+        }\r
+        if (compressSuccess==false) {\r
 \r
+            if(mhandler!=null)\r
+                mhandler.sendEmptyMessage(0);\r
+            return false;\r
+        }\r
+        String server= Config.getLogServerIP(runtime.getContextProxy().context);\r
+        int port= Config.getLogServerPort(runtime.getContextProxy().context);\r
+        String product=DeviceInfoUtil.getModule();\r
+        String pkgver=DeviceInfoUtil.getSWVersionDisplayName();\r
+        String imei=runtime.IMEI();\r
+        if (server.startsWith("http://")){\r
+            server=server.replace("http://","");\r
+        }\r
+        //为了兼容之前的只设置ip和端口的设置方式\r
+        String actionUrl = "http://"+server+":"+port + "/UploadFile.jsp?product=" + product + "&pkgver="+ pkgver + "&imei="+ imei+"&logtime="+logtime;\r
+        if (server.contains("/")){ //此时说明不是ip地址,而是个url\r
+            actionUrl= "http://"+server+"?product=" + product + "&pkgver="+ pkgver + "&imei="+ imei+"&logtime="+logtime;\r
+        }\r
+\r
+        ICLogger.i("url="+actionUrl+"\nfile="+zipfile);\r
+        return upLoadFile(actionUrl, new File(zipfile),mhandler);\r
+\r
+    }\r
     public static boolean uploadFile(String filename, Runtime runtime, String logtime, Handler mhandler)  {\r
 \r
         String zipfile=filename;\r
index 07e610c..9e66f47 100644 (file)
@@ -57,23 +57,23 @@ public class SharPreferenceUtil {
         PreferenceManager.getDefaultSharedPreferences(context).edit().putString(key, value).commit();\r
     }\r
 \r
-\r
-    public static String getPrefStringPublic(Context context, String key, String value) {\r
-        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_READABLE);\r
-        return sp.getString(key, value);\r
-    }\r
-    public static void setPrefStringPublic(Context context, String key, String value) {\r
-        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_WRITEABLE);\r
-        sp.edit().putString(key, value).commit();\r
-    }\r
-    public static void setPrefIntPublic(Context context, String key, int value) {\r
-        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_WRITEABLE);\r
-        sp.edit().putInt(key, value).commit();\r
-    }\r
-    public static int getPrefIntPublic(Context context, String key, int value) {\r
-        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_READABLE);\r
-        return sp.getInt(key, value);\r
-    }\r
+//\r
+//    public static String getPrefStringPublic(Context context, String key, String value) {\r
+//        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_READABLE);\r
+//        return sp.getString(key, value);\r
+//    }\r
+//    public static void setPrefStringPublic(Context context, String key, String value) {\r
+//        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_WRITEABLE);\r
+//        sp.edit().putString(key, value).commit();\r
+//    }\r
+//    public static void setPrefIntPublic(Context context, String key, int value) {\r
+//        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_WRITEABLE);\r
+//        sp.edit().putInt(key, value).commit();\r
+//    }\r
+//    public static int getPrefIntPublic(Context context, String key, int value) {\r
+//        SharedPreferences sp=context.getSharedPreferences("icprotocolconfig",Context.MODE_WORLD_READABLE);\r
+//        return sp.getInt(key, value);\r
+//    }\r
 \r
 //// 其他应用读取写入访问的方法\r
 //    public static String getPrefStringPublic(Context context, String key, String value) {\r
index 46d11c8..7f62045 100644 (file)
@@ -9,7 +9,9 @@ import com.enqualcomm.support.Constants;
 import com.enqualcomm.support.CoreService;\r
 import com.enqualcomm.support.bean.Runtime;\r
 import com.enqualcomm.support.bean.StringMessage;\r
+import com.enqualcomm.support.bean.heartRateStatus;\r
 import com.enqualcomm.support.service.Deliver;\r
+import com.enqualcomm.support.service.HeartRateManager;\r
 import com.ic.jni.ICJniUtils;\r
 import com.ic.protocols.protocolAPIHelper;\r
 \r
@@ -52,48 +54,72 @@ public class TemperatureUtil {
             @Override\r
             public void run() {\r
 \r
-                if (ICJniUtils.isTemperatureDevAvailable() >ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {\r
-                    ICJniUtils.enableTemperature();\r
-                    try {\r
-                        Thread.sleep(1000);\r
-                    } catch (InterruptedException e) {\r
-                        e.printStackTrace();\r
-                    }\r
-\r
-\r
-                    double wrist_temp, body_temp;\r
-\r
-                    wrist_temp = TemperatureUtil.get_temp_value_adjusted();\r
-                    body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);\r
-                    StringMessage temperatureMsg = protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp, null);\r
-                    Deliver.sendLocationMSG(temperatureMsg);\r
-                    if  (temperatureMsg!=null) ICLogger.i("发送体温测量值 " + temperatureMsg.isFromCache());\r
-\r
-                    Runtime runtime = CoreService.getInstance().getRuntime();\r
-                    runtime.tempInfo.setTemp(body_temp, wrist_temp);\r
-                    ICJniUtils.disableTemperature();\r
-\r
-\r
-                    if (Config.needTemperature_abnormal_alarm) {\r
-                        switch (runtime.tempInfo.isBodyTempAbnormal()) {\r
-                            case 0:\r
-                                break;\r
-                            case 1:\r
-                                runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_HIGH);\r
-                                //trigger AP10 报警定位\r
-                                Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));\r
-                                break;\r
-                            case 2:\r
-                                runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_LOW);\r
-                                //trigger AP10 报警定位\r
-                                Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));\r
-                                break;\r
-                        }\r
-                    }\r
+                DoTempTest();\r
+            }\r
+        },500);\r
+    }\r
+\r
+    public static void DoTempTest(){\r
+        if (ICJniUtils.isTemperatureDevAvailable() >ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_NONE.ordinal()) {\r
+\r
+            ICJniUtils.enableTemperature();\r
+            try {\r
+                Thread.sleep(1000);\r
+            } catch (InterruptedException e) {\r
+                e.printStackTrace();\r
+            }\r
 \r
 \r
+            double wrist_temp, body_temp;\r
+\r
+            wrist_temp = TemperatureUtil.get_temp_value_adjusted();\r
+            if(wrist_temp< 0.001f){\r
+                try {\r
+                    Thread.sleep(1000);\r
+                } catch (InterruptedException e) {\r
+                    e.printStackTrace();\r
                 }\r
+                ICLogger.i("retry read temp for 0");\r
+                wrist_temp = TemperatureUtil.get_temp_value_adjusted();\r
             }\r
-        },500);\r
+            if(ICJniUtils.isTemperatureDevAvailable()==ICJniUtils.TempSensorType.TEMPSENSOR_TYPE_IC68.ordinal()){\r
+                //如果是IC68,只有体温,没有腕温\r
+                body_temp=wrist_temp;\r
+            }else {\r
+                body_temp = TemperatureUtil.getBodyTemp(wrist_temp, 26.0f);\r
+            }\r
+            if(Runtime.practising==true){\r
+                ICLogger.i("自由锻炼中,设置测量体温!" +String.format("%.1f",body_temp));\r
+                Runtime.healthInfo.setTemperatureData(body_temp);\r
+            }else {\r
+                StringMessage temperatureMsg = protocolAPIHelper.getTemperatureMSG(wrist_temp, body_temp, null);\r
+                Deliver.sendLocationMSG(temperatureMsg);\r
+                if  (temperatureMsg!=null) ICLogger.i("发送体温测量值 " + temperatureMsg.isFromCache());\r
+            }\r
+\r
+            Runtime runtime = CoreService.getInstance().getRuntime();\r
+            runtime.tempInfo.setTemp(body_temp, wrist_temp);\r
+            ICJniUtils.disableTemperature();\r
+\r
+            //体温异常报警检测开启的会进行异常报警\r
+            if (Config.needTemperature_abnormal_alarm) {\r
+                switch (runtime.tempInfo.isBodyTempAbnormal()) {\r
+                    case 0:\r
+                        break;\r
+                    case 1:\r
+                        runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_HIGH);\r
+                        //trigger AP10 报警定位\r
+                        Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));\r
+                        break;\r
+                    case 2:\r
+                        runtime.setAlarmType(Runtime.AlarmType.ALARM_TEMP_LOW);\r
+                        //trigger AP10 报警定位\r
+                        Deliver.sendLocationMSG(protocolAPIHelper.getWarningMSG(runtime));\r
+                        break;\r
+                }\r
+            }\r
+\r
+\r
+        }\r
     }\r
 }\r
index 9c9e0d0..d727af5 100644 (file)
@@ -629,4 +629,28 @@ public class protocolAPIHelper {
         }\r
         return ret;\r
     }\r
+\r
+    public static StringMessage getPRACTICE(){\r
+        if (is_protocol_not_Initialled()) return null;\r
+        StringMessage ret=null;\r
+        switch(Config.protocol_no)\r
+        {\r
+            case Config.PROTOCOL_JIAI:\r
+                ret=null;\r
+                break;\r
+            case Config.PROTOCOL_BEEHOME:\r
+                ret=null;\r
+                break;\r
+            case Config.PROTOCOL_IC:\r
+                ret = null;\r
+                break;\r
+            case Config.PROTOCOL_FZD:\r
+                ret=protocol_fzd.PRACTICE(Runtime.healthInfo);\r
+                break;\r
+            case Config.PROTOCOL_MQTT:\r
+                ret=null;\r
+                break;\r
+        }\r
+        return ret;\r
+    }\r
 }\r
index 1f5eff1..c4f309e 100644 (file)
@@ -12,6 +12,7 @@ import com.enqualcomm.support.CoreService;
 import com.enqualcomm.support.bean.Alarm;\r
 import com.enqualcomm.support.bean.Contact;\r
 import com.enqualcomm.support.bean.Content;\r
+import com.enqualcomm.support.bean.HealthInfo;\r
 import com.enqualcomm.support.bean.ICLocation;\r
 import com.enqualcomm.support.bean.Runtime;\r
 import com.enqualcomm.support.bean.StringMessage;\r
@@ -95,6 +96,7 @@ public class protocol_fzd {
         oxygen,//血氧上传\r
         blood,//血压上传\r
         heart,//心率上传\r
+        PRACTICE,//自由锻炼数据上传\r
         UNKNOWN_CMD,\r
     }\r
 \r
@@ -143,6 +145,7 @@ public class protocol_fzd {
         cmdMap.put(CMD_TYPE.oxygen, "oxygen");\r
         cmdMap.put(CMD_TYPE.blood, "blood");\r
         cmdMap.put(CMD_TYPE.heart, "heart");\r
+        cmdMap.put(CMD_TYPE.PRACTICE, "PRACTICE");\r
     }\r
 \r
     private Connection mConnection=null;\r
@@ -709,6 +712,13 @@ public class protocol_fzd {
         dev.getContextProxy().context.startActivity(intent);\r
     }\r
 \r
+    public static StringMessage PRACTICE(HealthInfo healthInfo){\r
+        if (healthInfo!=null && healthInfo.getInfoCount()>0)\r
+            return genFZDCMD(cmdMap.get(CMD_TYPE.PRACTICE),String.valueOf(healthInfo.getBufferDataStr()));\r
+        else\r
+            return null;\r
+    }\r
+\r
     public boolean handleCmd(CMD_TYPE type, String cmd , String data) {\r
 \r
         //普通非二进制命令用此函数处理\r
index fdaed85..aa67d5a 100644 (file)
@@ -1,2 +1,2 @@
-#Wed Sep 16 07:33:12 CST 2020\r
-VERSION_CODE=617\r
+#Thu Sep 17 17:15:58 CST 2020\r
+VERSION_CODE=618\r