瀏覽代碼

解决手机有通话时,有新的呼叫进来,待通话结束后没有显示新呼叫的问题

weizhengliang 2 年之前
父節點
當前提交
a288545624

+ 3 - 3
home/src/main/code/com/wdkl/ncs/android/component/home/activity/NewCallListActivity.kt

@@ -257,15 +257,15 @@ class NewCallListActivity : BaseToolActivity(), NewCallItemAdapter.CallClickList
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onMoonEvent(messageEvent: MessageEvent) {
-        if (messageEvent.tag == Constants.EVENT_NEW_CALL) { //新呼叫
+        if (messageEvent.tag == Constants.EVENT_UPDATE_CALL) { //新呼叫
             updateCallList()
-        } else if (messageEvent.tag == Constants.EVENT_NEW_TCP) {
+        } /*else if (messageEvent.tag == Constants.EVENT_NEW_TCP) {
             val tcpModel = messageEvent.getMessage() as TcpModel
             if (tcpModel.getAction() === TcpAction.VoiceAction.CANCEL || tcpModel.action == TcpAction.VoiceAction.VOICE_OFF) {
                 //对方取消呼叫或者呼叫已被其他主机处理(接听或拒绝)
                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 removeCall(interactionVO)
             }
-        }
+        }*/
     }
 }

+ 36 - 12
home/src/main/code/com/wdkl/ncs/android/component/home/service/WdKeepAliveService.kt

@@ -224,7 +224,7 @@ class WdKeepAliveService : AbsWorkService() {
 
                             //更新界面
                             if (mNewCallListActive) {
-                                EventBus.getDefault().post(MessageEvent(tcpModel, Constants.EVENT_NEW_CALL))
+                                EventBus.getDefault().post(MessageEvent(tcpModel, Constants.EVENT_UPDATE_CALL))
                             } else {
                                 val intent = Intent()
                                 intent.setClass(this, NewCallListActivity::class.java)
@@ -240,14 +240,16 @@ class WdKeepAliveService : AbsWorkService() {
                                     }
                                     waitingCall = false
 
-                                    //更新界面
-                                    if (mNewCallListActive) {
-                                        EventBus.getDefault().post(MessageEvent(tcpModel, Constants.EVENT_NEW_CALL))
-                                    } else {
-                                        val intent = Intent()
-                                        intent.setClass(this, NewCallListActivity::class.java)
-                                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
-                                        startActivity(intent)
+                                    if (Constants.newCallList.size > 0) {
+                                        //更新界面
+                                        if (mNewCallListActive) {
+                                            EventBus.getDefault().post(MessageEvent(tcpModel, Constants.EVENT_UPDATE_CALL))
+                                        } else {
+                                            val intent = Intent()
+                                            intent.setClass(this, NewCallListActivity::class.java)
+                                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                                            startActivity(intent)
+                                        }
                                     }
                                 }.start()
                             }
@@ -324,7 +326,9 @@ class WdKeepAliveService : AbsWorkService() {
                 if (tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS) {
                     EventBus.getDefault().post(MessageEvent(tcpModel, 1))
                 } else if (tcpModel.getAction() == TcpAction.VoiceAction.CALL) {
-                    if (DeviceChannel.calling) {
+                    EventBus.getDefault().post(MessageEvent(tcpModel, 1))
+
+                    /*if (DeviceChannel.calling) {
                         Log.d(TAG, "通话中,来电 " + tcpModel.getFromId() + "<>" + DeviceChannel.callId)
                         //相同来源,重新建立通话
                         if (tcpModel.getFromId() == DeviceChannel.callId) {
@@ -332,13 +336,33 @@ class WdKeepAliveService : AbsWorkService() {
                         }
                     } else { //得到通话
                         EventBus.getDefault().post(MessageEvent(tcpModel, 1))
-                    }
+                    }*/
                 } else if (tcpModel.getAction() == TcpAction.VoiceAction.ACCEPT //我方呼出,对方接受
                         || tcpModel.getAction() == TcpAction.VoiceAction.REJECT //我方呼出,对方拒绝
                         || tcpModel.getAction() == TcpAction.VoiceAction.CALLING //我方呼出,对方通话中
                         || tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF
                         || tcpModel.getAction() == TcpAction.VoiceAction.FAILED //我方呼出,对方不在线,设备离线或其它错误
-                        || tcpModel.getAction() == TcpAction.VoiceAction.CANCEL) {
+                        || tcpModel.getAction() == TcpAction.VoiceAction.CANCEL
+                        || tcpModel.getAction() == TcpAction.VoiceAction.VOICE_OFF) {
+
+                    if (tcpModel.getAction() === TcpAction.VoiceAction.CANCEL || tcpModel.action == TcpAction.VoiceAction.VOICE_OFF) {
+                        //对方取消呼叫或者呼叫已被其他主机处理(接听或拒绝)
+                        val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+                        val iterator = Constants.newCallList.iterator()
+                        while (iterator.hasNext()) {
+                            val it = iterator.next()
+                            val interaction = Gson().fromJson(it.data.toString(), InteractionVO::class.java)
+                            if (interaction.id.equals(interactionVO.id)) {
+                                iterator.remove()
+                            }
+                        }
+
+                        //更新界面
+                        if (mNewCallListActive) {
+                            EventBus.getDefault().post(MessageEvent(tcpModel, Constants.EVENT_UPDATE_CALL))
+                        }
+                    }
+
                     EventBus.getDefault().post(MessageEvent(tcpModel, 2))
                 }
             }

+ 1 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/common/Constants.kt

@@ -86,6 +86,6 @@ class Constants {
         const val EVENT_NEW_TCP = 0x48
         const val EVENT_HEADSET_HOOK = 0x49
         const val EVENT_CLEAR_IM = 0x50
-        const val EVENT_NEW_CALL = 0x51
+        const val EVENT_UPDATE_CALL = 0x51
     }
 }