From: snickersun Date: Mon, 14 Sep 2020 15:18:36 +0000 (+0800) Subject: release V615 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=bef88aff6f634d8ec5f0f7428a0dea0cbfdaed2e;p=protocol_srv.git release V615 1、通过变量persist.sys.disableNTP 控制 NTP 时间同步是否开启,默认关闭NTP。因此协议中的时间设置都实现了一遍。 主要解决时间同步造成的系统多次重置时间,使得timer相关的线程出错的问题。 2、FZD协议添加AL,LGZONE 3、CoreService LocationClient 添加每次心跳进行BLE扫描,检测是否逃逸。 --- diff --git a/app/app.iml b/app/app.iml index 10a51020..e442bebb 100644 --- a/app/app.iml +++ b/app/app.iml @@ -29,15 +29,15 @@ - - + + - + diff --git a/app/release/ICSer_V612_2009121648_release.apk b/app/release/ICSer_V615_2009142317_release.apk similarity index 78% rename from app/release/ICSer_V612_2009121648_release.apk rename to app/release/ICSer_V615_2009142317_release.apk index 11436e1c..cc3c2869 100644 Binary files a/app/release/ICSer_V612_2009121648_release.apk and b/app/release/ICSer_V615_2009142317_release.apk differ diff --git a/app/release/output.json b/app/release/output.json new file mode 100644 index 00000000..57207e6f --- /dev/null +++ b/app/release/output.json @@ -0,0 +1 @@ +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":615,"versionName":"2009142317","enabled":true,"outputFile":"ICSer_V615_2009142317_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V615_2009142317_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/Config.java b/app/src/main/java/com/enqualcomm/support/Config.java index 9fec9a41..8647020c 100644 --- a/app/src/main/java/com/enqualcomm/support/Config.java +++ b/app/src/main/java/com/enqualcomm/support/Config.java @@ -350,6 +350,30 @@ public class Config { public static boolean needTemperature_abnormal_alarm=false; public static boolean A9_noBroadCastActionStrip=false; public static boolean L004_BroadCastActionStrip=false; + public static boolean disable_ntp_server=false; + + public static void enable_NTP_Server(Context context,boolean enable){ + try { + int autotime = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME); + int autotimezone = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME_ZONE); + + ICLogger.i("get NTP Settings AutoTime "+autotime+" AutoTimeZone "+autotimezone); + + if(enable) + { + Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 1); + Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME, 1); + }else { + Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME_ZONE, 0); + Settings.Global.putInt(context.getContentResolver(), Settings.Global.AUTO_TIME, 0); + } + autotime = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME); + autotimezone = Settings.Global.getInt(context.getContentResolver(),Settings.Global.AUTO_TIME_ZONE); + ICLogger.i("get NTP Settings AutoTime "+autotime+" AutoTimeZone "+autotimezone); + } catch (Settings.SettingNotFoundException e) { + e.printStackTrace(); + } + } public static void LoadMessageConfigs(){ String tmp=Util.getSystemProperties("persist.sys.doBroadcastMSG"); boolean ret=false; @@ -358,6 +382,9 @@ public class Config { do_broadCast_message_no_indication = ret; + //默认关闭NTP + disable_ntp_server=Util.getSystemProperties("persist.sys.disableNTP","true").equals("true"); + c43_branch_name=Util.getSystemProperties("persist.sys.c43.branch"); if ((c43_branch_name.equals("l03")) ||(c43_branch_name.equals("l05"))){ diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index b6e26e86..6789d04d 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -560,7 +560,6 @@ public class CoreService extends Service { Config.setTemperatureTestCycle(runtime, 0); Config.setConfigInitFlag(this, 1); } - }else if (Config.custom_branch_name.equals("AK")) { if (Config.getConfigInitFlag(this)==0) { Config.setPPGTestCycle(this, 0); @@ -608,7 +607,7 @@ public class CoreService extends Service { Config.loadCustomServerAddr(this); Config.loadServerSettings(runtime); - + Config.enable_NTP_Server(this,!Config.disable_ntp_server); //初始化温度测试相关参数 @@ -993,6 +992,7 @@ public class CoreService extends Service { if (this.mKeepAlive != null) { if (connection.isServerConnected() && runtime.isServerProtocolConnected()) { this.mKeepAlive.onHeartAlarm(this.connection, this.runtime); + locationClient.triggerBLEProcess();//每次心跳检测一次BLE } else { // if (this.mKeepAlive.is_retry_time_above_limit()) { ICLogger.i("check 发送心跳包时,如果发现服务器没有响应,或者socket连接,则重新尝试连接服务器!"); diff --git a/app/src/main/java/com/enqualcomm/support/LocationClient.java b/app/src/main/java/com/enqualcomm/support/LocationClient.java index bfe9cdbb..16a6cdcf 100644 --- a/app/src/main/java/com/enqualcomm/support/LocationClient.java +++ b/app/src/main/java/com/enqualcomm/support/LocationClient.java @@ -104,7 +104,7 @@ public class LocationClient { private int preLbsCid; int preNetworkTypeNomber; - + private boolean scanBLEOnly=false; private static LocationClient gLocationCline=null; // private BroadcastReceiver screenOnReceiver = new BroadcastReceiver() { @@ -141,14 +141,32 @@ public class LocationClient { } ICLogger.i("Bt Dev Is in Area " + runtime.bleInfo.is_in_area); - if (runtime.bleInfo.is_in_area == false) { - ICLogger.i("BT 不在区域内,开启定位流程"); - startLocationProcess(runtime.getLocationInstance().getWorkingMod()); - }else{ - ICLogger.i("BT 在区域内,直接发送区域坐标即可!"); - StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime); - Deliver.sendLocationMSG(AP01_CMD); + if(scanBLEOnly==true){ + if (runtime.bleInfo.is_in_area == false ) { + runtime.updateFZDDevStatusEscape(true); + if ( runtime.bleInfo.last_is_in_area==true) { + //只有上一次在区域内,这次出区域才需要报警 + StringMessage AL_CMD = protocolAPIHelper.getWarningMSG(runtime); + Deliver.sendLocationMSG(AL_CMD); + } + } + }else { + if (runtime.bleInfo.is_in_area == false) { + ICLogger.i("BT 不在区域内,开启定位流程"); + startLocationProcess(runtime.getLocationInstance().getWorkingMod()); + } else { + ICLogger.i("BT 在区域内,直接发送区域坐标即可!"); + runtime.updateFZDDevStatusEscape(false); + StringMessage AP01_CMD = protocolAPIHelper.getGPSLocationMSG(runtime); + Deliver.sendLocationMSG(AP01_CMD); + } } + + //处理过此次数据后,把当前状态赋值给上次检测状态 + runtime.bleInfo.last_is_in_area=runtime.bleInfo.is_in_area; + //扫描结束就清掉scanBLEOnly,保证下次不会被误操作。 + scanBLEOnly=false; + } }); gLocationCline=this; @@ -221,6 +239,10 @@ public class LocationClient { mhandler.sendEmptyMessage(msgWhat_StartLocationProcess); } + public void triggerBLEProcess(){ + mhandler.sendEmptyMessage(msgWhat_StartBLEProcess); + } + public void triggerSOSLocationProcess(){ mhandler.sendEmptyMessage(msgWhat_StartSOSLocationProcess); } @@ -309,6 +331,7 @@ public class LocationClient { private final static int msgWhat_WaitAndSendLocation=100; private final static int msgWhat_StartLocationProcess=0; + private final static int msgWhat_StartBLEProcess=1; private final static int msgWhat_StartSOSLocationProcess=2; Handler mhandler=new Handler(){ @@ -318,15 +341,20 @@ public class LocationClient { Single.just(null).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1() { public void call(Object param1Object) { waitAndSendLocation(); } }); - }else if (msg.what == msgWhat_StartLocationProcess){ - if (runtime.bleInfo.btMacList.size()>0){ + }else if (msg.what == msgWhat_StartLocationProcess) { + if (runtime.bleInfo.btMacList.size() > 0) { //有蓝牙搜索要求则 先进行蓝牙扫描 btHelper.scanBLE(); - }else{ + } else { //没有蓝牙搜索要求,就正常定位 startLocationProcess(runtime.getLocationInstance().getWorkingMod()); } - + }else if (msg.what == msgWhat_StartBLEProcess){ + if (runtime.bleInfo.btMacList.size() > 0) { + //有蓝牙搜索要求则 先进行蓝牙扫描 + scanBLEOnly=true; + btHelper.scanBLE(); + } }else if (msg.what == msgWhat_StartSOSLocationProcess){ startSOSLocation=true;//启动SOS定位,为了快速响应,只要wifi定位即可。 forceLocation=1; @@ -625,6 +653,8 @@ public void updateCellInfo() { return; } noMove=runtime.getLastStepCount() == runtime.getTotalStepCount(); + runtime.updateFZDDevStatusMoving(!noMove); //设置当前运动状态 + // 不强制定位 且 WorkingMod 不是紧急模式,且 没有移动过 if ( ( forceLocation != 1 ) && ( mod != ICLocation.REALTIME_MOD )&& diff --git a/app/src/main/java/com/enqualcomm/support/bean/BLEInfo.java b/app/src/main/java/com/enqualcomm/support/bean/BLEInfo.java index 7f09f530..09d8b7e7 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/BLEInfo.java +++ b/app/src/main/java/com/enqualcomm/support/bean/BLEInfo.java @@ -11,6 +11,6 @@ public class BLEInfo { public String gps_n=""; public String gps_e=""; public boolean is_in_area=false; - + public boolean last_is_in_area=false; } diff --git a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java index bdd03f35..33be5291 100644 --- a/app/src/main/java/com/enqualcomm/support/bean/Runtime.java +++ b/app/src/main/java/com/enqualcomm/support/bean/Runtime.java @@ -146,12 +146,6 @@ public class Runtime { language=_language; } - private String alarmType="00"; - public String getAlarmType(){ - return alarmType; - } - - //0 代表没有出围栏,如果出围栏则置1,每次报警再加1 @@ -181,18 +175,33 @@ public class Runtime { ALARM_TEMP_HIGH, ALARM_TEMP_LOW, ALARM_POWER_OFF, + ALARM_ESCAPE, ALARM_NONE, }; private AlarmType g_alarm=AlarmType.ALARM_NONE; -/*** + + private String alarmType="00"; + public String getAlarmType(){ + return alarmType; + } + + //32 bit 数据 + private int fzdDevStatus=0x00000000; + + + /*** * 00为报警状态,00为无任何报警(01:SOS,02:低电,03:脱落报警,04:佩戴提醒,05:剪断报警,06:跌倒报警, * 07:心率异常, 08:心率过高, 09:心率过低,10:收缩压过高,11:收缩压过低,12:舒张压过高,13:舒张压过低, - * 14:久坐提醒,15:非法解锁(剪断报警),16:锁定提醒(佩戴提醒),17:体温过高,18体温过低) + * 14:久坐提醒,15:非法解锁(剪断报警),16:锁定提醒(佩戴提醒),17:体温过高,18体温过低) 19 关机事件(非服务器指令关机), 20,escape逃跑事件(离开蓝牙管控范围) */ public void setAlarmType(AlarmType alarm){ // if ( !fall && !lowbattery && !sos && antioff) g_alarm=alarm; + + //同时更新防走丢设备状态标志 + setFZDDevStatus(alarm); + switch (alarm){ case ALARM_SOS: alarmType="01"; @@ -261,7 +270,11 @@ public class Runtime { alarmType="18"; break; case ALARM_POWER_OFF: + alarmType="19"; + break; case ALARM_NONE: + alarmType="20"; + break; default: alarmType="00"; break; @@ -269,6 +282,157 @@ public class Runtime { } + + /*** + * 终端状态 00000000 ( 16 进 + * 制) 用二进制字符串表示为 + * 0000 0000 0000 0010 0000 0000 0000 0000 含义如下: + * 左边高 16bit 表示报警,右边低 16bit 表示状态. Bit 位(0 开始) 含义(1 有效) + * 0低电状态 00000000000000000000000000000001 0x00000001 + * 1出围栏状态(目前没用到) 00000000000000000000000000000010 0x00000002 + * 2进围栏状态(目前没用到) 00000000000000000000000000000100 0x00000004 + * 3手环戴上取下状态 (佩戴检测) 00000000000000000000000000001000 0x00000008 + * 4手表运行静止状态 00000000000000000000000000010000 0x00000010 + * 16SOS 报警 00000000000000010000000000000000 0x00010000 + * 17低电报警 00000000000000100000000000000000 0x00020000 + * 18出围栏报警(逃跑出蓝牙监控范围) 00000000000001000000000000000000 0x00040000 + * 19进围栏报警(目前没用到) 00000000000010000000000000000000 0x00080000 + * 20手环拆除报警 (表带剪断) 00000000000100000000000000000000 0x00100000 + * 21跌倒报警 00000000001000000000000000000000 0x00200000 + * 22震动报警 00000000010000000000000000000000 0x00400000 + * 23断电报警 (手表关机报警) 00000000100000000000000000000000 0x00800000 + * 24心率骤降报警 00000001000000000000000000000000 0x01000000 + * 25车辆启动 (手表用不到) 00000010000000000000000000000000 0x02000000 + * 比如 00200010,即表示00000000001000000000000000010000 + * 这个项目需要支持防拆 20、00000000000100000000000000000000 0x 00100000 1048576 + * 低电 17、00000000000000100000000000000000 0x 00020000 131072 + * 离线 23、00000000100000000000000000000000 0x 00800000 8388608 + * 逃逸报警 18\ 00000000000001000000000000000000 0x 00040000 262144 + * 分别是第四位为 1,第 21 位为 1,对应 21 位是跌倒报警 + * @param runtime + * @return + */ + public String getFZDDevStatus(Runtime runtime) { + StringBuilder sb = new StringBuilder(); + sb.append(Integer.toHexString(runtime.fzdDevStatus)); + if (sb.length() <8) { + for (int i=0;i< 8-sb.length();i++) + sb.insert(0, '0'); // pad with leading zero if needed + } + String hex = sb.toString(); + return hex; + } + + + public void updateFZDDevStatusLowbat(boolean lowbattery){ + + if(lowbattery){ + fzdDevStatus&=0x00000001; + }else{ + fzdDevStatus&=~0x00000001; + } + } + public void updateFZDDevStatusWeared(boolean weared) { + if(weared){ + fzdDevStatus&=0x00000008; + }else{ + fzdDevStatus&=~0x00000008; + } + } + + public void updateFZDDevStatusMoving(boolean moving) { + if(moving){ + fzdDevStatus&=~0x00000010; + }else{ + fzdDevStatus&=0x00000010; + } + } + + public void updateFZDDevStatusEscape(boolean escape){ + if(escape){ + fzdDevStatus&=0x00040000; + }else{ + fzdDevStatus&=~0x00040000; + } + + } + + public void setFZDDevStatus(AlarmType _alarmType){ + + switch (_alarmType){ + case ALARM_SOS: + fzdDevStatus&=0x00010000; + break; + case ALARM_LOWBATTERY: + fzdDevStatus&=0x00020000; + break; + case ALARM_ANTIOFF: +// fzdDevStatus&=0x00000008; + updateFZDDevStatusWeared(false); + break; + case ALARM_WEARED: + updateFZDDevStatusWeared(true); +// fzdDevStatus&=~0x00000008; + break; + case ALARM_LOCK_WATCH: + fzdDevStatus&=~0x00100000; + break; + case ALARM_CUTOFF: + case ALARM_ILLEGAL_CUTOFF: + fzdDevStatus&=0x00100000; + break; + case ALARM_FALL: + fzdDevStatus&=0x00200000; + break; + case ALARM_ABNORMAL_HEART_RATE: + fzdDevStatus&=0x01000000; + break; + case ALARM_HEART_RATE_HIGH: +// alarmType1="08"; + break; + + case ALARM_HEART_RATE_LOW: +// alarmType1="09"; + break; + + case ALARM_BPH_HIGH: +// alarmType1="10"; + break; + + case ALARM_BPH_LOW: +// alarmType1="11"; + break; + + case ALARM_BPL_HIGH: +// alarmType1="12"; + break; + + case ALARM_BPL_LOW: +// alarmType1="13"; + break; + case ALARM_SEDENTARY: +// alarmType1="14"; + break; + case ALARM_TEMP_HIGH: +// alarmType1="17"; + break; + case ALARM_TEMP_LOW: +// alarmType1="18"; + break; + case ALARM_POWER_OFF: + fzdDevStatus&=0x00800000; + break; + + case ALARM_ESCAPE: + updateFZDDevStatusEscape(true); + break; + case ALARM_NONE: + default: +// alarmType1="00000000"; + break; + } + + } public String preCdmaInfo; public String preCellInfo; @@ -428,7 +592,10 @@ public class Runtime { public void setBattery(String paramString) { this.battery = paramString; } - public void setBatteryLow(boolean paramBoolean) { this.batteryLow = paramBoolean; } + public void setBatteryLow(boolean paramBoolean) { + this.batteryLow = paramBoolean; + updateFZDDevStatusLowbat(batteryLow); //设置batterylow Alarm + } public void setBatterychanging(boolean paramBoolean) { this.batterychanging = paramBoolean; } @@ -682,118 +849,6 @@ public class Runtime { return sb.toString(); } - public String fzdAlarmStatus="00000000"; - - - /*** - * 终端状态 00000000 ( 16 进 - * 制) 用二进制字符串表示为 - * 0000 0000 0000 0010 0000 0000 0000 0000 含义如下: - * 左边高 16bit 表示报警,右边低 16bit 表示状态. Bit 位(0 开始) 含义(1 有效) - * 0低电状态 - * 1出围栏状态(目前没用到) - * 2进围栏状态(目前没用到) - * 3手环戴上取下状态 - * 4手表运行静止状态 - * 16SOS 报警 - * 17低电报警 - * 18出围栏报警(目前没用到) - * 19进围栏报警(目前没用到) - * 20手环拆除报警 - * 21跌倒报警 - * 22震动报警 - * 23断电报警 - * 24心率骤降报警 - * 25车辆启动 - * 比如 00200010,即表示00000000001000000000000000010000 - * 这个项目需要支持防拆 20、00000000000100000000000000000000 0x 00100000 1048576 - * 低电 17、00000000000000100000000000000000 0x 00020000 131072 - * 离线 23、00000000100000000000000000000000 0x 00800000 8388608 - * 逃逸报警 18\ 00000000000001000000000000000000 0x 00040000 262144 - * 分别是第四位为 1,第 21 位为 1,对应 21 位是跌倒报警 - * @param runtime - * @return - */ - public String getFZDDevStatus(Runtime runtime){ - String alarmType1="00000000"; - switch (runtime.g_alarm){ - case ALARM_SOS: - // alarmType1="01"; - break; - case ALARM_LOWBATTERY: - alarmType1="00020000"; - break; - case ALARM_ANTIOFF: -// alarmType1="00100000"; - break; - case ALARM_WEARED: -// alarmType1="04"; - break; - case ALARM_CUTOFF: - alarmType1="00100000"; - break; - case ALARM_FALL: -// alarmType1="06"; - break; - - case ALARM_ABNORMAL_HEART_RATE: -// alarmType1="07"; - break; - - case ALARM_HEART_RATE_HIGH: -// alarmType1="08"; - break; - - case ALARM_HEART_RATE_LOW: -// alarmType1="09"; - break; - - case ALARM_BPH_HIGH: -// alarmType1="10"; - break; - - case ALARM_BPH_LOW: -// alarmType1="11"; - break; - - case ALARM_BPL_HIGH: -// alarmType1="12"; - break; - - case ALARM_BPL_LOW: -// alarmType1="13"; - break; - - case ALARM_SEDENTARY: -// alarmType1="14"; - break; - - case ALARM_ILLEGAL_CUTOFF: -// alarmType1="15"; - break; - - case ALARM_LOCK_WATCH: -// alarmType1="16"; - break; - - case ALARM_TEMP_HIGH: -// alarmType1="17"; - break; - - case ALARM_TEMP_LOW: -// alarmType1="18"; - break; - case ALARM_POWER_OFF: - alarmType1="00800000"; - break; - case ALARM_NONE: - default: -// alarmType1="00000000"; - break; - } - fzdAlarmStatus=alarmType1; - return fzdAlarmStatus; - } public String getGPSHeading(){ int headingi=(int)gpsp.getLocation().heading; int headingl=(int) ((gpsp.getLocation().heading - headingi)*100); diff --git a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java index 2024d917..ddaeeee9 100644 --- a/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java +++ b/app/src/main/java/com/enqualcomm/support/service/KeepAlive.java @@ -7,6 +7,7 @@ import android.content.IntentFilter; import android.os.Handler; //import com.eiot.watch_lib.LauncherCtrl; +import com.enqualcomm.support.Config; import com.enqualcomm.support.CoreService; import com.enqualcomm.support.LocationClient; import com.ic.protocols.protocolAPIHelper; @@ -125,8 +126,19 @@ public class KeepAlive extends AbstractConnectionService { @Override public void run() { connection.send(protocolAPIHelper.getBindingMSG(mRuntime)); + + if (Config.protocol_no==Config.PROTOCOL_FZD){ + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + connection.send(protocolAPIHelper.getSyncTimeMSG(mRuntime)); + } + },1000); + } } },1000); + + } else { connection.send(protocolAPIHelper.getLoginMSG(mRuntime)); } @@ -151,10 +163,10 @@ public class KeepAlive extends AbstractConnectionService { // } scheduled.setContinueExistingPeriodicTasksAfterShutdownPolicy(true); scheduled.setExecuteExistingDelayedTasksAfterShutdownPolicy(false); - scheduled.setRemoveOnCancelPolicy(true); +// scheduled.setRemoveOnCancelPolicy(true); ICLogger.i("Wait for thread pool getContinueExistingPeriodicTasksAfterShutdownPolicy " +scheduled.getContinueExistingPeriodicTasksAfterShutdownPolicy()+ - "\ngetExecuteExistingDelayedTasksAfterShutdownPolicy "+scheduled.getExecuteExistingDelayedTasksAfterShutdownPolicy()+ - "\ngetRemoveOnCancelPolicy "+scheduled.getRemoveOnCancelPolicy()); + "\ngetExecuteExistingDelayedTasksAfterShutdownPolicy "+scheduled.getExecuteExistingDelayedTasksAfterShutdownPolicy());//+ +// "\ngetRemoveOnCancelPolicy "+scheduled.getRemoveOnCancelPolicy()); // while(!scheduled.isTerminated()) // { // StringBuilder sb=new StringBuilder(); @@ -301,12 +313,21 @@ public class KeepAlive extends AbstractConnectionService { //发送心跳包 connection.send(protocolAPIHelper.getHeartbeatMSG(paramRuntime)); //发送完心跳后,开始检查服务器响应 - new Handler().postDelayed(new Runnable() { - @Override - public void run() { - connection.send(protocolAPIHelper.getBindingMSG(mRuntime)); - } - },1000); +// new Handler().postDelayed(new Runnable() { +// @Override +// public void run() { +// connection.send(protocolAPIHelper.getBindingMSG(mRuntime)); +// } +// },1000); +// +// if (Config.protocol_no==Config.PROTOCOL_FZD){ +// new Handler().postDelayed(new Runnable() { +// @Override +// public void run() { +// connection.send(protocolAPIHelper.getSyncTimeMSG(mRuntime)); +// } +// },2000); +// } startResponseCheckTimer(); @@ -355,8 +376,17 @@ public class KeepAlive extends AbstractConnectionService { @Override public void run() { connection.send(protocolAPIHelper.getBindingMSG(mRuntime)); + if (Config.protocol_no==Config.PROTOCOL_FZD){ + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + connection.send(protocolAPIHelper.getSyncTimeMSG(mRuntime)); + } + },1000); + } } },1000); + startResponseCheckTimer(); } },3500); @@ -374,14 +404,15 @@ public class KeepAlive extends AbstractConnectionService { public void onReceive(Context param1Context, Intent param1Intent) { boolean bool = param1Intent.getBooleanExtra("reboot", false); ICLogger.i("Shutdown Received! reboot="+bool); - if (KeepAlive.this.mRuntime.getBatteryLow() && !KeepAlive.this.mRuntime.getBatterychanging() && !bool && !KeepAlive.this.mRuntime.isShutdown()/*不是服务器让关闭的*/){ - - if (KeepAlive.this.mRuntime.getBatteryLow()){ - KeepAlive.this.mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); + if (KeepAlive.this.mRuntime.getBatteryLow() && !KeepAlive.this.mRuntime.getBatterychanging() && !bool && !KeepAlive.this.mRuntime.isShutdown()){ + /*电量低,没有充电,且不是服务器让关闭的*/ +// if (KeepAlive.this.mRuntime.getBatteryLow()){ +// KeepAlive.this.mRuntime.setAlarmType(Runtime.AlarmType.ALARM_LOWBATTERY); + KeepAlive.this.mRuntime.setAlarmType(Runtime.AlarmType.ALARM_POWER_OFF); KeepAlive.this.connection.send(protocolAPIHelper.getWarningMSG(KeepAlive.this.mRuntime)); ICLogger.i("Shutdown Received! send AP10 !"); - } +// } } diff --git a/app/src/main/java/com/ic/protocols/protocolAPIHelper.java b/app/src/main/java/com/ic/protocols/protocolAPIHelper.java index adf5d763..9c9e0d0e 100644 --- a/app/src/main/java/com/ic/protocols/protocolAPIHelper.java +++ b/app/src/main/java/com/ic/protocols/protocolAPIHelper.java @@ -107,7 +107,6 @@ public class protocolAPIHelper { } return ret; } - public static StringMessage getBindingMSG(Runtime runtime){ if (is_protocol_not_Initialled()) return null; StringMessage ret=null; @@ -131,6 +130,29 @@ public class protocolAPIHelper { } return ret; } + public static StringMessage getSyncTimeMSG(Runtime runtime){ + if (is_protocol_not_Initialled()) return null; + StringMessage ret=null; + switch(Config.protocol_no) + { + case Config.PROTOCOL_JIAI: + ret=null; + break; + case Config.PROTOCOL_BEEHOME: + ret=null; + break; + case Config.PROTOCOL_IC: + ret=null; + break; + case Config.PROTOCOL_FZD: + ret=protocol_fzd.LGZONE(runtime); + break; + case Config.PROTOCOL_MQTT: + ret=null; + break; + } + return ret; + } public static StringMessage getTemperatureMSG(double temp_adusted,double body_temp,Runtime runtime){ if (is_protocol_not_Initialled()) return null; @@ -186,7 +208,7 @@ public class protocolAPIHelper { ret=protocol_ic.AP10(runtime); break; case Config.PROTOCOL_FZD: - ret=null; + ret=protocol_fzd.AL(runtime); break; case Config.PROTOCOL_MQTT: ret=protocol_mqtt.AL(runtime); diff --git a/app/src/main/java/com/ic/protocols/protocol_fzd.java b/app/src/main/java/com/ic/protocols/protocol_fzd.java index 936901db..1f5eff12 100644 --- a/app/src/main/java/com/ic/protocols/protocol_fzd.java +++ b/app/src/main/java/com/ic/protocols/protocol_fzd.java @@ -28,6 +28,7 @@ import com.enqualcomm.support.utils.regexUtil; import java.io.File; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import chestnut.utils.PhoneUtils; @@ -58,7 +59,7 @@ public class protocol_fzd { UD,//位置上传 UD2,//盲点位置上传 AL,//报警数据上传 - Time,//获取服务器时间 + LGZONE,//获取服务器时区时间 WT,//获取天气 img,//上传图片 VOICE,//上传语音 @@ -107,7 +108,7 @@ public class protocol_fzd { cmdMap.put(CMD_TYPE.UD, "UD"); cmdMap.put(CMD_TYPE.UD2, "UD2"); cmdMap.put(CMD_TYPE.AL, "AL"); - cmdMap.put(CMD_TYPE.Time, "Time"); + cmdMap.put(CMD_TYPE.LGZONE, "LGZONE"); cmdMap.put(CMD_TYPE.WT, "WT"); cmdMap.put(CMD_TYPE.img, "img"); cmdMap.put(CMD_TYPE.VOICE, "VOICE"); @@ -370,6 +371,52 @@ public class protocol_fzd { } + + public static StringMessage LGZONE(Runtime runtime) { + return genFZDCMD(cmdMap.get(CMD_TYPE.LGZONE)); + } + public void handleLGZONE(Runtime runtime, String data){ + + /*** + * 平台回复:[XT*YYYYYYYYYYYYYYY*LEN*LGZONE,时区,时间,日期] + * 实例: [XT*1234567890*001D*LGZONE,+8,08:00:00,2016-01-12] + */ + String[] list=data.split(CMDSPLIT); + if (list.length==4){ + String timeZone=list[1].trim(); + String date=list[3].trim(); + String time=list[2].trim(); + Date datetime= TimeUtil.parseDatetiime(date,time); + + int timezone; + try + { + timezone=Integer.parseInt(timeZone.replace("+","").trim()); + }catch (Exception e){ + ICLogger.e("timezone",e); + timezone=8; + } + + if (datetime!=null){ + ICLogger.i("==="+timezone+" "+TimeUtil.getDefaultTimeZone()); + TimeUtil.setTimeZone(timezone); + + + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + TimeUtil.setSysDateTime(runtime.getContextProxy().context,datetime,timezone); + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + } +// Set Datetime 20200505112734 +// Set TimeZone 8 + + }else{ + ICLogger.i("LGZONE Format Error!"); + } + + + } + + /*LBS+GPS混合定位*/ public static StringMessage UD(Runtime runtime) { /*** @@ -470,8 +517,21 @@ public class protocol_fzd { * 实例:[IC*334588000000156*0002*AL] * 说明:终端产生警情后发送报警信息到平台,若终端没有收到回复,则定时上报直到收到报警确认为止. */ - return null; + StringBuilder sb=new StringBuilder(); + String cmd=cmdMap.get(CMD_TYPE.AL); + sb.append(TimeUtil.getSystemDateYYMMDD()).append(CMDSPLIT) + .append(TimeUtil.getSystemTimeHHmmss()).append(CMDSPLIT) + .append(runtime.getFZDGPSData()).append(CMDSPLIT) + .append(String.format("%03d",abs(runtime.getSignalStrength()))).append(CMDSPLIT) + .append(runtime.getBattery()).append(CMDSPLIT) + .append(runtime.getTotalStepCount()).append(CMDSPLIT) + .append(runtime.getRolltimes()).append(CMDSPLIT) + .append(runtime.getFZDDevStatus(runtime)).append(CMDSPLIT) + .append(runtime.getFZDLBSMultiStationData()).append(CMDSPLIT) + .append(runtime.getFZDWifiData()); + + return genFZDCMD(cmd,sb.toString()); } public static StringMessage UPLOAD(){ @@ -783,6 +843,10 @@ public class protocol_fzd { ICLogger.i("服务器收到上传的心率heart"); mConnection.DeliverCMDMessageToSystem("heart",cmd);//通知下面线程状态变化 break; + case LGZONE: + ICLogger.i("收到服务器时间 LGZONE "+data); + handleLGZONE(mRuntime,data); + break; // case BP84: // handleBP84(cmd,mConnection); // ICLogger.i("收到服务器白名单命令"); diff --git a/app/src/main/java/com/ic/protocols/protocol_ic.java b/app/src/main/java/com/ic/protocols/protocol_ic.java index 31a9d40f..74e63f61 100644 --- a/app/src/main/java/com/ic/protocols/protocol_ic.java +++ b/app/src/main/java/com/ic/protocols/protocol_ic.java @@ -29,6 +29,7 @@ import com.enqualcomm.support.utils.WakeLockUtil; import java.io.File; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import static com.enqualcomm.support.Constants.ACTION_HEATR_RATE_START; @@ -397,18 +398,18 @@ public class protocol_ic { log("handleBP00", "Set Datetime " + msg[1]); log("handleBP00", "Set TimeZone " + msg[2]); -// Date datetime= TimeUtil.parseDatetiime(msg[1]); -// int timezone=Integer.parseInt(msg[2]); -// if (datetime!=null){ -// ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); -// TimeUtil.setTimeZone(timezone); -// -// -// ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); -// TimeUtil.setSysDateTime(runtime.getContextProxy().context,datetime,timezone); -// ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); -// -// } + Date datetime= TimeUtil.parseDatetiime(msg[1]); + int timezone=Integer.parseInt(msg[2]); + if (datetime!=null){ + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + TimeUtil.setTimeZone(timezone); + + + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + TimeUtil.setSysDateTime(runtime.getContextProxy().context,datetime,timezone); + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + + } // Set Datetime 20200505112734 // Set TimeZone 8 @@ -2257,10 +2258,11 @@ public class protocol_ic { public boolean handleCmd(CMD_TYPE type, String cmd) { - //普通非二进制命令用此函数处理 + //普通非二进制命令用此函数处理 boolean ret=true; ICLogger.i("handleCmd "+type.name() + " strLen="+cmd.length()); if (Config.LOG_TOFILE)ICLogger.logToFile("APILog", " recv " + cmd); + cmd=cmd.replace(" ",""); switch (type){ case BP00: //登录包 handleBP00(mRuntime,cmd); diff --git a/app/src/main/java/com/ic/protocols/protocol_jiai.java b/app/src/main/java/com/ic/protocols/protocol_jiai.java index 2914c90f..c2e55c97 100644 --- a/app/src/main/java/com/ic/protocols/protocol_jiai.java +++ b/app/src/main/java/com/ic/protocols/protocol_jiai.java @@ -332,18 +332,18 @@ public class protocol_jiai { log("handleBP00", "Set Datetime " + msg[1]); log("handleBP00", "Set TimeZone " + msg[2]); -// Date datetime= TimeUtil.parseDatetiime(msg[1]); -// int timezone=Integer.parseInt(msg[2]); -// if (datetime!=null){ -// ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); -// TimeUtil.setTimeZone(timezone); -// -// -// ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); -// TimeUtil.setSysDateTime(runtime.getContextProxy().context,datetime,timezone); -// ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); -// -// } + Date datetime= TimeUtil.parseDatetiime(msg[1]); + int timezone=Integer.parseInt(msg[2]); + if (datetime!=null){ + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + TimeUtil.setTimeZone(timezone); + + + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + TimeUtil.setSysDateTime(runtime.getContextProxy().context,datetime,timezone); + ICLogger.i("==="+TimeUtil.getDefaultTimeZone()); + + } // Set Datetime 20200505112734 // Set TimeZone 8 diff --git a/app/version_code.properties b/app/version_code.properties index a2a48174..13498fa4 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Sat Sep 12 16:48:19 CST 2020 -VERSION_CODE=612 +#Mon Sep 14 23:17:08 CST 2020 +VERSION_CODE=615