|
|
@ -158,11 +158,15 @@ public class AppMaster {
|
|
|
|
|
|
|
|
|
|
|
|
sleep(1000);
|
|
|
|
sleep(1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int masterHttpstatus = 0;//0--接口请求正常但未处理 1--访问运维服务器正常,处理也正常 -1----访问运维服务器异常
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
runImpl(isCriticalTime);
|
|
|
|
masterHttpstatus= runImpl(isCriticalTime);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
|
|
|
|
if (masterHttpstatus == -1) {
|
|
|
|
|
|
|
|
mService.setMntnMode(false,false);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
@ -186,14 +190,14 @@ public class AppMaster {
|
|
|
|
}).start();
|
|
|
|
}).start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean runImpl(final boolean isCriticalTime) {
|
|
|
|
private int runImpl(final boolean isCriticalTime) {
|
|
|
|
String masterUrl = mMasterUrl;
|
|
|
|
String masterUrl = mMasterUrl;
|
|
|
|
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(masterUrl)) {
|
|
|
|
if (TextUtils.isEmpty(masterUrl)) {
|
|
|
|
return false;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean res = false;
|
|
|
|
|
|
|
|
HttpURLConnection httpURLConnection = null;
|
|
|
|
HttpURLConnection httpURLConnection = null;
|
|
|
|
InputStream inputStream = null;
|
|
|
|
InputStream inputStream = null;
|
|
|
|
Date now = new Date();
|
|
|
|
Date now = new Date();
|
|
|
@ -336,13 +340,14 @@ public class AppMaster {
|
|
|
|
String response = convertStreamToString(inputStream);
|
|
|
|
String response = convertStreamToString(inputStream);
|
|
|
|
process(response);
|
|
|
|
process(response);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = true;
|
|
|
|
res = 1;
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
// ex.printStackTrace();
|
|
|
|
// ex.printStackTrace();
|
|
|
|
mService.logger.warning(ex.getMessage());
|
|
|
|
res = -1;
|
|
|
|
|
|
|
|
mService.logger.warning("运维服务器连接失败! " + ex.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
if (res == 1) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -435,13 +440,13 @@ public class AppMaster {
|
|
|
|
if (items.length > 12 && items.length <= 18) {
|
|
|
|
if (items.length > 12 && items.length <= 18) {
|
|
|
|
// v2
|
|
|
|
// v2
|
|
|
|
|
|
|
|
|
|
|
|
long ts = (((long)items[12]) & 0xFFFFFFFFl) | ((((long)items[13]) << 32) & 0xFFFFFFFF00000000l);
|
|
|
|
long ts = (((long) items[12]) & 0xFFFFFFFFl) | ((((long) items[13]) << 32) & 0xFFFFFFFF00000000l);
|
|
|
|
stats.add(new Pair<String, String>("lastHbTime", Long.toString(ts)));
|
|
|
|
stats.add(new Pair<String, String>("lastHbTime", Long.toString(ts)));
|
|
|
|
|
|
|
|
|
|
|
|
ts = (((long)items[14]) & 0xFFFFFFFFl) | ((((long)items[15]) << 32) & 0xFFFFFFFF00000000l);
|
|
|
|
ts = (((long) items[14]) & 0xFFFFFFFFl) | ((((long) items[15]) << 32) & 0xFFFFFFFF00000000l);
|
|
|
|
stats.add(new Pair<String, String>("lastHbRespTime", Long.toString(ts)));
|
|
|
|
stats.add(new Pair<String, String>("lastHbRespTime", Long.toString(ts)));
|
|
|
|
|
|
|
|
|
|
|
|
ts = (((long)items[16]) & 0xFFFFFFFFl) | ((((long)items[17]) << 32) & 0xFFFFFFFF00000000l);
|
|
|
|
ts = (((long) items[16]) & 0xFFFFFFFFl) | ((((long) items[17]) << 32) & 0xFFFFFFFF00000000l);
|
|
|
|
stats.add(new Pair<String, String>("lastRecvTime", Long.toString(ts)));
|
|
|
|
stats.add(new Pair<String, String>("lastRecvTime", Long.toString(ts)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -472,7 +477,7 @@ public class AppMaster {
|
|
|
|
cnts[0]++;
|
|
|
|
cnts[0]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// if (pathname.lastModified() >= weekStartTime) {
|
|
|
|
// if (pathname.lastModified() >= weekStartTime) {
|
|
|
|
cnts[1]++;
|
|
|
|
cnts[1]++;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -486,7 +491,6 @@ public class AppMaster {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getImei(int number) {
|
|
|
|
private String getImei(int number) {
|
|
|
|
return (number == 1) ? SysApi.getImei(mService) : SysApi.getImei2(mService);
|
|
|
|
return (number == 1) ? SysApi.getImei(mService) : SysApi.getImei2(mService);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -494,8 +498,8 @@ public class AppMaster {
|
|
|
|
private String getFreeROM() {
|
|
|
|
private String getFreeROM() {
|
|
|
|
long[] flashInfo = SysApi.getFlashInfo();
|
|
|
|
long[] flashInfo = SysApi.getFlashInfo();
|
|
|
|
if (flashInfo != null && flashInfo.length > 1) {
|
|
|
|
if (flashInfo != null && flashInfo.length > 1) {
|
|
|
|
double fd = (double)(flashInfo[1] * 100) / (double)flashInfo[0];
|
|
|
|
double fd = (double) (flashInfo[1] * 100) / (double) flashInfo[0];
|
|
|
|
return Integer.toString((int)fd) + "%";
|
|
|
|
return Integer.toString((int) fd) + "%";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -628,7 +632,7 @@ public class AppMaster {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_DOWNLOAD_FILE)) {
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_DOWNLOAD_FILE)) {
|
|
|
|
|
|
|
|
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
String url = jsonObject.optString("url", null);
|
|
|
|
String url = jsonObject.optString("url", null);
|
|
|
@ -683,14 +687,14 @@ public class AppMaster {
|
|
|
|
int enable = jsonObject.optInt("enable", 1);
|
|
|
|
int enable = jsonObject.optInt("enable", 1);
|
|
|
|
mService.logger.warning("Recv EN OTG: " + enable);
|
|
|
|
mService.logger.warning("Recv EN OTG: " + enable);
|
|
|
|
SysApi.setOtgState((enable != 0));
|
|
|
|
SysApi.setOtgState((enable != 0));
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_PULL_FILE)) {
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_PULL_FILE)) {
|
|
|
|
pullFiles(jsonObject);
|
|
|
|
pullFiles(jsonObject);
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_DELETE_FILE)) {
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_DELETE_FILE)) {
|
|
|
|
|
|
|
|
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
mService.logger.warning("Recv Del File: " + path);
|
|
|
|
mService.logger.warning("Recv Del File: " + path);
|
|
|
|
deleteFile(path);
|
|
|
|
deleteFile(path);
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_LIST_FILES)) {
|
|
|
|
} else if (TextUtils.equals(cmd, CMD_LIST_FILES)) {
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
String path = jsonObject.optString("path", null);
|
|
|
|
String filter = jsonObject.optString("filter", null);
|
|
|
|
String filter = jsonObject.optString("filter", null);
|
|
|
|
mService.logger.warning("Recv List Files: " + path);
|
|
|
|
mService.logger.warning("Recv List Files: " + path);
|
|
|
@ -904,7 +908,7 @@ public class AppMaster {
|
|
|
|
if (packageName.equals(MicroPhotoContext.PACKAGE_NAME_MPMASTER)) {
|
|
|
|
if (packageName.equals(MicroPhotoContext.PACKAGE_NAME_MPMASTER)) {
|
|
|
|
MpMasterService.restartMpMasterApp(mService.getApplicationContext(), "Config Updated");
|
|
|
|
MpMasterService.restartMpMasterApp(mService.getApplicationContext(), "Config Updated");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
MpMasterService.restartAppByPackage(mService.getApplicationContext(), packageName,"Config Updated");
|
|
|
|
MpMasterService.restartAppByPackage(mService.getApplicationContext(), packageName, "Config Updated");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -957,7 +961,7 @@ public class AppMaster {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MpMasterService.restartMpApp(context,"CMA Updated");
|
|
|
|
MpMasterService.restartMpApp(context, "CMA Updated");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -983,7 +987,7 @@ public class AppMaster {
|
|
|
|
|
|
|
|
|
|
|
|
MicroPhotoContext.saveMpAppConfig(context, appConfig);
|
|
|
|
MicroPhotoContext.saveMpAppConfig(context, appConfig);
|
|
|
|
|
|
|
|
|
|
|
|
MpMasterService.restartMpApp(context.getApplicationContext(),"HB Duration Updated");
|
|
|
|
MpMasterService.restartMpApp(context.getApplicationContext(), "HB Duration Updated");
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1331,5 +1335,4 @@ public class AppMaster {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|