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

ptz
Hydromel 4 months ago
parent 291d72b135
commit 003193d95a

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

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

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

@ -1,10 +1,13 @@
package com.xypower.mpmaster.sms;
import android.os.Environment;
import com.xypower.common.MicroPhotoContext;
import org.json.JSONArray;
import java.io.File;
import java.util.HashMap;
public class ValueTypeUtil {
@ -37,18 +40,34 @@ public class ValueTypeUtil {
*
* */
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<>();
String filePath = null;
String fileName = null;
switch (fileType) {
case 1:
filePath =MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/";
filePath =path+MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/";
fileName = "App.json";
break;
case 2:
filePath =MicroPhotoContext.PACKAGE_NAME_MPMASTER + "/data/";
fileName = "Master.json";
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 92:
case 93:
@ -58,7 +77,7 @@ public class ValueTypeUtil {
case 97:
case 98:
case 99:
filePath =MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/channels/";
filePath =path+MicroPhotoContext.PACKAGE_NAME_MPAPP + "/data/channels/";
fileName = Integer.toString(fileType - 90) + ".json";
break;
default:

Loading…
Cancel
Save