|
@@ -67,6 +67,7 @@ import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
|
|
|
import com.wdkl.ncs.android.middleware.utils.CommonUtils
|
|
|
import com.wdkl.ncs.android.middleware.utils.MessageEvent
|
|
|
import com.wdkl.ncs.android.middleware.utils.StringUtil
|
|
|
+import com.wdkl.ncs.host.service.WdklSipService
|
|
|
import com.wdkl.ncs.janus.util.JanusConstant
|
|
|
import io.reactivex.Observable
|
|
|
import kotlinx.android.synthetic.main.activity_nurse_home.*
|
|
@@ -76,6 +77,9 @@ import org.freedesktop.gstreamer.GStreamer
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
+import org.linphone.core.AccountCreator
|
|
|
+import org.linphone.core.RegistrationState
|
|
|
+import org.linphone.core.TransportType
|
|
|
import java.io.File
|
|
|
import java.io.FileOutputStream
|
|
|
import java.io.InputStream
|
|
@@ -112,6 +116,7 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
var receiver :TimeReceiver? = null
|
|
|
var batteryBroadcastReceiver: BatteryBroadcastReceiver? = null
|
|
|
|
|
|
+ private var mAccountCreator: AccountCreator? = null
|
|
|
|
|
|
//呼叫对方设备id
|
|
|
var callTargetId: Int? = -1
|
|
@@ -192,6 +197,20 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
}
|
|
|
|
|
|
private fun permissionGranted() {
|
|
|
+ if (SettingConfig.getSipEnabled(activity)) {
|
|
|
+ //启动sip服务
|
|
|
+ val serviceIntent = Intent(BaseApplication.appContext, WdklSipService::class.java)
|
|
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
+ //android8.0以上通过startForegroundService启动service
|
|
|
+ startForegroundService(serviceIntent)
|
|
|
+ } else {
|
|
|
+ startService(serviceIntent)
|
|
|
+ }
|
|
|
+ view_title_layout_tv_point.text = "sip"
|
|
|
+ } else {
|
|
|
+ view_title_layout_tv_point.text = "rtc"
|
|
|
+ }
|
|
|
+
|
|
|
//显示设备信息
|
|
|
Constants.mac = NetHelper.getInstance().macAddress
|
|
|
Constants.imei = NetHelper.getInstance().imei
|
|
@@ -640,6 +659,10 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
Constants.hospital_id = data.hospitalId
|
|
|
}
|
|
|
|
|
|
+ if (data.sipIp != null) {
|
|
|
+ Constants.sip_ip = data.sipIp
|
|
|
+ }
|
|
|
+
|
|
|
Constants.DEVICE_CODE = data.code
|
|
|
Constants.DEVICE_MODEL = data.model
|
|
|
Constants.DEVICE_HARD_VER = data.hardVer
|
|
@@ -1048,6 +1071,29 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
Log.e(TAG,"收到返回的设置配置信息 ")
|
|
|
Log.e(TAG,"partId "+data.partId)
|
|
|
|
|
|
+ if (SettingConfig.getSipEnabled(activity)) {
|
|
|
+ //配置sip账户
|
|
|
+ if (WdklSipService.getCore() != null) {
|
|
|
+ mAccountCreator = WdklSipService.getCore().createAccountCreator(null)
|
|
|
+ // 以下三项必须
|
|
|
+ if (!TextUtils.isEmpty(Constants.sip_id) && !TextUtils.isEmpty(Constants.sip_ip)) {
|
|
|
+ Log.e(TAG, "sip connect: ${Constants.sip_id} : ${Constants.sip_ip}")
|
|
|
+ mAccountCreator!!.setDomain(Constants.sip_ip)
|
|
|
+ mAccountCreator!!.setUsername(Constants.sip_id)
|
|
|
+ mAccountCreator!!.setPassword(Constants.sip_id)
|
|
|
+ //默认使用udp
|
|
|
+ mAccountCreator!!.transport = TransportType.Udp
|
|
|
+
|
|
|
+ // 这里会自动创建代理配置、认证信息到 SIP核心
|
|
|
+ val cfg = mAccountCreator!!.createProxyConfig()
|
|
|
+ // 确保新创建的是最新
|
|
|
+ WdklSipService.getCore().defaultProxyConfig = cfg
|
|
|
+ } else {
|
|
|
+ showMessage("SIP 数据不全")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
loadLedDevice()
|
|
|
|
|
|
try {
|
|
@@ -1493,6 +1539,7 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
hookonTime = System.currentTimeMillis()
|
|
|
} else if (intent.action == Constants.HOOK_OFF) {
|
|
|
Log.e(TAG,"手柄拿起 ")
|
|
|
+ EventBus.getDefault().post(MessageEvent(false, Constants.EVENT_TOGGLE_SPEAKER))
|
|
|
if (System.currentTimeMillis() - hookoffTime > 2000) {
|
|
|
Constants.hookOn = false
|
|
|
VoiceManagerUtil.switchAudioMode(activity, false)
|
|
@@ -1517,6 +1564,7 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
Log.d(TAG, "keyDown ====> keyCode: $keyCode, action: ${event?.action}")
|
|
|
if (keyCode == 135) {
|
|
|
//手柄拿起
|
|
|
+ EventBus.getDefault().post(MessageEvent(false, Constants.EVENT_TOGGLE_SPEAKER))
|
|
|
if (System.currentTimeMillis() - hookoffTime > 2000) {
|
|
|
Constants.hookOn = false
|
|
|
VoiceManagerUtil.switchAudioMode(activity, false)
|
|
@@ -1620,6 +1668,33 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun updateSipState(state: RegistrationState) {
|
|
|
+ runOnUiThread {
|
|
|
+ when (state) {
|
|
|
+ RegistrationState.Ok -> {
|
|
|
+ //连接完成
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.green)
|
|
|
+ }
|
|
|
+
|
|
|
+ RegistrationState.Failed -> {
|
|
|
+ //连接错误
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.red_color)
|
|
|
+ }
|
|
|
+
|
|
|
+ RegistrationState.Progress -> {
|
|
|
+ //正在连接
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.yellow_color)
|
|
|
+ }
|
|
|
+
|
|
|
+ RegistrationState.None, RegistrationState.Cleared -> {
|
|
|
+ //默认状态,断开连接
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.register_text_color)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ view_title_layout_tv_point.text = "sip"
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private fun updateNetState() {
|
|
|
if (NetHelper.getInstance().networkType == ConnectivityManager.TYPE_WIFI) {
|
|
|
wifi_state_imagev.visibility = View.VISIBLE
|
|
@@ -1642,10 +1717,16 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
private fun updateTcpState() {
|
|
|
if (Constants.tcp_connected) {
|
|
|
tcp_state_imagev.setImageResource(R.drawable.ic_tcp_success)
|
|
|
- view_title_layout_tv_point.setBackgroundResource(R.color.green)
|
|
|
+ if (!SettingConfig.getSipEnabled(activity)) {
|
|
|
+ view_title_layout_tv_point.text = "rtc"
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.green)
|
|
|
+ }
|
|
|
} else {
|
|
|
tcp_state_imagev.setImageResource(R.drawable.ic_tcp_fail)
|
|
|
- view_title_layout_tv_point.setBackgroundResource(R.color.red_color)
|
|
|
+ if (!SettingConfig.getSipEnabled(activity)) {
|
|
|
+ view_title_layout_tv_point.text = "rtc"
|
|
|
+ view_title_layout_tv_point.setBackgroundResource(R.color.red_color)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1679,6 +1760,15 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
fun onMoonEvent(messageEvent: MessageEvent) {
|
|
|
when (messageEvent.getType()) {
|
|
|
+ //Sip注册状态
|
|
|
+ Constants.EVENT_SIP_REGISTER_STATUS -> {
|
|
|
+ if (messageEvent.getMessage() is RegistrationState) {
|
|
|
+ val state = messageEvent.getMessage() as RegistrationState
|
|
|
+ Log.d(TAG, "sip register state: $state")
|
|
|
+ updateSipState(state)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//退出通话界面
|
|
|
Constants.EVENT_REMOVE_CALL_FRAGMENT -> {
|
|
|
if (skyCallFragment != null) {
|
|
@@ -1749,28 +1839,54 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
Constants.CALL_STATE = Constants.CALL_OUTGOING
|
|
|
|
|
|
if (Constants.tcp_connected && !TextUtils.isEmpty(Constants.sip_id)) {
|
|
|
- //去电直接启动call fragment
|
|
|
- var fragment = SkyCallFragment()
|
|
|
- var bundle = Bundle()
|
|
|
- bundle.putBoolean("audio_only", Constants.call_type == 0)
|
|
|
- bundle.putInt("call_state", 0)
|
|
|
- bundle.putBoolean("visiting", false)
|
|
|
- //bundle.putString("targetId", targetId)
|
|
|
- if (DeviceTypeEnum.DOCTOR_HOST.value() == interactionVO.toDeviceType
|
|
|
- || DeviceTypeEnum.NURSE_HOST.value() == interactionVO.toDeviceType
|
|
|
- || DeviceTypeEnum.OTHER_HOST.value() == interactionVO.toDeviceType) {
|
|
|
- //医生机,护士主机,其他主机,总控主机等
|
|
|
- bundle.putString("call_name", interactionVO.toDeviceName)
|
|
|
- } else if (DeviceTypeEnum.NURSE_WATCH.value() == interactionVO.toDeviceType) {
|
|
|
- //移动设备
|
|
|
- bundle.putString("call_name", interactionVO.toMemberName)
|
|
|
+ if (SettingConfig.getSipEnabled(activity)) {
|
|
|
+ var fragment = SipCallFragment()
|
|
|
+ var bundle = Bundle()
|
|
|
+ bundle.putBoolean("audio_only", Constants.call_type == 0)
|
|
|
+ bundle.putInt("call_state", 0)
|
|
|
+ bundle.putBoolean("visiting", false)
|
|
|
+ //bundle.putString("targetId", targetId)
|
|
|
+ if (DeviceTypeEnum.DOCTOR_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.NURSE_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.OTHER_HOST.value() == interactionVO.toDeviceType
|
|
|
+ ) {
|
|
|
+ //医生机,护士主机,其他主机,总控主机等
|
|
|
+ bundle.putString("call_name", interactionVO.toDeviceName)
|
|
|
+ } else if (DeviceTypeEnum.NURSE_WATCH.value() == interactionVO.toDeviceType) {
|
|
|
+ //移动设备
|
|
|
+ bundle.putString("call_name", interactionVO.toMemberName)
|
|
|
+ } else {
|
|
|
+ //其他设备
|
|
|
+ bundle.putString("call_name", interactionVO.toFrameFullName)
|
|
|
+ }
|
|
|
+ bundle.putSerializable("interaction", interactionVO)
|
|
|
+ fragment.arguments = bundle
|
|
|
+ addCallFragment(fragment)
|
|
|
} else {
|
|
|
- //其他设备
|
|
|
- bundle.putString("call_name", interactionVO.toFrameFullName)
|
|
|
+ //去电直接启动call fragment
|
|
|
+ var fragment = SkyCallFragment()
|
|
|
+ var bundle = Bundle()
|
|
|
+ bundle.putBoolean("audio_only", Constants.call_type == 0)
|
|
|
+ bundle.putInt("call_state", 0)
|
|
|
+ bundle.putBoolean("visiting", false)
|
|
|
+ //bundle.putString("targetId", targetId)
|
|
|
+ if (DeviceTypeEnum.DOCTOR_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.NURSE_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.OTHER_HOST.value() == interactionVO.toDeviceType
|
|
|
+ ) {
|
|
|
+ //医生机,护士主机,其他主机,总控主机等
|
|
|
+ bundle.putString("call_name", interactionVO.toDeviceName)
|
|
|
+ } else if (DeviceTypeEnum.NURSE_WATCH.value() == interactionVO.toDeviceType) {
|
|
|
+ //移动设备
|
|
|
+ bundle.putString("call_name", interactionVO.toMemberName)
|
|
|
+ } else {
|
|
|
+ //其他设备
|
|
|
+ bundle.putString("call_name", interactionVO.toFrameFullName)
|
|
|
+ }
|
|
|
+ bundle.putSerializable("interaction", interactionVO)
|
|
|
+ fragment.arguments = bundle
|
|
|
+ addCallFragment(fragment)
|
|
|
}
|
|
|
- bundle.putSerializable("interaction", interactionVO)
|
|
|
- fragment.arguments = bundle
|
|
|
- addCallFragment(fragment)
|
|
|
} else {
|
|
|
showMessage(R.string.call_init_error)
|
|
|
Constants.CALL_STATE = Constants.CALL_STANDBY
|
|
@@ -2155,31 +2271,55 @@ class NurseHomeActivity : BaseActivity<NurseHomeActivityPresenter, ActivityNurs
|
|
|
private fun acceptCall(interactionVO: InteractionVO, audioOnly: Boolean) {
|
|
|
//如果当前不是门禁请求界面才显示通话界面
|
|
|
if (/*entraceGuardVideoFragment == null && */skyCallFragment == null) {
|
|
|
- if (audioOnly) {
|
|
|
- Constants.call_type = 0
|
|
|
- } else {
|
|
|
- Constants.call_type = 1
|
|
|
- }
|
|
|
- var fragment = SkyCallFragment()
|
|
|
- var bundle = Bundle()
|
|
|
- bundle.putInt("call_state", 1)
|
|
|
- bundle.putBoolean("visiting", false)
|
|
|
- bundle.putBoolean("audio_only", audioOnly)
|
|
|
- if (DeviceTypeEnum.DOCTOR_HOST.value() == interactionVO.toDeviceType
|
|
|
- || DeviceTypeEnum.NURSE_HOST.value() == interactionVO.toDeviceType
|
|
|
- || DeviceTypeEnum.OTHER_HOST.value() == interactionVO.toDeviceType) {
|
|
|
- //医生机,护士主机,其他主机,总控主机等
|
|
|
- bundle.putString("call_name", interactionVO.fromDeviceName)
|
|
|
- } else if (DeviceTypeEnum.NURSE_WATCH.value() == interactionVO.toDeviceType) {
|
|
|
- //移动设备
|
|
|
- bundle.putString("call_name", interactionVO.fromMemberName)
|
|
|
+ if (SettingConfig.getSipEnabled(activity)) {
|
|
|
+ var fragment = SipCallFragment()
|
|
|
+ var bundle = Bundle()
|
|
|
+ bundle.putInt("call_state", 1)
|
|
|
+ bundle.putBoolean("visiting", false)
|
|
|
+ bundle.putBoolean("audio_only", true)
|
|
|
+ if (DeviceTypeEnum.DOCTOR_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.NURSE_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.OTHER_HOST.value() == interactionVO.toDeviceType
|
|
|
+ ) {
|
|
|
+ //医生机,护士主机,其他主机,总控主机等
|
|
|
+ bundle.putString("call_name", interactionVO.fromDeviceName)
|
|
|
+ } else if (DeviceTypeEnum.NURSE_WATCH.value() == interactionVO.toDeviceType) {
|
|
|
+ //移动设备
|
|
|
+ bundle.putString("call_name", interactionVO.fromMemberName)
|
|
|
+ } else {
|
|
|
+ //其他设备
|
|
|
+ bundle.putString("call_name", interactionVO.fromFrameFullName)
|
|
|
+ }
|
|
|
+ fragment.arguments = bundle
|
|
|
+ addCallFragment(fragment)
|
|
|
} else {
|
|
|
- //其他设备
|
|
|
- bundle.putString("call_name", interactionVO.fromFrameFullName)
|
|
|
+ if (audioOnly) {
|
|
|
+ Constants.call_type = 0
|
|
|
+ } else {
|
|
|
+ Constants.call_type = 1
|
|
|
+ }
|
|
|
+ var fragment = SkyCallFragment()
|
|
|
+ var bundle = Bundle()
|
|
|
+ bundle.putInt("call_state", 1)
|
|
|
+ bundle.putBoolean("visiting", false)
|
|
|
+ bundle.putBoolean("audio_only", audioOnly)
|
|
|
+ if (DeviceTypeEnum.DOCTOR_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.NURSE_HOST.value() == interactionVO.toDeviceType
|
|
|
+ || DeviceTypeEnum.OTHER_HOST.value() == interactionVO.toDeviceType
|
|
|
+ ) {
|
|
|
+ //医生机,护士主机,其他主机,总控主机等
|
|
|
+ bundle.putString("call_name", interactionVO.fromDeviceName)
|
|
|
+ } else if (DeviceTypeEnum.NURSE_WATCH.value() == interactionVO.toDeviceType) {
|
|
|
+ //移动设备
|
|
|
+ bundle.putString("call_name", interactionVO.fromMemberName)
|
|
|
+ } else {
|
|
|
+ //其他设备
|
|
|
+ bundle.putString("call_name", interactionVO.fromFrameFullName)
|
|
|
+ }
|
|
|
+ bundle.putSerializable("interaction", interactionVO)
|
|
|
+ fragment.arguments = bundle
|
|
|
+ addCallFragment(fragment)
|
|
|
}
|
|
|
- bundle.putSerializable("interaction", interactionVO)
|
|
|
- fragment.arguments = bundle
|
|
|
- addCallFragment(fragment)
|
|
|
}
|
|
|
}
|
|
|
|