短信通用版本修改中:清除第二次短信进来时,上一次发送的短信内容

增加jsonarray类型的判断
streaming
liuguijing 4 months ago
parent de466ba891
commit ae75a59f51

@ -68,6 +68,8 @@ public class SimUtil {
//短信解析 //短信解析
public static void analysisSMSInfo(final Context context, final Intent intent, final SmsMessage smsMessage) { public static void analysisSMSInfo(final Context context, final Intent intent, final SmsMessage smsMessage) {
sendmessage = null;
restartType = -1;
SmsMessageModel smsInfo = getSMSInfo(intent, smsMessage); SmsMessageModel smsInfo = getSMSInfo(intent, smsMessage);
if (smsInfo != null) { if (smsInfo != null) {
String content = smsInfo.getContent(); String content = smsInfo.getContent();
@ -82,13 +84,13 @@ public class SimUtil {
return; return;
} }
if (content.toLowerCase().contains(SmsTypeEnum.UPD_CFG_FILE.value().toLowerCase())) { //修改配置文件中参数 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())) {//获取配置文件中参数 } 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())) {//替换配置文件 } 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())) {//获取整个配置文件 } else if (content.toLowerCase().contains(SmsTypeEnum.GET_FILE.value().toLowerCase())) {//获取整个配置文件
queryFile(context, content); queryFile(content);
} }
sendSms(context, slot, sender, sendmessage, restartType); 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; boolean ifmessageCorrect = true;
Map<String, String> fields = new HashMap<>(); Map<String, String> fields = new HashMap<>();
try { try {
@ -840,7 +842,7 @@ public class SimUtil {
fields.put(key, value); fields.put(key, value);
} }
} }
HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(fileType);
filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH);
fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME);
if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(fileName) && numberOfFields > 0) { 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; boolean ifmessageCorrect = true;
Map<String, String> fields = new HashMap<>(); Map<String, String> fields = new HashMap<>();
try { try {
@ -925,7 +927,7 @@ public class SimUtil {
} }
if (StringUtils.isNotEmpty(fileStr)) { if (StringUtils.isNotEmpty(fileStr)) {
if (StringUtils.isEmpty(filePath)) { if (StringUtils.isEmpty(filePath)) {
HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(fileType);
filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH);
fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME);
if (StringUtils.isEmpty(filePath) || StringUtils.isEmpty(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; boolean ifmessageCorrect = true;
String result = null; String result = null;
try { try {
@ -985,7 +987,7 @@ public class SimUtil {
filePath = value; filePath = value;
} }
} }
HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(fileType);
filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH);
fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME);
if (!TextUtils.isEmpty(filePath + 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; boolean ifmessageCorrect = true;
try { try {
String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.GET_CFG_FILE.value().length())); String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.GET_CFG_FILE.value().length()));
@ -1049,7 +1051,7 @@ public class SimUtil {
fields.put(key, value); fields.put(key, value);
} }
} }
HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(context, fileType); HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(fileType);
filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH);
fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME);

@ -1,9 +1,10 @@
package com.xypower.mpmaster.sms; package com.xypower.mpmaster.sms;
import android.content.Context;
import com.xypower.common.MicroPhotoContext; import com.xypower.common.MicroPhotoContext;
import org.json.JSONArray;
import java.util.HashMap; import java.util.HashMap;
public class ValueTypeUtil { public class ValueTypeUtil {
@ -23,6 +24,8 @@ public class ValueTypeUtil {
return 0; return 0;
} else if (item instanceof Double) { } else if (item instanceof Double) {
return 2; return 2;
} else if (item instanceof JSONArray) {
return 3;
} else { } else {
return -1; return -1;
} }
@ -33,7 +36,7 @@ public class ValueTypeUtil {
* *
* *
* */ * */
public static HashMap checkFilePathAndName(Context context, int fileType) { public static HashMap checkFilePathAndName( int fileType) {
HashMap<String, String> hashMap = new HashMap<>(); HashMap<String, String> hashMap = new HashMap<>();
String filePath = null; String filePath = null;
String fileName = null; String fileName = null;

Loading…
Cancel
Save