fixed gator wetalk issues.
authorTrillGates <williamtrillgates@gmail.com>
Mon, 9 Aug 2021 07:21:40 +0000 (15:21 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Mon, 9 Aug 2021 07:21:40 +0000 (15:21 +0800)
app/src/main/java/com/enqualcomm/support/service/Deliver.java
app/src/main/java/com/enqualcomm/support/utils/DeviceInfoUtil.java
app/src/main/java/com/enqualcomm/support/utils/ProcessReceiver.java
app/src/main/java/com/ic/protocols/protocol_gator.java
app/src/main/res/values-de-rCH/strings.xml
app/src/main/res/values-fr-rCH/strings.xml
app/src/main/res/values-it-rCH/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-w820dp/strings.xml
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values/strings.xml

index 9b87355..b26fbff 100644 (file)
@@ -188,8 +188,8 @@ public class Deliver extends AbstractConnectionService {
                     .append("\nDate ").append(msg.getDate()).append(msg.getTime())
                     .append("\nflag ").append(msg.haveSent())
                     .append("\ntopic ").append(msg.cmd());
-            if(Config.protocol_no == Config.PROTOCOL_GATOR){
-                if(msg.isFromCache().length()>8) {
+            if (Config.protocol_no == Config.PROTOCOL_GATOR) {
+                if (msg.isFromCache().length() > 8) {
                     sb.append("\norigin ").append(AESCipher.aesDecryptStringFixedKey(msg.isFromCache().substring(8)));
                 }
             }
@@ -394,7 +394,7 @@ public class Deliver extends AbstractConnectionService {
     }
 
     public PowerManager.WakeLock getWakeLock() {
-        PowerManager.WakeLock wakeLock = ((PowerManager) (this.mRuntime.getContextProxy()).context.getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Deliver.class.getSimpleName());
+        PowerManager.WakeLock wakeLock = ((PowerManager) (mRuntime.getContextProxy()).context.getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, Deliver.class.getSimpleName());
         wakeLock.acquire(40000L);
         return wakeLock;
     }
@@ -447,7 +447,7 @@ public class Deliver extends AbstractConnectionService {
                 if (mConnection instanceof NettyConnection) {
                     ((NettyConnection) mConnection).sendMsg("RAWPACKET",
                             protocolAPIHelper.getVoicePacketItem(voicepacket.getSender(),
-                                    voicepacket.getDurationHex(),voicepacket.getPacketTime(),
+                                    voicepacket.getDurationHex(), voicepacket.getPacketTime(),
                                     voicepacket.getPacketCount(),
                                     (voicepacket.getCurrentIndexToSent() + 1),
                                     voicepacket.getVoicePacketWithIndex(voicepacket.getCurrentIndexToSent()).getPacketLen(),
@@ -455,7 +455,7 @@ public class Deliver extends AbstractConnectionService {
                     );
                 }
             } else {
-                ICLogger.i("voicepacket Sender "+voicepacket.getSender()+" duration 0x"+voicepacket.getDurationHex()+" " + voicepacket.getName() + " filetype " + voicepacket.getFiletype() + " , datatype " + voicepacket.getDateType() + " " + voicepacket.getPacketTime() + " sent Done!");
+                ICLogger.i("voicepacket Sender " + voicepacket.getSender() + " duration 0x" + voicepacket.getDurationHex() + " " + voicepacket.getName() + " filetype " + voicepacket.getFiletype() + " , datatype " + voicepacket.getDateType() + " " + voicepacket.getPacketTime() + " sent Done!");
             }
             return true;
         } else if ("PhotoRemoteTaken".equals(paramStringMessage.cmd())) {
@@ -485,13 +485,11 @@ public class Deliver extends AbstractConnectionService {
                     contentValues);
             ICLogger.i("receive taken photo to send " + msgUrl);
             //保存到防走丢的数据库里
-
             //创建voiceConent并添加到数据
             final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP,
-                    "123", msgUrl,"0000", 2, 2);
-
+                    "123", msgUrl, "0000", 2, 2);
             // 把voiceContent拆解成1024的分包
-            Util.parseToVoicePacketSent(voiceContent,1024);
+            Util.parseToVoicePacketSent(voiceContent, 1024);
             //trigger 分包发送
             if (CoreService.getInstance().getConnection() != null) {
                 //H88 专用功能拍照时检测用户体温心率
@@ -500,7 +498,6 @@ public class Deliver extends AbstractConnectionService {
                     if (mRuntime.check_stat_do_temp_test()) {
                         TemperatureUtil.getInstance().DoTempTest(FROM_SERVER);
                     }
-
                     Util.mSleep(5000);
                     //开启测量PPG
                     if (mRuntime.check_stat_do_ppg_test()) {
@@ -529,92 +526,69 @@ public class Deliver extends AbstractConnectionService {
             }, 2000);
             return true;
         } else if ("FactoryResetCheckSim".equals(paramStringMessage.cmd())) {
-
             if (SimSignalUtil.hasSimCard(paramRuntime.getContextProxy().context)) {
                 ICLogger.i("Has Sim Card Skip FactoryReset!");
                 Util.ShowToast(paramRuntime, "Has Sim Card Skip FactoryReset!");
-
                 return true;
             } else {
                 Util.ShowToast(paramRuntime, "Do FactoryReset!");
             }
-            mSendMSGHandler.postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    Util.doMasterClear(paramRuntime.getContextProxy().context);
-                }
-            }, 2000);
+            mSendMSGHandler.postDelayed(() -> Util.doMasterClear(paramRuntime.getContextProxy().context), 2000);
             return true;
         } else if ("poweroff".equals(paramStringMessage.cmd())) {
             paramRuntime.setShutdown(true);
-            mSendMSGHandler.postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    Util.shutdown();
-                }
-            }, 2000);
+            mSendMSGHandler.postDelayed(() -> Util.shutdown(), 2000);
             return true;
         } else if ("FactoryReset".equals(paramStringMessage.cmd())) {
-            mSendMSGHandler.postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    Util.doMasterClear(paramRuntime.getContextProxy().context);
-                }
-            }, 2000);
+            mSendMSGHandler.postDelayed(() -> Util.doMasterClear(paramRuntime.getContextProxy().context), 2000);
             return true;
         } else if ("Reboot".equals(paramStringMessage.cmd())) {
-            mSendMSGHandler.postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    Util.reboot(paramRuntime.getContextProxy().context);
-                }
-            }, 2000);
+            mSendMSGHandler.postDelayed(() -> Util.reboot(paramRuntime.getContextProxy().context), 2000);
             return true;
         } else if ("heartbeat".equals(paramStringMessage.cmd())) {
             //每次心跳,查询一下 是否有语音消息需要接收。
-//      paramConnection.send(protocolAPIHelper.genStringMessage("AP05",protocolAPIHelper.AP05(true)));
-
+            //paramConnection.send(protocolAPIHelper.genStringMessage("AP05",protocolAPIHelper.AP05(true)));
         } else if ("getWeather".equals(paramStringMessage.cmd())) {
             ICLogger.i("获取天气");
             mConnection.send(protocolAPIHelper.getWeatherMSG(mRuntime));
         } else if ("NewVoice".equals(paramStringMessage.cmd())) {
-            mSendMSGHandler.postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    final Context context = (Deliver.this.mRuntime.getContextProxy()).context;
-                    Contact param2Contact = new Contact(CATEGORY_GROUP,
-                            (mRuntime.getContextProxy()).context.getResources().getString(R.string.all_group),
-                            Contact.GROUP_ALL);
-                    int i = mRuntime.getContextProxy().getTelephonyManager().getCallState();
-                    if (!mRuntime.getBatteryLow() && 1 != i && 2 != i) {
-                        if (Config.do_broadCast_message) {
-                            ICLogger.d(Constants.ACTION_MESSAGE_RECEIVED + " " + paramStringMessage.isFromCache());
-                            //广播 voice消息
-                            Intent intent = new Intent();
-                            intent.setAction(Constants.ACTION_MESSAGE_RECEIVED);
-                            intent.putExtra(Constants.KEY_MESSAGE_TYPE, "voice");
-                            intent.putExtra(Constants.KEY_MESSAGE_FROM, "广播消息");
-                            intent.putExtra(Constants.KEY_MESSAGE_URL, paramStringMessage.isFromCache());
-                            //playVoice(context,paramStringMessage.isFromCache());
-                            context.sendBroadcast(intent);
-                        }
-                        if (!Config.noVoiceNotifyDialog) {
-                            Intent intent = new Intent();
-                            //显示提示窗口
-                            intent.setAction(DIALOG_ACTION);
-                            intent.putExtra("contact", param2Contact);
-                            context.sendBroadcast(intent);
-                        }
-
+            mSendMSGHandler.postDelayed(() -> {
+                final Context context = (Deliver.mRuntime.getContextProxy()).context;
+                Contact param2Contact = new Contact(CATEGORY_GROUP,
+                        (mRuntime.getContextProxy()).context.getResources().getString(R.string.all_group),
+                        Contact.GROUP_ALL);
+                int i = mRuntime.getContextProxy().getTelephonyManager().getCallState();
+                if (!mRuntime.getBatteryLow() && 1 != i && 2 != i) {
+                    ICLogger.d("Config.do_broadCast_message == > " + Config.do_broadCast_message);
+                    if (Config.do_broadCast_message) {
+                        ICLogger.d(Constants.ACTION_MESSAGE_RECEIVED + " " + paramStringMessage.isFromCache());
+                        //广播 voice消息
+                        Intent intent = new Intent();
+                        intent.setAction(Constants.ACTION_MESSAGE_RECEIVED);
+                        intent.putExtra(Constants.KEY_MESSAGE_TYPE, "voice");
+                        intent.putExtra(Constants.KEY_MESSAGE_FROM, "广播消息");
+                        intent.putExtra(Constants.KEY_MESSAGE_URL, paramStringMessage.isFromCache());
+                        //playVoice(context,paramStringMessage.isFromCache());
+                        context.sendBroadcast(intent);
                     }
+                    ICLogger.d("Config.noVoiceNotifyDialog ==> " + Config.noVoiceNotifyDialog);
+                    if (!Config.noVoiceNotifyDialog) {
+                        Intent intent = new Intent();
+                        //显示提示窗口
+                        intent.setAction(DIALOG_ACTION);
+                        intent.putExtra("contact", param2Contact);
+                        context.sendBroadcast(intent);
+                    }
+
                 }
             }, 500);
             return true;
         } else if ("NewTalkMsg".equals(paramStringMessage.cmd())) {
-            final Context context = (Deliver.this.mRuntime.getContextProxy()).context;
+            final Context context = (Deliver.mRuntime.getContextProxy()).context;
             String textData = paramStringMessage.isFromCache();
             Contact param2Contact = new Contact(CATEGORY_GROUP,
-                    (mRuntime.getContextProxy()).context.getResources().getString(R.string.all_group),
+                    (mRuntime.getContextProxy()).context.getResources()
+                            .getString(R.string.receiver_we_talk_msg),
                     Contact.GROUP_ALL, textData);
             if (!Config.noVoiceNotifyDialog) {
                 Intent intent = new Intent();
@@ -665,9 +639,9 @@ public class Deliver extends AbstractConnectionService {
                  *        *        * 1 语音——    1.监听语音      *   2.SOS语音      *      3.扩展
                  *        *          * 2 图片——  1.签到图片      *   2.指令图片      *   3.设备图片      *   4.扩展
                  */
-                final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, "123","0000", recordfilepath, 1, 1);
+                final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, "123", "0000", recordfilepath, 1, 1);
                 // 把voiceContent拆解成1024的分包
-                Util.parseToVoicePacketSent(voiceContent,1024);
+                Util.parseToVoicePacketSent(voiceContent, 1024);
                 //trigger 分包发送
                 if (CoreService.getInstance().getConnection() != null)
                     CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
index ec0a604..beae787 100644 (file)
@@ -226,8 +226,8 @@ public class DeviceInfoUtil {
      */
     public static boolean isTopActivity(Context paramContext) {
         ArrayList<String> arrayList = new ArrayList();
-        arrayList.add("com.ic.icwetalk.MainActivity");
-        return arrayList.contains(((ActivityManager.RunningTaskInfo) ((ActivityManager) paramContext.getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(1).get(0)).topActivity.getClassName());
+        arrayList.add("com.ic.wetalk.MainActivity");
+        return arrayList.contains((((ActivityManager) paramContext.getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(1).get(0)).topActivity.getClassName());
     }
 
     public static boolean isFactoryTestTopActivity(Context paramContext) {
index 0a33022..d3f37ef 100644 (file)
@@ -112,12 +112,11 @@ public class ProcessReceiver extends BroadcastReceiver {
             mCustomDialog = tmpDialog.setMessage(contentBuilder.toString()).setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface var1x, int var2x) {
                     var1x.dismiss();
-                    ComponentName var3 = new ComponentName("com.ic.icwetalk",
-                            "com.ic.icwetalk.MainActivity");
-                    Intent intent = new Intent("android.intent.action.MAIN");
+                    ComponentName var3 = new ComponentName("com.ic.wetalk",
+                            "com.ic.wetalk.MainActivity");
+                    Intent intent = new Intent();
                     intent.putExtra("ACTIVITY_TYPE", 2);
                     intent.putExtra("contact", contact);
-                    intent.addCategory("android.intent.category.DEFAULT");
                     intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
                     intent.setComponent(var3);
                     VibrateUtil.getInstance(context).vibrateOn(false);
@@ -127,13 +126,10 @@ public class ProcessReceiver extends BroadcastReceiver {
                         e.printStackTrace();
                         ICLogger.e(e.getMessage(), e);
                     }
-
-                }
-            }).setNegativeButton(context.getString(R.string.cancel), new DialogInterface.OnClickListener() {
-                public void onClick(DialogInterface var1, int var2) {
-                    var1.dismiss();
-                    VibrateUtil.getInstance(context).vibrateOn(false);
                 }
+            }).setNegativeButton(context.getString(R.string.cancel), (var1, var2) -> {
+                var1.dismiss();
+                VibrateUtil.getInstance(context).vibrateOn(false);
             }).create();
             mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST);
             mCustomDialog.show();
@@ -428,7 +424,7 @@ public class ProcessReceiver extends BroadcastReceiver {
                     }
                 }
             } else if (paramIntent.hasExtra("talkTextMsg")) {
-                contact = (Contact) paramIntent.getParcelableExtra("talkTextMsg");
+                contact = paramIntent.getParcelableExtra("talkTextMsg");
                 SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
                 isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
                 if (contact != null && !isSilence) {
index e673235..73c5b97 100644 (file)
@@ -532,9 +532,14 @@ public class protocol_gator {
         ArrayList<Contact> contactArray = new ArrayList<>();
         ContentValues contentValues = new ContentValues();
         ContentResolver resolver = runtime.getContextProxy().getResolver();
+        //白名单
         resolver.delete(Uri.parse(ICMembersProvider.MEMBERS), "type=?", new String[]{
                 ICDatabaseHelper.MemberType.WHITE_LIST + ""
         });
+        //微聊,gator的联系人,可以做白名单,也可以作为微聊的联系人
+        resolver.delete(Uri.parse(ICMembersProvider.MEMBERS), "type=?", new String[]{
+                ICDatabaseHelper.MemberType.FRIEND + ""
+        });
         for (int i = 0; i < numbers.size(); i++) {
             String phoneNum = numbers.get(i);
             String name = names.get(i);
@@ -550,6 +555,8 @@ public class protocol_gator {
             //后面所有地方都切换到新库了,才删除上面的代码
             // TODO:需要修改白名单拦截的地方.
             resolver.insert(Uri.parse(ICMembersProvider.MEMBERS), contentValues);
+            contentValues.put(ICDatabaseHelper.fType, ICDatabaseHelper.MemberType.FRIEND);
+            resolver.insert(Uri.parse(ICMembersProvider.MEMBERS), contentValues);
         }
         //TODO:保存到fzd的联系人列表,类型为白名单
         runtime.getDbHelper().saveContacts(contactArray, false, false, true, false, false, false);
@@ -588,7 +595,6 @@ public class protocol_gator {
                 ArrayList<String> numbers = new ArrayList<>();
                 ArrayList<String> names = new ArrayList<>();
                 ArrayList<String> types = new ArrayList<>();
-
                 for (int i = 1; i < cmdlist1.length; i += 3) {
                     String number = cmdlist1[i];
                     String name = cmdlist1[i + 1];
@@ -619,12 +625,10 @@ public class protocol_gator {
                     }
                 }
                 appendContact(ds, numbers, names);
-
             } else {
                 ICLogger.e("AP06 format error1 !");
                 connection.send(BPXX_REPLY(ds, CMD_TYPE.BP06, cmdlist[1], false));
             }
-
             ICLogger.d(sb.toString());
             connection.send(BPXX_REPLY(ds, CMD_TYPE.BP06, cmdlist[1], true));
         } else {
@@ -937,7 +941,6 @@ public class protocol_gator {
             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");
                 ICLogger.i("save Amr file to " + amrFilepath);
@@ -950,9 +953,9 @@ public class protocol_gator {
                 voiceContent.preview = String.valueOf(Util.getDuration(voiceContent.content));
                 ds.getDbHelper().updateMessage(voiceContent, uri2);
                 //插入到数据库中
-                message2Db("", amrFilepath, ICDatabaseHelper.MessageType.VOICE);
-//                runtime.getContextProxy().sendBroadcast(ACTION_IMESSAGE, runtime);
-                connection.DeliverCMDMessageToSystem("NewVoice", amrFilepath);//通知下面线程状态变化
+                message2Db(sourceNumb, amrFilepath, ICDatabaseHelper.MessageType.VOICE);
+                //runtime.getContextProxy().sendBroadcast(ACTION_IMESSAGE, runtime);
+                connection.DeliverCMDMessageToSystem("NewTalkMsg", amrFilepath);//通知下面线程状态变化
             }
         } else {
             ICLogger.e("AP12 format error");
index 993d27d..80d7cbc 100644 (file)
     <string name="send_success_tips_text">发送成功</string>\r
     <string name="back_text">返回</string>\r
     <string name="send_text">发送</string>\r
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>\r
 </resources>\r
index 993d27d..80d7cbc 100644 (file)
     <string name="send_success_tips_text">发送成功</string>\r
     <string name="back_text">返回</string>\r
     <string name="send_text">发送</string>\r
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>\r
 </resources>\r
index 358fc5f..c5ce296 100644 (file)
     <string name="send_success_tips_text">发送成功</string>\r
     <string name="back_text">返回</string>\r
     <string name="send_text">发送</string>\r
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>\r
 </resources>\r
index 022080f..d712bea 100644 (file)
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>
 
 </resources>
index 49acd3b..3132e01 100644 (file)
@@ -6,4 +6,5 @@
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>
 </resources>
\ No newline at end of file
index 089d5ff..4196c29 100644 (file)
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>
 </resources>
index cf9b7f8..35755d1 100644 (file)
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="receiver_we_talk_msg">收到微聊消息.</string>
 
 </resources>