Browse Source

## [1.1.12] version 31 - 2020-07-30
### Fixed
- 修复单个客户交互列表刷新加载更多时,加载所有人的交互问题
- 修复多个SOS到来时不播放音乐问题
- 队列执行SOS呼入
### Changed
- 去掉交互列表可点击响应事件

allen 3 years ago
parent
commit
91049f6624

+ 2 - 2
build.gradle

@@ -47,12 +47,12 @@ buildscript {
     /**
      * APP版本码
      */
-    ext.app_version_code = 30
+    ext.app_version_code = 31
 
     /**
      * APP版本号
      */
-    ext.app_version = "1.1.11"
+    ext.app_version = "1.1.12"
 
     /**
      * 项目依赖库

+ 19 - 6
home/src/main/code/com/wdkl/ncs/android/component/home/activity/SOSEmergencyCallActivity.kt

@@ -9,6 +9,7 @@ import android.view.KeyEvent
 import android.view.View
 import com.google.gson.Gson
 import com.wdkl.ncs.android.component.home.R
+import com.wdkl.ncs.android.component.home.service.WdKeepAliveService
 import com.wdkl.ncs.android.component.home.util.MediaPlayHelper
 import com.wdkl.ncs.android.component.nursehome.common.Constants
 import com.wdkl.ncs.android.lib.utils.AppTool
@@ -25,6 +26,7 @@ import kotlinx.android.synthetic.main.activity_sos_emergency_call.*
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
+import java.util.concurrent.ConcurrentLinkedQueue
 
 
 class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
@@ -36,9 +38,12 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+        Constants.sosActive = true
         setContentView(R.layout.activity_sos_emergency_call)
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
         interactionVO = Gson().fromJson(tcpModel!!.getData().toString(), InteractionVO::class.java)
+        init()
+
         //震动
         mVibrator = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
         mVibrator.cancel()
@@ -49,7 +54,8 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
         } else {
             mVibrator.vibrate(pattern, 0)
         }
-        init()
+
+        MediaPlayHelper.getInstance().stopMusic()
         MediaPlayHelper.getInstance().playResMusic(R.raw.sos2, 1.0f, true)
     }
 
@@ -68,11 +74,13 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
         when (p0.id) {
             R.id.hang_up_imagev -> {
                 DeviceChannel.calling = false    //解除通话状态中
-                MediaPlayHelper.getInstance().stopMusic()
+                MediaPlayHelper.getInstance().releaseMusic()
                 //给服务器发送处理SOStcp
                 var otherUtilTcpModel = OtherUtil.SOSCancel(Constants.deviceId.toInt(), tcpModel?.fromId, interactionVO?.id)
                 TcpClient.getInstance().sendMsg(otherUtilTcpModel.toJson())
-                mVibrator.cancel()
+                if (mVibrator!=null) {
+                    mVibrator.cancel()
+                }
                 finish()
             }
         }
@@ -82,16 +90,21 @@ class SOSEmergencyCallActivity : Activity(), View.OnClickListener {
         super.onStop()
         DeviceChannel.calling = false    //解除通话状态中
         mVibrator.cancel()
-        MediaPlayHelper.getInstance().stopMusic()
+        MediaPlayHelper.getInstance().releaseMusic()
         EventBus.getDefault().unregister(this)
     }
 
     override fun finish() {
-        super.finish()
+        Constants.sosActive = false
+        AppTool.Time.delay(1000){
+            EventBus.getDefault().post(MessageEvent(TcpModel(),Constants.EVENT_SOS_POLL))
+        }
+
         DeviceChannel.calling = false    //解除通话状态中
         mVibrator.cancel()
-        MediaPlayHelper.getInstance().stopMusic()
+        MediaPlayHelper.getInstance().releaseMusic()
         EventBus.getDefault().unregister(this)
+        super.finish()
     }
 
     @Subscribe(threadMode = ThreadMode.MAIN)

+ 10 - 0
home/src/main/code/com/wdkl/ncs/android/component/home/activity/TakeoverActivity.kt

@@ -19,6 +19,8 @@ import com.wdkl.ncs.android.middleware.logic.contract.home.TakeoverContract
 import com.wdkl.ncs.android.middleware.logic.presenter.home.TakeoverPresenter
 import com.wdkl.ncs.android.middleware.tcp.TcpClient
 import com.wdkl.ncs.android.middleware.tcp.channel.DeviceUtil
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
+import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
 import com.wdkl.ncs.android.middleware.utils.MessageEvent
 import kotlinx.android.synthetic.main.activity_takeover.*
 import kotlinx.android.synthetic.main.takeover_item.*
@@ -97,6 +99,14 @@ class TakeoverActivity: BaseActivity<TakeoverPresenter, ActivityTakeoverBinding>
 
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onMoonEvent(messageEvent: MessageEvent) {
+        if (messageEvent.tag == 2) {
+            val resTcpModel = messageEvent.getMessage() as TcpModel
+            if (resTcpModel.action  == TcpAction.VoiceAction.FAILED){
+                showMessage("呼叫失败,可能对方不在线")
+            } else if (resTcpModel.action == TcpAction.VoiceAction.CALLING){
+                showMessage("对方通话中")
+            }
+        }
     }
 
     override fun destory() {

+ 40 - 33
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchCallRecordsActivity.kt

@@ -31,7 +31,6 @@ import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
 import com.wdkl.ncs.android.middleware.utils.MessageEvent
 import kotlinx.android.synthetic.main.watch_activity_call_records.*
 import kotlinx.android.synthetic.main.watch_activity_call_records.refresh
-import kotlinx.android.synthetic.main.watch_contacts_lay.*
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
@@ -61,10 +60,11 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
     private lateinit var loadingDialog: LoadingDialog
 
     private var customerId = ""
-    private var ACTION = "ACTION"
+
     var all = "ALL"
-    var initiator = "INITATOR"
+    var customerRecords = "CUSTOMER_RECORDS"
     var unread = "UNREAD"
+
     var action: String? = null
     var receivedData: WatchContactsVO? = null
 
@@ -98,10 +98,11 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
         receivedData = intent.getSerializableExtra("data") as WatchContactsVO?
         action = intent.getStringExtra("action")
         customerId = intent.getStringExtra("customer_id")
-        if (action == all) {
-            if (customerId.equals("")) {
-                presenter.loadPage(all, 1, 30, Constants.deviceId, 0, 0)
+
+        when(action){
+            all->{
                 call_relyout.visibility = View.GONE
+                presenter.loadPage(all, 1, 30, Constants.deviceId, 0, 0)
 
                 refresh.setOnLoadMoreListener {
                     page += 1
@@ -111,36 +112,40 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
                     presenter.loadPage(all, 1, 30, Constants.deviceId, 0, 0)
                 }
             }
-        } else if (action == unread) {
-            presenter.loadPage(all, 1, 30, Constants.deviceId, 0, 1)
-            call_relyout.visibility = View.GONE
-
-            refresh.setOnLoadMoreListener {
-                page += 1
-                presenter.loadPage(all, page, 30, Constants.deviceId, 0, 1)
-            }
-            refresh.setOnRefreshListener {
+            unread->{
+                call_relyout.visibility = View.GONE
                 presenter.loadPage(all, 1, 30, Constants.deviceId, 0, 1)
-            }
-        } else if (action == initiator) {
-            call_relyout.visibility = View.VISIBLE
-            presenter.loadPage(initiator, 1, 30, Constants.deviceId, customerId.toInt(), -1)
-            call_relyout.setOnClickListener {
-                loadingDialog.show()
-                call_relyout.isEnabled = false
-                var tcpModel = VoiceUtil.voiceCall(Constants.deviceId, receivedData!!.deviceId)
-                TcpClient.getInstance().sendMsg(tcpModel.toJson())
-                countDownTimer.start()
-            }
 
-            refresh.setOnLoadMoreListener {
-                page += 1
-                presenter.loadPage(all, page, 30, Constants.deviceId, 0, -1)
+                refresh.setOnLoadMoreListener {
+                    page += 1
+                    presenter.loadPage(all, page, 30, Constants.deviceId, 0, 1)
+                }
+                refresh.setOnRefreshListener {
+                    presenter.loadPage(all, 1, 30, Constants.deviceId, 0, 1)
+                }
             }
-            refresh.setOnRefreshListener {
-                presenter.loadPage(all, 1, 30, Constants.deviceId, 0, -1)
+            customerRecords->{
+                call_relyout.visibility = View.VISIBLE
+                call_relyout.setOnClickListener {
+                    loadingDialog.show()
+                    call_relyout.isEnabled = false
+                    var tcpModel = VoiceUtil.voiceCall(Constants.deviceId, receivedData!!.deviceId)
+                    TcpClient.getInstance().sendMsg(tcpModel.toJson())
+                    countDownTimer.start()
+                }
+
+                presenter.loadPage(customerRecords, 1, 30, Constants.deviceId, customerId.toInt(), -1)
+
+                refresh.setOnLoadMoreListener {
+                    page += 1
+                    presenter.loadPage(customerRecords, page, 30, Constants.deviceId, customerId.toInt(), -1)
+                }
+                refresh.setOnRefreshListener {
+                    presenter.loadPage(customerRecords, 1, 30, Constants.deviceId, customerId.toInt(), -1)
+                }
             }
         }
+
         initCountDownTimer()
     }
 
@@ -228,7 +233,7 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onMoonEvent(messageEvent: MessageEvent) {
         if (messageEvent.tag == 1 || messageEvent.tag == 2) {
-            var tcpModel = messageEvent.getMessage() as TcpModel
+            val tcpModel = messageEvent.getMessage() as TcpModel
             Log.i(TAG, tcpModel.toJson())
             if (tcpModel.type == TcpType.VOICE) {
                 if (tcpModel.action == TcpAction.VoiceAction.SUCCESS) {
@@ -238,7 +243,9 @@ class WatchCallRecordsActivity : BaseActivity<WatchCallRecordsFragmentPresenter,
                     loadingDialog.dismiss()
                     call_relyout.isEnabled = true
                     DeviceChannel.calling = false;
-                    showMessage("对方不在线")
+                    showMessage("呼叫失败,可能对方不在线")
+                }else if (tcpModel.action == TcpAction.VoiceAction.CALLING){
+                    showMessage("对方通话中")
                 }
             }
         }

+ 1 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchContactsActivity.kt

@@ -102,7 +102,7 @@ class WatchContactsActivity : BaseActivity<WatchActivityPresenter, WatchContacts
             val watchContactsVO :WatchContactsVO = data
             var intent = Intent(this, WatchCallRecordsActivity::class.java)
             intent.putExtra("data", watchContactsVO)
-            intent.putExtra("action", "INITATOR")
+            intent.putExtra("action", "CUSTOMER_RECORDS")
             intent.putExtra("customer_id", ""+customerId)
             startActivity(intent)
 

+ 8 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WatchEventDetailActivity.kt

@@ -247,7 +247,7 @@ class WatchEventDetailActivity : BaseActivity<WatchHomeActivityPresenter, WatchA
     @Subscribe(threadMode = ThreadMode.MAIN)
     fun onMoonEvent(messageEvent: MessageEvent) {
         if (messageEvent.tag == 4) {
-            var resTcpModel = messageEvent.getMessage() as TcpModel
+            val resTcpModel = messageEvent.getMessage() as TcpModel
             if (resTcpModel.type == TcpType.DATA && resTcpModel.action == TcpAction.DataAction.INTERACTION) {
                 if (resTcpModel.data != null) {
                     loadingDialog.dismiss()
@@ -272,6 +272,13 @@ class WatchEventDetailActivity : BaseActivity<WatchHomeActivityPresenter, WatchA
             loadingDialog.dismiss()
             mVibrator.cancel()
             //具体逻辑在TcpHandleService中处理
+        } else if (messageEvent.tag == 2) {
+            val resTcpModel = messageEvent.getMessage() as TcpModel
+            if (resTcpModel.action  == TcpAction.VoiceAction.FAILED){
+                showMessage("呼叫失败,可能对方不在线")
+            } else if (resTcpModel.action == TcpAction.VoiceAction.CALLING){
+                showMessage("对方通话中")
+            }
         }
     }
 }

+ 35 - 35
home/src/main/code/com/wdkl/ncs/android/component/home/adapter/WatchCallRecordsItemAdapter.kt

@@ -182,41 +182,41 @@ class WatchCallRecordsItemAdapter(val data: ArrayList<InteractionVO>) : BaseDele
                 }
             }
 
-            binding.projectTv.setOnClickListener {
-                if (itemData.actionEnd != null)return@setOnClickListener
-                Log.i(TAG, "点击了事件按钮")
-
-                Thread(Runnable {
-                    run {
-                        if (!Constants.deviceId.equals("")) {
-                            var eventTcpModel = EventUtil.eventResponse(Constants.deviceId.toInt(), itemData.fromDeviceId, itemData.id)
-                            TcpClient.getInstance().sendMsg(eventTcpModel.toJson())
-                        } else {
-                            showMessage("获取不到当给前设备id")
-                        }
-                    }
-                }).start()
-
-                //处理完之后要刷新数据
-            }
-            binding.playTv.setOnClickListener {
-                if (itemData.actionEnd != null)return@setOnClickListener
-                //点击之后播放语音留言
-                showMessage("点击了播放留言")
-                Thread(Runnable {
-                    run {
-                        if (!Constants.deviceId.equals("")) {
-                            var imUtilTcpModel = ImUtil.imRead(Constants.deviceId.toInt(), itemData.fromDeviceId, itemData.id)
-                            TcpClient.getInstance().sendMsg(imUtilTcpModel.toJson())
-                            MediaPlayHelper.getInstance().playUrlMusic(UrlManager.build().device_url+itemData.data,0.8f,false)
-                        } else {
-                            showMessage("获取不到当给前设备id")
-                        }
-                    }
-                }).start()
-
-                //处理完之后要刷新数据
-            }
+//            binding.projectTv.setOnClickListener {
+//                if (itemData.actionEnd != null)return@setOnClickListener
+//                Log.i(TAG, "点击了事件按钮")
+//
+//                Thread(Runnable {
+//                    run {
+//                        if (!Constants.deviceId.equals("")) {
+//                            var eventTcpModel = EventUtil.eventResponse(Constants.deviceId.toInt(), itemData.fromDeviceId, itemData.id)
+//                            TcpClient.getInstance().sendMsg(eventTcpModel.toJson())
+//                        } else {
+//                            showMessage("获取不到当给前设备id")
+//                        }
+//                    }
+//                }).start()
+//
+//                //处理完之后要刷新数据
+//            }
+//            binding.playTv.setOnClickListener {
+//                if (itemData.actionEnd != null)return@setOnClickListener
+//                //点击之后播放语音留言
+//                showMessage("点击了播放留言")
+//                Thread(Runnable {
+//                    run {
+//                        if (!Constants.deviceId.equals("")) {
+//                            var imUtilTcpModel = ImUtil.imRead(Constants.deviceId.toInt(), itemData.fromDeviceId, itemData.id)
+//                            TcpClient.getInstance().sendMsg(imUtilTcpModel.toJson())
+//                            MediaPlayHelper.getInstance().playUrlMusic(UrlManager.build().device_url+itemData.data,0.8f,false)
+//                        } else {
+//                            showMessage("获取不到当给前设备id")
+//                        }
+//                    }
+//                }).start()
+//
+//                //处理完之后要刷新数据
+//            }
 
         }
     }

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

@@ -1,39 +1,30 @@
 package com.wdkl.ncs.android.component.home.service
 
+import android.app.ActivityManager
+import android.content.ComponentName
+import android.content.Context
 import android.content.Intent
 import android.os.Handler
 import android.os.IBinder
 import android.os.Messenger
 import android.util.Log
-import com.enation.javashop.net.engine.model.NetState
-import com.enation.javashop.net.engine.plugin.connection.ConnectionQuality
-import com.enation.javashop.net.engine.plugin.exception.ExceptionHandle
-import com.enation.javashop.net.engine.utils.ThreadFromUtils
 import com.google.common.base.Strings
 import com.google.gson.FieldNamingPolicy
 import com.google.gson.Gson
 import com.google.gson.GsonBuilder
 import com.wdkl.core.consts.Urls
 import com.wdkl.core.socket.SocketManager
+import com.wdkl.ncs.android.component.home.BuildConfig
 import com.wdkl.ncs.android.component.home.activity.*
 import com.wdkl.ncs.android.component.home.settingconfig.SettingConfig
 import com.wdkl.ncs.android.component.home.util.AppUtils
-import com.wdkl.ncs.keepbackground.work.AbsWorkService
 import com.wdkl.ncs.android.component.home.util.NetHelper
 import com.wdkl.ncs.android.component.home.util.SpeechUtil
 import com.wdkl.ncs.android.component.home.util.Util
 import com.wdkl.ncs.android.component.nursehome.common.Constants
-import com.wdkl.ncs.android.lib.utils.AppTool
-import com.wdkl.ncs.android.lib.utils.ConnectionObserver
-import com.wdkl.ncs.android.lib.utils.getEventCenter
 import com.wdkl.ncs.android.lib.utils.getJsonString
-import com.wdkl.ncs.android.lib.vo.NetStateEvent
 import com.wdkl.ncs.android.middleware.api.ApiManager
-import com.wdkl.ncs.android.middleware.api.WatchDeviceInfoAndTCPMailingAddressApi
-import com.wdkl.ncs.android.middleware.di.MiddlewareDaggerComponent
 import com.wdkl.ncs.android.middleware.model.dos.PartSettingDO
-import com.wdkl.ncs.android.middleware.model.dto.TcpSeverDTO
-import com.wdkl.ncs.android.middleware.model.vo.DeviceVO
 import com.wdkl.ncs.android.middleware.model.vo.InteractionVO
 import com.wdkl.ncs.android.middleware.tcp.TcpClient
 import com.wdkl.ncs.android.middleware.tcp.TcpClientHandler
@@ -42,17 +33,18 @@ import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
 import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
 import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
 import com.wdkl.ncs.android.middleware.utils.MessageEvent
-import io.reactivex.disposables.Disposable
+import com.wdkl.ncs.keepbackground.work.AbsWorkService
 import org.greenrobot.eventbus.EventBus
 import org.greenrobot.eventbus.Subscribe
 import org.greenrobot.eventbus.ThreadMode
 import java.util.*
-import javax.inject.Inject
+import java.util.concurrent.ConcurrentLinkedQueue
 
 class WdKeepAliveService : AbsWorkService() {
     val TAG = "WdKeepAliveService"
     companion object instance {
         var updateLastTime : Long = System.currentTimeMillis() / 1000
+        var sosQueue : ConcurrentLinkedQueue<TcpModel> = ConcurrentLinkedQueue<TcpModel>()
     }
 
     private var mIsRunning = false
@@ -130,74 +122,89 @@ class WdKeepAliveService : AbsWorkService() {
             }
             //事件与语音留言通道
             3->{
-                while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
-                    Thread.sleep(400)
-                }
+                Thread(Runnable {
+                    while (DeviceChannel.calling) {
+                        Thread.sleep(400)
+                    }
 
-                SpeechUtil.getInstance().stopSpeak()
+                    SpeechUtil.getInstance().stopSpeak()
 
-                Util.wakeUpAndUnlock(this)
+                    Util.wakeUpAndUnlock(this)
 
-                val tcpModel = messageEvent.getMessage() as TcpModel
-                val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
-                if (tcpModel.type == TcpType.IM) {
-                    SpeechUtil.getInstance().newSpeech("您有新的语音留言待处理", false)
-                } else if (tcpModel.type == TcpType.EVENT) {
-                    var eventStr = ""
-                    if (interactionVO != null) {
-                        eventStr = Util.appendSpace(interactionVO.fromFrameFullName.replace("-", "")) + ", " + interactionVO.data
+                    val tcpModel = messageEvent.getMessage() as TcpModel
+                    val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+                    if (tcpModel.type == TcpType.IM) {
+                        SpeechUtil.getInstance().newSpeech("您有新的语音留言待处理", false)
+                    } else if (tcpModel.type == TcpType.EVENT) {
+                        var eventStr = ""
+                        if (interactionVO != null) {
+                            eventStr = Util.appendSpace(interactionVO.fromFrameFullName.replace("-", "")) + ", " + interactionVO.data
+                        }
+                        SpeechUtil.getInstance().newSpeech("您有新的事件待处理, " + eventStr, false)
                     }
-                    SpeechUtil.getInstance().newSpeech("您有新的事件待处理, " + eventStr, false)
-                }
-                tcpModel.data = interactionVO
-
-                val intent = Intent()
-                intent.setClass(this, WatchEventDetailActivity::class.java)
-                intent.putExtra("tcpModelStr", tcpModel.toJson())
-                intent.putExtra("boolVibrator", true)
-                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
-                startActivity(intent)
-            }
-            //SOS通道
-            999->{
-                while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
-                    Thread.sleep(400)
-                }
+                    tcpModel.data = interactionVO
 
-                SpeechUtil.getInstance().stopSpeak()
-
-//                DeviceChannel.calling = true    //置于通话状态中,不可呼叫
-                Util.wakeUpAndUnlock(this)
-                val tcpModel = messageEvent.getMessage() as TcpModel
-                if (tcpModel.type == TcpType.SOS && tcpModel.action === TcpAction.SOSAction.CALL) {
                     val intent = Intent()
-                    intent.setClass(this, SOSEmergencyCallActivity::class.java)
-                    intent.putExtra("TcpModel", tcpModel)
+                    intent.setClass(this, WatchEventDetailActivity::class.java)
+                    intent.putExtra("tcpModelStr", tcpModel.toJson())
+                    intent.putExtra("boolVibrator", true)
                     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                     startActivity(intent)
+                }).start()
+            }
+            //SOS通道
+            999->{
+                val tcpModelIn = messageEvent.getMessage() as TcpModel
+                if (tcpModelIn.action == TcpAction.SOSAction.CALL) {
+                    sosQueue.offer(tcpModelIn)
+                    if (!Constants.sosActive) {
+                        val tcpModel = sosQueue.poll()
+                        openSos(tcpModel)
+                    }
+                } else {
+                    var tcpModelRm:TcpModel? = null
+                    val interactionVoIn = Gson().fromJson(tcpModelIn.data.toString(), InteractionVO::class.java)
+                    sosQueue.forEach {
+                        val interactionVO = Gson().fromJson(it.data.toString(), InteractionVO::class.java)
+                        if (interactionVO.id == interactionVoIn.id){
+                            tcpModelRm = it
+                            return
+                        }
+                    }
+                    if (tcpModelRm!=null){
+                        sosQueue.remove(tcpModelRm)
+                    }
                 }
             }
+            Constants.EVENT_SOS_POLL->{
+                val tcpModel = sosQueue.poll()
+                openSos(tcpModel)
+            }
             //用户切换
             Constants.EVENT_USER_CHANGE->{
-                while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
-                    Thread.sleep(400)
-                }
-                DeviceChannel.calling = true    //置于通话状态中,不可呼叫
-                Util.wakeUpAndUnlock(this)
-                AppUtils.restartApp()
+                Thread(Runnable {
+                    while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
+                        Thread.sleep(400)
+                    }
+                    DeviceChannel.calling = true    //置于通话状态中,不可呼叫
+                    Util.wakeUpAndUnlock(this)
+                    AppUtils.restartApp()
+                }).start()
             }
             //设备切换
             Constants.EVENT_DEVICE_CHANGE->{
-                while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
-                    Thread.sleep(400)
-                }
+                Thread(Runnable {
+                    while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
+                        Thread.sleep(400)
+                    }
 
-                DeviceChannel.calling = true    //置于通话状态中,不可呼叫
-                Util.wakeUpAndUnlock(this)
-                val tcpModel = messageEvent.getMessage() as TcpModel
-                if (tcpModel.action == TcpAction.DeviceAction.RESTART) {
-                    AppUtils.restartApp()
-                }
+                    DeviceChannel.calling = true    //置于通话状态中,不可呼叫
+                    Util.wakeUpAndUnlock(this)
+                    val tcpModel = messageEvent.getMessage() as TcpModel
+                    if (tcpModel.action == TcpAction.DeviceAction.RESTART) {
+                        AppUtils.restartApp()
+                    }
+                }).start()
             }
             //系统设置
             Constants.EVENT_DEVICE_SETTING->{
@@ -224,22 +231,24 @@ class WdKeepAliveService : AbsWorkService() {
             }
             //APP升级
             Constants.EVENT_APP_UPDATE->{
-                while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
-                    Thread.sleep(400)
-                }
+                Thread(Runnable {
+                    while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
+                        Thread.sleep(400)
+                    }
 
-                DeviceChannel.calling = true    //置于通话状态中,不可呼叫
-                Util.wakeUpAndUnlock(this)
-                val tcpModel = messageEvent.getMessage() as TcpModel
-                if (tcpModel.action == TcpAction.DeviceAction.APP_UPDATE) {
-                    if ((System.currentTimeMillis() / 1000) - updateLastTime > 10){   //大于10秒可继续升级
-                        updateLastTime = System.currentTimeMillis() / 1000
-                        val intent = Intent()
-                        intent.setClass(this, AppUpdateActivity::class.java)
-                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
-                        startActivity(intent)
+                    DeviceChannel.calling = true    //置于通话状态中,不可呼叫
+                    Util.wakeUpAndUnlock(this)
+                    val tcpModel = messageEvent.getMessage() as TcpModel
+                    if (tcpModel.action == TcpAction.DeviceAction.APP_UPDATE) {
+                        if ((System.currentTimeMillis() / 1000) - updateLastTime > 10){   //大于10秒可继续升级
+                            updateLastTime = System.currentTimeMillis() / 1000
+                            val intent = Intent()
+                            intent.setClass(this, AppUpdateActivity::class.java)
+                            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                            startActivity(intent)
+                        }
                     }
-                }
+                }).start()
             }
             //网络断开,1000ms重连
             Constants.EVENT_TCP_BREAK->{
@@ -249,7 +258,31 @@ class WdKeepAliveService : AbsWorkService() {
                     wakeLock?.release()
                 }).start()
                 Log.w(TAG, "EVENT TCP BREAK")
-                TcpClient.getInstance().doConnect()
+                if (TcpClient.getInstance().channel==null || TcpClient.getInstance().bootstrap == null) {
+                    TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat)
+                } else if (!TcpClient.getInstance().channel.isActive){
+                    TcpClient.getInstance().doConnect()
+                }
+            }
+        }
+    }
+
+    fun openSos(tcpModel: TcpModel?){
+        if (tcpModel!=null) {
+            while (DeviceChannel.calling) {    //通话中不处理,一直等待至结束
+                Thread.sleep(400)
+            }
+
+            SpeechUtil.getInstance().stopSpeak()
+            Util.wakeUpAndUnlock(this)
+
+            if (tcpModel.type == TcpType.SOS && tcpModel.action === TcpAction.SOSAction.CALL) {
+                DeviceChannel.calling = true    //置于通话状态中,不可呼叫
+                val intent = Intent()
+                intent.setClass(this, SOSEmergencyCallActivity::class.java)
+                intent.putExtra("TcpModel", tcpModel)
+                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+                startActivity(intent)
             }
         }
     }
@@ -284,7 +317,11 @@ class WdKeepAliveService : AbsWorkService() {
                             Thread.sleep(1000)
                             wakeLock?.release()
                         })
-                        TcpClient.getInstance().doConnect()
+                        if (TcpClient.getInstance().channel==null || TcpClient.getInstance().bootstrap == null) {
+                            TcpClient.getInstance().init(Constants.tcpServer, Constants.tcpPort, Constants.heartBeat)
+                        } else if (!TcpClient.getInstance().channel.isActive){
+                            TcpClient.getInstance().doConnect()
+                        }
                     }
                 }
             }

+ 5 - 4
home/src/main/code/com/wdkl/ncs/android/component/home/util/MediaPlayHelper.java

@@ -123,7 +123,7 @@ public class MediaPlayHelper {
     //播放本地res音频资源
     private void playResMusicNow() {
         if (mediaPlayer != null) {
-            mediaPlayer.stop();
+            stopMusicNow();
         }
         mediaPlayer = MediaPlayer.create(BaseApplication.appContext, mResId);
         try {
@@ -134,8 +134,8 @@ public class MediaPlayHelper {
             mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                 @Override
                 public void onCompletion(MediaPlayer player) {
-                    //playMusicComplete();
-                    //stopMusicNow();
+//                    playMusicComplete();
+                    stopMusicNow();
                 }
             });
             mediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@@ -147,7 +147,7 @@ public class MediaPlayHelper {
                     return false;
                 }
             });
-            initMediaSession();
+//            initMediaSession();
         } catch (Exception e) {
             //playMusicError();
             e.printStackTrace();
@@ -204,6 +204,7 @@ public class MediaPlayHelper {
                 if (mediaPlayer.isPlaying()) {
                     mediaPlayer.stop();
                 }
+                mediaPlayer.release();
             } catch (IllegalStateException e) {
                 e.printStackTrace();
             }

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

@@ -20,12 +20,15 @@ class Constants {
         var heartBeat: Int = 9    //tcp心跳
         var ttsState: Int = 0
 
+        var sosActive = false
+
         const val EVENT_BATTERY_PERCENT = 0x07 //电量
         var EVENT_BATTERY_ALARM = true
 
         const val EVENT_UNTREATED_QUANTITY = 0x10 //未处理数量
 
         const val EVENT_TCP_BREAK = 0x15 //tcp掉线
+        const val EVENT_SOS_POLL = 0x55
         const val EVENT_RTC_STATE = 0x66
         const val EVENT_USER_CHANGE = 0x77
         const val EVENT_DEVICE_CHANGE = 0x88 //切换设备

+ 6 - 2
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClient.java

@@ -25,7 +25,7 @@ public class TcpClient {
 
     private NioEventLoopGroup workGroup = new NioEventLoopGroup();
     public Channel channel;
-    private Bootstrap bootstrap;
+    public Bootstrap bootstrap;
 
     //数据处理
     TcpClientHandler tcpClientHandler = new TcpClientHandler();
@@ -45,7 +45,11 @@ public class TcpClient {
     }
 
     //初始化Netty Tcp Client 并连接
-    public void init(String serverIP, Integer serverPort, Integer heartBeatSeconds) {
+    public synchronized void init(String serverIP, Integer serverPort, Integer heartBeatSeconds) {
+        if (bootstrap!=null){
+            return;
+        }
+
         final Integer hbSeconds = heartBeatSeconds;
         bootstrap = new Bootstrap();
         if (workGroup==null){

+ 10 - 0
readme.md

@@ -26,6 +26,16 @@
 
 ---
 
+## [1.1.12] version 31 - 2020-07-30
+### Fixed
+- 修复单个客户交互列表刷新加载更多时,加载所有人的交互问题
+- 修复多个SOS到来时不播放音乐问题
+    - 队列执行SOS呼入
+### Changed
+- 去掉交互列表可点击响应事件
+
+---
+
 ## [1.1.11] version 30 - 2020-07-30
 ### Changed
 - 优化交互列表呈现