|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package com.xypower.mpmaster.sms;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
|
import android.app.Activity;
|
|
|
|
|
import android.app.PendingIntent;
|
|
|
|
@ -19,11 +20,6 @@ import androidx.core.app.ActivityCompat;
|
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
|
import org.json.JSONException;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -43,8 +39,9 @@ public class SimUtil {
|
|
|
|
|
|
|
|
|
|
//自定义ACTION常数 作为广播的IntentFilter识别常数
|
|
|
|
|
public static String SMS_SEND_ACTION = "com.xypower.mpmaster.SMS_SEND_ACTION";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static String SMSTYPE = "smstype";
|
|
|
|
|
public static String SMSDATA = "smsdata";
|
|
|
|
|
|
|
|
|
|
public static String SMSIFCORRECT = "smsifcorrect";
|
|
|
|
|
|
|
|
|
@ -65,29 +62,29 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
if (content.contains(SmsTypeEnum.REBOOT1.value())) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
sendmessage = content + " OK";
|
|
|
|
|
sendtype = SmsTypeEnum.REBOOT1.value();
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.REBOOT2.value())) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
sendmessage = content + " OK";
|
|
|
|
|
sendtype = SmsTypeEnum.REBOOT2.value();
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
if (split1 != null && split1.length == 2) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString2(s);
|
|
|
|
|
if (split2 != null && split2.length >= 1) {
|
|
|
|
|
int length = split2.length;
|
|
|
|
|
if (length % 2 == 1) {
|
|
|
|
|
int spilt2len = split2.length;
|
|
|
|
|
if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) {
|
|
|
|
|
String num = split2[0];
|
|
|
|
|
Integer integer = StringUtils.convert2Int(num);
|
|
|
|
|
if (integer != null) {
|
|
|
|
|
if (integer == 0) {//删除所有运维
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
} else {
|
|
|
|
|
if (length == integer + 1) {
|
|
|
|
|
if (spilt2len == integer * 2 + 1) {
|
|
|
|
|
int times = 0;
|
|
|
|
|
for (int i = 0; i < split2.length; i++) {
|
|
|
|
|
for (int i = 0; i < spilt2len; i++) {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
@ -116,15 +113,8 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendtype = SmsTypeEnum.SET_YW_SCHEDULE.value();
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_YW_SCHEDULE.value())) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
List<Integer> absHeartbeats = UpdateSysConfigUtil.getAbsHeartbeats(context);
|
|
|
|
@ -137,7 +127,6 @@ public class SimUtil {
|
|
|
|
|
int mAbsHeartbeatTime = 0;
|
|
|
|
|
mAbsHeartbeatTime = absHeartbeats.get(i);
|
|
|
|
|
int hour = mAbsHeartbeatTime / 60;
|
|
|
|
|
// int leftsecond = mAbsHeartbeatTime % 60;
|
|
|
|
|
int minute = mAbsHeartbeatTime % 60;
|
|
|
|
|
sendmessage += "," + hour + "," + minute;
|
|
|
|
|
}
|
|
|
|
@ -155,18 +144,12 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_OPERATE.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_OPERATE.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
int mntnMode = UpdateSysConfigUtil.getMntnMode(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_OPERATE + "=" + mntnMode;
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_OPERATE.value() + "=" + mntnMode;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_OPERATE_URL.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_OPERATE_URL.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
@ -186,18 +169,12 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_OPERATE_URL.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_OPERATE.value();
|
|
|
|
|
sendtype = SmsTypeEnum.GET_OPERATE_URL.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String mntnServer = UpdateSysConfigUtil.getMntnServer(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_OPERATE + "=" + mntnServer;
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_OPERATE_URL.value() + "=" + mntnServer;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.UPDATE.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.UPDATE.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
@ -206,32 +183,21 @@ public class SimUtil {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
DownloadUtils downloadUtils = new DownloadUtils(context.getApplicationContext(), s, "test.app");
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_CMDID.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_CMDID.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String cmdid = split1[1];
|
|
|
|
|
UpdateSysConfigUtil.setCmdid(context, cmdid);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_CMDID.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_CMDID.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String cmdid = UpdateSysConfigUtil.getCmdid(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_OPERATE + "=" + cmdid;
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + cmdid;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_IP.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_IP.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
@ -248,7 +214,6 @@ public class SimUtil {
|
|
|
|
|
int encrypto = -1;
|
|
|
|
|
if (integer != null) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
}
|
|
|
|
|
if (split2.length == 4) {
|
|
|
|
|
String s1 = split2[2];
|
|
|
|
|
utcp = StringUtils.convert2Int(s1);
|
|
|
|
@ -258,39 +223,92 @@ public class SimUtil {
|
|
|
|
|
UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_IP.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_IP.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String ip = UpdateSysConfigUtil.getIP(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_IP + "=" + ip;
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_IP.value() + "=" + ip;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_OSD.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_OSD.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
if (split1 != null && split1.length == 2) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
HashMap<String, String> osdmap = new HashMap<>();
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString2(s);
|
|
|
|
|
if (split2 != null && split2.length == 2) {
|
|
|
|
|
int spilt2len = split2.length;
|
|
|
|
|
if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) {
|
|
|
|
|
String num = split2[0];
|
|
|
|
|
Integer integer = StringUtils.convert2Int(num);
|
|
|
|
|
if (integer != null) {
|
|
|
|
|
if (integer == 0) {//所有通道
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
} else {
|
|
|
|
|
for (int i = 0; i < spilt2len; i++) {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (i % 2 == 1) {
|
|
|
|
|
if ((i + 1) <= spilt2len) {
|
|
|
|
|
String s1 = split2[i];
|
|
|
|
|
Integer position = StringUtils.convert2Int(s1);
|
|
|
|
|
if (position != null) {
|
|
|
|
|
if (position == 1) {
|
|
|
|
|
osdmap.put("leftTop", split2[i + 1]);
|
|
|
|
|
} else if (position == 2) {
|
|
|
|
|
osdmap.put("rightTop", split2[i + 1]);
|
|
|
|
|
} else if (position == 3) {
|
|
|
|
|
osdmap.put("leftBottom", split2[i + 1]);
|
|
|
|
|
} else if (position == 4) {
|
|
|
|
|
osdmap.put("rightBottom", split2[i + 1]);
|
|
|
|
|
} else {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
UpdateSysConfigUtil.setChannelOSD(integer, osdmap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_OSD.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_OSD.value();
|
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
|
if (split != null && split.length == 2) {
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_OSD.value() + "=";
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split[0]);
|
|
|
|
|
HashMap<String, String> channelOSD = UpdateSysConfigUtil.getChannelOSD(channel);
|
|
|
|
|
String leftTop = channelOSD.get("leftTop");
|
|
|
|
|
String rightTop = channelOSD.get("rightTop");
|
|
|
|
|
String leftBottom = channelOSD.get("leftBottom");
|
|
|
|
|
String rightBottom = channelOSD.get("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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_OSD.value();
|
|
|
|
|
sendtype = SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
@ -298,13 +316,7 @@ public class SimUtil {
|
|
|
|
|
if (split2 != null && split2.length == 2) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
@ -322,28 +334,43 @@ public class SimUtil {
|
|
|
|
|
Integer videoCY = StringUtils.convert2Int(split2[4]);
|
|
|
|
|
if (channel != null && resolutionCX != null && resolutionCY != null && videoCX != null && videoCY != null) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
UpdateSysConfigUtil.setChannelResolution(packageName, channel, resolutionCX, resolutionCY, videoCX, videoCY);
|
|
|
|
|
UpdateSysConfigUtil.setChannelResolution(channel, resolutionCX, resolutionCY, videoCX, videoCY);
|
|
|
|
|
UpdateSysConfigUtil.restartApp(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_RESOLUTION.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_RESOLUTION.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split[0]);
|
|
|
|
|
HashMap<String, Integer> hashMap = UpdateSysConfigUtil.getChannelResolution(packageName, channel);
|
|
|
|
|
HashMap<String, Integer> hashMap = UpdateSysConfigUtil.getChannelResolution(channel);
|
|
|
|
|
Integer resolutionCX = hashMap.get("resolutionCX");
|
|
|
|
|
Integer resolutionCY = hashMap.get("resolutionCY");
|
|
|
|
|
Integer videoCX = hashMap.get("videoCX");
|
|
|
|
|
Integer videoCY = hashMap.get("videoCY");
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_RESOLUTION.value() + "=" + resolutionCX + "," + resolutionCY + "," + videoCX + "," + videoCY;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.TAKE_PHOTO.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.TAKE_PHOTO.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
|
if (split != null && split.length == 3) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split[0]);
|
|
|
|
|
Integer preset = StringUtils.convert2Int(split[1]);
|
|
|
|
|
Integer type = StringUtils.convert2Int(split[2]);
|
|
|
|
|
if (channel != null) {
|
|
|
|
|
boolean photoOrVideo;
|
|
|
|
|
if (type == 0) {
|
|
|
|
|
photoOrVideo = true;
|
|
|
|
|
} else {
|
|
|
|
|
photoOrVideo = false;
|
|
|
|
|
}
|
|
|
|
|
UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo);
|
|
|
|
|
}
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
}
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_HEART.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_HEART.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
@ -353,13 +380,7 @@ public class SimUtil {
|
|
|
|
|
Integer integer = StringUtils.convert2Int(s);
|
|
|
|
|
UpdateSysConfigUtil.setHB(context, integer);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_HEART.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_HEART.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
@ -374,17 +395,10 @@ public class SimUtil {
|
|
|
|
|
Integer integer = StringUtils.convert2Int(s);
|
|
|
|
|
UpdateSysConfigUtil.setTB(context, integer);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_TP.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_TP.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
|
int tb = UpdateSysConfigUtil.getTB(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) {
|
|
|
|
@ -396,13 +410,7 @@ public class SimUtil {
|
|
|
|
|
Integer integer = StringUtils.convert2Int(s);
|
|
|
|
|
UpdateSysConfigUtil.setPackage(context, integer);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_PACKAGE.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
@ -412,29 +420,27 @@ public class SimUtil {
|
|
|
|
|
sendtype = SmsTypeEnum.CLEAR_PHOTO.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryPic(context);
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.CLEAR_LOG.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.CLEAR_LOG.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryLogs(context);
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.CLEAR_ALL.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.CLEAR_ALL.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryPic(context);
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryLogs(context);
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
}
|
|
|
|
|
sendSms(context, slot, sender, sendmessage, sendtype, ifmessageCorrect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getSendString(String content, boolean ifmessageCorrect) {
|
|
|
|
|
String sendmessage;
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
@ -442,10 +448,7 @@ public class SimUtil {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
}
|
|
|
|
|
sendSms(context, slot, sender, sendmessage, sendtype, ifmessageCorrect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sendmessage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//短信解析
|
|
|
|
@ -528,7 +531,8 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//指定sim卡位置发送短信
|
|
|
|
|
public static void sendSms(Context mContext, int slot, String sender, String message, String value, boolean ifmessageCorrect) {
|
|
|
|
|
public static void sendSms(Context mContext, int slot, String sender, String message, String
|
|
|
|
|
value, boolean ifmessageCorrect) {
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
|
|
|
SubscriptionManager localSubscriptionManager = SubscriptionManager.from(mContext);
|
|
|
|
|
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
@ -536,15 +540,19 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
if (localSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
|
|
|
|
|
List localList = localSubscriptionManager.getActiveSubscriptionInfoList();
|
|
|
|
|
|
|
|
|
|
boolean doubleSim = isDoubleSim(mContext);
|
|
|
|
|
SubscriptionInfo simInfoAnother = null;
|
|
|
|
|
if (doubleSim) {
|
|
|
|
|
if (localList != null && localList.size() > 1) {
|
|
|
|
|
SubscriptionInfo simInfo1 = (SubscriptionInfo) localList.get(0);
|
|
|
|
|
SubscriptionInfo simInfo2 = (SubscriptionInfo) localList.get(1);
|
|
|
|
|
SubscriptionInfo simInfoAnother;
|
|
|
|
|
if (slot == 0) {
|
|
|
|
|
simInfoAnother = simInfo1;
|
|
|
|
|
} else {
|
|
|
|
|
simInfoAnother = simInfo2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Intent itSend = new Intent(SMS_SEND_ACTION);
|
|
|
|
|
itSend.putExtra(SMSTYPE, value);
|
|
|
|
|
itSend.putExtra(SMSIFCORRECT, ifmessageCorrect);
|
|
|
|
@ -555,10 +563,12 @@ public class SimUtil {
|
|
|
|
|
// Intent itDeliver = new Intent(SMS_DELIVERED_ACTION);
|
|
|
|
|
//deliveryIntent参数为传送后接受的广播信息PendingIntent
|
|
|
|
|
// PendingIntent deliverPI = PendingIntent.getBroadcast(mContext,0,itDeliver,0);
|
|
|
|
|
if (simInfoAnother != null) {
|
|
|
|
|
SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId()).sendTextMessage(sender, null, message, sendPI, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否是双卡
|
|
|
|
@ -626,7 +636,8 @@ public class SimUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//申请该权限
|
|
|
|
|
public static void requestOnePermission(Activity activity, String permission, int permissionCode) {
|
|
|
|
|
public static void requestOnePermission(Activity activity, String permission,
|
|
|
|
|
int permissionCode) {
|
|
|
|
|
if (activity != null) {
|
|
|
|
|
activity.requestPermissions(new String[]{permission}, permissionCode);
|
|
|
|
|
}
|
|
|
|
|