|
@@ -225,8 +225,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
|
|
|
//亮屏
|
|
|
AppUtil.wakeUp(activity)
|
|
|
- //设置默认熄屏时间为1分钟
|
|
|
- AppTool.Setting.setScreenOffTimeOut(applicationContext, Constant.SLEEP_MINUTE)
|
|
|
+ setScreenOffTime()
|
|
|
|
|
|
checkServer()
|
|
|
|
|
@@ -306,18 +305,32 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
private fun checkServerConnect() {
|
|
|
val timerTask: TimerTask = object : TimerTask() {
|
|
|
override fun run() {
|
|
|
- if (Constant.TCP_CONNECTED) {
|
|
|
- serverConnectTimes = 0
|
|
|
- } else {
|
|
|
- //设备有ip地址,但是tcp未连接,可能是服务器地址不对或者中途网络断开或者服务端异常
|
|
|
- if (!TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
|
|
|
- serverConnectTimes++
|
|
|
+ try {
|
|
|
+ checkNet()
|
|
|
+
|
|
|
+ if (Constant.TCP_CONNECTED) {
|
|
|
+ serverConnectTimes = 0
|
|
|
+ } else {
|
|
|
+ //设备有ip地址,但是tcp未连接,可能是服务器地址不对或者中途网络断开或者服务端异常
|
|
|
+ if (!TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
|
|
|
+ serverConnectTimes++
|
|
|
+ }
|
|
|
+ Log.e(TAG, "check tcp server connect ===> serverConnectTimes=$serverConnectTimes")
|
|
|
+ if (serverConnectTimes >= 10) {
|
|
|
+ //tcp检测断开连接次数超过20则重启设备
|
|
|
+ AppUpdateHelper.systemRestart()
|
|
|
+ }
|
|
|
}
|
|
|
- Log.e(TAG, "check tcp server connect ===> serverConnectTimes=$serverConnectTimes")
|
|
|
- if (serverConnectTimes >= 20) {
|
|
|
- //tcp检测断开连接次数超过20则重启设备
|
|
|
- AppUpdateHelper.systemRestart()
|
|
|
+
|
|
|
+ if (Constant.CUSTOM_ID == -1) {
|
|
|
+ //床位未入住,设备休眠
|
|
|
+ AppUtil.goToSleep(activity)
|
|
|
+ } else if (Constant.NIGHT_BRIGHTNESS == 0 && Constant.day_state == 1 && !Constant.IS_RECORDING && skyCallFragment == null) {
|
|
|
+ //当前为夜晚熄屏模式,设备休眠
|
|
|
+ AppUtil.goToSleep(activity)
|
|
|
}
|
|
|
+ } catch (e: Exception) {
|
|
|
+ //
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -960,7 +973,9 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
private fun startTcp() {
|
|
|
if (Constant.TCP_SERVER_URL != null && !tcpConnect) {
|
|
|
tcpConnect = true
|
|
|
- Thread(Runnable { TcpClient.getInstance().init(Constant.TCP_SERVER_URL, Constant.TCP_PORT, Constant.TCP_HEART_BEAT) }).start()
|
|
|
+ Thread {
|
|
|
+ TcpClient.getInstance().init(Constant.TCP_SERVER_URL, Constant.TCP_PORT, Constant.TCP_HEART_BEAT)
|
|
|
+ }.start()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1500,7 +1515,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
+ ", net error count: " + count)
|
|
|
if (!Constant.TCP_CONNECTED && TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
|
|
|
netErrCount++
|
|
|
- Log.e(TAG, "network error!!! ==> netErrCount: $netErrCount, reset count: $count")
|
|
|
+ Log.e("checkNet", "network error!!! ==> netErrCount: $netErrCount, reset count: $count")
|
|
|
} else {
|
|
|
netErrCount = 0
|
|
|
if (count > 0) {
|
|
@@ -1528,7 +1543,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
//隔2个小时再重启
|
|
|
val time = System.currentTimeMillis()
|
|
|
val errTime = time - checkTime
|
|
|
- Log.e(TAG, "show net error dialog --> errTime = $errTime")
|
|
|
+ Log.e("checkNet", "show net error dialog --> errTime = $errTime")
|
|
|
if (errTime >= 2*60*60*1000) {
|
|
|
checkTime = time
|
|
|
netOffReset()
|
|
@@ -1658,8 +1673,8 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
}*/
|
|
|
|
|
|
|
|
|
- if (Constant.day_state == 0) {
|
|
|
- //白天亮屏
|
|
|
+ if (Constant.day_state == 0 && Constant.CUSTOM_ID != -1) {
|
|
|
+ //当前是白天且床位有入住才亮屏
|
|
|
AppUtil.wakeUp(activity)
|
|
|
}
|
|
|
|
|
@@ -1683,7 +1698,7 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
//还未连接tcp服务器
|
|
|
presenter.loadTcpServerHost()
|
|
|
}*/
|
|
|
- checkNet()
|
|
|
+ //checkNet()
|
|
|
} else if (intent.action == ConnectivityManager.CONNECTIVITY_ACTION) {
|
|
|
updateNetState()
|
|
|
}
|
|
@@ -1701,9 +1716,15 @@ class CallingbedActivity :BaseActivity<CallingbedActivityPresenter, Callingbed2M
|
|
|
Log.d(TAG, "set screen off timeout: ${Constant.SLEEP_MINUTE}")
|
|
|
AppTool.Setting.setScreenOffTimeOut(applicationContext, Constant.SLEEP_MINUTE)
|
|
|
} else {
|
|
|
- //屏幕常亮
|
|
|
- Log.d(TAG, "keep screen on")
|
|
|
- AppTool.Setting.setScreenOffTimeOut2(applicationContext, 2147483647)
|
|
|
+ if (Constant.CUSTOM_ID != -1) {
|
|
|
+ //有人入住,屏幕常亮
|
|
|
+ Log.d(TAG, "keep screen on")
|
|
|
+ AppTool.Setting.setScreenOffTimeOut2(applicationContext, 2147483647)
|
|
|
+ } else {
|
|
|
+ //无人入住,自动休眠
|
|
|
+ Log.d(TAG, "no customer, set screen off timeout: ${Constant.SLEEP_MINUTE}")
|
|
|
+ AppTool.Setting.setScreenOffTimeOut(applicationContext, Constant.SLEEP_MINUTE)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|