修复bug

serial
BlueMatthew 1 year ago
parent 100fbeb7cb
commit 9beeef5d18

@ -3,6 +3,7 @@ package com.xypower.mpmaster;
import android.content.Context; import android.content.Context;
import android.os.Environment; import android.os.Environment;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Pair; import android.util.Pair;
import android.util.Base64; import android.util.Base64;
@ -88,6 +89,10 @@ public class AppMaster {
mService = null; mService = null;
} }
private long getBootTime() {
return (System.currentTimeMillis() - SystemClock.elapsedRealtimeNanos() / 1000000) / 1000000;
}
public void start() { public void start() {
new Thread(new Runnable() { new Thread(new Runnable() {
@ -125,11 +130,12 @@ public class AppMaster {
List<Pair<String, String>> postParams = new ArrayList<>(); List<Pair<String, String>> postParams = new ArrayList<>();
postParams.add(new Pair<String, String>("id", mCmdid)); postParams.add(new Pair<String, String>("id", mCmdid));
postParams.add(new Pair<String, String>("XyDev", "1")); postParams.add(new Pair<String, String>("XyDev", "1"));
postParams.add(new Pair<String, String>("bootTime", Long.toString(getBootTime())));
postParams.add(new Pair<String, String>("i1Version", mService.getMpAppVersion())); postParams.add(new Pair<String, String>("i1Version", mService.getMpAppVersion()));
postParams.add(new Pair<String, String>("maintainVersion", mService.getMasterAppVersion())); postParams.add(new Pair<String, String>("maintainVersion", mService.getMasterAppVersion()));
// postParams(httpURLConnection.getOutputStream(), postParams); // postParams(httpURLConnection.getOutputStream(), postParams);
buildParams(httpURLConnection.getOutputStream()); buildParams(httpURLConnection.getOutputStream(), postParams);
httpURLConnection.connect(); httpURLConnection.connect();
inputStream = httpURLConnection.getInputStream(); inputStream = httpURLConnection.getInputStream();
@ -467,14 +473,15 @@ public class AppMaster {
} }
} }
private void buildParams(OutputStream output) { private void buildParams(OutputStream output, List<Pair<String, String>> params) {
BufferedWriter bufferedWriter = null; BufferedWriter bufferedWriter = null;
OutputStreamWriter outputStreamWriter = null; OutputStreamWriter outputStreamWriter = null;
try { try {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", mCmdid);
jsonObject.put("i1Version", mService.getMpAppVersion()); for (Pair<String, String> pair : params) {
jsonObject.put("maintainVersion", mService.getMasterAppVersion()); jsonObject.put(pair.first, pair.second);
}
outputStreamWriter = new OutputStreamWriter(output, "UTF-8"); outputStreamWriter = new OutputStreamWriter(output, "UTF-8");
bufferedWriter = new BufferedWriter(outputStreamWriter); bufferedWriter = new BufferedWriter(outputStreamWriter);

Loading…
Cancel
Save