diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java index 1d81d28a..69f27934 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java @@ -68,6 +68,8 @@ public class SimUtil { //短信解析 public static void analysisSMSInfo(final Context context, final Intent intent, final SmsMessage smsMessage) { + sendmessage = null; + restartType = -1; SmsMessageModel smsInfo = getSMSInfo(intent, smsMessage); if (smsInfo != null) { String content = smsInfo.getContent(); @@ -82,13 +84,13 @@ public class SimUtil { return; } if (content.toLowerCase().contains(SmsTypeEnum.UPD_CFG_FILE.value().toLowerCase())) { //修改配置文件中参数 - updateConfig(context, content); + updateConfig(content); } else if (content.toLowerCase().contains(SmsTypeEnum.GET_CFG_FILE.value().toLowerCase())) {//获取配置文件中参数 - queryConfig(context, content); + queryConfig(content); } else if (content.toLowerCase().contains(SmsTypeEnum.UPD_FILE.value().toLowerCase())) {//替换配置文件 - updateFile(context, content); + updateFile(content); } else if (content.toLowerCase().contains(SmsTypeEnum.GET_FILE.value().toLowerCase())) {//获取整个配置文件 - queryFile(context, content); + queryFile(content); } sendSms(context, slot, sender, sendmessage, restartType); @@ -807,7 +809,7 @@ public class SimUtil { //修改配置文件中参数 - private static void updateConfig(Context context, String content) { + private static void updateConfig(String content) { boolean ifmessageCorrect = true; Map fields = new HashMap<>(); try { @@ -840,7 +842,7 @@ public class SimUtil { fields.put(key, value); } } - HashMap hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); + HashMap hashMap = ValueTypeUtil.checkFilePathAndName(fileType); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(fileName) && numberOfFields > 0) { @@ -892,7 +894,7 @@ public class SimUtil { } //替换配置文件 - private static void updateFile(Context context, String content) { + private static void updateFile(String content) { boolean ifmessageCorrect = true; Map fields = new HashMap<>(); try { @@ -925,7 +927,7 @@ public class SimUtil { } if (StringUtils.isNotEmpty(fileStr)) { if (StringUtils.isEmpty(filePath)) { - HashMap hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); + HashMap hashMap = ValueTypeUtil.checkFilePathAndName(fileType); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); if (StringUtils.isEmpty(filePath) || StringUtils.isEmpty(fileName)) { @@ -957,7 +959,7 @@ public class SimUtil { } //获取配置文件 - private static void queryFile(Context context, String content) { + private static void queryFile(String content) { boolean ifmessageCorrect = true; String result = null; try { @@ -985,7 +987,7 @@ public class SimUtil { filePath = value; } } - HashMap hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); + HashMap hashMap = ValueTypeUtil.checkFilePathAndName(fileType); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); if (!TextUtils.isEmpty(filePath + fileName)) { @@ -1017,7 +1019,7 @@ public class SimUtil { } //获取配置文件参数 - private static void queryConfig(Context context, String content) { + private static void queryConfig(String content) { boolean ifmessageCorrect = true; try { String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.GET_CFG_FILE.value().length())); @@ -1049,7 +1051,7 @@ public class SimUtil { fields.put(key, value); } } - HashMap hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); + HashMap hashMap = ValueTypeUtil.checkFilePathAndName(fileType); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/ValueTypeUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/ValueTypeUtil.java index 86b08cc5..f9a8248d 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/ValueTypeUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/ValueTypeUtil.java @@ -1,9 +1,10 @@ package com.xypower.mpmaster.sms; -import android.content.Context; import com.xypower.common.MicroPhotoContext; +import org.json.JSONArray; + import java.util.HashMap; public class ValueTypeUtil { @@ -23,6 +24,8 @@ public class ValueTypeUtil { return 0; } else if (item instanceof Double) { return 2; + } else if (item instanceof JSONArray) { + return 3; } else { return -1; } @@ -33,7 +36,7 @@ public class ValueTypeUtil { * 根据短信类型来判断是修改哪个配置文件 * * */ - public static HashMap checkFilePathAndName(Context context, int fileType) { + public static HashMap checkFilePathAndName( int fileType) { HashMap hashMap = new HashMap<>(); String filePath = null; String fileName = null;