|
@@ -16,6 +16,7 @@ import com.wdkl.ncs.android.component.nursehome.launch.NurseHomeLaunch
|
|
|
import com.wdkl.ncs.android.lib.base.BaseActivity
|
|
|
import io.reactivex.Observable
|
|
|
import com.wdkl.ncs.android.component.nursehome.BuildConfig
|
|
|
+import com.wdkl.ncs.android.component.nursehome.settingconfig.SettingConfig
|
|
|
import com.wdkl.ncs.android.component.nursehome.util.*
|
|
|
import com.wdkl.ncs.android.middleware.common.Constants
|
|
|
import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
@@ -36,6 +37,7 @@ import org.greenrobot.eventbus.Subscribe
|
|
|
import org.greenrobot.eventbus.ThreadMode
|
|
|
import serialporttest.utils.SerialPortUtil
|
|
|
import java.lang.StringBuilder
|
|
|
+import java.util.*
|
|
|
import java.util.concurrent.TimeUnit
|
|
|
|
|
|
/**
|
|
@@ -54,6 +56,9 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
|
|
|
private var cancelRestart = false
|
|
|
private var homeLaunch = false
|
|
|
|
|
|
+ //网络异常计数
|
|
|
+ private var netErrCount : Int = 0
|
|
|
+
|
|
|
/**
|
|
|
* 提供layoutID
|
|
|
*/
|
|
@@ -205,7 +210,7 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- Thread.sleep(30000)
|
|
|
+ Thread.sleep(45000)
|
|
|
} catch (ex: Exception) {
|
|
|
ex.printStackTrace()
|
|
|
}
|
|
@@ -214,6 +219,10 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
|
|
|
}
|
|
|
|
|
|
private fun checkServerInfo(info: ThirdServerInfo?) {
|
|
|
+ runOnUiThread {
|
|
|
+ checkNet()
|
|
|
+ }
|
|
|
+
|
|
|
//检查获取到的服务器ip是否可用,可用则重启app重新初始化,不可用则什么都不做,等待下次重新获取服务器ip
|
|
|
if (info != null) {
|
|
|
if (info.thirdServer == null || info.thirdServerPort == null) {
|
|
@@ -301,6 +310,9 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
|
|
|
Constants.back_id = data.backupId
|
|
|
}
|
|
|
|
|
|
+ SettingConfig.setNetErrResetCount(this, 0)
|
|
|
+ WarningDialogHelper.dismiss()
|
|
|
+
|
|
|
if(TextUtils.isEmpty(data.partId.toString())|| TextUtils.isEmpty(data.id.toString())
|
|
|
|| TextUtils.isEmpty(data.sipId)){
|
|
|
feedback_device_info_tv.setText(R.string.device_init_fail)
|
|
@@ -367,7 +379,7 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
|
|
|
btn_reboot.setOnClickListener {
|
|
|
cancelRestart = true
|
|
|
handler.removeCallbacksAndMessages(null)
|
|
|
- AppUpdateHelper.restartApp(activity)
|
|
|
+ AppUpdateHelper.reboot(activity)
|
|
|
}
|
|
|
|
|
|
btn_set_language.setOnClickListener {
|
|
@@ -384,6 +396,54 @@ class RegisterActivity : BaseActivity<DevicePresenter, ActivityRegisterBinding>(
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private fun checkNet() {
|
|
|
+ /*
|
|
|
+ * 检查网络情况,若tcp断开连接多次且IP也是空的则网络异常,重启设备
|
|
|
+ * 仅对3128设备有效
|
|
|
+ */
|
|
|
+ if (Build.MODEL.equals("rk3128")) {
|
|
|
+ var count = SettingConfig.getNetErrResetCount(this)
|
|
|
+ Log.e("checkNet", "checkNet --> netErrCount: " + netErrCount
|
|
|
+ + ", IP isEmpty: " + TextUtils.isEmpty(NetHelper.getInstance().localIP)
|
|
|
+ + ", count: " + count)
|
|
|
+ if (!Constants.tcp_connected && TextUtils.isEmpty(NetHelper.getInstance().localIP)) {
|
|
|
+ netErrCount++
|
|
|
+ } else {
|
|
|
+ netErrCount = 0
|
|
|
+ if (count > 0) {
|
|
|
+ count = 0
|
|
|
+ SettingConfig.setNetErrResetCount(this, count)
|
|
|
+ WarningDialogHelper.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (netErrCount >= 5) {
|
|
|
+ //如果重启次数超过8次还是无网则不再重启
|
|
|
+ if (count < 8) {
|
|
|
+ count++
|
|
|
+ SettingConfig.setNetErrResetCount(this, count)
|
|
|
+ Handler().postDelayed({
|
|
|
+ AppUpdateHelper.reboot(activity)
|
|
|
+ }, 5000)
|
|
|
+ } else {
|
|
|
+ WarningDialogHelper.showDialog(activity, getString(R.string.device_error),true)
|
|
|
+
|
|
|
+ //隔2个小时再重启
|
|
|
+ val calendar = Calendar.getInstance()
|
|
|
+ val hour = calendar[Calendar.HOUR_OF_DAY]
|
|
|
+ val minute = calendar[Calendar.MINUTE]
|
|
|
+ Log.e("checkNet", "show net error dialog --> hour: $hour, minute: $minute")
|
|
|
+ if (hour%2 == 0 && minute == 0) {
|
|
|
+ Handler().postDelayed({
|
|
|
+ AppUpdateHelper.reboot(activity)
|
|
|
+ }, 5000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*页面销毁回调
|
|
|
*/
|