|
|
@ -28,14 +28,18 @@ import androidx.core.app.ActivityCompat;
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
import com.dev.devapi.api.SysApi;
|
|
|
|
import com.xypower.common.FilesUtils;
|
|
|
|
import com.xypower.common.FilesUtils;
|
|
|
|
import com.xypower.common.JSONUtils;
|
|
|
|
import com.xypower.common.JSONUtils;
|
|
|
|
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
import com.xypower.common.NetworkUtils;
|
|
|
|
import com.xypower.common.NetworkUtils;
|
|
|
|
import com.xypower.mpmaster.MpMasterService;
|
|
|
|
import com.xypower.mpmaster.MpMasterService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -55,9 +59,12 @@ public class SimUtil {
|
|
|
|
// 自定义ACTION常数 作为广播的IntentFilter识别常数
|
|
|
|
// 自定义ACTION常数 作为广播的IntentFilter识别常数
|
|
|
|
public static String SMS_SEND_ACTION = "com.xypower.mpmaster.SMS_SEND_ACTION";
|
|
|
|
public static String SMS_SEND_ACTION = "com.xypower.mpmaster.SMS_SEND_ACTION";
|
|
|
|
|
|
|
|
|
|
|
|
public static String RESTARTTYPE = "restartType";
|
|
|
|
public static String SMSRESTARTTYPE = "restartType";
|
|
|
|
|
|
|
|
|
|
|
|
private static int mRequestCode = 1;
|
|
|
|
private static int mRequestCode = 1;
|
|
|
|
|
|
|
|
private static String sendmessage = null;//要回复的短信
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int restartType = -1;//重启类型
|
|
|
|
|
|
|
|
|
|
|
|
//短信解析
|
|
|
|
//短信解析
|
|
|
|
public static void analysisSMSInfo(final Context context, final Intent intent, final SmsMessage smsMessage) {
|
|
|
|
public static void analysisSMSInfo(final Context context, final Intent intent, final SmsMessage smsMessage) {
|
|
|
@ -70,19 +77,18 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int slot = smsInfo.getSlot();//那张卡收到的短信
|
|
|
|
int slot = smsInfo.getSlot();//那张卡收到的短信
|
|
|
|
String sender = smsInfo.getSender();//收到的短信的手机号
|
|
|
|
String sender = smsInfo.getSender();//收到的短信的手机号
|
|
|
|
String sendmessage = null;//要回复的短信
|
|
|
|
|
|
|
|
int restartType = 0;//重启类型
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
|
if (StringUtils.isEmpty(content)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (content.toLowerCase().contains(SmsTypeEnum.UPD_CFG_FILE.value().toLowerCase())) { //修改配置文件中参数
|
|
|
|
if (content.toLowerCase().contains(SmsTypeEnum.UPD_CFG_FILE.value().toLowerCase())) { //修改配置文件中参数
|
|
|
|
updateConfig(sendmessage, restartType, context, content);
|
|
|
|
updateConfig(context, content);
|
|
|
|
} else if (content.toLowerCase().contains(SmsTypeEnum.GET_CFG_FILE.value().toLowerCase())) {//获取配置文件中参数
|
|
|
|
} else if (content.toLowerCase().contains(SmsTypeEnum.GET_CFG_FILE.value().toLowerCase())) {//获取配置文件中参数
|
|
|
|
queryConfig(sendmessage, restartType, context, content);
|
|
|
|
queryConfig(context, content);
|
|
|
|
} else if (content.toLowerCase().contains(SmsTypeEnum.UPD_FILE.value().toLowerCase())) {//替换配置文件
|
|
|
|
} else if (content.toLowerCase().contains(SmsTypeEnum.UPD_FILE.value().toLowerCase())) {//替换配置文件
|
|
|
|
updateFile(sendmessage, restartType, context, content);
|
|
|
|
updateFile(context, content);
|
|
|
|
} else if (content.toLowerCase().contains(SmsTypeEnum.GET_FILE.value().toLowerCase())) {//获取整个配置文件
|
|
|
|
} else if (content.toLowerCase().contains(SmsTypeEnum.GET_FILE.value().toLowerCase())) {//获取整个配置文件
|
|
|
|
queryFile(sendmessage, restartType, context, content);
|
|
|
|
queryFile(context, content);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sendSms(context, slot, sender, sendmessage, restartType);
|
|
|
|
sendSms(context, slot, sender, sendmessage, restartType);
|
|
|
|
|
|
|
|
|
|
|
@ -801,11 +807,11 @@ public class SimUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改配置文件中参数
|
|
|
|
//修改配置文件中参数
|
|
|
|
private static void updateConfig(String sendmessage, int restartType, Context context, String content) {
|
|
|
|
private static void updateConfig(Context context, String content) {
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
Map<String, String> fields = new HashMap<>();
|
|
|
|
Map<String, String> fields = new HashMap<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String[] parts = StringUtils.splitStringByDh(SmsTypeEnum.UPD_CFG_FILE.value(), content);
|
|
|
|
String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.UPD_CFG_FILE.value().length()));
|
|
|
|
int fileType = 0;
|
|
|
|
int fileType = 0;
|
|
|
|
int numberOfFields = 0;
|
|
|
|
int numberOfFields = 0;
|
|
|
|
String filePath = null;
|
|
|
|
String filePath = null;
|
|
|
@ -847,11 +853,14 @@ public class SimUtil {
|
|
|
|
if (configType == 0) { // Number
|
|
|
|
if (configType == 0) { // Number
|
|
|
|
Long val = Long.parseLong(configValue);
|
|
|
|
Long val = Long.parseLong(configValue);
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, val);
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, val);
|
|
|
|
|
|
|
|
} else if (configType == 1) {
|
|
|
|
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, configValue);
|
|
|
|
} else if (configType == 2) { // Float
|
|
|
|
} else if (configType == 2) { // Float
|
|
|
|
Float val = Float.parseFloat(configValue);
|
|
|
|
Float val = Float.parseFloat(configValue);
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, val);
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, val);
|
|
|
|
} else {
|
|
|
|
} else if (configType == 3) { //数组
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, configValue);
|
|
|
|
JSONArray objects = new JSONArray(configValue);
|
|
|
|
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, objects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ifmessageCorrect = false;
|
|
|
|
ifmessageCorrect = false;
|
|
|
@ -883,11 +892,11 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//替换配置文件
|
|
|
|
//替换配置文件
|
|
|
|
private static void updateFile(String sendmessage, int restartType, Context context, String content) {
|
|
|
|
private static void updateFile(Context context, String content) {
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
Map<String, String> fields = new HashMap<>();
|
|
|
|
Map<String, String> fields = new HashMap<>();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String[] parts = StringUtils.splitStringByDh(SmsTypeEnum.UPD_FILE.value(), content);
|
|
|
|
String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.UPD_FILE.value().length()));
|
|
|
|
int fileType = 0;
|
|
|
|
int fileType = 0;
|
|
|
|
int numberOfFields = 0;
|
|
|
|
int numberOfFields = 0;
|
|
|
|
String filePath = null;
|
|
|
|
String filePath = null;
|
|
|
@ -948,11 +957,11 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取配置文件
|
|
|
|
//获取配置文件
|
|
|
|
private static void queryFile(String sendmessage, int restartType, Context context, String content) {
|
|
|
|
private static void queryFile(Context context, String content) {
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
String result = null;
|
|
|
|
String result = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String[] parts = StringUtils.splitStringByDh(SmsTypeEnum.GET_FILE.value(), content);
|
|
|
|
String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.GET_FILE.value().length()));
|
|
|
|
int fileType = 0;
|
|
|
|
int fileType = 0;
|
|
|
|
String filePath = null;
|
|
|
|
String filePath = null;
|
|
|
|
String fileName = null;
|
|
|
|
String fileName = null;
|
|
|
@ -1008,10 +1017,10 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//获取配置文件参数
|
|
|
|
//获取配置文件参数
|
|
|
|
private static void queryConfig(String sendmessage, int restartType, Context context, String content) {
|
|
|
|
private static void queryConfig(Context context, String content) {
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
boolean ifmessageCorrect = true;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String[] parts = StringUtils.splitStringByDh(SmsTypeEnum.GET_CFG_FILE.value(), content);
|
|
|
|
String[] parts = StringUtils.splitStringByDh(content.substring(SmsTypeEnum.GET_CFG_FILE.value().length()));
|
|
|
|
int fileType = 0;
|
|
|
|
int fileType = 0;
|
|
|
|
String filePath = null;
|
|
|
|
String filePath = null;
|
|
|
|
String fileName = null;
|
|
|
|
String fileName = null;
|
|
|
@ -1253,7 +1262,8 @@ public class SimUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Intent itSend = new Intent(SMS_SEND_ACTION);
|
|
|
|
Intent itSend = new Intent(SMS_SEND_ACTION);
|
|
|
|
itSend.putExtra(RESTARTTYPE, restartType);
|
|
|
|
itSend.putExtra(SMSRESTARTTYPE, restartType);
|
|
|
|
|
|
|
|
// itSend.putExtra(SMSIFCORRECT, true);
|
|
|
|
// itSend.putExtra(SMSDATA, (Serializable) jsonArray);
|
|
|
|
// itSend.putExtra(SMSDATA, (Serializable) jsonArray);
|
|
|
|
//sendIntent参数为传送后接受的广播信息PendingIntent
|
|
|
|
//sendIntent参数为传送后接受的广播信息PendingIntent
|
|
|
|
PendingIntent sendPI = PendingIntent.getBroadcast(mContext, mRequestCode++, itSend, 0);
|
|
|
|
PendingIntent sendPI = PendingIntent.getBroadcast(mContext, mRequestCode++, itSend, 0);
|
|
|
@ -1263,7 +1273,7 @@ public class SimUtil {
|
|
|
|
// PendingIntent deliverPI = PendingIntent.getBroadcast(mContext,0,itDeliver,0);
|
|
|
|
// PendingIntent deliverPI = PendingIntent.getBroadcast(mContext,0,itDeliver,0);
|
|
|
|
if (simInfoAnother != null) {
|
|
|
|
if (simInfoAnother != null) {
|
|
|
|
SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId());
|
|
|
|
SmsManager smsManager = SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId());
|
|
|
|
if (message.length() > 70) {
|
|
|
|
if (message != null && message.length() > 70) {
|
|
|
|
ArrayList<String> msgs = smsManager.divideMessage(message);
|
|
|
|
ArrayList<String> msgs = smsManager.divideMessage(message);
|
|
|
|
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
|
|
|
|
ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
|
|
|
|
|
|
|
|
|
|
|
@ -1384,6 +1394,29 @@ public class SimUtil {
|
|
|
|
return getIcc(subID, getModelSlot(mContext));
|
|
|
|
return getIcc(subID, getModelSlot(mContext));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public static int saveConfig(Context mContext) {
|
|
|
|
|
|
|
|
// JSONObject jsonObject = MicroPhotoContext.getJsonObject(mContext);
|
|
|
|
|
|
|
|
// Field[] fields = masterConfig.getClass().getDeclaredFields();
|
|
|
|
|
|
|
|
// for (Field field : fields) {
|
|
|
|
|
|
|
|
// if (key.equalsIgnoreCase(field.getName()) && !key.equalsIgnoreCase(SmsTypeEnum.CFGFILE.value())) {
|
|
|
|
|
|
|
|
// if (value != null) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// if (field.getType() == String.class) {
|
|
|
|
|
|
|
|
// field.set(masterConfig, value);
|
|
|
|
|
|
|
|
// } else if (field.getType() == int.class) {
|
|
|
|
|
|
|
|
// Integer num = StringUtils.convert2Int(value);
|
|
|
|
|
|
|
|
// if (num != null) {
|
|
|
|
|
|
|
|
// field.set(masterConfig, num.intValue());
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// MicroPhotoContext.saveMasterConfig(mContext, masterConfig);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
//获取对应的卡槽ID和iccID 关联
|
|
|
|
//获取对应的卡槽ID和iccID 关联
|
|
|
|
private static List<ModelSlotAndSub> getModelSlot(Context mContext) {
|
|
|
|
private static List<ModelSlotAndSub> getModelSlot(Context mContext) {
|
|
|
|
List<ModelSlotAndSub> data = new ArrayList<>();
|
|
|
|
List<ModelSlotAndSub> data = new ArrayList<>();
|
|
|
|