comleted sign.
authorTrillGates <williamtrillgates@gmail.com>
Thu, 5 Aug 2021 12:20:45 +0000 (20:20 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Thu, 5 Aug 2021 12:20:45 +0000 (20:20 +0800)
app/src/main/java/com/enqualcomm/support/service/WebMsgStateObserver.java
app/src/main/java/com/enqualcomm/support/utils/Util.java
app/src/main/java/com/ic/protocols/protocol_s123.java

index 2f824df..7377e5d 100644 (file)
@@ -21,7 +21,7 @@ public class WebMsgStateObserver extends BaseSettingsObserver {
         ICLogger.d("on web msg setting change...");
         mHandler.post(() -> {
             //查询出设置项
-            String value = getSettingsValueByKey("sign_action_flag", "-1");
+            String value = getSettingsValueByKey("web_msg_read_state_flag", "");
             protocolAPIHelper.responseWebSms(value);
         });
     }
index 5aa661e..0c9d4f7 100644 (file)
@@ -235,6 +235,30 @@ public class Util {
         return serverip.toString();
     }
 
+    public static String utf8ToUnicode(String inStr) {
+        char[] myBuffer = inStr.toCharArray();
+
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < inStr.length(); i++) {
+            Character.UnicodeBlock ub = Character.UnicodeBlock.of(myBuffer[i]);
+            if (ub == Character.UnicodeBlock.BASIC_LATIN) {
+                //英文及数字等
+                sb.append(myBuffer[i]);
+            } else if (ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
+                //全角半角字符
+                int j = (int) myBuffer[i] - 65248;
+                sb.append((char) j);
+            } else {
+                //汉字
+                short s = (short) myBuffer[i];
+                String hexS = Integer.toHexString(s);
+                String unicode = "\\u" + hexS;
+                sb.append(unicode.toLowerCase());
+            }
+        }
+        return sb.toString();
+    }
+
     /**
      * 此函数专门给L02 协议使用 ,解析名字用
      *
@@ -327,8 +351,6 @@ public class Util {
                 outBuffer.append(aChar);
         }
         return outBuffer.toString();
-
-
     }
 
     public static String getSystemProperties(String prop) {
@@ -342,7 +364,7 @@ public class Util {
             e.printStackTrace();
             ICLogger.e(e.getMessage(), e);
         }
-        ICLogger.i("getSystemProperties str = "+str);
+        ICLogger.i("getSystemProperties str = " + str);
         return str;
     }
 
@@ -1113,7 +1135,7 @@ public class Util {
         }
     }
 
-    public static boolean parseToVoicePacketSent(VoiceContent voiceContent,int packetSize) {
+    public static boolean parseToVoicePacketSent(VoiceContent voiceContent, int packetSize) {
 
         long filesize;
         File voicefile = new File(voiceContent.content);
@@ -1137,11 +1159,11 @@ public class Util {
                 fis.close();
                 voicePacket.getInstanceSent().setCurrentIndexToSent(0);
                 voicePacket.getInstanceSent().setPacketTime(TimeUtil.getSystemTime3());
-                if( voiceContent.filetype==1) //* 1 语音——       1.监听语音      *   2.SOS语音      *      3.扩展
+                if (voiceContent.filetype == 1) //* 1 语音——     1.监听语音      *   2.SOS语音      *      3.扩展
                 {
-                    int duration=Util.getDuration(voiceContent.content);
-                    voicePacket.getInstanceSent().setDurationHex(String.format("%04X",duration));
-                }else{
+                    int duration = Util.getDuration(voiceContent.content);
+                    voicePacket.getInstanceSent().setDurationHex(String.format("%04X", duration));
+                } else {
                     voicePacket.getInstanceSent().setDurationHex("0000");
                 }
                 return true;
@@ -1247,6 +1269,7 @@ public class Util {
         }
         return ret;
     }
+
     public static String UrlGB2312ToUTF8(String url) {
         String ret = "";
         String src = url;
index 25dfef6..9b594eb 100644 (file)
@@ -108,7 +108,7 @@ public class protocol_s123 {
         ICLogger.d("value ==> " + value);
         //如果是-1,那么是空消息
         //如果是其他数字,通过id去查询即可
-        if (!"none".equals(value)) {
+        if (!"none".equals(value) && !"success".equals(value)) {
             //先查询出内容,再组装数据
             ContentResolver resolver = mRuntime.getContextProxy().getResolver();
             Cursor query = resolver.query(Uri.parse(ShootTextProvider.SHOOT_TEXT),
@@ -164,7 +164,7 @@ public class protocol_s123 {
                         .append(CMDSPLIT).append(lowPressure)
                         .append(CMDSPLIT).append(highPressure)
                         .append(CMDSPLIT).append(batteryLev)
-                        .append(CMDSPLIT).append(msg)
+                        .append(CMDSPLIT).append(Util.utf8ToUnicode(msg))//utf8转unicode
                         .append(CMDSPLIT).append(mRuntime.getS123GpsData())
                         .append(CMDSPLIT).append("wgs84")//原始经纬度
                         .append(CMDSPLIT).append(mRuntime.getSignalStrength())