短信:短信接收拍照时间表功能修改,短信控制拍照修改

ptz
Hydromel 4 months ago
parent 291d72b135
commit 003193d95a

@ -4,7 +4,7 @@ plugins {
def AppMajorVersion = 1 def AppMajorVersion = 1
def AppMinorVersion = 1 def AppMinorVersion = 1
def AppBuildNumber = 1 def AppBuildNumber = 2
def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber def AppVersionName = AppMajorVersion + "." + AppMinorVersion + "." + AppBuildNumber
def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber def AppVersionCode = AppMajorVersion * 100000 + AppMinorVersion * 1000 + AppBuildNumber

@ -81,7 +81,6 @@ public class SimUtil {
} }
int slot = smsInfo.getSlot();//那张卡收到的短信 int slot = smsInfo.getSlot();//那张卡收到的短信
String sender = smsInfo.getSender();//收到的短信的手机号 String sender = smsInfo.getSender();//收到的短信的手机号
String sendmessage = "ERROR";//要回复的短信
List<Integer> abslist = new ArrayList<>();//收到的短信内容拆分包装成数组 List<Integer> abslist = new ArrayList<>();//收到的短信内容拆分包装成数组
boolean ifmessageCorrect = false;//用来判断收到的短信内容是否正确 boolean ifmessageCorrect = false;//用来判断收到的短信内容是否正确
if (StringUtils.isEmpty(content)) { if (StringUtils.isEmpty(content)) {
@ -122,21 +121,21 @@ public class SimUtil {
String s = split1[1]; String s = split1[1];
String[] split2 = StringUtils.splitString2(s); String[] split2 = StringUtils.splitString2(s);
int spilt2len = split2.length; int spilt2len = split2.length;
if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { if (split2 != null && spilt2len > 0) {
String num = split2[0]; String num = split2[0];
Integer integer = StringUtils.convert2Int(num); Integer integer = StringUtils.convert2Int(num);
if (integer != null) { if (integer != null) {
if (integer == 0) {//删除所有运维 if (integer == 0) {//删除所有运维
ifmessageCorrect = true; ifmessageCorrect = true;
} else { } else {
if (spilt2len == integer * 2 + 1) { int times = 0;
int times = 0; for (int i = 0; i < spilt2len; i++) {
for (int i = 0; i < spilt2len; i++) { if (i == 0) {
if (i == 0) { continue;
continue; }
} String ts = split2[i];
String ts = split2[i]; Integer time = StringUtils.convert2Int(ts);
Integer time = StringUtils.convert2Int(ts); if (time != null) {
if (i % 2 == 1) { if (i % 2 == 1) {
if (time > 23) { if (time > 23) {
ifmessageCorrect = false; ifmessageCorrect = false;
@ -181,11 +180,14 @@ public class SimUtil {
String[] split1 = StringUtils.splitString1(content); String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) { if (split1 != null && split1.length > 1) {
String s = split1[1]; String s = split1[1];
Integer integer = StringUtils.convert2Int(s); String[] strings = StringUtils.splitString2(s);
if (integer != null) { if (strings != null && strings.length >= 1) {
if (integer == 0 || integer == 1) { Integer integer = StringUtils.convert2Int(strings[0]);
ifmessageCorrect = true; if (integer != null) {
UpdateSysConfigUtil.setMntnMode(context, integer); if (integer == 0 || integer == 1) {
ifmessageCorrect = true;
UpdateSysConfigUtil.setMntnMode(context, integer);
}
} }
} }
} }
@ -230,8 +232,14 @@ public class SimUtil {
String[] split1 = StringUtils.splitString1(content); String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) { if (split1 != null && split1.length > 1) {
ifmessageCorrect = true; ifmessageCorrect = true;
String cmdid = split1[1]; String s = split1[1];
UpdateSysConfigUtil.setCmdid(context, cmdid); String[] strings = StringUtils.splitString2(s);
if (strings != null && strings.length >= 1) {
String cmdid = strings[0];
if (cmdid != null) {
UpdateSysConfigUtil.setCmdid(context, cmdid);
}
}
} }
sendmessage = getSendString(content, ifmessageCorrect); sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_CMDID.value())) { } else if (content.contains(SmsTypeEnum.GET_CMDID.value())) {
@ -242,32 +250,32 @@ public class SimUtil {
restartType = 1; restartType = 1;
String[] split1 = StringUtils.splitString1(content); String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) { if (split1 != null && split1.length > 1) {
String server = null;
Integer port = null;
Integer utcp = null;
Integer encrypto = null;
String s = split1[1]; String s = split1[1];
String[] split2 = StringUtils.splitString2(s); String[] split2 = StringUtils.splitString2(s);
if (split2 != null && (split2.length == 2 || split2.length == 4)) { if (split2 != null && split2.length > 1) {
String server; ifmessageCorrect = true;
Integer integer; if (split2.length > 0) {
server = split2[0]; server = split2[0];
String port = split2[1]; }
integer = StringUtils.convert2Int(port); if (split2.length > 1) {
Integer utcp = -1; String s1 = split2[1];
Integer encrypto = -1; port = StringUtils.convert2Int(s1);
if (integer != null) { }
ifmessageCorrect = true; if (split2.length > 2) {
if (split2.length == 4) { String s2 = split2[2];
String s1 = split2[2]; utcp = StringUtils.convert2Int(s2);
utcp = StringUtils.convert2Int(s1); utcp = getUtcp(utcp);
utcp = getUtcp(utcp); }
String s2 = split2[3]; if (split2.length > 3) {
encrypto = StringUtils.convert2Int(s2); String s3 = split2[3];
encrypto = getEncrypto(encrypto); encrypto = StringUtils.convert2Int(s3);
if (utcp == -1 || encrypto == -1) {
ifmessageCorrect = false;
}
}
} }
if (ifmessageCorrect) { if (ifmessageCorrect) {
UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto); UpdateSysConfigUtil.setIP(context, server, port, utcp, encrypto);
} }
} }
} }
@ -279,13 +287,13 @@ public class SimUtil {
restartType = 1; restartType = 1;
String[] split1 = StringUtils.splitString1(content); String[] split1 = StringUtils.splitString1(content);
sendmessage = getSendString(content, ifmessageCorrect); sendmessage = getSendString(content, ifmessageCorrect);
if (split1 != null && split1.length == 2) { if (split1 != null && split1.length >= 2) {
ifmessageCorrect = true; ifmessageCorrect = true;
JSONObject osdmap = new JSONObject(); JSONObject osdmap = new JSONObject();
String s = split1[1]; String s = split1[1];
String[] split2 = StringUtils.splitString2(s); String[] split2 = StringUtils.splitString2(s);
int spilt2len = split2.length; int spilt2len = split2.length;
if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) { if (split2 != null && spilt2len > 1) {
String num = split2[0]; String num = split2[0];
Integer integer = StringUtils.convert2Int(num); Integer integer = StringUtils.convert2Int(num);
if (integer != null) { if (integer != null) {
@ -417,7 +425,7 @@ public class SimUtil {
if (split1 != null && split1.length > 1) { if (split1 != null && split1.length > 1) {
String s = split1[1]; String s = split1[1];
String[] split2 = StringUtils.splitString2(s); String[] split2 = StringUtils.splitString2(s);
if (split2 != null && split2.length == 2) { if (split2 != null && split2.length > 1) {
Integer channel = StringUtils.convert2Int(split2[0]); Integer channel = StringUtils.convert2Int(split2[0]);
if (channel != null) { if (channel != null) {
ifmessageCorrect = true; ifmessageCorrect = true;
@ -430,17 +438,21 @@ public class SimUtil {
} else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) { } else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) {
String[] split1 = StringUtils.splitString1(content); String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length == 2) { if (split1 != null && split1.length == 2) {
Integer channel = StringUtils.convert2Int(split1[1]); String s = split1[1];
String photoSchedules = UpdateSysConfigUtil.getPhotoSchedules(channel); String[] strings = StringUtils.splitString2(s);
sendmessage = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value() + "=" + photoSchedules; if (strings != null && strings.length >= 1) {
Integer integer = StringUtils.convert2Int(strings[0]);
String photoSchedules = UpdateSysConfigUtil.getPhotoSchedules(integer);
sendmessage = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value() + "=" + photoSchedules;
}
} }
} else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) { } else if (content.contains(SmsTypeEnum.SET_RESOLUTION.value())) {
restartType = 1; restartType = 1;
String[] split1 = StringUtils.splitString1(content); String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) { if (split1 != null && split1.length > 1) {
String s = split1[1]; String s = split1[1];
String[] split2 = StringUtils.splitString1(s); String[] split2 = StringUtils.splitString2(s);
if (split2 != null && split2.length == 5) { if (split2 != null && split2.length >= 5) {
Integer channel = StringUtils.convert2Int(split2[0]); Integer channel = StringUtils.convert2Int(split2[0]);
Integer resolutionCX = StringUtils.convert2Int(split2[1]); Integer resolutionCX = StringUtils.convert2Int(split2[1]);
Integer resolutionCY = StringUtils.convert2Int(split2[2]); Integer resolutionCY = StringUtils.convert2Int(split2[2]);
@ -465,19 +477,23 @@ public class SimUtil {
sendmessage = SmsTypeEnum.GET_RESOLUTION.value() + "=" + resolutionCX + "," + resolutionCY + "," + videoCX + "," + videoCY; sendmessage = SmsTypeEnum.GET_RESOLUTION.value() + "=" + resolutionCX + "," + resolutionCY + "," + videoCX + "," + videoCY;
} else if (content.contains(SmsTypeEnum.TAKE_PHOTO.value())) { } else if (content.contains(SmsTypeEnum.TAKE_PHOTO.value())) {
String[] split = StringUtils.splitString1(content); String[] split = StringUtils.splitString1(content);
if (split != null && split.length == 3) { if (split != null && split.length > 1) {
ifmessageCorrect = true; String s = split[1];
Integer channel = StringUtils.convert2Int(split[0]); String[] strings = StringUtils.splitString2(s);
Integer preset = StringUtils.convert2Int(split[1]); if (strings != null && strings.length >= 3) {
Integer type = StringUtils.convert2Int(split[2]); ifmessageCorrect = true;
if (channel != null) { Integer channel = StringUtils.convert2Int(strings[0]);
boolean photoOrVideo; Integer preset = StringUtils.convert2Int(strings[1]);
if (type == 0) { Integer type = StringUtils.convert2Int(strings[2]);
photoOrVideo = true; if (channel != null && preset != null && type != null) {
} else { boolean photoOrVideo;
photoOrVideo = false; if (type == 0) {
photoOrVideo = true;
} else {
photoOrVideo = false;
}
UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo);
} }
UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo);
} }
sendmessage = getSendString(content, ifmessageCorrect); sendmessage = getSendString(content, ifmessageCorrect);
} }
@ -487,8 +503,11 @@ public class SimUtil {
if (split1 != null && split1.length == 2) { if (split1 != null && split1.length == 2) {
ifmessageCorrect = true; ifmessageCorrect = true;
String s = split1[1]; String s = split1[1];
Integer integer = StringUtils.convert2Int(s); String[] strings = StringUtils.splitString2(s);
UpdateSysConfigUtil.setHB(context, integer); if (strings != null && strings.length >= 1) {
Integer integer = StringUtils.convert2Int(strings[0]);
UpdateSysConfigUtil.setHB(context, integer);
}
} }
sendmessage = getSendString(content, ifmessageCorrect); sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_HEART.value())) { } else if (content.contains(SmsTypeEnum.GET_HEART.value())) {
@ -505,8 +524,11 @@ public class SimUtil {
if (split1 != null && split1.length == 2) { if (split1 != null && split1.length == 2) {
ifmessageCorrect = true; ifmessageCorrect = true;
String s = split1[1]; String s = split1[1];
Integer integer = StringUtils.convert2Int(s); String[] strings = StringUtils.splitString2(s);
UpdateSysConfigUtil.setTB(context, integer); if (strings != null && strings.length >= 1) {
Integer integer = StringUtils.convert2Int(strings[0]);
UpdateSysConfigUtil.setTB(context, integer);
}
} }
sendmessage = getSendString(content, ifmessageCorrect); sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_TP.value())) { } else if (content.contains(SmsTypeEnum.GET_TP.value())) {
@ -518,8 +540,11 @@ public class SimUtil {
if (split1 != null && split1.length == 2) { if (split1 != null && split1.length == 2) {
ifmessageCorrect = true; ifmessageCorrect = true;
String s = split1[1]; String s = split1[1];
Integer integer = StringUtils.convert2Int(s); String[] strings = StringUtils.splitString2(s);
UpdateSysConfigUtil.setPackage(context, integer); if (strings != null && strings.length > 0) {
Integer integer = StringUtils.convert2Int(strings[0]);
UpdateSysConfigUtil.setPackage(context, integer);
}
} }
sendmessage = getSendString(content, ifmessageCorrect); sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) { } else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) {
@ -557,21 +582,35 @@ public class SimUtil {
return apputcp; return apputcp;
} }
private static int getEncrypto(Integer encrypto) { public static int getSmsUtcp(Integer apputcp) {
int appencrypto = -1; int smsutcp = -1;
//短信文档中 1密文,2明文 3不加密 app应用中 0不加密 1明文 2加密 所以需要转换一下 //短信文档中 0udp 1:tcp app应用中 0tcp 1:udp 所以需要转换一下
if (encrypto != null && (encrypto == 1 || encrypto == 2 || encrypto == 3)) { if (apputcp != null && (apputcp == 0 || apputcp == 1)) {
if (encrypto == 1) { if (apputcp == 0) {
appencrypto = 2; smsutcp = 1;
} else if (encrypto == 2) { } else if (apputcp == 1) {
appencrypto = 1; smsutcp = 0;
} else if (encrypto == 3) {
appencrypto = 0;
} }
} }
return appencrypto; return smsutcp;
} }
// 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) { private static String getSendString(String content, boolean ifmessageCorrect) {
String sendmessage; String sendmessage;
String menssageBack = ""; String menssageBack = "";
@ -774,19 +813,14 @@ public class SimUtil {
} else if (configType == 3) { //数组 } else if (configType == 3) { //数组
JSONArray objects = new JSONArray(configValue); JSONArray objects = new JSONArray(configValue);
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, objects); JSONUtils.updateConfigFile(filePath, fileName, configName, configType, objects);
} else if (configType == 4) { //对象
JSONObject objects = new JSONObject(configValue);
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, objects);
} }
} else { } else {
ifmessageCorrect = false; ifmessageCorrect = false;
} }
} }
// if (rebootMpApp != 0) {
// MicroPhotoContext.restartMpApp(context, "Config Updated From SMS");
// } else {
// Intent intent = new Intent();
// intent.setAction(MicroPhotoContext.ACTION_UPDATE_CONFIGS_MP);
// intent.setPackage(MicroPhotoContext.PACKAGE_NAME_MPAPP);
// context.sendBroadcast(intent);
// }
} else { } else {
ifmessageCorrect = false; ifmessageCorrect = false;
} }
@ -901,6 +935,8 @@ public class SimUtil {
HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(fileType); HashMap<String, String> hashMap = ValueTypeUtil.checkFilePathAndName(fileType);
filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH); filePath = hashMap.get(UpdateSysConfigUtil.FILEPATH);
fileName = hashMap.get(UpdateSysConfigUtil.FILENAME); fileName = hashMap.get(UpdateSysConfigUtil.FILENAME);
if (!TextUtils.isEmpty(filePath + fileName)) { if (!TextUtils.isEmpty(filePath + fileName)) {
File file = new File(filePath + fileName); File file = new File(filePath + fileName);
if (file.exists()) { if (file.exists()) {

@ -166,14 +166,18 @@ public class UpdateSysConfigUtil {
} }
//修改app的ip //修改app的ip
public static void setIP(Context context, String server, int port, int utcp, int encrypto) { public static void setIP(Context context, String server, Integer port, Integer utcp, Integer encrypto) {
MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context); MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context);
if (server!=null) {
mpAppConfig.server = server; mpAppConfig.server = server;
}
if (port!=null && port!=-1) {
mpAppConfig.port = port; mpAppConfig.port = port;
if (utcp != -1) { }
if (utcp != null&& utcp!=-1 ) {
mpAppConfig.networkProtocol = utcp; mpAppConfig.networkProtocol = utcp;
} }
if (encrypto != -1) { if (encrypto != null&& encrypto!=-1) {
mpAppConfig.encryption = encrypto; mpAppConfig.encryption = encrypto;
} }
MicroPhotoContext.saveMpAppConfig(context, mpAppConfig); MicroPhotoContext.saveMpAppConfig(context, mpAppConfig);
@ -186,8 +190,9 @@ public class UpdateSysConfigUtil {
String server = mpAppConfig.server; String server = mpAppConfig.server;
int port = mpAppConfig.port; int port = mpAppConfig.port;
int networkProtocol = mpAppConfig.networkProtocol; int networkProtocol = mpAppConfig.networkProtocol;
int smsUtcp = SimUtil.getSmsUtcp(networkProtocol);
int encryption = mpAppConfig.encryption; int encryption = mpAppConfig.encryption;
return server + "," + port + "," + networkProtocol + "," + encryption; return server + "," + port + "," + smsUtcp + "," + encryption;
} }
//修改app的心跳 //修改app的心跳
@ -372,8 +377,8 @@ public class UpdateSysConfigUtil {
List<Long> schedules = new ArrayList<>(); List<Long> schedules = new ArrayList<>();
long ts = System.currentTimeMillis() / 1000; long ts = System.currentTimeMillis() / 1000;
long val = 0; long val = 0;
val |= (channel << 16); val |= (channel << 12);
val |= (preset << 8); val |= (preset << 4);
val |= photoOrVideo ? 0L : 1L; val |= photoOrVideo ? 0L : 1L;
schedules.add(Long.valueOf(val)); schedules.add(Long.valueOf(val));

@ -1,10 +1,13 @@
package com.xypower.mpmaster.sms; package com.xypower.mpmaster.sms;
import android.os.Environment;
import com.xypower.common.MicroPhotoContext; import com.xypower.common.MicroPhotoContext;
import org.json.JSONArray; import org.json.JSONArray;
import java.io.File;
import java.util.HashMap; import java.util.HashMap;
public class ValueTypeUtil { public class ValueTypeUtil {
@ -37,18 +40,34 @@ public class ValueTypeUtil {
* *
* */ * */
public static HashMap checkFilePathAndName( int fileType) { public static HashMap checkFilePathAndName( int fileType) {
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
if (!path.endsWith(File.separator)) {
path += File.separator;
}
HashMap<String, String> hashMap = new HashMap<>(); HashMap<String, String> hashMap = new HashMap<>();
String filePath = null; String filePath = null;
String fileName = null; String fileName = null;
switch (fileType) { switch (fileType) {
case 1: case 1:
filePath =MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/"; filePath =path+MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/";
fileName = "App.json"; fileName = "App.json";
break; break;
case 2: case 2:
filePath =MicroPhotoContext.PACKAGE_NAME_MPMASTER + "/data/"; filePath =MicroPhotoContext.PACKAGE_NAME_MPMASTER + "/data/";
fileName = "Master.json"; fileName = "Master.json";
break; break;
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
filePath =path+MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/schedules/";
fileName = Integer.toString(fileType - 80);
break;
case 91: case 91:
case 92: case 92:
case 93: case 93:
@ -58,7 +77,7 @@ public class ValueTypeUtil {
case 97: case 97:
case 98: case 98:
case 99: case 99:
filePath =MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/channels/"; filePath =path+MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/channels/";
fileName = Integer.toString(fileType - 90) + ".json"; fileName = Integer.toString(fileType - 90) + ".json";
break; break;
default: default:

Loading…
Cancel
Save