From ae75a59f517944ec3ea5f45176a575b2bc6a7040 Mon Sep 17 00:00:00 2001 From: liuguijing <123456> Date: Fri, 14 Feb 2025 20:50:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=E9=80=9A=E7=94=A8=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BF=AE=E6=94=B9=E4=B8=AD=EF=BC=9A=E6=B8=85=E9=99=A4?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E7=9F=AD=E4=BF=A1=E8=BF=9B=E6=9D=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=B8=8A=E4=B8=80=E6=AC=A1=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=9A=84=E7=9F=AD=E4=BF=A1=E5=86=85=E5=AE=B9=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0jsonarray=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpmaster/sms/SimUtil.java | 26 ++++++++++--------- .../xypower/mpmaster/sms/ValueTypeUtil.java | 7 +++-- 2 files changed, 19 insertions(+), 14 deletions(-) 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;