|
|
|
@ -18,10 +18,12 @@ import android.text.TextUtils;
|
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
|
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Base64;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
@ -156,7 +158,7 @@ public class SimUtil {
|
|
|
|
|
if (split1 != null && split1.length > 1) {
|
|
|
|
|
String s = split1[1];
|
|
|
|
|
String[] split2 = StringUtils.splitString2(s);
|
|
|
|
|
if (split2 != null && split2.length == 2) {
|
|
|
|
|
if (split2 != null && split2.length >= 2) {
|
|
|
|
|
String ipAddress = split2[0];
|
|
|
|
|
String port = split2[1];
|
|
|
|
|
boolean b = RegexUtil.checkIpAddress(ipAddress);
|
|
|
|
@ -197,7 +199,8 @@ public class SimUtil {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_CMDID.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String cmdid = UpdateSysConfigUtil.getCmdid(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + cmdid;
|
|
|
|
|
String serialNo = SysApi.getSerialNo(context);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + serialNo + "," + cmdid;
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_IP.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_IP.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
@ -210,16 +213,23 @@ public class SimUtil {
|
|
|
|
|
server = split2[0];
|
|
|
|
|
String port = split2[1];
|
|
|
|
|
integer = StringUtils.convert2Int(port);
|
|
|
|
|
int utcp = -1;
|
|
|
|
|
int encrypto = -1;
|
|
|
|
|
Integer utcp = -1;
|
|
|
|
|
Integer encrypto = -1;
|
|
|
|
|
if (integer != null) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
if (split2.length == 4) {
|
|
|
|
|
String s1 = split2[2];
|
|
|
|
|
utcp = StringUtils.convert2Int(s1);
|
|
|
|
|
utcp = getUtcp(utcp);
|
|
|
|
|
String s2 = split2[3];
|
|
|
|
|
encrypto = StringUtils.convert2Int(s2);
|
|
|
|
|
encrypto = getEncrypto(encrypto);
|
|
|
|
|
if (utcp == -1 || encrypto == -1) {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -244,41 +254,51 @@ public class SimUtil {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
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(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;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
UpdateSysConfigUtil.setChannelOSD(integer, osdmap);
|
|
|
|
|
if (integer == 0) {//所有通道
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context);
|
|
|
|
|
int channelnum = mpAppConfig.channelnum;
|
|
|
|
|
if (channelnum != 0) {
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
for (int i = 1; i <= channelnum; i++) {
|
|
|
|
|
UpdateSysConfigUtil.setChannelOSD(i, osdmap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (ifmessageCorrect) {
|
|
|
|
|
UpdateSysConfigUtil.setChannelOSD(integer, osdmap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -290,10 +310,10 @@ public class SimUtil {
|
|
|
|
|
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");
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
@ -312,14 +332,26 @@ 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) {
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split2[0]);
|
|
|
|
|
if (channel != null) {
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String msg = split2[1];
|
|
|
|
|
UpdateSysConfigUtil.setPhotoSchedules(channel, msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendmessage = getSendString(content, ifmessageCorrect);
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value();
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
|
if (split1 != null && split1.length == 2) {
|
|
|
|
|
Integer channel = StringUtils.convert2Int(split1[1]);
|
|
|
|
|
String photoSchedules = UpdateSysConfigUtil.getPhotoSchedules(channel);
|
|
|
|
|
sendmessage = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value() + "=" + photoSchedules;
|
|
|
|
|
}
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) {
|
|
|
|
|
sendtype = SmsTypeEnum.SET_RESOLUTION.value();
|
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
@ -438,6 +470,33 @@ public class SimUtil {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int getUtcp(Integer utcp) {
|
|
|
|
|
int apputcp = -1;
|
|
|
|
|
//短信文档中 0:udp 1:tcp app应用中 0:tcp 1:udp 所以需要转换一下
|
|
|
|
|
if (utcp != null && (utcp == 0 || utcp == 1)) {
|
|
|
|
|
if (utcp == 0) {
|
|
|
|
|
apputcp = 1;
|
|
|
|
|
} else if (utcp == 1) {
|
|
|
|
|
apputcp = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return apputcp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int getEncrypto(Integer encrypto) {
|
|
|
|
|
int appencrypto = -1;
|
|
|
|
|
//短信文档中 1:密文,2:明文 3:不加密 app应用中 0:不加密 1:明文 2:加密 所以需要转换一下
|
|
|
|
|
if (encrypto != null && (encrypto == 1 || encrypto == 2 || encrypto == 3)) {
|
|
|
|
|
if (encrypto == 1) {
|
|
|
|
|
appencrypto = 2;
|
|
|
|
|
} else if (encrypto == 2) {
|
|
|
|
|
appencrypto = 1;
|
|
|
|
|
} else if (encrypto == 3) {
|
|
|
|
|
appencrypto = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return appencrypto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getSendString(String content, boolean ifmessageCorrect) {
|
|
|
|
|
String sendmessage;
|
|
|
|
@ -531,8 +590,7 @@ 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) {
|
|
|
|
@ -636,8 +694,7 @@ 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);
|
|
|
|
|
}
|
|
|
|
|