|
@@ -17,6 +17,7 @@ import com.google.gson.GsonBuilder
|
|
import com.google.gson.reflect.TypeToken
|
|
import com.google.gson.reflect.TypeToken
|
|
import com.wdkl.ncs.android.component.home.R
|
|
import com.wdkl.ncs.android.component.home.R
|
|
import com.wdkl.ncs.android.component.home.activity.AppUpdateActivity
|
|
import com.wdkl.ncs.android.component.home.activity.AppUpdateActivity
|
|
|
|
+import com.wdkl.ncs.android.component.home.activity.NewCallListActivity
|
|
import com.wdkl.ncs.android.component.home.activity.NewEventListActivity
|
|
import com.wdkl.ncs.android.component.home.activity.NewEventListActivity
|
|
import com.wdkl.ncs.android.component.home.settingconfig.SettingConfig
|
|
import com.wdkl.ncs.android.component.home.settingconfig.SettingConfig
|
|
import com.wdkl.ncs.android.component.home.ui.CallSingleActivity
|
|
import com.wdkl.ncs.android.component.home.ui.CallSingleActivity
|
|
@@ -58,6 +59,7 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
|
|
|
var mNewEventListActive = false
|
|
var mNewEventListActive = false
|
|
var instanceCreated = false
|
|
var instanceCreated = false
|
|
|
|
+ var mNewCallListActive = false
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -77,6 +79,7 @@ class WdKeepAliveService : AbsWorkService() {
|
|
//当前播放的群留言id
|
|
//当前播放的群留言id
|
|
private var channelImId = 0
|
|
private var channelImId = 0
|
|
private var waitingLoop = false
|
|
private var waitingLoop = false
|
|
|
|
+ private var waitingCall = false
|
|
|
|
|
|
private var warningTips = false
|
|
private var warningTips = false
|
|
private val keepHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
|
private val keepHandler: Handler = object : Handler(Looper.getMainLooper()) {
|
|
@@ -207,8 +210,51 @@ class WdKeepAliveService : AbsWorkService() {
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) { //有来电
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) { //有来电
|
|
//取消掉语音留言录音
|
|
//取消掉语音留言录音
|
|
RecordHelper.getInstance().stopCancelRecordByOther(true)
|
|
RecordHelper.getInstance().stopCancelRecordByOther(true)
|
|
|
|
+ //停止媒体播放,比如正在播放留言
|
|
|
|
+ MediaPlayHelper.getInstance().stopMusic(true)
|
|
|
|
+ RingPlayHelper.stopRingTone()
|
|
|
|
+ Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
|
|
|
|
+
|
|
|
|
+ //加入呼叫列表
|
|
|
|
+ Constants.newCallList.add(tcpModel)
|
|
|
|
+ //语音播报
|
|
|
|
+ if (!DeviceChannel.calling && !RecordHelper.getInstance().isRecording) {
|
|
|
|
+ val frameName = interactionVO.fromFrameFullName.replace("-", "")
|
|
|
|
+ SpeechUtil.getInstance().newSpeech(frameName + "呼叫," + frameName + "呼叫", 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)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (!waitingCall) {
|
|
|
|
+ Thread {
|
|
|
|
+ while (DeviceChannel.calling || RecordHelper.getInstance().isRecording) {
|
|
|
|
+ waitingCall = true
|
|
|
|
+ Thread.sleep(500)
|
|
|
|
+ }
|
|
|
|
+ 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)
|
|
|
|
+ }
|
|
|
|
+ }.start()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
- DeviceChannel.calling = true
|
|
|
|
|
|
+ /*DeviceChannel.calling = true
|
|
var roomId: String
|
|
var roomId: String
|
|
if (interactionVO.fromDeviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
if (interactionVO.fromDeviceType == DeviceTypeEnum.SIMULATE_BED_DEVICE.value()) {
|
|
//模拟分机呼叫,通话由手机端创建
|
|
//模拟分机呼叫,通话由手机端创建
|
|
@@ -223,11 +269,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
roomId = interactionVO.fromSipId
|
|
roomId = interactionVO.fromSipId
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
|
|
|
|
-
|
|
|
|
- //停止媒体播放,比如正在播放留言
|
|
|
|
- MediaPlayHelper.getInstance().stopMusic(true)
|
|
|
|
- RingPlayHelper.stopRingTone()
|
|
|
|
|
|
|
|
//启动 activity
|
|
//启动 activity
|
|
val intent = Intent(this, CallSingleActivity::class.java)
|
|
val intent = Intent(this, CallSingleActivity::class.java)
|
|
@@ -236,7 +277,7 @@ class WdKeepAliveService : AbsWorkService() {
|
|
intent.putExtra(CallSingleActivity.EXTRA_AUDIO_ONLY, true)
|
|
intent.putExtra(CallSingleActivity.EXTRA_AUDIO_ONLY, true)
|
|
intent.putExtra(CallSingleActivity.EXTRA_TCPMODEL, tcpModel)
|
|
intent.putExtra(CallSingleActivity.EXTRA_TCPMODEL, tcpModel)
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
- startActivity(intent)
|
|
|
|
|
|
+ startActivity(intent)*/
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -427,34 +468,38 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
|
|
|
4 -> { //更新通讯录,更新通话白名单列表
|
|
4 -> { //更新通讯录,更新通话白名单列表
|
|
Thread(Runnable {
|
|
Thread(Runnable {
|
|
- var jsonStr = ""
|
|
|
|
- val contactVos = ApiManager.API_WatchManageDevice.getWatchContactList(Constants.deviceId).map {
|
|
|
|
- jsonStr = it.getJsonString()
|
|
|
|
- val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
- val contactList: List<WatchContactVO> = gson.fromJson(jsonStr, object : TypeToken<List<WatchContactVO>>() {}.type)
|
|
|
|
- return@map contactList
|
|
|
|
- }.blockingSingle()
|
|
|
|
-
|
|
|
|
- if (contactVos != null && contactVos.size > 0) {
|
|
|
|
- for (contactVO in contactVos) {
|
|
|
|
- if (!Strings.isNullOrEmpty(contactVO.name) && !Strings.isNullOrEmpty(contactVO.phoneNumber)) {
|
|
|
|
- ContactHelper.setContact(this, contactVO.name, contactVO.phoneNumber)
|
|
|
|
|
|
+ try {
|
|
|
|
+ var jsonStr = ""
|
|
|
|
+ val contactVos = ApiManager.API_WatchManageDevice.getWatchContactList(Constants.deviceId).map {
|
|
|
|
+ jsonStr = it.getJsonString()
|
|
|
|
+ val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
+ val contactList: List<WatchContactVO> = gson.fromJson(jsonStr, object : TypeToken<List<WatchContactVO>>() {}.type)
|
|
|
|
+ return@map contactList
|
|
|
|
+ }.blockingSingle()
|
|
|
|
+
|
|
|
|
+ if (contactVos != null && contactVos.size > 0) {
|
|
|
|
+ for (contactVO in contactVos) {
|
|
|
|
+ if (!Strings.isNullOrEmpty(contactVO.name) && !Strings.isNullOrEmpty(contactVO.phoneNumber)) {
|
|
|
|
+ ContactHelper.setContact(this, contactVO.name, contactVO.phoneNumber)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
- //更新白名单列表
|
|
|
|
- val whiteList = ApiManager.API_WatchManageDevice.getPhoneWhiteList(Constants.deviceId).map {
|
|
|
|
- jsonStr = it.getJsonString()
|
|
|
|
- val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
- val whiteList: List<String> = gson.fromJson(jsonStr, object : TypeToken<List<String>>() {}.type)
|
|
|
|
- return@map whiteList
|
|
|
|
- }.blockingSingle()
|
|
|
|
|
|
+ //更新白名单列表
|
|
|
|
+ val whiteList = ApiManager.API_WatchManageDevice.getPhoneWhiteList(Constants.deviceId).map {
|
|
|
|
+ jsonStr = it.getJsonString()
|
|
|
|
+ val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
|
+ val whiteList: List<String> = gson.fromJson(jsonStr, object : TypeToken<List<String>>() {}.type)
|
|
|
|
+ return@map whiteList
|
|
|
|
+ }.blockingSingle()
|
|
|
|
|
|
|
|
|
|
- if (whiteList != null && whiteList.size > 0) {
|
|
|
|
- Constants.phoneWhiteList.clear()
|
|
|
|
- Constants.phoneWhiteList.addAll(whiteList)
|
|
|
|
|
|
+ if (whiteList != null && whiteList.size > 0) {
|
|
|
|
+ Constants.phoneWhiteList.clear()
|
|
|
|
+ Constants.phoneWhiteList.addAll(whiteList)
|
|
|
|
+ }
|
|
|
|
+ } catch (ex: Exception) {
|
|
|
|
+ ex.printStackTrace()
|
|
}
|
|
}
|
|
|
|
|
|
}).start()
|
|
}).start()
|
|
@@ -496,6 +541,13 @@ class WdKeepAliveService : AbsWorkService() {
|
|
//取消掉语音留言录音
|
|
//取消掉语音留言录音
|
|
RecordHelper.getInstance().stopCancelRecordByOther(true)
|
|
RecordHelper.getInstance().stopCancelRecordByOther(true)
|
|
|
|
|
|
|
|
+ //紧急呼叫去重
|
|
|
|
+ for (e in Constants.eventList) {
|
|
|
|
+ if (e.id == sosInteractionVO.id) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if (Constants.oldEvent) {
|
|
if (Constants.oldEvent) {
|
|
Constants.eventList.clear()
|
|
Constants.eventList.clear()
|
|
}
|
|
}
|