|
@@ -1,6 +1,5 @@
|
|
package com.wdkl.app.ncs.callingdoor.activity
|
|
package com.wdkl.app.ncs.callingdoor.activity
|
|
|
|
|
|
-import android.app.AlarmManager
|
|
|
|
import android.content.*
|
|
import android.content.*
|
|
import android.net.ConnectivityManager
|
|
import android.net.ConnectivityManager
|
|
import android.os.*
|
|
import android.os.*
|
|
@@ -12,7 +11,6 @@ import com.enation.javashop.android.jrouter.external.annotation.Router
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.enation.javashop.net.engine.model.NetState
|
|
import com.example.yf_rk3288_api.YF_RK3288_API_Manager
|
|
import com.example.yf_rk3288_api.YF_RK3288_API_Manager
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
-import com.wdkl.app.ncs.callingdoor.fragment.SkyCallFragment
|
|
|
|
import com.wdkl.app.ncs.callingdoor.BuildConfig
|
|
import com.wdkl.app.ncs.callingdoor.BuildConfig
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
import com.wdkl.app.ncs.callingdoor.R
|
|
import com.wdkl.app.ncs.callingdoor.agreement.CallingdoorAgreement
|
|
import com.wdkl.app.ncs.callingdoor.agreement.CallingdoorAgreement
|
|
@@ -48,7 +46,6 @@ import com.wdkl.ncs.android.middleware.tcp.enums.TcpType
|
|
import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
|
|
import com.wdkl.ncs.android.middleware.udp.ServerInfoUtil
|
|
import com.wdkl.ncs.android.middleware.utils.AppUtil
|
|
import com.wdkl.ncs.android.middleware.utils.AppUtil
|
|
import com.wdkl.ncs.android.middleware.utils.CommonUtils
|
|
import com.wdkl.ncs.android.middleware.utils.CommonUtils
|
|
-import com.wdkl.ncs.janus.util.JanusConstant
|
|
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.*
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.*
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.app_version
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.app_version
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_call
|
|
import kotlinx.android.synthetic.main.callingdoor_main_lay.room_action_call
|
|
@@ -67,7 +64,7 @@ import org.greenrobot.eventbus.Subscribe
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
import serialporttest.utils.SerialPortUtil
|
|
import serialporttest.utils.SerialPortUtil
|
|
import java.io.*
|
|
import java.io.*
|
|
-import java.lang.Process
|
|
|
|
|
|
+import java.util.*
|
|
import java.util.concurrent.TimeUnit
|
|
import java.util.concurrent.TimeUnit
|
|
|
|
|
|
|
|
|
|
@@ -104,7 +101,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
private var clickVersionTime : Long = 0
|
|
private var clickVersionTime : Long = 0
|
|
private var clickCount = 1
|
|
private var clickCount = 1
|
|
|
|
|
|
- private val uninstallApk = false
|
|
|
|
|
|
+ private val uninstallApk = true
|
|
|
|
|
|
private var serverSuccess = false
|
|
private var serverSuccess = false
|
|
private var cancelRestart = false
|
|
private var cancelRestart = false
|
|
@@ -156,22 +153,31 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
//更新状态图标
|
|
//更新状态图标
|
|
updateNetState()
|
|
updateNetState()
|
|
|
|
|
|
- if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
|
|
|
|
+ if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL)) {
|
|
//串口监听
|
|
//串口监听
|
|
setSerialListener()
|
|
setSerialListener()
|
|
|
|
+ SerialPortHelper.startHeartBeat()
|
|
|
|
|
|
- AppTool.Time.delay(3000) {
|
|
|
|
- //打开MIC
|
|
|
|
- SerialPortHelper.setMIC(true)
|
|
|
|
- SerialPortHelper.setHandsFree(true)
|
|
|
|
- SerialPortHelper.setSosLight("0")
|
|
|
|
- //默认门灯白色
|
|
|
|
- SerialPortHelper.setDoorLight(1, "111")
|
|
|
|
- }
|
|
|
|
|
|
+ Thread {
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(2000)
|
|
|
|
+ //打开MIC
|
|
|
|
+ SerialPortHelper.setMIC(true)
|
|
|
|
+ Thread.sleep(200)
|
|
|
|
+ SerialPortHelper.setHandsFree(true)
|
|
|
|
+ Thread.sleep(200)
|
|
|
|
+ SerialPortHelper.setSosLight("0")
|
|
|
|
+ //默认门灯白色
|
|
|
|
+ Thread.sleep(200)
|
|
|
|
+ SerialPortHelper.setDoorLight(1, "111")
|
|
|
|
+ } catch (e: Exception) {
|
|
|
|
+ e.printStackTrace()
|
|
|
|
+ }
|
|
|
|
+ }.start()
|
|
|
|
|
|
//设置默认时区为中国标准时间
|
|
//设置默认时区为中国标准时间
|
|
- val alarmManager = getSystemService(ALARM_SERVICE) as AlarmManager
|
|
|
|
- alarmManager.setTimeZone("Asia/Shanghai")
|
|
|
|
|
|
+ //val alarmManager = getSystemService(ALARM_SERVICE) as AlarmManager
|
|
|
|
+ //alarmManager.setTimeZone("Asia/Shanghai")
|
|
}
|
|
}
|
|
|
|
|
|
app_version.text = "V" + BuildConfig.VERSION_NAME
|
|
app_version.text = "V" + BuildConfig.VERSION_NAME
|
|
@@ -182,7 +188,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
//记录app启动时间
|
|
//记录app启动时间
|
|
val lastTime = SettingConfig.getAppStartTime(activity)
|
|
val lastTime = SettingConfig.getAppStartTime(activity)
|
|
val currentTime = TimeHandle.getDateTime(System.currentTimeMillis(), "MM-dd HH:mm:ss")
|
|
val currentTime = TimeHandle.getDateTime(System.currentTimeMillis(), "MM-dd HH:mm:ss")
|
|
- debugLog(TAG, "app last start time: $lastTime, current time: $currentTime")
|
|
|
|
|
|
+ //debugLog(TAG, "app last start time: $lastTime, current time: $currentTime")
|
|
|
|
+ Log.d(TAG, "app last start time: $lastTime, current time: $currentTime")
|
|
SettingConfig.setAppStartTime(activity, currentTime)
|
|
SettingConfig.setAppStartTime(activity, currentTime)
|
|
|
|
|
|
VoiceManagerUtil.setCallVoice(activity, SettingConfig.getExtensionCallVolume(activity))
|
|
VoiceManagerUtil.setCallVoice(activity, SettingConfig.getExtensionCallVolume(activity))
|
|
@@ -201,9 +208,11 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
|
|
|
checkServer()
|
|
checkServer()
|
|
|
|
|
|
- if ("rk3128".equals(Build.MODEL)) {
|
|
|
|
|
|
+ /*if ("rk3128".equals(Build.MODEL)) {
|
|
checkLaunch()
|
|
checkLaunch()
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ Log.d(TAG, "app data file: " + filesDir.absoluteFile + ", canWrite: " + filesDir.absoluteFile.canWrite())
|
|
}
|
|
}
|
|
|
|
|
|
private fun checkAppExist() : Boolean {
|
|
private fun checkAppExist() : Boolean {
|
|
@@ -221,7 +230,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
|
|
|
|
private fun uninstallApp() {
|
|
private fun uninstallApp() {
|
|
- val process: Process
|
|
|
|
|
|
+ val process: java.lang.Process
|
|
val printWriter: PrintWriter
|
|
val printWriter: PrintWriter
|
|
try {
|
|
try {
|
|
process = Runtime.getRuntime().exec("su")
|
|
process = Runtime.getRuntime().exec("su")
|
|
@@ -434,7 +443,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
|
|
|
|
if (Constant.inNursing) {
|
|
if (Constant.inNursing) {
|
|
Constant.inNursing = false
|
|
Constant.inNursing = false
|
|
- if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
|
|
|
|
+ if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL)) {
|
|
SerialPortHelper.setDoorLight(1, "111") //白色
|
|
SerialPortHelper.setDoorLight(1, "111") //白色
|
|
}
|
|
}
|
|
//room_action_nurse.text = "进入护理"
|
|
//room_action_nurse.text = "进入护理"
|
|
@@ -446,7 +455,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
Constant.inNursing = true
|
|
Constant.inNursing = true
|
|
- if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
|
|
|
|
+ if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL)) {
|
|
SerialPortHelper.setDoorLight(1, Constant.nursingColor) //绿色
|
|
SerialPortHelper.setDoorLight(1, Constant.nursingColor) //绿色
|
|
}
|
|
}
|
|
//room_action_nurse.text = "退出护理"
|
|
//room_action_nurse.text = "退出护理"
|
|
@@ -608,8 +617,6 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
private fun setSerialListener() {
|
|
private fun setSerialListener() {
|
|
SerialPortUtil.getInstance().setOnDataReceiveListener(this)
|
|
SerialPortUtil.getInstance().setOnDataReceiveListener(this)
|
|
SerialPortUtil.getInstance().setOnDataReceiveStringListener(this)
|
|
SerialPortUtil.getInstance().setOnDataReceiveStringListener(this)
|
|
- //开启串口心跳
|
|
|
|
- SerialPortUtil.getInstance().startHeartBeat()
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun checkAppVersion() {
|
|
override fun checkAppVersion() {
|
|
@@ -637,7 +644,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
MediaPlayHelper.getInstance().stopMusic()
|
|
MediaPlayHelper.getInstance().stopMusic()
|
|
|
|
|
|
- if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
|
|
|
|
+ if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL)) {
|
|
SerialPortUtil.getInstance().closeHeart()
|
|
SerialPortUtil.getInstance().closeHeart()
|
|
SerialPortUtil.getInstance().closeSerialPort()
|
|
SerialPortUtil.getInstance().closeSerialPort()
|
|
}
|
|
}
|
|
@@ -711,8 +718,8 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
Constant.TCP_PORT = data.tcpPort
|
|
Constant.TCP_PORT = data.tcpPort
|
|
Constant.TCP_HEART_BEAT = data.tcpIdleSeconds
|
|
Constant.TCP_HEART_BEAT = data.tcpIdleSeconds
|
|
|
|
|
|
- JanusConstant.JANUS_URL = "ws://" + data.rtcLocalIp + ":" + data.rtcPort
|
|
|
|
- JanusConstant.STUN_SERVER = arrayOf<String>(data.stunServer)
|
|
|
|
|
|
+ //JanusConstant.JANUS_URL = "ws://" + data.rtcLocalIp + ":" + data.rtcPort
|
|
|
|
+ //JanusConstant.STUN_SERVER = arrayOf<String>(data.stunServer)
|
|
//JanusConstant.TURN_SERVER = data.turnServer
|
|
//JanusConstant.TURN_SERVER = data.turnServer
|
|
|
|
|
|
//开启TCP连接
|
|
//开启TCP连接
|
|
@@ -955,13 +962,13 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
//通话之前先判断webrtc socket和tcp是否连接正常,否则不能建立通话
|
|
//通话之前先判断webrtc socket和tcp是否连接正常,否则不能建立通话
|
|
if (Constant.TCP_CONNECTED) {
|
|
if (Constant.TCP_CONNECTED) {
|
|
//去电界面
|
|
//去电界面
|
|
- Constant.CALL_TYPE = type
|
|
|
|
|
|
+ /*Constant.CALL_TYPE = type
|
|
Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
var fragment = SkyCallFragment()
|
|
var fragment = SkyCallFragment()
|
|
var bundle = Bundle()
|
|
var bundle = Bundle()
|
|
bundle.putInt("call_state", 0)
|
|
bundle.putInt("call_state", 0)
|
|
fragment.arguments = bundle
|
|
fragment.arguments = bundle
|
|
- addCallFragment(fragment)
|
|
|
|
|
|
+ addCallFragment(fragment)*/
|
|
} else {
|
|
} else {
|
|
showMessage("通话服务或网络未连接,请检查网络稍后再试")
|
|
showMessage("通话服务或网络未连接,请检查网络稍后再试")
|
|
}
|
|
}
|
|
@@ -974,12 +981,12 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
//去电界面
|
|
//去电界面
|
|
Constant.CALL_TYPE = type
|
|
Constant.CALL_TYPE = type
|
|
Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
Constant.CALL_STATE = Constant.CALL_OUTGOING
|
|
- var fragment = SkyCallFragment()
|
|
|
|
|
|
+ /*var fragment = SkyCallFragment()
|
|
var bundle = Bundle()
|
|
var bundle = Bundle()
|
|
bundle.putInt("call_state", 2)
|
|
bundle.putInt("call_state", 2)
|
|
bundle.putInt("bed_id", bedId)
|
|
bundle.putInt("bed_id", bedId)
|
|
fragment.arguments = bundle
|
|
fragment.arguments = bundle
|
|
- addCallFragment(fragment)
|
|
|
|
|
|
+ addCallFragment(fragment)*/
|
|
} else {
|
|
} else {
|
|
showMessage("通话服务或网络未连接,请检查网络稍后再试")
|
|
showMessage("通话服务或网络未连接,请检查网络稍后再试")
|
|
}
|
|
}
|
|
@@ -1020,12 +1027,12 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
Constant.CALL_STATE = Constant.CALL_INCOMING
|
|
Constant.CALL_STATE = Constant.CALL_INCOMING
|
|
if (Constant.TCP_CONNECTED && !TextUtils.isEmpty(Constant.SIP_ID)) {
|
|
if (Constant.TCP_CONNECTED && !TextUtils.isEmpty(Constant.SIP_ID)) {
|
|
//来电界面
|
|
//来电界面
|
|
- var fragment = SkyCallFragment()
|
|
|
|
|
|
+ /*var fragment = SkyCallFragment()
|
|
var bundle = Bundle()
|
|
var bundle = Bundle()
|
|
bundle.putInt("call_state", 1)
|
|
bundle.putInt("call_state", 1)
|
|
bundle.putSerializable("tcp_model", tcpModel)
|
|
bundle.putSerializable("tcp_model", tcpModel)
|
|
fragment.arguments = bundle
|
|
fragment.arguments = bundle
|
|
- addCallFragment(fragment)
|
|
|
|
|
|
+ addCallFragment(fragment)*/
|
|
} else {
|
|
} else {
|
|
showMessage("服务未连接或sipId为空")
|
|
showMessage("服务未连接或sipId为空")
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
Constant.CALL_STATE = Constant.CALL_STANDBY
|
|
@@ -1061,7 +1068,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
nursingInteId = interactionVO.id
|
|
nursingInteId = interactionVO.id
|
|
} else {
|
|
} else {
|
|
- if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL)) {
|
|
|
|
|
|
+ if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL)) {
|
|
DoorLightHelper.handleDoorLight(tcpModel)
|
|
DoorLightHelper.handleDoorLight(tcpModel)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1073,7 +1080,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
Log.d(TAG, "set sys time1: $time")
|
|
Log.d(TAG, "set sys time1: $time")
|
|
} catch (e: Exception) {
|
|
} catch (e: Exception) {
|
|
//"20211213:092314"
|
|
//"20211213:092314"
|
|
- val timeStr = TimeHandle.getDateTime(time, "yyyyMMdd.hhmmss")
|
|
|
|
|
|
+ val timeStr = TimeHandle.getDateTime(time, "yyyyMMdd.HHmmss")
|
|
AppUtil.setSysTime(timeStr)
|
|
AppUtil.setSysTime(timeStr)
|
|
Log.d(TAG, "set sys time2: $timeStr")
|
|
Log.d(TAG, "set sys time2: $timeStr")
|
|
}
|
|
}
|
|
@@ -1173,15 +1180,23 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
|
|
}
|
|
}
|
|
|
|
|
|
private fun updateSettings(forceSet: Boolean) {
|
|
private fun updateSettings(forceSet: Boolean) {
|
|
- val currentTimestamp = System.currentTimeMillis()
|
|
|
|
-
|
|
|
|
|
|
+ val currentTimestamp = System.currentTimeMillis()
|
|
//白天起始时间戳
|
|
//白天起始时间戳
|
|
var date = TimeHandle.getDateTime("yyyy-MM-dd")
|
|
var date = TimeHandle.getDateTime("yyyy-MM-dd")
|
|
var dayStartTimeStamp = TimeHandle.dateToStamp(date+" "+SettingConfig.getInitialDayTime(this)+":00", "yyyy-MM-dd HH:mm:ss")
|
|
var dayStartTimeStamp = TimeHandle.dateToStamp(date+" "+SettingConfig.getInitialDayTime(this)+":00", "yyyy-MM-dd HH:mm:ss")
|
|
//白天结束时间戳
|
|
//白天结束时间戳
|
|
var endOfDayTimeStamp = TimeHandle.dateToStamp(date+" "+SettingConfig.getEndOfDay(this)+":00", "yyyy-MM-dd HH:mm:ss")
|
|
var endOfDayTimeStamp = TimeHandle.dateToStamp(date+" "+SettingConfig.getEndOfDay(this)+":00", "yyyy-MM-dd HH:mm:ss")
|
|
-
|
|
|
|
val curInday = dayStartTimeStamp < currentTimestamp && currentTimestamp < endOfDayTimeStamp
|
|
val curInday = dayStartTimeStamp < currentTimestamp && currentTimestamp < endOfDayTimeStamp
|
|
|
|
+
|
|
|
|
+ /*val beginTime = SettingConfig.getInitialDayTime(this)
|
|
|
|
+ val endTime = SettingConfig.getEndOfDay(this)
|
|
|
|
+ val beginH = beginTime.substring(0, 2).toInt()
|
|
|
|
+ val beginM = beginTime.substring(3, 5).toInt()
|
|
|
|
+ val endH = endTime.substring(0, 2).toInt()
|
|
|
|
+ val endM = endTime.substring(3, 5).toInt()
|
|
|
|
+ val curInday = Utils.atTheCurrentTime(beginH, beginM, endH, endM)
|
|
|
|
+ Log.d(TAG, "curInday: $curInday, beginH: $beginH, beginM: $beginM, endH: $endH, endH: $endM")*/
|
|
|
|
+
|
|
if (curInday) {
|
|
if (curInday) {
|
|
//当前是白天并且原来不是白天
|
|
//当前是白天并且原来不是白天
|
|
if (Constant.day_state != 0 || forceSet) {
|
|
if (Constant.day_state != 0 || forceSet) {
|