From c951675671e3f95cd7b72b93e04eea23f40484fb Mon Sep 17 00:00:00 2001 From: liuguijing <123456> Date: Wed, 12 Feb 2025 15:33:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E4=BF=A1=20=E8=BF=90=E7=BB=B4?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=A1=A8=E4=B8=8D=E8=BF=94=E5=9B=9E=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20=E8=AE=BE=E7=BD=AECMD=5FID=E4=B8=8D=E5=BA=94?= =?UTF-8?q?=E7=AD=94=E4=BF=AE=E5=A4=8D=20=E8=AE=BE=E7=BD=AE=E4=B8=BB?= =?UTF-8?q?=E7=AB=99IP=E7=AB=AF=E5=8F=A3=E8=BF=94=E5=9B=9E=E7=9A=84?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E6=96=B9=E5=BC=8F=E5=92=8C=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E4=B8=8D=E4=B8=80=E8=87=B4=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=20=E6=B0=B4=E5=8D=B0=E6=9F=A5=E8=AF=A2=E5=92=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BF=AE=E5=A4=8D=20=E8=AE=BE=E7=BD=AE=E5=BF=83?= =?UTF-8?q?=E8=B7=B3=E5=8F=8A=E8=BF=9E=E6=8E=A5=E5=8D=8F=E8=AE=AE=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpmaster/sms/SimUtil.java | 137 ++++++++++++------ .../mpmaster/sms/UpdateSysConfigUtil.java | 24 ++- 2 files changed, 104 insertions(+), 57 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 93d92ca2..1823f3e7 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/SimUtil.java @@ -35,6 +35,9 @@ import com.xypower.common.NetworkUtils; import com.xypower.common.RegexUtil; import com.xypower.mpmaster.MpMasterService; +import org.json.JSONException; +import org.json.JSONObject; + import java.io.File; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -129,13 +132,13 @@ public class SimUtil { ifmessageCorrect = false; break; } - times = time * 60; + times = time * 3600; } else { if (time > 59) { ifmessageCorrect = false; break; } - times += time; + times += time * 60; abslist.add(times); } } @@ -160,8 +163,8 @@ public class SimUtil { for (int i = 0; i < length; i++) { int mAbsHeartbeatTime = 0; mAbsHeartbeatTime = absHeartbeats.get(i); - int hour = mAbsHeartbeatTime / 60; - int minute = mAbsHeartbeatTime % 60; + int hour = mAbsHeartbeatTime / 3600; + int minute = (mAbsHeartbeatTime % 3600) / 60; sendmessage += "," + hour + "," + minute; } } @@ -224,7 +227,7 @@ public class SimUtil { if (split1 != null && split1.length > 1) { ifmessageCorrect = true; String cmdid = split1[1]; - UpdateSysConfigUtil.setCmdid(context, cmdid); // + UpdateSysConfigUtil.setCmdid(context, cmdid); } sendmessage = getSendString(content, ifmessageCorrect); } else if (content.contains(SmsTypeEnum.GET_CMDID.value())) { @@ -278,7 +281,7 @@ public class SimUtil { sendmessage = getSendString(content, ifmessageCorrect); if (split1 != null && split1.length == 2) { ifmessageCorrect = true; - HashMap osdmap = new HashMap<>(); + JSONObject osdmap = new JSONObject(); String s = split1[1]; String[] split2 = StringUtils.splitString2(s); int spilt2len = split2.length; @@ -295,16 +298,20 @@ public class SimUtil { String s1 = split2[i]; Integer position = StringUtils.convert2Int(s1); if (position != null) { - if (position == 1) { - osdmap.put(UpdateSysConfigUtil.leftTop, split2[i + 1]); - } else if (position == 2) { - osdmap.put(UpdateSysConfigUtil.rightTop, split2[i + 1]); - } else if (position == 3) { - osdmap.put(UpdateSysConfigUtil.leftBottom, split2[i + 1]); - } else if (position == 4) { - osdmap.put(UpdateSysConfigUtil.rightBottom, split2[i + 1]); - } else { - ifmessageCorrect = false; + try { + if (position == 1) { + osdmap.put(UpdateSysConfigUtil.leftTop, split2[i + 1]); + } else if (position == 2) { + osdmap.put(UpdateSysConfigUtil.rightTop, split2[i + 1]); + } else if (position == 3) { + osdmap.put(UpdateSysConfigUtil.leftBottom, split2[i + 1]); + } else if (position == 4) { + osdmap.put(UpdateSysConfigUtil.rightBottom, split2[i + 1]); + } else { + ifmessageCorrect = false; + } + } catch (JSONException e) { + throw new RuntimeException(e); } } else { ifmessageCorrect = false; @@ -340,23 +347,70 @@ public class SimUtil { if (split != null && split.length == 2) { sendmessage = SmsTypeEnum.GET_OSD.value() + "="; ifmessageCorrect = true; - Integer channel = StringUtils.convert2Int(split[0]); - HashMap channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); - String leftTop = channelOSD.get(UpdateSysConfigUtil.leftTop); - String rightTop = channelOSD.get(UpdateSysConfigUtil.rightTop); - String leftBottom = channelOSD.get(UpdateSysConfigUtil.leftBottom); - String rightBottom = channelOSD.get(UpdateSysConfigUtil.rightBottom); - if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { - sendmessage += "1," + leftTop; - } - if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { - sendmessage += "2," + rightTop; - } - if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { - sendmessage += "3" + leftBottom; - } - if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { - sendmessage += "4," + leftTop; + Integer channel = StringUtils.convert2Int(split[1]); + if (channel != null) { + if (channel == 0) { + MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context); + int channelnum = mpAppConfig.channels; + if (channelnum != 0) { + if (ifmessageCorrect) { + for (int i = 1; i <= channelnum; i++) { + sendmessage += channel + ":{"; + JSONObject channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); + if (channelOSD != null) { + String leftTop = channelOSD.optString(UpdateSysConfigUtil.leftTop); + String rightTop = channelOSD.optString(UpdateSysConfigUtil.rightTop); + String leftBottom = channelOSD.optString(UpdateSysConfigUtil.leftBottom); + String rightBottom = channelOSD.optString(UpdateSysConfigUtil.rightBottom); + if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { + sendmessage += "左上:" + leftTop; + } + if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { + sendmessage += ",右上:" + rightTop; + } + if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { + sendmessage += ",左下:" + leftBottom; + } + if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { + sendmessage += ",右下:" + rightBottom; + } + } else { + sendmessage += "无水印"; + } + if (i == channelnum) { + sendmessage += channel + "}"; + } else { + sendmessage += channel + "},"; + } + } + } + } + } else { + JSONObject channelOSD = UpdateSysConfigUtil.getChannelOSD(channel); + if (channelOSD != null) { + String leftTop = channelOSD.optString(UpdateSysConfigUtil.leftTop); + String rightTop = channelOSD.optString(UpdateSysConfigUtil.rightTop); + String leftBottom = channelOSD.optString(UpdateSysConfigUtil.leftBottom); + String rightBottom = channelOSD.optString(UpdateSysConfigUtil.rightBottom); + if (leftTop != null && StringUtils.isNotEmpty(leftTop)) { + sendmessage += "左上:" + leftTop; + } + if (rightTop != null && StringUtils.isNotEmpty(rightTop)) { + sendmessage += ",右上:" + rightTop; + } + if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) { + sendmessage += ",左下:" + leftBottom; + } + if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) { + sendmessage += ",右下:" + rightBottom; + } + } else { + sendmessage += "无水印"; + } + } + + } else { + ifmessageCorrect = false; } } } else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) { @@ -661,8 +715,7 @@ public class SimUtil { if (TextUtils.equals(value, "on")) { onOff = true; } - } - else if (TextUtils.equals(key, "type")) { + } else if (TextUtils.equals(key, "type")) { if (TextUtils.equals(value, "net")) { autoTimeType = 1; } else if (TextUtils.equals(value, "gps")) { @@ -865,10 +918,10 @@ public class SimUtil { switch (simState) { case TelephonyManager.SIM_STATE_UNKNOWN: return "未知"; - case TelephonyManager.SIM_STATE_ABSENT: - return "无卡"; - case TelephonyManager.SIM_STATE_PIN_REQUIRED: - return "PIN解锁"; + case TelephonyManager.SIM_STATE_ABSENT: + return "无卡"; + case TelephonyManager.SIM_STATE_PIN_REQUIRED: + return "PIN解锁"; case TelephonyManager.SIM_STATE_PUK_REQUIRED: return "PUK解锁"; case TelephonyManager.SIM_STATE_NETWORK_LOCKED: @@ -1008,7 +1061,7 @@ public class SimUtil { Integer intVal = (Integer) value; slot = intVal.intValue(); } else if (value instanceof String) { - String str = (String)value; + String str = (String) value; if (str.equals("0") | str.equals("1") | str.equals("2")) { // slot = bundle.getInt(key, -1); slot = Integer.parseInt(str); @@ -1055,9 +1108,9 @@ public class SimUtil { SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId()); if (message.length() > 70) { ArrayList msgs = smsManager.divideMessage(message); - ArrayList sentIntents = new ArrayList(); + ArrayList sentIntents = new ArrayList(); - for(int i = 0;i < msgs.size(); i++){ + for (int i = 0; i < msgs.size(); i++) { sentIntents.add(sendPI); } smsManager.sendMultipartTextMessage(sender, null, msgs, sentIntents, null); diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java b/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java index d63e14c3..11bafb3d 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/sms/UpdateSysConfigUtil.java @@ -35,6 +35,7 @@ public class UpdateSysConfigUtil { public static final String EXTRA_PARAM_TAKING_TIME = "TakingTime"; public static final String EXTRA_PARAM_TIME = "Time"; + public static String osd = "osd"; public static String leftTop = "leftTop"; public static String rightTop = "rightTop"; public static String leftBottom = "leftBottom"; @@ -262,14 +263,11 @@ public class UpdateSysConfigUtil { } //设置通道水印 - public static boolean setChannelOSD(int channel, HashMap hashMap) { + public static boolean setChannelOSD(int channel, JSONObject osdjsonObject) { String path = getChannelDir(channel); JSONObject jsonObject = JSONUtils.loadJson(path); try { - jsonObject.put(UpdateSysConfigUtil.leftTop, hashMap.get(UpdateSysConfigUtil.leftTop)); - jsonObject.put(UpdateSysConfigUtil.rightTop, hashMap.get(UpdateSysConfigUtil.rightTop)); - jsonObject.put(UpdateSysConfigUtil.leftBottom, hashMap.get(UpdateSysConfigUtil.leftBottom)); - jsonObject.put(UpdateSysConfigUtil.rightBottom, hashMap.get(UpdateSysConfigUtil.rightBottom)); + jsonObject.put(UpdateSysConfigUtil.osd, osdjsonObject); } catch (Exception ex) { ex.printStackTrace(); } @@ -277,23 +275,19 @@ public class UpdateSysConfigUtil { } //查询通道分辨率 - public static HashMap getChannelOSD(int channel) { + public static JSONObject getChannelOSD(int channel) { HashMap hashMap = new HashMap<>(); + JSONObject osdjsonObject = null; String path = getChannelDir(channel); JSONObject jsonObject = JSONUtils.loadJson(path); try { - String leftTop = jsonObject.getString(UpdateSysConfigUtil.leftTop); - String rightTop = jsonObject.getString(UpdateSysConfigUtil.rightTop); - String leftBottom = jsonObject.getString(UpdateSysConfigUtil.leftBottom); - String rightBottom = jsonObject.getString(UpdateSysConfigUtil.rightBottom); - hashMap.put(UpdateSysConfigUtil.leftTop, leftTop); - hashMap.put(UpdateSysConfigUtil.rightTop, rightTop); - hashMap.put(UpdateSysConfigUtil.leftBottom, leftBottom); - hashMap.put(UpdateSysConfigUtil.rightBottom, rightBottom); + if (jsonObject != null) { + osdjsonObject = jsonObject.getJSONObject(UpdateSysConfigUtil.osd); + } } catch (Exception ex) { ex.printStackTrace(); } - return hashMap; + return osdjsonObject; }