release ICProtocol8.1_V909_2108140014_release.apk
authorsnickersun <snickersun@qq.com>
Fri, 13 Aug 2021 17:52:51 +0000 (01:52 +0800)
committersnickersun <snickersun@qq.com>
Fri, 13 Aug 2021 17:52:51 +0000 (01:52 +0800)
修改fzd协议 parserCmd函数,保证buffer都能被解析到

app/release/ICProtocol8.1_V909_2108140014_release.apk [moved from app/release/ICSer_V766_2103192133_release.apk with 74% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/Constants.java
app/src/main/java/com/enqualcomm/support/MainActivity.java
app/src/main/java/com/enqualcomm/support/utils/CellInfoUtil.java
app/src/main/java/com/enqualcomm/support/utils/regexUtil.java
app/src/main/java/com/ic/protocols/protocol_fzd.java
app/version_code.properties

similarity index 74%
rename from app/release/ICSer_V766_2103192133_release.apk
rename to app/release/ICProtocol8.1_V909_2108140014_release.apk
index a0b9f2e..9974f1c 100644 (file)
Binary files a/app/release/ICSer_V766_2103192133_release.apk and b/app/release/ICProtocol8.1_V909_2108140014_release.apk differ
index 9e23c21..16848de 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":908,"versionName":"2108061814","enabled":true,"outputFile":"ICProtocol8.1_V908_2108061814_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol8.1_V908_2108061814_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":909,"versionName":"2108140014","enabled":true,"outputFile":"ICProtocol8.1_V909_2108140014_release.apk","fullName":"release","baseName":"release"},"path":"ICProtocol8.1_V909_2108140014_release.apk","properties":{}}]
\ No newline at end of file
index 925c67c..79630ee 100644 (file)
@@ -79,7 +79,7 @@ public interface Constants {
 
     String ACTION_SEND_EMEGENCY_LOCATION_START = "action.emegency.location.start";
     String ACTION_SEND_EMEGENCY_LOCATION_STOP = "action.emegency.location.stop";
-    String ACTION_LOCAL_SOS_ACTION = "com.enqualcomm.support.local_sos";
+    String ACTION_LOCAL_SOS_ACTION = "com.ic.action.SOS";
 
     String ACTION_SEND_SOS_VIDEO_FILE = "com.enqualcomm.support.action_send_sos_video_file";
 
index 332328d..4b0a9b6 100644 (file)
@@ -22,6 +22,7 @@ import com.enqualcomm.support.utils.ICLogger;
 import com.enqualcomm.support.utils.ImageUtil;
 import com.enqualcomm.support.utils.TimeUtil;
 import com.enqualcomm.support.utils.Util;
+import com.enqualcomm.support.utils.regexUtil;
 
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -112,11 +113,12 @@ public class MainActivity extends Activity {
 //
 //        ICLogger.i(" lat="+latitude+",lon="+longitude);
 
+        ICLogger.d("DW*860359001000040*0006*PING is "+regexUtil.isFZDCompanyCMD("DW","DW*860359001000040*0006*PING"));
 
         TextView tv_version=(TextView)findViewById(R.id.textViewVersion);
         tv_version.setText(DeviceInfoUtil.getVersionCode(this)+"-"+DeviceInfoUtil.getVersionName(this));
 //        testpic();
-        AESCipher.test2();
+        //AESCipher.test2();
 
     }
 
index c85e2bb..f35a6f2 100644 (file)
@@ -89,7 +89,7 @@ public class CellInfoUtil {
         try {
             CellLocation celllocation = tm.getCellLocation();
             if (celllocation == null) {
-                ICLogger.i("cellLocation = null");
+                ICLogger.i("no signal, cellLocation = null");
                 return 1;
             } else {
                 if (celllocation instanceof GsmCellLocation) {
index 6170cd2..ca8a4b0 100644 (file)
@@ -153,7 +153,12 @@ public class regexUtil {
         public static boolean isFZDCMD(String s){\r
             return Pattern.compile("IC\\*\\d{15}\\*[a-fA-F0-9]{4}\\*[a-zA-Z0-9]+$").matcher(s).matches();\r
         }\r
-\r
+        public static boolean isFZDCompanyCMD(String company,String s){\r
+            return Pattern.compile(company+"\\*\\d{15}\\*[a-fA-F0-9]{4}\\*[a-zA-Z0-9]+$").matcher(s).matches();\r
+        }\r
+        public static boolean isFZDCompanyCMD(String company,String cmd, String s){\r
+            return Pattern.compile(company+"\\*\\d{15}\\*[a-fA-F0-9]{4}\\*"+cmd).matcher(s).matches();\r
+        }\r
         public static boolean isFZDCMD(String cmd, String s){\r
            return Pattern.compile("IC\\*\\d{15}\\*[a-fA-F0-9]{4}\\*"+cmd).matcher(s).matches();\r
         }\r
index a144dee..0350377 100644 (file)
@@ -89,10 +89,11 @@ public class protocol_fzd {
     private static final String PRIVATE_KEY = "XMQcHi0lGIdru6xzW7lygBwBT8N0c09P";
     private static final String CMD_HEADER = "[";
     private static final String CMD_COMPANY = "IC";
+//    private static final String CMD_COMPANY = "DW";
     private static final String CMD_END = "]";
     private static final String CMD_HEADER_SPLIT = "*";
     private static final String CMD_SPLIT = ",";
-    private static final boolean doEncryption = Util.getSystemProperties("persist.sys.encrypt_fzd", "true").equals("true");
+    private static final boolean doEncryption = Util.getSystemProperties("persist.sys.encrypt_fzd", "false").equals("true");
     public static final String defaultServerIP = "fzd.xcloudtech.com";
     public static final int defaultServerPort = 9000;
     private final SharedPreferences sharedPreferences;
@@ -570,10 +571,9 @@ public class protocol_fzd {
             String cmd = cmd_msgbuf.substring(0, cmdindex);
             cmd_msgbuf = cmd;
         }
-
-        if (regexUtil.isFZDCMD(cmd_msgbuf)) {
+        if (regexUtil.isFZDCompanyCMD(CMD_COMPANY,cmd_msgbuf)) {
             for (CMD_TYPE key : cmdMap.keySet()) {
-                if (regexUtil.isFZDCMD(cmdMap.get(key), cmd_msgbuf)) { //如果是FZD命令,则进行处理,否则保留数据动
+                if (regexUtil.isFZDCompanyCMD(CMD_COMPANY,cmdMap.get(key), cmd_msgbuf)) { //如果是FZD命令,则进行处理,否则保留数据动
                     ICLogger.i("found cmd keyid=" + key + " ,keyname=" + cmdMap.get(key));
                     return cmdMap.get(key);
                 }
@@ -604,72 +604,55 @@ public class protocol_fzd {
     }
 
     private int dataPart = 1;
-
+    private StringBuffer cmdbuf = new StringBuffer();
     private byte[] totalByte;
-
     /*
-    返回true 表示 cmd 全部解析成功
-    返回false表示 cmd至少有一条解析失败,失败的数据归入buffer,下一次识别接着使用
-    字符串通过#号进行识别。
-    每个字符串如果发现 #,却又没有Header,“IW”则会被丢弃
-     */
+       返回true 表示 cmd 全部解析成功
+       返回false表示 cmd至少有一条解析失败,失败的数据归入buffer,下一次识别接着使用
+       字符串通过#号进行识别。
+       每个字符串如果发现 #,却又没有Header,“IW”则会被丢弃
+        */
     public boolean parserCmd(byte[] bytes) {
-        ICLogger.d("source byte size == > " + bytes.length);
-        String dataStr = new String(bytes);
-        //因为buffer有限,所以以[判断开头,以]判断结尾,这些数据要叠加起来
-        //这样才是完整的数据
-        //by TrillGates
-        ICLogger.d("添加第" + dataPart + "部分数据.");
-        dataPart++;
-        if (dataStr.startsWith(CMD_HEADER + CMD_COMPANY + CMD_HEADER_SPLIT)) {
-            ICLogger.d("头部数据,开始接收数据了...");
-            //命令开始,准备好容器,开始保存数据
-            dataPart = 1;
-            totalByte = bytes;
-        } else {
-            //对数据进行合并
-            totalByte = byteMerger(totalByte, bytes);
-        }
-        //命令结束,开始处理内容
-        if (dataStr.endsWith(CMD_END)) {
-            ICLogger.d("数据接收结束..开始处理数据." + totalByte.length);
-            //处理数据了
-            //获取指令
-            String content = new String(totalByte);
-            ICLogger.d("total content == > " + content);
-            //切割出指令
-            int cmdIndex = content.indexOf(CMD_SPLIT);
-            ICLogger.d("cmdIndex == > " + cmdIndex);
-            //指令带数据的
-            String cmd = null;
-            if (cmdIndex > 0) { //如果开头不是CMDHEADER但是包含CMDHEADER则删除前面的数据
-                cmd = content.substring(1, cmdIndex);
-            } else if (content.startsWith(CMD_HEADER) && content.endsWith(CMD_END)) {
-                //纯指令的:[IC*860314001009830*0002*LK],没有逗号的
-                cmd = content.replace("[", "").replace("]", "");
+
+        ICLogger.d("bytes.size " + bytes.length);
+        cmdbuf.append( new String(bytes));
+        ICLogger.d("cmdbuf.size " + cmdbuf.length() + " " + cmdbuf.toString());
+
+        while( !isCmdStr(cmdbuf.toString()).isEmpty()) {
+            String cmd_msgbuf = "";
+            int cmdindexHead = cmdbuf.indexOf(CMD_HEADER);
+            int cmdindexEnd = cmdbuf.indexOf(CMD_END);
+            if (cmdindexEnd > 0 && cmdindexHead >= 0) {
+                cmd_msgbuf = cmdbuf.substring(cmdindexHead+1, cmdindexEnd);
             }
-            ICLogger.d("cmd ---> " + cmd);
-            //处理内容
+
+//            if (cmdbuf.toString().split(CMD_COMPANY + CMD_HEADER_SPLIT).length > 1) {
+//                ICLogger.d("More than 1 cmd in buffer ! just log it");
+//            }
+            String cmdname=isCmdStr(cmd_msgbuf);
             for (CMD_TYPE key : cmdMap.keySet()) {
-                //如果是FZD命令,则进行处理,否则保留数据动
-                if (regexUtil.isFZDCMD(cmdMap.get(key), cmd)) {
+//                ICLogger.d("key " + cmdMap.get(key) +" "+cmdname+" cmdbuf " + cmd_msgbuf);
+                if (cmdMap.get(key).equals(cmdname)) { //如果是FZD命令,则进行处理,否则保留数据动
+
                     ICLogger.d("key is == > " + key);
-                    if (key == CMD_TYPE.TK) {
-                        handlerGroupChatVoiceContent(totalByte);
-                    } else if (key == CMD_TYPE.TKOne) {
-                        handlerOneChatVoiceContent(totalByte);
-                    } else if (key == CMD_TYPE.TKIMG) {
-                        handleImage(totalByte);
-                    } else {
-                        String data = content.replace(CMD_HEADER, "").replace(cmd, "").replace(CMD_END, "");
-                        if (data.startsWith(CMD_SPLIT)) {
-                            data = data.substring(1);
-                        }
-                        handleCmd(key, cmd, data);
+//                    if (key == CMD_TYPE.TK) {
+//                        handlerGroupChatVoiceContent(totalByte);
+//                    } else if (key == CMD_TYPE.TKOne) {
+//                        handlerOneChatVoiceContent(totalByte);
+//                    } else if (key == CMD_TYPE.TKIMG) {
+//                        handleImage(totalByte);
+//                    }
+//                    else
+                    {
+
+                        handleCmd(key, cmdname, cmd_msgbuf);
                     }
+                    cmdbuf.delete(0, cmd_msgbuf.length()+2);//处理后清空
+                    break;
                 }
             }
         }
+        ICLogger.d("parserCmd done");
         return true;
     }
 
index d4553e0..f98cd49 100644 (file)
@@ -1,2 +1,2 @@
-#Fri Aug 06 18:14:49 CST 2021\r
-VERSION_CODE=908\r
+#Sat Aug 14 01:52:07 CST 2021\r
+VERSION_CODE=910\r