1509 盲点补传先传新数据再传历史数据,只补当天数据,跨天数据不用补传;
authorTrillGates <williamtrillgates@gmail.com>
Wed, 13 Oct 2021 07:02:28 +0000 (15:02 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Wed, 13 Oct 2021 07:02:28 +0000 (15:02 +0800)
app/src/main/java/com/enqualcomm/support/Config.java
app/src/main/java/com/enqualcomm/support/ICSmsManager.java
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/utils/DBHelper.java
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_beehome.java

index cd6e827..ce1649e 100644 (file)
@@ -45,7 +45,7 @@ public class Config {
     public static int HeartBeatAlarmCycle = 5;
 
     //如果重试都失败,则丢弃命令不进行盲点续传
-    public static boolean discard_cmd_after_retryfailed = true;
+    public static boolean discard_cmd_after_retry_failed = true;
 
     public static boolean enableDataRoaming = false;
 
index 031f875..80657f8 100644 (file)
@@ -1190,7 +1190,6 @@ public class ICSmsManager extends BroadcastReceiver {
                 }, 5000);
             }
         } else if (cmd.startsWith("testCMDRecords")) {
-
             if (CoreService.getInstance() != null) {
                 StringMessage msg = protocolAPIHelper.getLBSLocationMSG(runtime);
                 runtime.getDbHelper().insertCMDRecord(msg);
index f217030..582dc7e 100644 (file)
@@ -1,16 +1,11 @@
 package com.enqualcomm.support.service;
 
-import android.app.AlarmManager;
-import android.app.PendingIntent;
-import android.content.BroadcastReceiver;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.Intent;
-import android.net.ConnectivityManager;
 import android.net.Uri;
 import android.net.wifi.WifiConfiguration;
 import android.net.wifi.WifiManager;
-import android.os.Build;
 import android.os.Handler;
 import android.os.HandlerThread;
 import android.os.PowerManager;
@@ -30,7 +25,6 @@ import com.enqualcomm.support.provider.FZDMessageProvider;
 import com.enqualcomm.support.service.base.AbstractConnectionService;
 import com.enqualcomm.support.utils.AESCipher;
 import com.enqualcomm.support.utils.Connection;
-import com.enqualcomm.support.utils.FileCache;
 import com.enqualcomm.support.utils.ICLogger;
 import com.enqualcomm.support.utils.NettyConnection;
 import com.enqualcomm.support.utils.SharePreferenceUtil;
@@ -41,11 +35,8 @@ import com.enqualcomm.support.utils.Util;
 import com.ic.protocols.protocolAPIHelper;
 
 import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.ReentrantLock;
 
-import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
-import static com.enqualcomm.support.Constants.ACTION_WAKEUP_ALARM;
 import static com.enqualcomm.support.Constants.DIALOG_ACTION;
 import static com.enqualcomm.support.Constants.FROM_SERVER;
 import static com.enqualcomm.support.bean.Contact.CATEGORY_GROUP;
@@ -141,22 +132,22 @@ public class Deliver extends AbstractConnectionService {
     private static int CheckCount = 0;
 
     private static boolean checkNeedServerResponse(StringMessage cmd) {
-        return false;
-//        boolean NeedCheckServerResponse;
-//        if (cmd != null &&
-//                Config.protocol_no == Config.PROTOCOL_FZD &&
-//                (protocolAPIHelper.isCmdStr(cmd).equals("UD")
-//                        || protocolAPIHelper.isCmdStr(cmd).equals("UD2"))
-//        ) {
-//            NeedCheckServerResponse = false;
-//        } else if (cmd != null &&
-//                Config.protocol_no == Config.PROTOCOL_FZD &&
-//                (protocolAPIHelper.isCmdStr(cmd).equals("AP10"))) {
-//            NeedCheckServerResponse = false;
-//        } else {
-//            NeedCheckServerResponse = true;
-//        }
-//        return NeedCheckServerResponse;
+//        return false;
+        boolean NeedCheckServerResponse;
+        if (cmd != null &&
+                Config.protocol_no == Config.PROTOCOL_FZD &&
+                (protocolAPIHelper.isCmdStr(cmd).equals("UD")
+                        || protocolAPIHelper.isCmdStr(cmd).equals("UD2"))
+        ) {
+            NeedCheckServerResponse = false;
+        } else if (cmd != null &&
+                Config.protocol_no == Config.PROTOCOL_FZD &&
+                (protocolAPIHelper.isCmdStr(cmd).equals("AP10"))) {
+            NeedCheckServerResponse = false;
+        } else {
+            NeedCheckServerResponse = true;
+        }
+        return NeedCheckServerResponse;
     }
 
     public static void dumpMessage(StringMessage msg) {
@@ -184,12 +175,15 @@ public class Deliver extends AbstractConnectionService {
             ICLogger.i("queue locked " + mLock.isLocked() +
                     "  current Thread is == > "
                     + Thread.currentThread().getName());
-            if (mLock.isLocked()) return false;
+            if (mLock.isLocked()) {
+                return false;
+            }
             mLock.lock();
             try {
                 String str;
                 //如果没有数据从缓存中尝试读取
                 //检查刚刚发送出去的包是否需要检查server response
+                //FLAG为1的表示等待发送的指令
                 StringMessage msgWait = mRuntime.getDbHelper().queryWaitCMDRecord();
                 dumpMessage(msgWait);
                 if (msgWait != null) {
@@ -206,26 +200,27 @@ public class Deliver extends AbstractConnectionService {
                     if (CheckCount > 5) {
                         ICLogger.i("checkSrvResponse CheckCount=" + CheckCount + " Timeout or cmd is null, skip ");
                         //C5要的临时版本,去掉盲点续传。
-                        if (Config.discard_cmd_after_retryfailed) {
+                        if (Config.discard_cmd_after_retry_failed) {
                             if (msgWait.getIndex() >= 0) {
                                 //有些协议需要对盲点数据进行修改(盲点数据可能是不同的topic),在此对数据修改后更新数据库
                                 mRuntime.getDbHelper().updateCMDRecord(msgWait.getIndex(), 3);//设置为盲点不发送
                             }
                             dumpMessage(msgWait);
                         }
-                        if (Config.LOG_TOFILE)
+                        if (Config.LOG_TOFILE) {
                             ICLogger.logToFile("APILog", "response timeout skip!  ");
+                        }
                         CheckCount = 0;
-                        if (mLock != null && mLock.isLocked())
+                        if (mLock != null && mLock.isLocked()) {
                             mLock.unlock();
+                        }
                         return false;
                     }
-
                 }
 
                 StringBuilder stringBuilder = new StringBuilder();
                 StringMessage msgSent;
-                if (Config.discard_cmd_after_retryfailed) {
+                if (Config.discard_cmd_after_retry_failed) {
                     //如果可以丢弃数据,则直接查找没发送的数据即可
                     msgSent = mRuntime.getDbHelper().queryNotSentCMDRecord();
                 } else {
@@ -248,7 +243,7 @@ public class Deliver extends AbstractConnectionService {
                         if (checkNetwork()) {
                             connection.send(msgSent);
                             //如果需要CheckResponse
-                            if (checkNeedServerResponse(msgSent) == true) {
+                            if (checkNeedServerResponse(msgSent)) {
                                 ICLogger.i("checkSrvResponse " + topic + " " + cmd);
                                 mRuntime.getDbHelper().updateCMDRecord(msgSent.getIndex(), 1); //设置为等待响应
                             } else {
@@ -274,11 +269,11 @@ public class Deliver extends AbstractConnectionService {
                     //但是有些协议要求此数据 需要转变为 盲点续传数据(已经是盲点的跳过)
                     mRuntime.getDbHelper().updateCMDRecordForUD2(0, msgSent); //重发时无网络 //把UD改为UD2 保存到数据库
                 }
-
                 //ICLogger.i("\n"+queue.size()+" left in Queue!");
             } finally {
-                if (mLock != null && mLock.isLocked())
+                if (mLock != null && mLock.isLocked()) {
                     mLock.unlock();
+                }
             }
         }
         ICLogger.d("getAndSendMsgFromQueue == > ret == > " + ret);
@@ -290,7 +285,7 @@ public class Deliver extends AbstractConnectionService {
         StringMessage msgWait = mRuntime.getDbHelper().queryWaitCMDRecord();
         dumpMessage(msgWait);
         if (msgWait != null) {
-            if (Config.discard_cmd_after_retryfailed) {
+            if (Config.discard_cmd_after_retry_failed) {
                 while (msgWait != null) {
                     //所有缓存数据都设置为放弃发送
                     mRuntime.getDbHelper().updateCMDRecord(msgWait.getIndex(), 3);
index 0bf3b04..0c4e0c7 100644 (file)
@@ -1103,7 +1103,6 @@ public class DBHelper {
                     flagcontent.put("TOPIC", UD2.cmd());
                     flagcontent.put("CMD", UD2.isFromCache());
                     this.cr.update(ICContentProvider.PROTOCOL_CMD_RECORDS_URI, flagcontent, WhereClause, null);
-
                     ICLogger.d(" 更新 UD " + msg.isFromCache() + "\nto UD2 " + UD2.isFromCache());
                 } else {
                     ICLogger.e("genMissedUD2Msg failed, skip gen UD2 msg");
@@ -1120,9 +1119,9 @@ public class DBHelper {
         String WhereClause = null;
         if (id >= 0) {
             WhereClause = new StringBuilder("_id=").append(id).toString();
-            ContentValues flagcontent = new ContentValues();
-            flagcontent.put("FLAG", flag);
-            this.cr.update(ICContentProvider.PROTOCOL_CMD_RECORDS_URI, flagcontent, WhereClause, null);
+            ContentValues values = new ContentValues();
+            values.put("FLAG", flag);
+            this.cr.update(ICContentProvider.PROTOCOL_CMD_RECORDS_URI, values, WhereClause, null);
         }
     }
 
@@ -1167,7 +1166,6 @@ public class DBHelper {
                     msg.setSentFlag(flag);
                     msg.setIndex(index);
                     ICLogger.i("get cmd Record not sent  _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
-
                 }
                 cmdrecords.close();
             } else { //没有警报,就查询 UD 消息发送 //当前数据优先于 UD2数据
@@ -1235,21 +1233,17 @@ public class DBHelper {
     public StringMessage queryWaitCMDRecord() {
         ContentResolver pcr = this.cr;
         Uri table = ICContentProvider.PROTOCOL_CMD_RECORDS_URI;
-        StringBuilder where = new StringBuilder();
-        where.append("FLAG=1");
-        // ICLogger.i("Query cmdRecords "+where);
-        Cursor cmdrecords = pcr.query(table, (String[]) null, where.toString(), (String[]) null, (String) null);
+        Cursor cmdRecords = pcr.query(table, null, "FLAG=1", null, null);
         StringMessage msg = null;
-        if (cmdrecords != null) {
-            int score = 0;
-            if (cmdrecords.getCount() > 0) {
-                if (cmdrecords.moveToFirst()) {
-                    String topic = cmdrecords.getString(cmdrecords.getColumnIndex("TOPIC"));
-                    String cmd = cmdrecords.getString(cmdrecords.getColumnIndex("CMD"));
-                    String date = cmdrecords.getString(cmdrecords.getColumnIndex("DATE"));
-                    String time = cmdrecords.getString(cmdrecords.getColumnIndex("TIME"));
-                    int flag = cmdrecords.getInt(cmdrecords.getColumnIndex("FLAG"));
-                    int index = cmdrecords.getInt(cmdrecords.getColumnIndex("_id"));
+        if (cmdRecords != null) {
+            if (cmdRecords.getCount() > 0) {
+                if (cmdRecords.moveToFirst()) {
+                    String topic = cmdRecords.getString(cmdRecords.getColumnIndex("TOPIC"));
+                    String cmd = cmdRecords.getString(cmdRecords.getColumnIndex("CMD"));
+                    String date = cmdRecords.getString(cmdRecords.getColumnIndex("DATE"));
+                    String time = cmdRecords.getString(cmdRecords.getColumnIndex("TIME"));
+                    int flag = cmdRecords.getInt(cmdRecords.getColumnIndex("FLAG"));
+                    int index = cmdRecords.getInt(cmdRecords.getColumnIndex("_id"));
 
                     msg = new StringMessage(new String[]{topic});
                     msg.refresh(cmd);
@@ -1257,10 +1251,9 @@ public class DBHelper {
                     msg.setSentFlag(flag);
                     msg.setIndex(index);
                     ICLogger.i("get cmd Record wait response _id " + index + " " + date + time + " topic " + topic + " cmd " + cmd);
-
                 }
             }
-            cmdrecords.close();
+            cmdRecords.close();
 
             if (msg == null)
                 ICLogger.i("no cmd record in wait status !");
index fb0d833..6d29b6d 100644 (file)
@@ -541,7 +541,7 @@ public class protocolAPIHelper {
                 ret = protocol_jiai.AP02(runtime);
                 break;
             case Config.PROTOCOL_BEEHOME:
-                ret = protocol_beehome.AP02(runtime);
+                ret = protocol_beehome.AP01(runtime);
                 break;
             case Config.PROTOCOL_IC:
                 ret = protocol_ic.AP02(runtime);
@@ -564,8 +564,9 @@ public class protocolAPIHelper {
         }
         return ret;
     }
-    public static void sendVoice(int duration, String remoteNum, String content, String voiceId){
-        if (is_protocol_not_Initialled()) return ;
+
+    public static void sendVoice(int duration, String remoteNum, String content, String voiceId) {
+        if (is_protocol_not_Initialled()) return;
 
         switch (Config.protocol_no) {
             case Config.PROTOCOL_JIAI:
@@ -575,7 +576,7 @@ public class protocolAPIHelper {
             case Config.PROTOCOL_IC:
                 break;
             case Config.PROTOCOL_FZD:
-                protocolfzd_handler.sendVoice(duration,remoteNum,content,voiceId);
+                protocolfzd_handler.sendVoice(duration, remoteNum, content, voiceId);
                 break;
             case Config.PROTOCOL_MQTT:
 
@@ -587,13 +588,14 @@ public class protocolAPIHelper {
 
                 break;
             case Config.PROTOCOL_GATOR:
-                protocolgator_handler.sendVoicePackage(duration,remoteNum,content,voiceId);
+                protocolgator_handler.sendVoicePackage(duration, remoteNum, content, voiceId);
                 break;
         }
 
     }
+
     public static void sendPicture(String remoteNum, String imagePath, String imageId) {
-        if (is_protocol_not_Initialled()) return ;
+        if (is_protocol_not_Initialled()) return;
 
         switch (Config.protocol_no) {
             case Config.PROTOCOL_JIAI:
@@ -603,7 +605,7 @@ public class protocolAPIHelper {
             case Config.PROTOCOL_IC:
                 break;
             case Config.PROTOCOL_FZD:
-                protocolfzd_handler.sendPicture(remoteNum,imagePath,imageId);
+                protocolfzd_handler.sendPicture(remoteNum, imagePath, imageId);
                 break;
             case Config.PROTOCOL_MQTT:
 
@@ -620,7 +622,8 @@ public class protocolAPIHelper {
         }
 
     }
-    public static byte[] getVoicePacketItem(String sender,String durationHEX,String packetTime, int count, int index, int datalen, byte[] amrdata, int filetype, int datatype) {
+
+    public static byte[] getVoicePacketItem(String sender, String durationHEX, String packetTime, int count, int index, int datalen, byte[] amrdata, int filetype, int datatype) {
         byte[] ret = null;
         if (is_protocol_not_Initialled()) return null;
         switch (Config.protocol_no) {
@@ -664,7 +667,7 @@ public class protocolAPIHelper {
                 }
                 break;
             case Config.PROTOCOL_GATOR:
-                ret = protocol_gator.BP34_Raw(sender,packetTime,durationHEX,count,index,datalen,amrdata);
+                ret = protocol_gator.BP34_Raw(sender, packetTime, durationHEX, count, index, datalen, amrdata);
                 break;
         }
         return ret;
@@ -1146,6 +1149,7 @@ public class protocolAPIHelper {
 
     /**
      * 获取VideoCall 联系人列表
+     *
      * @param runtime
      * @return
      */
@@ -1183,6 +1187,7 @@ public class protocolAPIHelper {
 
     /**
      * 获取VideoCall ID
+     *
      * @param runtime
      * @return
      */
@@ -1220,12 +1225,13 @@ public class protocolAPIHelper {
 
     /**
      * 拒接VideoCall
+     *
      * @param runtime
      * @param remoteId
      * @param type
      * @return
      */
-    public static StringMessage rejectVideoCall(Runtime runtime,String remoteId, int type) {
+    public static StringMessage rejectVideoCall(Runtime runtime, String remoteId, int type) {
         if (is_protocol_not_Initialled()) return null;
         StringMessage ret = null;
         switch (Config.protocol_no) {
@@ -1256,7 +1262,8 @@ public class protocolAPIHelper {
         }
         return ret;
     }
-    public static StringMessage dialVideoCall(Runtime runtime,int type, int remoteUserId) {
+
+    public static StringMessage dialVideoCall(Runtime runtime, int type, int remoteUserId) {
         if (is_protocol_not_Initialled()) return null;
         StringMessage ret = null;
         switch (Config.protocol_no) {
@@ -1385,7 +1392,7 @@ public class protocolAPIHelper {
     }
 
     public static void updateEnvState(Runtime runtime, int state) {
-        if (is_protocol_not_Initialled()) return ;
+        if (is_protocol_not_Initialled()) return;
 
         switch (Config.protocol_no) {
             case Config.PROTOCOL_JIAI:
@@ -1398,7 +1405,7 @@ public class protocolAPIHelper {
 
                 break;
             case Config.PROTOCOL_FZD:
-                 protocolfzd_handler.updateEnvState(state);
+                protocolfzd_handler.updateEnvState(state);
                 break;
             case Config.PROTOCOL_MQTT:
 
index 1b152cd..e53b368 100644 (file)
@@ -2085,7 +2085,6 @@ public class protocol_beehome {
                 ICLogger.i("服务器收到心跳包AP03");
                 mConnection.DeliverCMDMessageToSystem("heartbeat", cmd);//通知下面线程状态变化
                 break;
-
             case BP07:
                 //收到发送的语音包
                 handleBP07(cmd, mConnection);