|
|
@ -28,11 +28,14 @@ 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.MicroPhotoContext;
|
|
|
|
import com.xypower.common.MicroPhotoContext;
|
|
|
|
import com.xypower.common.NetworkUtils;
|
|
|
|
import com.xypower.common.NetworkUtils;
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
import com.xypower.common.RegexUtil;
|
|
|
|
import com.xypower.mpmaster.MpMasterService;
|
|
|
|
import com.xypower.mpmaster.MpMasterService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
@ -40,6 +43,7 @@ import java.util.Base64;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
import java.util.TimeZone;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
@ -454,9 +458,14 @@ public class SimUtil {
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
sendmessage = getSimcardInfo(context);
|
|
|
|
sendmessage = getSimcardInfo(context);
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_AUTO_TIME.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_AUTO_TIME.value())) {
|
|
|
|
sendtype = SmsTypeEnum.SIMCARD.value();
|
|
|
|
sendtype = SmsTypeEnum.SET_AUTO_TIME.value();
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
sendmessage = setAutoTime(context, content);
|
|
|
|
sendmessage = setAutoTime(context, content);
|
|
|
|
|
|
|
|
} else if (content.contains(SmsTypeEnum.UPD_CFG_FILE.value())) {
|
|
|
|
|
|
|
|
sendtype = SmsTypeEnum.UPD_CFG_FILE.value();
|
|
|
|
|
|
|
|
ifmessageCorrect = true;
|
|
|
|
|
|
|
|
sendmessage = " OK";
|
|
|
|
|
|
|
|
updateConfigFile(context, content);
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_TP.value())) {
|
|
|
|
} else if (content.contains(SmsTypeEnum.SET_TP.value())) {
|
|
|
|
sendtype = SmsTypeEnum.SET_TP.value();
|
|
|
|
sendtype = SmsTypeEnum.SET_TP.value();
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
|
String[] split1 = StringUtils.splitString1(content);
|
|
|
@ -686,6 +695,101 @@ public class SimUtil {
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void updateConfigFile(Context context, String content) {
|
|
|
|
|
|
|
|
String result = "";
|
|
|
|
|
|
|
|
Map<String, String> fields = new HashMap<>();
|
|
|
|
|
|
|
|
int rebootMpApp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String[] parts = TextUtils.split(content.substring(SmsTypeEnum.UPD_CFG_FILE.value().length()), "(\\s|,|,)");
|
|
|
|
|
|
|
|
int fileType = 0;
|
|
|
|
|
|
|
|
int numberOfFields = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parts != null) {
|
|
|
|
|
|
|
|
for (String part : parts) {
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(part)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int pos = part.indexOf("=");
|
|
|
|
|
|
|
|
if (pos == -1) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String key = part.substring(0, pos);
|
|
|
|
|
|
|
|
String value = part.substring(pos + 1);
|
|
|
|
|
|
|
|
if (TextUtils.equals(key, "f")) {
|
|
|
|
|
|
|
|
fileType = Integer.parseInt(value);
|
|
|
|
|
|
|
|
} else if (TextUtils.equals(key, "c")) {
|
|
|
|
|
|
|
|
numberOfFields = Integer.parseInt(value);
|
|
|
|
|
|
|
|
} else if (TextUtils.equals(key, "r")) {
|
|
|
|
|
|
|
|
rebootMpApp = Integer.parseInt(value);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fields.put(key, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String filePath = null;
|
|
|
|
|
|
|
|
String fileName = null;
|
|
|
|
|
|
|
|
switch (fileType) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
filePath = MicroPhotoContext.buildMpAppDir(context) + "/data/";
|
|
|
|
|
|
|
|
fileName = "App.json";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
|
|
filePath = MicroPhotoContext.buildMasterAppDir(context) + "/data/";
|
|
|
|
|
|
|
|
fileName = "Master.json";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 91:
|
|
|
|
|
|
|
|
case 92:
|
|
|
|
|
|
|
|
case 93:
|
|
|
|
|
|
|
|
case 94:
|
|
|
|
|
|
|
|
case 95:
|
|
|
|
|
|
|
|
case 96:
|
|
|
|
|
|
|
|
case 97:
|
|
|
|
|
|
|
|
case 98:
|
|
|
|
|
|
|
|
case 99:
|
|
|
|
|
|
|
|
filePath = MicroPhotoContext.buildMpAppDir(context) + "/data/channels/";
|
|
|
|
|
|
|
|
fileName = Integer.toString(fileType - 90) + ".json";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(filePath) && !TextUtils.isEmpty(fileName) && numberOfFields > 0) {
|
|
|
|
|
|
|
|
for (int idx = 0; idx <= numberOfFields; idx++) {
|
|
|
|
|
|
|
|
String idxStr = Integer.toString(idx);
|
|
|
|
|
|
|
|
// JSONObject jsonConfig = jsonConfigs.getJSONObject(idx);
|
|
|
|
|
|
|
|
String configName = fields.containsKey("n" + idxStr) ? fields.get("n" + idxStr) : null;
|
|
|
|
|
|
|
|
int configType = fields.containsKey("t" + idxStr) ? Integer.parseInt(fields.get("t" + idxStr)) : 0;
|
|
|
|
|
|
|
|
String configValue = fields.containsKey("v" + idxStr) ? fields.get("v" + idxStr) : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (configType == 0) { // Number
|
|
|
|
|
|
|
|
Long val = Long.parseLong(configValue);
|
|
|
|
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, val);
|
|
|
|
|
|
|
|
} else if (configType == 2) { // Float
|
|
|
|
|
|
|
|
Float val = Float.parseFloat(configValue);
|
|
|
|
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, val);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
JSONUtils.updateConfigFile(filePath, fileName, configName, configType, configValue);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rebootMpApp != 0) {
|
|
|
|
|
|
|
|
MicroPhotoContext.restartMpApp(context);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
|
|
|
intent.setAction(MicroPhotoContext.ACTION_UPDATE_CONFIGS_MP);
|
|
|
|
|
|
|
|
intent.setPackage(MicroPhotoContext.PACKAGE_NAME_MPAPP);
|
|
|
|
|
|
|
|
context.sendBroadcast(intent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String getSimStateName(int simState) {
|
|
|
|
public static String getSimStateName(int simState) {
|
|
|
|
switch (simState) {
|
|
|
|
switch (simState) {
|
|
|
|
case TelephonyManager.SIM_STATE_UNKNOWN:
|
|
|
|
case TelephonyManager.SIM_STATE_UNKNOWN:
|
|
|
|