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; }