|
|
@ -16,9 +16,11 @@ import com.xypower.common.MicroPhotoContext;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
public class UpdateSysConfigUtil {
|
|
|
|
public class UpdateSysConfigUtil {
|
|
|
|
public static final String PACKAGE_NAME_MPAPP = "com.xypower.mpapp";
|
|
|
|
public static final String PACKAGE_NAME_MPAPP = "com.xypower.mpapp";
|
|
|
@ -399,4 +401,76 @@ public class UpdateSysConfigUtil {
|
|
|
|
msg = Base64.encodeToString(bytes, Base64.DEFAULT);
|
|
|
|
msg = Base64.encodeToString(bytes, Base64.DEFAULT);
|
|
|
|
return msg;
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void setCommon(Context context, String actType, ArrayList<HashMap> list, String restartType) {
|
|
|
|
|
|
|
|
if (actType.toLowerCase().equalsIgnoreCase(SmsTypeEnum.SET.value().toLowerCase())) {
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
|
|
|
HashMap<String, String> hashMap = list.get(i);
|
|
|
|
|
|
|
|
String s = (String) hashMap.get(SmsTypeEnum.CFGFILE.value());
|
|
|
|
|
|
|
|
if (s.equalsIgnoreCase(SmsTypeEnum.APP.value())) {
|
|
|
|
|
|
|
|
MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context);
|
|
|
|
|
|
|
|
Field[] fields = mpAppConfig.getClass().getDeclaredFields();
|
|
|
|
|
|
|
|
for (Field field : fields) {
|
|
|
|
|
|
|
|
hashMap.forEach((key, value) -> {
|
|
|
|
|
|
|
|
if (key.equalsIgnoreCase(field.getName()) && !key.equalsIgnoreCase(SmsTypeEnum.CFGFILE.value())) {
|
|
|
|
|
|
|
|
if (value != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (field.getType() == String.class) {
|
|
|
|
|
|
|
|
field.set(mpAppConfig, value);
|
|
|
|
|
|
|
|
} else if (field.getType() == int.class) {
|
|
|
|
|
|
|
|
Integer num = StringUtils.convert2Int(value);
|
|
|
|
|
|
|
|
if (num != null) {
|
|
|
|
|
|
|
|
field.set(mpAppConfig, num.intValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (IllegalAccessException e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MicroPhotoContext.saveMpAppConfig(context, mpAppConfig);
|
|
|
|
|
|
|
|
} else if (s.equalsIgnoreCase(SmsTypeEnum.MASTER.value())) {
|
|
|
|
|
|
|
|
MicroPhotoContext.MasterConfig masterConfig = MicroPhotoContext.getMasterConfig(context);
|
|
|
|
|
|
|
|
Field[] fields = masterConfig.getClass().getDeclaredFields();
|
|
|
|
|
|
|
|
for (Field field : fields) {
|
|
|
|
|
|
|
|
hashMap.forEach((key, value) -> {
|
|
|
|
|
|
|
|
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(context, masterConfig);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (actType.toLowerCase().equalsIgnoreCase(SmsTypeEnum.GET.value().toLowerCase())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (actType.toLowerCase().equalsIgnoreCase(SmsTypeEnum.SETFILE.value().toLowerCase())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (actType.toLowerCase().equalsIgnoreCase(SmsTypeEnum.GETFILE.value().toLowerCase())) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取app的心跳
|
|
|
|
|
|
|
|
public static int getCommon(Context context) {
|
|
|
|
|
|
|
|
MicroPhotoContext.AppConfig mpAppConfig = MicroPhotoContext.getMpAppConfig(context);
|
|
|
|
|
|
|
|
int heartbeat = mpAppConfig.heartbeat;
|
|
|
|
|
|
|
|
return heartbeat;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|