|
|
@ -63,7 +63,7 @@ import qianmu.container.util.ViplexCore; |
|
|
|
|
|
|
|
|
public class ContainerHandler extends Handler { |
|
|
public class ContainerHandler extends Handler { |
|
|
|
|
|
|
|
|
public static final int HEART_BEAT_DELAY_TIME = 60 * 1000; //心跳包时间间隔
|
|
|
|
|
|
|
|
|
public static final int HEART_BEAT_DELAY_TIME = 70 * 1000; //心跳包时间间隔
|
|
|
public static final int DELAY_TIME = 1000; //handler延时时间
|
|
|
public static final int DELAY_TIME = 1000; //handler延时时间
|
|
|
public static final int CONNECT_LOCAL_SOCKET = 3; //连接本地socket
|
|
|
public static final int CONNECT_LOCAL_SOCKET = 3; //连接本地socket
|
|
|
public static final int CLOSE_LOCAL_SOCKET = 4; //关闭本地socket
|
|
|
public static final int CLOSE_LOCAL_SOCKET = 4; //关闭本地socket
|
|
|
@ -131,6 +131,7 @@ public class ContainerHandler extends Handler { |
|
|
public void onSuccess() { |
|
|
public void onSuccess() { |
|
|
//检查,MQTT状态
|
|
|
//检查,MQTT状态
|
|
|
mqttState(); |
|
|
mqttState(); |
|
|
|
|
|
removeMessages(MQTT_ALIVE); |
|
|
printDisplayStatus(); |
|
|
printDisplayStatus(); |
|
|
sendEmptyMessageDelayed(MQTT_ALIVE,15000); |
|
|
sendEmptyMessageDelayed(MQTT_ALIVE,15000); |
|
|
sendEmptyMessageDelayed(MQTT_ALIVE,35000); |
|
|
sendEmptyMessageDelayed(MQTT_ALIVE,35000); |
|
|
@ -145,10 +146,6 @@ public class ContainerHandler extends Handler { |
|
|
} ); |
|
|
} ); |
|
|
|
|
|
|
|
|
getMemory(); |
|
|
getMemory(); |
|
|
if("nova".equals(Constant.androidBoardType) && isExactlyNineClock()){ |
|
|
|
|
|
LoggerUtil.e("reboot: ","设备重启"); |
|
|
|
|
|
SignWayUtil.reboot(); |
|
|
|
|
|
} |
|
|
|
|
|
// watchDog();
|
|
|
// watchDog();
|
|
|
getCoreServiceState(); |
|
|
getCoreServiceState(); |
|
|
// DeviceData.getPrimaryMachine(null, this::updateClientStateByIP);
|
|
|
// DeviceData.getPrimaryMachine(null, this::updateClientStateByIP);
|
|
|
@ -158,14 +155,7 @@ public class ContainerHandler extends Handler { |
|
|
LoggerUtil.e("heartBeatDelayTime", StringUtil.getThrowableStr(t)); |
|
|
LoggerUtil.e("heartBeatDelayTime", StringUtil.getThrowableStr(t)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// nova 设备每天两点重启一次
|
|
|
|
|
|
public boolean isExactlyNineClock() { |
|
|
|
|
|
// 获取系统当前的日历时间对象(包含年月日时分秒)
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
int hour = calendar.get(Calendar.HOUR_OF_DAY); |
|
|
|
|
|
int minute = calendar.get(Calendar.MINUTE); |
|
|
|
|
|
return hour == 2 && minute <2; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//获取屏幕状态
|
|
|
//获取屏幕状态
|
|
|
private static void printDisplayStatus() { |
|
|
private static void printDisplayStatus() { |
|
|
DisplayManager dm = (DisplayManager) MyApplication.getInstance().getSystemService(Context.DISPLAY_SERVICE); |
|
|
DisplayManager dm = (DisplayManager) MyApplication.getInstance().getSystemService(Context.DISPLAY_SERVICE); |
|
|
@ -226,17 +216,17 @@ public class ContainerHandler extends Handler { |
|
|
// if(cpuUsage>50){
|
|
|
// if(cpuUsage>50){
|
|
|
// LoggerUtil.e("ContainerHandler","cpu使用率:"+cpuUsage+"%");
|
|
|
// LoggerUtil.e("ContainerHandler","cpu使用率:"+cpuUsage+"%");
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
|
|
|
if(totalPss/1024>1000 && DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE).equals("导视") && !Constant.whoActivity.equals(Constant.ROUTE_WEB_VIEW)){ |
|
|
|
|
|
//内存超过了1G会出现卡顿
|
|
|
|
|
|
long currentTime = System.currentTimeMillis(); |
|
|
|
|
|
if(currentTime-goNavTime>360000){ |
|
|
|
|
|
LoggerUtil.e("getMemory()","内存超过1000 进入导视释放内存"); |
|
|
|
|
|
ARouter.getInstance().build(Constant.ROUTE_WEB_VIEW).withBoolean(Constant.KEY_LOAD_H5_URL, true).navigation(); |
|
|
|
|
|
goNavTime = currentTime; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if(totalPss/1024>1400){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(totalPss/1024>1400 && DeviceData.getDeviceInfo(DeviceData.HINT_DEVICE_TYPE).equals("导视") && !Constant.whoActivity.equals(Constant.ROUTE_WEB_VIEW)){
|
|
|
|
|
|
// //内存超过了1G会出现卡顿
|
|
|
|
|
|
// long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
// if(currentTime-goNavTime>360000){
|
|
|
|
|
|
// LoggerUtil.e("getMemory()","内存超过1000 进入导视释放内存");
|
|
|
|
|
|
// ARouter.getInstance().build(Constant.ROUTE_WEB_VIEW).withBoolean(Constant.KEY_LOAD_H5_URL, true).navigation();
|
|
|
|
|
|
// goNavTime = currentTime;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
if(totalPss/1024>1200){ |
|
|
//内存超过了1G会出现卡顿,内存溢出问题。重启设备。
|
|
|
//内存超过了1G会出现卡顿,内存溢出问题。重启设备。
|
|
|
LoggerUtil.e("getMemory()","内存溢出重启软件"); |
|
|
LoggerUtil.e("getMemory()","内存溢出重启软件"); |
|
|
EventBus.getDefault().post(new MessageEvent(Constant.ACTION_RESTART_APP)); |
|
|
EventBus.getDefault().post(new MessageEvent(Constant.ACTION_RESTART_APP)); |
|
|
|