Merge branch 'main' of http://61.169.135.146:8081/git/xymp/TermApp
commit
f39a3cfad6
@ -1,4 +1,4 @@
|
|||||||
package com.xypower.mpmaster;
|
package com.xypower.common;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.xypower.mpmaster.sms;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.xypower.common.JSONUtils;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class UpdateSysConfigUtil {
|
||||||
|
|
||||||
|
public static String SysConfigName = "data/Master.json";
|
||||||
|
|
||||||
|
//创建运维配置文件文件夹
|
||||||
|
public static String buildAppDir(String packageurl) {
|
||||||
|
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||||
|
if (!path.endsWith(File.separator)) {
|
||||||
|
path += File.separator;
|
||||||
|
}
|
||||||
|
path += packageurl + File.separator;
|
||||||
|
File pathFile = new File(path);
|
||||||
|
if (!pathFile.exists() && !pathFile.mkdirs()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取配置文件地址
|
||||||
|
public static String getAppDir(String packageurl) {
|
||||||
|
String path = buildAppDir(packageurl);
|
||||||
|
path += SysConfigName;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改运维时间表
|
||||||
|
public static boolean updateAbsHeartbeats(String packageurl, JSONArray jsonArray) {
|
||||||
|
String path = getAppDir(packageurl);
|
||||||
|
JSONObject jsonObject = JSONUtils.loadJson(path);
|
||||||
|
try {
|
||||||
|
jsonObject.put("absHeartbeats", jsonArray);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return JSONUtils.saveJson(path, jsonObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改运维状态 TODO
|
||||||
|
public boolean updateMntn(String packageurl, String url) {
|
||||||
|
if (TextUtils.isEmpty(url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String path = getAppDir(packageurl);
|
||||||
|
JSONObject jsonObject = JSONUtils.loadJson(path);
|
||||||
|
String oldUrl = null;
|
||||||
|
try {
|
||||||
|
oldUrl = jsonObject.getString("url");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
if (TextUtils.equals(url, oldUrl)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
jsonObject.put("url", url);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return JSONUtils.saveJson(path, jsonObject);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue