|
@@ -12,6 +12,7 @@ import android.net.NetworkInfo;
|
|
|
import android.os.Environment;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
@@ -31,6 +32,7 @@ import com.wdkl.callingbed.util.DownloadUtil;
|
|
|
import com.wdkl.callingbed.util.LogUtil;
|
|
|
import com.wdkl.callingbed.util.NetUtil;
|
|
|
import com.wdkl.callingbed.util.ScreenManagerUtil;
|
|
|
+import com.wdkl.callingbed.util.SharedPreferencesUtil;
|
|
|
import com.wdkl.callingbed.util.StringUtils;
|
|
|
import com.wdkl.callingbed.util.ToastUtil;
|
|
|
import com.wdkl.callingbed.util.UdpSendUtil;
|
|
@@ -78,7 +80,7 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
|
String macAddress = "";
|
|
|
|
|
|
SerialPortUtil serialPortUtil;
|
|
|
- private int countsReboot;//重启计数
|
|
|
+ private static int countsReboot;//重启计数
|
|
|
|
|
|
@Override
|
|
|
public int getLayoutId() {
|
|
@@ -186,6 +188,7 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
|
ToastUtil.showToast("无网络连接;以太网是否连接正常?");//网络信息初始化错误
|
|
|
//autoReboot();//wuyq remove
|
|
|
|
|
|
+ resetEthernet();
|
|
|
}
|
|
|
} else {
|
|
|
updateHandler.sendEmptyMessageDelayed(404, DATEREFRESH_DELAYMILLIS);
|
|
@@ -198,9 +201,9 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
|
/**
|
|
|
* =================================================(网络不通)15次以上自动重启系统=====================================================
|
|
|
*/
|
|
|
- private void autoReboot() {
|
|
|
- if (countsReboot == 16) {
|
|
|
- AutoRebootUtil.calculate(this);
|
|
|
+ private void resetEthernet() {
|
|
|
+ if (countsReboot == 15) {
|
|
|
+ updateHandler.sendEmptyMessage(222);
|
|
|
countsReboot = 0;
|
|
|
}
|
|
|
countsReboot++;
|
|
@@ -262,6 +265,10 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
|
private void getInitData() {
|
|
|
LogUtil.d("getInitData", "URL==" + Constants.URL + Constants.URL_END + Constants.CALLINGBED_INIT);
|
|
|
final String ipStr = NetUtil.getLocalIP();
|
|
|
+ //网络恢复正常,重置重启计数
|
|
|
+ if (!TextUtils.isEmpty(ipStr)) {
|
|
|
+ SharedPreferencesUtil.putIntSp(context, Constants.REBOOT_COUNT, Constants.REBOOT_COUNT, 0);
|
|
|
+ }
|
|
|
if (Constants.URL.length() > 7) {
|
|
|
OkHttpUtils
|
|
|
.post()
|
|
@@ -584,6 +591,23 @@ public class InitActivity extends BaseActivity implements SerialPortUtil.ISerial
|
|
|
stopRecord();
|
|
|
}
|
|
|
break;
|
|
|
+ case 222:
|
|
|
+ int count = SharedPreferencesUtil.getIntSp(context, Constants.REBOOT_COUNT, Constants.REBOOT_COUNT);
|
|
|
+ LogUtil.d("wzlll", "NetReset reboot count: " + count);
|
|
|
+ if (count >= 10) {
|
|
|
+ ToastUtil.showToast("设备出现异常,请确保网络连接正常或重启设备");
|
|
|
+ } else {
|
|
|
+ count++;
|
|
|
+ SharedPreferencesUtil.putIntSp(context, Constants.REBOOT_COUNT, Constants.REBOOT_COUNT, count);
|
|
|
+ ToastUtil.showToast("网络异常,即将重启");
|
|
|
+ updateHandler.sendEmptyMessageDelayed(333, 5000);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 333:
|
|
|
+ LogUtil.d("wzlll", "NetReset reboot...");
|
|
|
+ AutoRebootUtil.reboot(MyApplication.getAppContext());
|
|
|
+ CallingBedSendCommand.setNetStatus(serialPortUtil, "1");
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
};
|