|
|
|
@ -27,6 +27,7 @@ import java.io.Serializable;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.TimeZone;
|
|
|
|
@ -55,7 +56,7 @@ public class SimUtil {
|
|
|
|
|
String content = smsInfo.getContent();
|
|
|
|
|
int slot = smsInfo.getSlot();//那张卡收到的短信
|
|
|
|
|
String sender = smsInfo.getSender();//收到的短信的手机号
|
|
|
|
|
String sendmessage = "";//要回复的短信
|
|
|
|
|
String sendmessage = "ERROR";//要回复的短信
|
|
|
|
|
String sendtype = "";//收到的短信类型
|
|
|
|
|
List<Integer> abslist = new ArrayList<>();//收到的短信内容拆分包装成数组
|
|
|
|
|
boolean ifmessageCorrect = false;//用来判断收到的短信内容是否正确
|
|
|
|
@ -97,13 +98,13 @@ public class SimUtil {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
times = time * 3600;
|
|
|
|
|
times = time * 60;
|
|
|
|
|
} else {
|
|
|
|
|
if (time > 59) {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
times += time * 60;
|
|
|
|
|
times += time;
|
|
|
|
|
abslist.add(times);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -135,9 +136,9 @@ public class SimUtil {
|
|
|
|
|
for (int i = 0; i < length; i++) {
|
|
|
|
|
int mAbsHeartbeatTime = 0;
|
|
|
|
|
mAbsHeartbeatTime = absHeartbeats.get(i);
|
|
|
|
|
int hour = mAbsHeartbeatTime / 3600;
|
|
|
|
|
int leftsecond = mAbsHeartbeatTime % 3600;
|
|
|
|
|
int minute = leftsecond / 3600;
|
|
|
|
|
int hour = mAbsHeartbeatTime / 60;
|
|
|
|
|
// int leftsecond = mAbsHeartbeatTime % 60;
|
|
|
|
|
int minute = mAbsHeartbeatTime % 60;
|
|
|
|
|
sendmessage += "," + hour + "," + minute;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -171,7 +172,7 @@ public class SimUtil {
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString1(s);
|
|
|
|
|
String[] split2 = StringUtils.splitString2(s);
|
|
|
|
|
if (split2 != null && split2.length == 2) {
|
|
|
|
|
String ipAddress = split2[0];
|
|
|
|
|
String port = split2[1];
|
|
|
|
@ -236,7 +237,7 @@ public class SimUtil {
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString1(s);
|
|
|
|
|
String[] split2 = StringUtils.splitString2(s);
|
|
|
|
|
if (split2 != null && (split2.length == 2 || split2.length == 4)) {
|
|
|
|
|
String server;
|
|
|
|
|
Integer integer;
|
|
|
|
@ -270,14 +271,12 @@ public class SimUtil {
|
|
|
|
|
String ip = UpdateSysConfigUtil.getIP(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_IP + "=" + ip;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_OSD.value())) {
|
|
|
|
|
//TODO 水印功能待开发
|
|
|
|
|
sendtype = SmsTypeEnum.SET_OSD.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString1(s);
|
|
|
|
|
String[] split2 = StringUtils.splitString2(s);
|
|
|
|
|
if (split2 != null && split2.length == 2) {
|
|
|
|
|
// UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
@ -288,20 +287,15 @@ public class SimUtil {
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_OSD.value())) {
|
|
|
|
|
//TODO 水印功能待开发
|
|
|
|
|
sendtype = SmsTypeEnum.GET_OSD.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
// String ip = UpdateSysConfigUtil.getIP(context);
|
|
|
|
|
// sendmessage = SmsTypeEnum.GET_OSD + "=" + ip;
|
|
|
|
|
}else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) {
|
|
|
|
|
//TODO 水印功能待开发
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_OSD.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString1(s);
|
|
|
|
|
if (split2 != null && split2.length == 2) {
|
|
|
|
|
// UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
@ -311,12 +305,143 @@ public class SimUtil {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_OSD.value())) {
|
|
|
|
|
//TODO 水印功能待开发
|
|
|
|
|
sendtype = SmsTypeEnum.GET_OSD.value();
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_RESOLUTION.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString1(s);
|
|
|
|
|
if (split2 != null && split2.length == 5) {
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split2[0]);
|
|
|
|
|
Integer resolutionCX = StringUtils.convert2Int(split2[1]);
|
|
|
|
|
Integer resolutionCY = StringUtils.convert2Int(split2[2]);
|
|
|
|
|
Integer videoCX = StringUtils.convert2Int(split2[3]);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_RESOLUTION.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_RESOLUTION.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
// String ip = UpdateSysConfigUtil.getIP(context);
|
|
|
|
|
// sendmessage = SmsTypeEnum.GET_OSD + "=" + ip;
|
|
|
|
|
String[] split = StringUtils.splitString1(content);
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split[0]);
|
|
|
|
|
HashMap<String, Integer> hashMap = UpdateSysConfigUtil.getChannelResolution(packageName, 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.SET_HEART.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_HEART.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length == 2) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
Integer integer = StringUtils.convert2Int(s);
|
|
|
|
|
UpdateSysConfigUtil.setHB(context, integer);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_HEART.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_HEART.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
int hb = UpdateSysConfigUtil.getHB(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_HEART.value() + "=" + hb;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_TP.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_TP.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length == 2) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
Integer integer = StringUtils.convert2Int(s);
|
|
|
|
|
UpdateSysConfigUtil.setTB(context, integer);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} 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())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_PACKAGE.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length == 2) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
Integer integer = StringUtils.convert2Int(s);
|
|
|
|
|
UpdateSysConfigUtil.setPackage(context, integer);
|
|
|
|
|
}
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_PACKAGE.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
int aPackage = UpdateSysConfigUtil.getPackage(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_PACKAGE.value() + "=" + aPackage;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.CLEAR_PHOTO.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.CLEAR_PHOTO.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryPic(context);
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
} 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;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.CLEAR_ALL.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.CLEAR_ALL.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryPic(context);
|
|
|
|
|
UpdateSysConfigUtil.clearHistoryLogs(context);
|
|
|
|
|
String menssageBack = "";
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
menssageBack = " OK";
|
|
|
|
|
} else {
|
|
|
|
|
menssageBack = " ERROR";
|
|
|
|
|
}
|
|
|
|
|
sendmessage = content + menssageBack;
|
|
|
|
|
}
|
|
|
|
|
sendSms(context, slot, sender, sendmessage, sendtype, ifmessageCorrect);
|
|
|
|
|
}
|
|
|
|
@ -330,7 +455,7 @@ public class SimUtil {
|
|
|
|
|
if (SMS_RECEIVED_ACTION.equals(action) || SMS_DELIVER_ACTION.equals(action)) {
|
|
|
|
|
Bundle bundle = intent.getExtras();
|
|
|
|
|
if (bundle != null) {
|
|
|
|
|
String content = "";
|
|
|
|
|
StringBuilder content = new StringBuilder();
|
|
|
|
|
String sender = "";
|
|
|
|
|
String dateContent = "";
|
|
|
|
|
Object[] pdus = (Object[]) bundle.get("pdus");
|
|
|
|
@ -341,7 +466,7 @@ public class SimUtil {
|
|
|
|
|
messages[i] = SmsMessage.createFromPdu(pdu);
|
|
|
|
|
}
|
|
|
|
|
for (SmsMessage message : messages) {
|
|
|
|
|
content = message.getMessageBody();// 得到短信内容
|
|
|
|
|
content.append(message.getMessageBody());// 得到短信内容
|
|
|
|
|
// 得到发信息的号码
|
|
|
|
|
sender = message.getOriginatingAddress();
|
|
|
|
|
Date date = new Date(message.getTimestampMillis());
|
|
|
|
@ -350,7 +475,7 @@ public class SimUtil {
|
|
|
|
|
dateContent = format.format(date);
|
|
|
|
|
}
|
|
|
|
|
int smsSlot = getSmsSlot(bundle);
|
|
|
|
|
smsMessageModel.setContent(content);
|
|
|
|
|
smsMessageModel.setContent(content.toString());
|
|
|
|
|
smsMessageModel.setSender(sender);
|
|
|
|
|
smsMessageModel.setDateContent(dateContent);
|
|
|
|
|
smsMessageModel.setSlot(smsSlot);
|
|
|
|
@ -387,6 +512,9 @@ public class SimUtil {
|
|
|
|
|
case "slotIdx":
|
|
|
|
|
slot = bundle.getInt("slotIdx", -1);
|
|
|
|
|
break;
|
|
|
|
|
case "android.telephony.extra.SLOT_INDEX":
|
|
|
|
|
slot = bundle.getInt("android.telephony.extra.SLOT_INDEX", -1);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (key.toLowerCase().contains("slot") | key.toLowerCase().contains("sim")) {
|
|
|
|
|
String value = bundle.getString(key, "-1");
|
|
|
|
|