S123添加远程拍照上传功能
authorTrillGates <williamtrillgates@gmail.com>
Thu, 21 Oct 2021 03:22:23 +0000 (11:22 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Thu, 21 Oct 2021 03:22:23 +0000 (11:22 +0800)
16 files changed:
app/release/ICSer_V979_2110201800_release.apk [moved from app/release/ICSer_V978_2110191611_release.apk with 77% similarity]
app/release/output.json
app/src/main/java/com/enqualcomm/support/bean/VoicePacket.java [moved from app/src/main/java/com/enqualcomm/support/bean/voicePacket.java with 90% similarity]
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/service/WeTalkMsgObserver.java
app/src/main/java/com/enqualcomm/support/utils/LedUtil.java
app/src/main/java/com/enqualcomm/support/utils/ProcessReceiver.java
app/src/main/java/com/enqualcomm/support/utils/Util.java
app/src/main/java/com/ic/protocols/protocolAPIHelper.java
app/src/main/java/com/ic/protocols/protocol_anan.java
app/src/main/java/com/ic/protocols/protocol_beehome.java
app/src/main/java/com/ic/protocols/protocol_gator.java
app/src/main/java/com/ic/protocols/protocol_ic.java
app/src/main/java/com/ic/protocols/protocol_jiai.java
app/src/main/java/com/ic/protocols/protocol_s123.java
app/version_code.properties

similarity index 77%
rename from app/release/ICSer_V978_2110191611_release.apk
rename to app/release/ICSer_V979_2110201800_release.apk
index 78a1a2f..a7f936b 100644 (file)
Binary files a/app/release/ICSer_V978_2110191611_release.apk and b/app/release/ICSer_V979_2110201800_release.apk differ
index b1131be..3df6eac 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":978,"versionName":"2110191611","enabled":true,"outputFile":"ICSer_V978_2110191611_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V978_2110191611_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":979,"versionName":"2110201800","enabled":true,"outputFile":"ICSer_V979_2110201800_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V979_2110201800_release.apk","properties":{}}]
\ No newline at end of file
@@ -3,22 +3,23 @@ package com.enqualcomm.support.bean;
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
 \r
-public class voicePacket {\r
+public class VoicePacket {\r
 \r
 \r
-    private static voicePacket gvoicePacket = null;\r
+    private static VoicePacket gvoicePacket = null;\r
 \r
-    public synchronized static voicePacket getInstance() {\r
+    public synchronized static VoicePacket getInstance() {\r
         if (gvoicePacket == null)\r
-            gvoicePacket = new voicePacket();\r
+            gvoicePacket = new VoicePacket();\r
         return gvoicePacket;\r
     }\r
 \r
-    private static voicePacket gvoicepacket_sent = null;\r
+    private static VoicePacket gvoicepacket_sent = null;\r
 \r
-    public synchronized static voicePacket getInstanceSent() {\r
-        if (gvoicepacket_sent == null)\r
-            gvoicepacket_sent = new voicePacket();\r
+    public synchronized static VoicePacket getInstanceSent() {\r
+        if (gvoicepacket_sent == null) {\r
+            gvoicepacket_sent = new VoicePacket();\r
+        }\r
         return gvoicepacket_sent;\r
     }\r
 \r
index de6d242..5369152 100644 (file)
@@ -24,7 +24,7 @@ import com.enqualcomm.support.bean.Contact;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.provider.WeTalkMessageProvider;
 import com.enqualcomm.support.service.base.AbstractConnectionService;
@@ -441,7 +441,10 @@ public class Deliver extends AbstractConnectionService {
         if (cmd.equals("SentVoicePacket")) {
             //收到BP07 表示服务器收到一个voicePacket 分包成功,开始检查下一个包是否存在需要发送。
             //收到SentVoicePacket 表示 有一个VoiceMessage要发送,需要从第0个包开始发送语音分包。
-            voicePacket voicepacket = voicePacket.getInstanceSent();
+            VoicePacket voicepacket = VoicePacket.getInstanceSent();
+            ICLogger.d("voicepacket toString " + voicepacket.toString());
+            ICLogger.d("voicepacket.getCurrentIndexToSent() ==> " + voicepacket.getCurrentIndexToSent());
+            ICLogger.d("voicepacket.getPacketCount() ==> " + voicepacket.getPacketCount());
             if (voicepacket.getCurrentIndexToSent() < voicepacket.getPacketCount()) {
                 ICLogger.i("voicepacket " + voicepacket.getName() + " filetype " + voicepacket.getFiletype() + " , datatype " + voicepacket.getDateType() + " " + voicepacket.getPacketTime() + " send " + (voicepacket.getCurrentIndexToSent() + 1) + "/" + voicepacket.getPacketCount());
                 if (mConnection instanceof NettyConnection) {
@@ -643,8 +646,8 @@ public class Deliver extends AbstractConnectionService {
                     if (CoreService.getInstance().getConnection() != null)
                         CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
                 }, recordtime * 1000);
-            }catch (Exception e){
-                ICLogger.e(e.getMessage(),e);
+            } catch (Exception e) {
+                ICLogger.e(e.getMessage(), e);
             }
             return true;
         }
index f211e38..c3c19c6 100644 (file)
@@ -47,6 +47,7 @@ public class WeTalkMsgObserver extends ContentObserver {
                 ICLogger.d("content --- > " + content);
                 //todo:还有类型也要查询出来
                 int type = query.getInt(query.getColumnIndex("type"));
+                ICLogger.d("type ==> " + type);
                 query.close();
                 if (type == ICDatabaseHelper.MessageType.VOICE) {
                     protocolAPIHelper.sendVoice(duration, remoteNum, content, lastPathSegment);
index 505f03d..b267fb7 100644 (file)
@@ -1,7 +1,5 @@
 package com.enqualcomm.support.utils;\r
 \r
-import com.enqualcomm.support.bean.voicePacket;\r
-\r
 import java.io.File;\r
 import java.io.FileInputStream;\r
 import java.io.FileNotFoundException;\r
index c0af1bf..ab54803 100644 (file)
@@ -320,8 +320,9 @@ public class ProcessReceiver extends BroadcastReceiver {
                 // 把voiceContent拆解成1024的分包
                 Util.parseToVoicePacketSent(voiceContent, 1024);
                 //trigger 分包发送
-                if (CoreService.getInstance().getConnection() != null)
+                if (CoreService.getInstance().getConnection() != null) {
                     CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
+                }
             } else if (msgType.equals("pic")) {
                 //创建voiceConent并添加到数据
                 final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 3);
@@ -330,7 +331,6 @@ public class ProcessReceiver extends BroadcastReceiver {
                 Util.parseToVoicePacketSent(voiceContent, 1024);
                 //trigger 分包发送
                 if (CoreService.getInstance().getConnection() != null) {
-
                     //h88专用功能,拍照时检查体温心率
                     if (Util.getSystemProperties("persist.sys.do_check_condition", "false").equals("true")) {
                         //开启测温
index 1c994d2..96be0e2 100644 (file)
@@ -22,7 +22,7 @@ import com.enqualcomm.support.Config;
 import com.enqualcomm.support.CoreService;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.service.Deliver;
 import com.ic.protocols.protocolAPIHelper;
 
@@ -246,7 +246,7 @@ public class Util {
                 sb.append("00").append(hexS.toLowerCase());
             } else if (ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
                 //全角半角字符
-                int j =  ((int) myBuffer[i] - 65248);
+                int j = ((int) myBuffer[i] - 65248);
                 String hexS = Integer.toHexString(j);
                 sb.append("00").append(hexS);
             } else {
@@ -1164,42 +1164,42 @@ public class Util {
     }
 
     public static boolean parseToVoicePacketSent(VoiceContent voiceContent, int packetSize) {
-
-        long filesize;
-        File voicefile = new File(voiceContent.content);
-        if (voicefile.exists()) {
-            filesize = voicefile.length();
-
-            int count = (int) (filesize / packetSize);
-            if ((filesize % packetSize) > 0)
+        long fileSize;
+        File voiceFile = new File(voiceContent.content);
+        ICLogger.d("voiceFile ==> " + voiceFile);
+        if (voiceFile.exists()) {
+            fileSize = voiceFile.length();
+            int count = (int) (fileSize / packetSize);
+            if ((fileSize % packetSize) > 0) {
                 count++;
-            ICLogger.i("File " + voiceContent.content + ", size " + filesize + ", count " + count + " filetype " + voiceContent.filetype + ", datatype " + voiceContent.datatype);
-            voicePacket.getInstanceSent().clearPacket();
-            voicePacket.getInstanceSent().setFileType(voiceContent.filetype, voiceContent.datatype);
-            voicePacket.getInstanceSent().setSender(voiceContent.contactNumber);
+            }
+            ICLogger.i("File " + voiceContent.content + ", size " + fileSize + ", count " + count + " filetype " + voiceContent.filetype + ", datatype " + voiceContent.datatype);
+            VoicePacket.getInstanceSent().clearPacket();
+            VoicePacket.getInstanceSent().setFileType(voiceContent.filetype, voiceContent.datatype);
+            VoicePacket.getInstanceSent().setSender(voiceContent.contactNumber);
             try {
-                FileInputStream fis = new FileInputStream(voicefile);
-                byte[] audiobuf = new byte[packetSize];
+                FileInputStream fis = new FileInputStream(voiceFile);
+                byte[] audioBuf = new byte[packetSize];
                 for (int i = 0; i < count; i++) {
-                    int readbytes = fis.read(audiobuf, 0, packetSize);
-                    voicePacket.getInstanceSent().appendVoice(voiceContent.contactNumber, "", count, i, readbytes, audiobuf);
+                    int readBytes = fis.read(audioBuf, 0, packetSize);
+                    VoicePacket.getInstanceSent().appendVoice(voiceContent.contactNumber, "", count, i, readBytes, audioBuf);
                 }
                 fis.close();
-                voicePacket.getInstanceSent().setCurrentIndexToSent(0);
-                voicePacket.getInstanceSent().setPacketTime(TimeUtil.getSystemTime3());
+                VoicePacket.getInstanceSent().setCurrentIndexToSent(0);
+                VoicePacket.getInstanceSent().setPacketTime(TimeUtil.getSystemTime3());
                 if (voiceContent.filetype == 1) //* 1 语音——     1.监听语音      *   2.SOS语音      *      3.扩展
                 {
                     int duration = Util.getDuration(voiceContent.content);
-                    voicePacket.getInstanceSent().setDurationHex(String.format("%04X", duration));
+                    VoicePacket.getInstanceSent().setDurationHex(String.format("%04X", duration));
                 } else {
-                    voicePacket.getInstanceSent().setDurationHex("0000");
+                    VoicePacket.getInstanceSent().setDurationHex("0000");
                 }
+                ICLogger.d("handle data okay ==> " + VoicePacket.getInstanceSent().toString());
                 return true;
             } catch (Exception e) {
                 e.printStackTrace();
                 ICLogger.e(e.getMessage(), e);
             }
-
         }
         return false;
     }
index efb539c..e87876d 100644 (file)
@@ -734,13 +734,11 @@ public class protocolAPIHelper {
                 protocolfzd_handler.sendPicture(remoteNum, imagePath, imageId);
                 break;
             case Config.PROTOCOL_MQTT:
-
                 break;
             case PROTOCOL_ANAN:
-
                 break;
             case Config.PROTOCOL_S123:
-
+                protocols123_handler.sendPicture(remoteNum, imagePath, imageId);
                 break;
             case Config.PROTOCOL_GATOR:
 
index 0f19e9d..c8ca0bc 100644 (file)
@@ -13,8 +13,6 @@ import android.database.Cursor;
 import android.media.AudioManager;
 import android.net.Uri;
 import android.os.Environment;
-import android.os.SystemProperties;
-import android.os.UserHandle;
 import android.provider.Settings;
 import android.support.v4.app.ActivityCompat;
 import android.telephony.TelephonyManager;
@@ -34,7 +32,7 @@ import com.enqualcomm.support.bean.ICLocation;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICAlarmProvider;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.provider.ICGlobalSettingsProvider;
@@ -1406,7 +1404,7 @@ public class protocol_anan {
                         packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
                 connection.DeliverCMDMessageToSystem("SentVoicePacket", "SentVoicePacket");
@@ -1930,15 +1928,15 @@ public class protocol_anan {
 
                 ICLogger.d(stringBuffer.toString());
                 connection.send(AP28(Name, appendIndex, packetCount, currentId, 1));
-                voicePacket.getInstance().appendVoice(Name,
+                VoicePacket.getInstance().appendVoice(Name,
                         appendIndex, packetCount, currentId, packetLen, packetData);
-                ICLogger.d("================" + voicePacket.getInstance().toString());
-                if (voicePacket.getInstance().isFinished()) {
+                ICLogger.d("================" + VoicePacket.getInstance().toString());
+                if (VoicePacket.getInstance().isFinished()) {
 
                     String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
-                    String amrFilepath = Util.saveFile(voicePacket.getInstance().getVoicePacketBytes(), 0, voicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + voicePacket.getInstance().getPacketTime() + ".amr");
+                    String amrFilepath = Util.saveFile(VoicePacket.getInstance().getVoicePacketBytes(), 0, VoicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + VoicePacket.getInstance().getPacketTime() + ".amr");
                     ICLogger.i("save Amr file to " + amrFilepath);
-                    voicePacket.getInstance().clearPacket();
+                    VoicePacket.getInstance().clearPacket();
                     VoiceContent voiceContent = VoiceContent.placeHolderIn(Content.CONTACT_CATEGORY_GROUP, GROUP_ALL, amrFilepath);
 
 
index c104fd9..af93a0b 100644 (file)
@@ -16,7 +16,7 @@ import com.enqualcomm.support.bean.ICLocation;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICAlarmProvider;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.service.HeartRateManager;
@@ -1041,7 +1041,7 @@ public class protocol_beehome {
                 ICLogger.i("服务器在" + time + " 收到语音 " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
                 connection.DeliverCMDMessageToSystem("SentVoicePacket", "SentVoicePacket");
@@ -1448,14 +1448,14 @@ public class protocol_beehome {
 
                 log(stringBuffer.toString());
                 connection.send(AP28(Name, appendIndex, packetCount, currentId, 1));
-                voicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
-                log("================" + voicePacket.getInstance().toString());
-                if (voicePacket.getInstance().isFinished()) {
+                VoicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
+                log("================" + VoicePacket.getInstance().toString());
+                if (VoicePacket.getInstance().isFinished()) {
 
                     String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
-                    String amrFilepath = Util.saveFile(voicePacket.getInstance().getVoicePacketBytes(), 0, voicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + voicePacket.getInstance().getPacketTime() + ".amr");
+                    String amrFilepath = Util.saveFile(VoicePacket.getInstance().getVoicePacketBytes(), 0, VoicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + VoicePacket.getInstance().getPacketTime() + ".amr");
                     ICLogger.i("save Amr file to " + amrFilepath);
-                    voicePacket.getInstance().clearPacket();
+                    VoicePacket.getInstance().clearPacket();
                     VoiceContent voiceContent = VoiceContent.placeHolderIn(Content.CONTACT_CATEGORY_GROUP, GROUP_ALL, amrFilepath);
 
 
index a4ce6f9..f39a69c 100644 (file)
@@ -22,7 +22,7 @@ import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.Silent;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICAlarmProvider;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.provider.ICMembersProvider;
@@ -1008,13 +1008,13 @@ public class protocol_gator {
             connection.send(BP12(ds, sourceNumb, count, index, time, true));
             byte packetData[] = Util.subArray(bytes, cmdlist[0].length() + cmdlist[1].length() + cmdlist[2].length() + cmdlist[3].length() + cmdlist[4].length() + cmdlist[5].length() + 6, bytes.length - 1);
 
-            voicePacket.getInstance().appendVoice(sourceNumb, time, count, index, ipackagelen, packetData);
-            log("================" + voicePacket.getInstance().toString());
-            if (voicePacket.getInstance().isFinished()) {
+            VoicePacket.getInstance().appendVoice(sourceNumb, time, count, index, ipackagelen, packetData);
+            log("================" + VoicePacket.getInstance().toString());
+            if (VoicePacket.getInstance().isFinished()) {
                 String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
-                String amrFilepath = Util.saveFile(voicePacket.getInstance().getVoicePacketBytes(), 0, voicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + voicePacket.getInstance().getPacketTime() + ".amr");
+                String amrFilepath = Util.saveFile(VoicePacket.getInstance().getVoicePacketBytes(), 0, VoicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + VoicePacket.getInstance().getPacketTime() + ".amr");
                 ICLogger.i("save Amr file to " + amrFilepath);
-                voicePacket.getInstance().clearPacket();
+                VoicePacket.getInstance().clearPacket();
                 VoiceContent voiceContent = VoiceContent.placeHolderIn(Content.CONTACT_CATEGORY_GROUP, GROUP_ALL, amrFilepath);
                 final Uri uri2 = ds.getDbHelper().insertMessage(voiceContent);
                 //回复UI消息,表示已经接收到
@@ -1432,7 +1432,7 @@ SOS报警上行WIFI、LBS混合定位数据,步数为255步,电量等级5,数
                 ICLogger.i("服务器在" + time + " 收到 " + sender + " 语音 " + duration + " " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : (receiveSuccess == 0 ? "失敗" : "非亲情号")));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                     //发送消息,再次检查要发送的语音包,确认其发送完毕
                     connection.DeliverCMDMessageToSystem("SentVoicePacket", "SentVoicePacket");
                 } else if (receiveSuccess == 0) {
index 1683894..f844c2d 100644 (file)
@@ -25,7 +25,7 @@ import com.enqualcomm.support.bean.ICLocation;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICAlarmProvider;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.service.HeartRateManager;
@@ -1161,7 +1161,7 @@ public class protocol_ic {
                 ICLogger.i("服务器在" + time + " 收到语音 " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
                 connection.DeliverCMDMessageToSystem("SentVoicePacket", "SentVoicePacket");
@@ -1587,14 +1587,14 @@ public class protocol_ic {
 
                 log(stringBuffer.toString());
                 connection.send(AP28(Name, appendIndex, packetCount, currentId, 1));
-                voicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
-                log("================" + voicePacket.getInstance().toString());
-                if (voicePacket.getInstance().isFinished()) {
+                VoicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
+                log("================" + VoicePacket.getInstance().toString());
+                if (VoicePacket.getInstance().isFinished()) {
 
                     String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
-                    String amrFilepath = Util.saveFile(voicePacket.getInstance().getVoicePacketBytes(), 0, voicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + voicePacket.getInstance().getPacketTime() + ".amr");
+                    String amrFilepath = Util.saveFile(VoicePacket.getInstance().getVoicePacketBytes(), 0, VoicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + VoicePacket.getInstance().getPacketTime() + ".amr");
                     ICLogger.i("save Amr file to " + amrFilepath);
-                    voicePacket.getInstance().clearPacket();
+                    VoicePacket.getInstance().clearPacket();
                     VoiceContent voiceContent = VoiceContent.placeHolderIn(Content.CONTACT_CATEGORY_GROUP, GROUP_ALL, amrFilepath);
                     final Uri uri2 = runtime.getDbHelper().insertMessage(voiceContent);
                     //回复UI消息,表示已经接收到
@@ -2318,7 +2318,7 @@ public class protocol_ic {
                 ICLogger.i("服务器在收到 index " + time + ", 文件类型 " + ftype + ",内容类型 " + dtype + " " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                     //voicePacket.getInstanceSent().setFileType(ftype,dtype);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
index c017ca5..815f6ba 100644 (file)
@@ -16,7 +16,7 @@ import com.enqualcomm.support.bean.ICLocation;
 import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICAlarmProvider;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.service.HeartRateManager;
@@ -1033,7 +1033,7 @@ public class protocol_jiai {
                 ICLogger.i("服务器在" + time + " 收到语音 " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
                 connection.DeliverCMDMessageToSystem("SentVoicePacket", "SentVoicePacket");
@@ -1466,14 +1466,14 @@ public class protocol_jiai {
 
                 log(stringBuffer.toString());
                 connection.send(AP28(Name, appendIndex, packetCount, currentId, 1));
-                voicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
-                log("================" + voicePacket.getInstance().toString());
-                if (voicePacket.getInstance().isFinished()) {
+                VoicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
+                log("================" + VoicePacket.getInstance().toString());
+                if (VoicePacket.getInstance().isFinished()) {
 
                     String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
-                    String amrFilepath = Util.saveFile(voicePacket.getInstance().getVoicePacketBytes(), 0, voicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + voicePacket.getInstance().getPacketTime() + ".amr");
+                    String amrFilepath = Util.saveFile(VoicePacket.getInstance().getVoicePacketBytes(), 0, VoicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + VoicePacket.getInstance().getPacketTime() + ".amr");
                     ICLogger.i("save Amr file to " + amrFilepath);
-                    voicePacket.getInstance().clearPacket();
+                    VoicePacket.getInstance().clearPacket();
                     VoiceContent voiceContent = VoiceContent.placeHolderIn(Content.CONTACT_CATEGORY_GROUP, GROUP_ALL, amrFilepath);
 
 
index 7f63202..e9aa052 100644 (file)
@@ -34,7 +34,7 @@ import com.enqualcomm.support.bean.Runtime;
 import com.enqualcomm.support.bean.SleepInfo;
 import com.enqualcomm.support.bean.StringMessage;
 import com.enqualcomm.support.bean.VoiceContent;
-import com.enqualcomm.support.bean.voicePacket;
+import com.enqualcomm.support.bean.VoicePacket;
 import com.enqualcomm.support.provider.ICAlarmProvider;
 import com.enqualcomm.support.provider.ICDatabaseHelper;
 import com.enqualcomm.support.provider.ICGlobalSettingsProvider;
@@ -73,6 +73,7 @@ import static com.enqualcomm.support.Constants.DIALOG_ACTION;
 import static com.enqualcomm.support.Constants.FROM_SERVER;
 import static com.enqualcomm.support.LocationClient.LOCATION_MODE;
 import static com.enqualcomm.support.bean.Contact.GROUP_ALL;
+import static com.enqualcomm.support.bean.Content.CONTACT_CATEGORY_GROUP;
 import static java.lang.Math.abs;
 
 /**
@@ -186,6 +187,23 @@ public class protocol_s123 {
         mConnection.send(stringMessage);
     }
 
+    public void sendPicture(String remoteNum, String imagePath, String imageId) {
+        //发送图片
+        final VoiceContent voiceContent =
+                VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, remoteNum, "0000",
+                        imagePath, 2, 3);
+        remoteNum = "s123";
+        ICLogger.d("remote number is ==> " + remoteNum);
+        voiceContent.contactNumber = remoteNum;
+        // 把voiceContent拆解成1024的分包
+        Util.parseToVoicePacketSent(voiceContent, 1024);
+        //trigger 分包发送
+        if (CoreService.getInstance().getConnection() != null) {
+            //开启发送图片
+            CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
+        }
+    }
+
     public enum CMD_TYPE {
         /*终端发起*/
         AP00,//登录包
@@ -326,6 +344,8 @@ public class protocol_s123 {
         APWF,
         BPSM,//快捷回复指令
         APSM,
+        BP39,//白名单的补充
+        AP39,
         UNKNOWN_CMD,
     }
 
@@ -363,6 +383,7 @@ public class protocol_s123 {
         cmdMap.put(CMD_TYPE.BPRP, "BPRP");
         cmdMap.put(CMD_TYPE.APFF, "APFF");
         cmdMap.put(CMD_TYPE.BPFF, "BPFF");
+        cmdMap.put(CMD_TYPE.BP39, "BP39");
         /* 服务器发起*/
         cmdMap.put(CMD_TYPE.BP45, "BP45");
         cmdMap.put(CMD_TYPE.AP45, "AP45");
@@ -470,6 +491,7 @@ public class protocol_s123 {
         cmdMap.put(CMD_TYPE.APWF, "APWF");
         cmdMap.put(CMD_TYPE.BPSM, "BPSM");
         cmdMap.put(CMD_TYPE.APSM, "APSM");
+        cmdMap.put(CMD_TYPE.AP39, "AP39");
     }
 
 
@@ -1278,7 +1300,7 @@ public class protocol_s123 {
             resolver.delete(Uri.parse(ICMembersProvider.MEMBERS), "type=? and group_type is null", new String[]{
                     ICDatabaseHelper.MemberType.WHITE_LIST + ""
             });
-            resolver.delete(Uri.parse(ICMembersProvider.MEMBERS), "type=? and (group_type=? or group_type is null)", new String[]{
+            resolver.delete(Uri.parse(ICMembersProvider.MEMBERS), "type=? and group_type=?", new String[]{
                     ICDatabaseHelper.MemberType.WHITE_LIST + "", "0"
             });
             //从记录上看,
@@ -1504,7 +1526,7 @@ public class protocol_s123 {
                 ICLogger.i("服务器在" + time + " 收到语音 " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
                 connection.DeliverCMDMessageToSystem("SentVoicePacket", "SentVoicePacket");
@@ -1930,14 +1952,14 @@ public class protocol_s123 {
 
                 log(stringBuffer.toString());
                 connection.send(AP28(Name, appendIndex, packetCount, currentId, 1));
-                voicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
-                log("================" + voicePacket.getInstance().toString());
-                if (voicePacket.getInstance().isFinished()) {
+                VoicePacket.getInstance().appendVoice(Name, appendIndex, packetCount, currentId, packetLen, packetData);
+                log("================" + VoicePacket.getInstance().toString());
+                if (VoicePacket.getInstance().isFinished()) {
 
                     String dir = Environment.getExternalStorageDirectory() + "/Android/VoiceCache";
-                    String amrFilepath = Util.saveFile(voicePacket.getInstance().getVoicePacketBytes(), 0, voicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + voicePacket.getInstance().getPacketTime() + ".amr");
+                    String amrFilepath = Util.saveFile(VoicePacket.getInstance().getVoicePacketBytes(), 0, VoicePacket.getInstance().getVoicePacketLen(), new File(dir), "receive_" + VoicePacket.getInstance().getPacketTime() + ".amr");
                     ICLogger.i("save Amr file to " + amrFilepath);
-                    voicePacket.getInstance().clearPacket();
+                    VoicePacket.getInstance().clearPacket();
                     VoiceContent voiceContent = VoiceContent.placeHolderIn(Content.CONTACT_CATEGORY_GROUP, GROUP_ALL, amrFilepath);
                     final Uri uri2 = runtime.getDbHelper().insertMessage(voiceContent);
                     //回复UI消息,表示已经接收到
@@ -2703,7 +2725,7 @@ public class protocol_s123 {
                 ICLogger.i("服务器在收到 index " + time + ", 文件类型 " + ftype + ",内容类型 " + dtype + " " + packetIndex + "/" + packetCount + " " + (receiveSuccess == 1 ? "成功" : "失敗"));
                 if (receiveSuccess == 1) {
                     //如果服务器接收 语音成功,则设置下一个要发送的语音包Index,当index == packetCount的时候表示所有包发送完毕,停止继续发送
-                    voicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
+                    VoicePacket.getInstanceSent().setCurrentIndexToSent(packetIndex);
                     //voicePacket.getInstanceSent().setFileType(ftype,dtype);
                 }
                 //发送消息,再次检查要发送的语音包,确认其发送完毕
@@ -3860,10 +3882,92 @@ public class protocol_s123 {
                 break;
             case APFX:
                 break;
+            case BP39:
+                ICLogger.d("收到白名单扩展..");
+                handleBP39(cmd);
+                break;
         }
         return ret;
     }
 
+    /**
+     * IWBP39,353456789012345,080835,1,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx,
+     * D3590D54|135xxxxxxxxxx#
+     *
+     * @param cmd
+     */
+    private void handleBP39(String cmd) {
+        cmd = cmd.replace(CMDEND, "");
+        //对数据进行切割
+        String[] split = cmd.split(CMDSPLIT);
+        if (split.length == 14) {
+            String index = split[2];
+            String groupId = split[3];
+            StringBuilder sb = new StringBuilder();
+            sb.append(CMDHEADER);
+            sb.append(cmdMap.get(CMD_TYPE.AP39));
+            sb.append(CMDSPLIT);
+            sb.append(index);
+            sb.append(CMDSPLIT);
+            ICLogger.d("index==> " + index + " group id ==> " + groupId);
+            //删除数据库里的数据
+            mRuntime.getContextProxy().getResolver()
+                    .delete(Uri.parse(ICMembersProvider.MEMBERS),
+                            "type=? and group_type=?", new String[]{
+                                    ICDatabaseHelper.MemberType.WHITE_LIST + "", groupId
+                            });
+            for (int i = 4; i < 14; i++) {
+                String item = split[i];
+                ICLogger.d("item ==> " + item);
+                //数据入库
+                sb.append(item);
+                if (i != split.length - 1) {
+                    sb.append(CMDSPLIT);
+                } else {
+                    sb.append(CMDEND);
+                }
+                if ("|".equals(item)) {
+                    continue;
+                }
+                //数据入库
+                String[] tmp = item.split("\\|");
+                if (tmp.length == 2) {
+                    String name = Util.decodeUnicode2Utf8(tmp[0]);
+                    String phonem = tmp[1];
+                    ICLogger.i("phnums[" + i + "]=" + item + ",split = " + tmp.length + " , name=" + name + ",-" + phonem);
+                    //contactArray.add(new Contact(Contact.CATEGORY_CALL, name, phonem));
+                    ContentValues contentValues = new ContentValues();
+                    contentValues.put(ICDatabaseHelper.fType, ICDatabaseHelper.MemberType.WHITE_LIST);
+                    contentValues.put(ICDatabaseHelper.fPhoneNum, phonem);
+                    contentValues.put(ICDatabaseHelper.fUserName, name);
+                    //这个是第0组
+                    contentValues.put(ICDatabaseHelper.fGroup, groupId);
+                    contentValues.put(ICDatabaseHelper.fCreateTime, System.currentTimeMillis());
+                    contentValues.put(ICDatabaseHelper.fUpdateTime, System.currentTimeMillis());
+                    //TODO:保存到fzd的联系人列表,类型为白名单
+                    mRuntime.getContextProxy().getResolver()
+                            .insert(Uri.parse(ICMembersProvider.MEMBERS), contentValues);
+                } else {
+                    ICLogger.i("phnums[" + i + "]=" + item + ",split = " + tmp.length);
+                }
+            }
+            String responseText = sb.toString();
+            ICLogger.d("responseText ==> " + responseText);
+            mConnection.send(genStringMessage(cmdMap.get(CMD_TYPE.AP39), responseText));
+        } else {
+            ICLogger.d("parse error =14=> " + cmd);
+        }
+    }
+
     /**
      * 设置二维码
      *
index 590d11f..ce820e1 100644 (file)
@@ -1,2 +1,2 @@
-#Tue Oct 19 16:11:41 CST 2021\r
-VERSION_CODE=978\r
+#Wed Oct 20 18:00:38 CST 2021\r
+VERSION_CODE=979\r