运维修改重启方式

lowmem
liuguijing 2 months ago
parent b216ad7546
commit e59f6fbbea

@ -0,0 +1,20 @@
package com.xypower.mpmaster.sms;
public enum RestartTypeEnum {
//命令类型
REBOOT1(0), //重启系统1
REBOOT2(4), //重启系统2
RESTARTMPAPP(1), //重启MpApp
RESTARTMPMASTER(2), //重启MpMaster
RESTARTBOTH(3); //两个应用都重启
private int type;
RestartTypeEnum(int type) {
this.type = type;
}
public int value() {
return this.type;
}
}

@ -96,23 +96,23 @@ public class SimUtil {
queryFile(content);
} else if (content.contains(SmsTypeEnum.REBOOT1.value())) {
ifmessageCorrect = true;
restartType = 0;
restartType = RestartTypeEnum.REBOOT1.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.REBOOT2.value()) || content.contains(SmsTypeEnum.REBOOT3.value())) {
ifmessageCorrect = true;
restartType = 0;
restartType = RestartTypeEnum.REBOOT2.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.RESTART_MP.value()) || content.contains(SmsTypeEnum.RESTART_MP2.value())) {
ifmessageCorrect = true;
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.RESTART_MPMST.value()) || content.contains(SmsTypeEnum.RESTART_MPMST2.value())) {
ifmessageCorrect = true;
restartType = 2;
restartType = RestartTypeEnum.RESTARTMPMASTER.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.RESTART_BOTH_APPS.value()) || content.contains(SmsTypeEnum.RESTART_BOTH_APPS2.value())) {
ifmessageCorrect = true;
restartType = 3;
restartType = RestartTypeEnum.RESTARTBOTH.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
ifmessageCorrect = true;
@ -159,7 +159,7 @@ public class SimUtil {
}
}
}
restartType = 2;
restartType = RestartTypeEnum.RESTARTMPMASTER.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_YW_SCHEDULE.value())) {
List<Integer> absHeartbeats = UpdateSysConfigUtil.getAbsHeartbeats(context);
@ -191,13 +191,13 @@ public class SimUtil {
}
}
}
restartType = 2;
restartType = RestartTypeEnum.RESTARTMPMASTER.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_OPERATE.value())) {
int mntnMode = UpdateSysConfigUtil.getMntnMode(context);
sendmessage = SmsTypeEnum.GET_OPERATE.value() + "=" + mntnMode;
} else if (content.contains(SmsTypeEnum.SET_OPERATE_URL.value())) {
restartType = 2;
restartType = RestartTypeEnum.RESTARTMPMASTER.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
String s = split1[1];
@ -228,7 +228,7 @@ public class SimUtil {
}
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.SET_CMDID.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
ifmessageCorrect = true;
@ -247,7 +247,7 @@ public class SimUtil {
String serialNo = UpdateSysConfigUtil.getSerialNo();
sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + serialNo + "," + cmdid;
} else if (content.contains(SmsTypeEnum.SET_IP.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
String server = null;
@ -284,7 +284,7 @@ public class SimUtil {
String ip = UpdateSysConfigUtil.getIP(context);
sendmessage = SmsTypeEnum.GET_IP.value() + "=" + ip;
} else if (content.contains(SmsTypeEnum.SET_OSD.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
sendmessage = getSendString(content, ifmessageCorrect);
if (split1 != null && split1.length >= 2) {
@ -420,7 +420,7 @@ public class SimUtil {
}
}
} else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
String s = split1[1];
@ -447,7 +447,7 @@ public class SimUtil {
}
}
} else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
String s = split1[1];
@ -497,7 +497,7 @@ public class SimUtil {
sendmessage = getSendString(content, ifmessageCorrect);
}
} else if (content.contains(SmsTypeEnum.SET_HEART.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length == 2) {
ifmessageCorrect = true;
@ -515,10 +515,10 @@ public class SimUtil {
} else if (content.contains(SmsTypeEnum.SIMCARD.value())) {
sendmessage = getSimcardInfo(context);
} else if (content.contains(SmsTypeEnum.SET_AUTO_TIME.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
sendmessage = setAutoTime(context, content);
} else if (content.contains(SmsTypeEnum.SET_TP.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length == 2) {
ifmessageCorrect = true;
@ -534,7 +534,7 @@ public class SimUtil {
int tb = UpdateSysConfigUtil.getTB(context);
sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb;
} else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) {
restartType = 1;
restartType = RestartTypeEnum.RESTARTMPAPP.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length == 2) {
ifmessageCorrect = true;

@ -12,6 +12,8 @@ import android.util.Log;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* 广
@ -24,10 +26,12 @@ public class SmsReceiver extends BroadcastReceiver {
public static long mLastSmsTime = 0;
private static final SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void onReceive(Context context, Intent intent) {
Logger logger = Logger.getLogger("com.xypower.mpmaster.logger");
logger.setLevel(Level.ALL);
try {
if (intent.getAction().equals(Telephony.Sms.Intents.SMS_RECEIVED_ACTION)) {
SmsMessage[] smsMessages = Telephony.Sms.Intents.getMessagesFromIntent(intent);
for (SmsMessage smsMessage : smsMessages) {
@ -36,7 +40,7 @@ public class SmsReceiver extends BroadcastReceiver {
if (mLastSmsTime!= 0 &&smsMessage.getTimestampMillis() < mLastSmsTime) {
Date dt = new Date(smsMessage.getTimestampMillis());
Log.e("SMS", "MSG @" + mSimpleDateFormat.format(dt) + " Dropped: " + smsMessage.getMessageBody()+" mLastSmsTime:"+mLastSmsTime+" "+mSimpleDateFormat.format(mLastSmsTime));
logger.info("MSG @" + mSimpleDateFormat.format(dt) + " Dropped: " + smsMessage.getMessageBody()+" mLastSmsTime:"+mLastSmsTime+" "+mSimpleDateFormat.format(mLastSmsTime));
SimUtil.setSmsMessageRead(context, smsMessage);
continue;
}

@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.dev.devapi.api.SysApi;
import com.xypower.common.MicroPhotoContext;
import com.xypower.mpmaster.MpMasterService;
@ -48,15 +49,17 @@ public class SmsSendReceiver extends BroadcastReceiver {
}
public void processSms(Context context, int restartType) {
if (restartType == 0) {
if (restartType == RestartTypeEnum.REBOOT1.value()) {
MpMasterService.rebootDevice();
} else if (restartType == 1) {
} else if (restartType == RestartTypeEnum.RESTARTMPAPP.value()) {
MpMasterService.restartMpApp(context.getApplicationContext(), "SMS RESTART");
} else if (restartType == 2) {
} else if (restartType == RestartTypeEnum.RESTARTMPMASTER.value()) {
MpMasterService.restartMpMasterApp(context.getApplicationContext(), "SMS RESTART");
} else if (restartType == 3) {
} else if (restartType == RestartTypeEnum.RESTARTBOTH.value()) {
MpMasterService.restartMpApp(context.getApplicationContext(), "SMS RESTART");
MpMasterService.restartMpMasterApp(context.getApplicationContext(), "SMS RESTART");
} else if (restartType == RestartTypeEnum.REBOOT2.value()) {
SysApi.reboot(context);
}
// if (type.contains(SmsTypeEnum.REBOOT1.value())) {

Loading…
Cancel
Save