防走丢协议加入配置项可以去除加密信息
authorsnickersun <scy@incartech.cn>
Fri, 29 Jan 2021 02:02:23 +0000 (10:02 +0800)
committersnickersun <scy@incartech.cn>
Fri, 29 Jan 2021 02:02:23 +0000 (10:02 +0800)
persist.sys.encrypt_fzd 默认true

app/src/main/java/com/ic/protocols/protocol_fzd.java

index 1ce6b00..16fb98a 100644 (file)
@@ -1,3 +1,4 @@
+
 package com.ic.protocols;
 
 import android.content.ComponentName;
@@ -37,7 +38,7 @@ public class protocol_fzd {
     private static final String CMDEND = "]";
     private static final String CMDHEADERSPLIT = "*";
     private static final String CMDSPLIT = ",";
-
+    private static final boolean doEncryption=Util.getSystemProperties("persist.sys.encrypt_fzd","true").equals("true");
     public static final String defaultServerIP = "api.xcloudtech.com";
     public static final int defaultServerPort = 9000;
 
@@ -308,8 +309,12 @@ public class protocol_fzd {
         StringBuilder sb = new StringBuilder();
         int len = CMD.length();
         String header = genHeader(len, CMD);
-        String keyheader = keyheader(CMD, len);
-        sb.append(CMDHEADER).append(keyheader).append(header).append(CMDEND);
+        if(doEncryption) {
+             String keyheader = keyheader(CMD, len);
+             sb.append(CMDHEADER).append(keyheader).append(header).append(CMDEND);
+        }else{
+            sb.append(CMDHEADER).append(header).append(CMDEND);
+        }
         return genStringMessage(CMD, sb.toString());
     }
 
@@ -318,8 +323,12 @@ public class protocol_fzd {
         String data_buf = CMD + CMDSPLIT + data;
         int data_buf_len = data_buf.length();
         String header = genHeader(data_buf_len, CMD);
-        String keyheader = keyheader(CMD, data_buf_len);//计算header md5值
-        sb.append(CMDHEADER).append(keyheader).append(header).append(CMDSPLIT).append(data).append(CMDEND);
+        if(doEncryption) {
+             String keyheader = keyheader(CMD, data_buf_len);//计算header md5值
+             sb.append(CMDHEADER).append(keyheader).append(header).append(CMDSPLIT).append(data).append(CMDEND);
+        }else{
+            sb.append(CMDHEADER).append(header).append(CMDSPLIT).append(data).append(CMDEND);
+        }
         return genStringMessage(CMD, sb.toString());
     }