记录历史最大充电电压并上报

nx2024TEMP
Matthew 9 months ago
parent 55e0698c4f
commit ab0d06fabd

@ -262,12 +262,16 @@ public class AppMaster {
// }
try {
String battery = getBatteryVoltage() + "V/" + getChargingBatteryVoltage() + "V";
String battery = mService.getBatteryVoltage() + "V/" + mService.getChargingBatteryVoltage() + "V";
postParams.add(new Pair<String, String>("battery", battery));
} catch (Exception ex) {
ex.printStackTrace();
}
if (mService.isSeparateNetwork()) {
postParams.add(new Pair<String, String>("maxBCV", mService.getAndResetMaxBCV()));
}
for (int idx = 0; idx < 3; idx++) {
try {
httpURLConnection = (HttpURLConnection) url.openConnection();
@ -442,28 +446,33 @@ public class AppMaster {
}
}
private String getBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(115);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
private String getCrashTimes(final long startTimeMs, final long endTimeMs) {
String path = "/data/system/dropbox/";
final String prefixFileName = "data_app_crash@";
final int[] cnts = new int[2];
cnts[0] = 0;
cnts[1] = 0;
return "";
long weekStartTime = startTimeMs - 86400000 * 7;
FileFilter fileFilter = new FileFilter() {
@Override
public boolean accept(File pathname) {
if (pathname.isFile() && pathname.getName().startsWith(prefixFileName) && pathname.lastModified() <= endTimeMs) {
if (pathname.lastModified() >= startTimeMs) {
cnts[0]++;
}
private String getChargingBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(112);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
// if (pathname.lastModified() >= weekStartTime) {
cnts[1]++;
// }
}
return false;
}
};
File file = new File(path);
String[] files = file.list();
File[] subFiles = file.listFiles(fileFilter);
return "";
return ((cnts[0] == 0) && (cnts[1] == 0)) ? null : Integer.toString(cnts[0]) + " " + Integer.toString(cnts[1]);
}
private String getImei(int number) {

@ -127,6 +127,9 @@ public class MpMasterService extends Service {
private long mPreviousMpHbTime = 0;
private int mMaxBCV = 0;
private long mMaxBCVTime = 0;
private String mIccid1 = null;
private String mIccid2 = null;
@ -198,6 +201,8 @@ public class MpMasterService extends Service {
mPreviousMpHbTime = System.currentTimeMillis();
buildChargingBatteryVoltage(System.currentTimeMillis());
logger.info("MpMaster started version=" + mMpMasterVersion);
mHander = new Handler();
@ -530,6 +535,8 @@ public class MpMasterService extends Service {
mService.mPreviousHeartbeatTime = 0;
mService.registerHeartbeatTimer();
mService.buildChargingBatteryVoltage(System.currentTimeMillis());
if (!keepAlive) {
mService.startMaster(false);
}
@ -546,6 +553,7 @@ public class MpMasterService extends Service {
mService.registerHeartbeatTimer();
mService.buildChargingBatteryVoltage(System.currentTimeMillis());
if (!mService.mSeparateNetwork && (!mService.mMntnMode)) {
mService.startMaster(true);
}
@ -609,7 +617,6 @@ public class MpMasterService extends Service {
SysApi.installOTA(context, context.getPackageName(), path);
}
});
}
private void registerHeartbeatTimer() {
@ -919,6 +926,57 @@ public class MpMasterService extends Service {
return signalLevel;
}
public static String getBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(115);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
return "";
}
private void buildChargingBatteryVoltage(long ts) {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(112);
if (val > 0) {
break;
}
}
if (val > 0) {
if (val > mMaxBCV) {
mMaxBCV = val;
mMaxBCVTime = ts;
}
}
}
public String getAndResetMaxBCV() {
String val = Integer.toString(mMaxBCV / 1000) + "." + Integer.toString((mMaxBCV % 1000) / 100)
+ "/" + Long.toString(mMaxBCVTime / 1000);
mMaxBCV = 0;
mMaxBCVTime = 0;
return val;
}
public static String getChargingBatteryVoltage() {
int val = 0;
for (int idx = 0; idx < 3; idx++) {
val = MpMasterService.getInt(112);
if (val > 0) {
return Integer.toString(val / 1000) + "." + Integer.toString((val % 1000) / 100);
}
}
return "";
}
public void downloadAndInstall(final String url) {
final Context context = getApplicationContext();

Loading…
Cancel
Save