From 9beeef5d1817196a8f86c76f04e5955ac5bff033 Mon Sep 17 00:00:00 2001 From: BlueMatthew Date: Tue, 16 Jan 2024 17:12:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/xypower/mpmaster/AppMaster.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java b/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java index cadf0edc..7a809238 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java @@ -3,6 +3,7 @@ package com.xypower.mpmaster; import android.content.Context; import android.os.Environment; import android.os.PowerManager; +import android.os.SystemClock; import android.text.TextUtils; import android.util.Pair; import android.util.Base64; @@ -88,6 +89,10 @@ public class AppMaster { mService = null; } + private long getBootTime() { + return (System.currentTimeMillis() - SystemClock.elapsedRealtimeNanos() / 1000000) / 1000000; + } + public void start() { new Thread(new Runnable() { @@ -125,11 +130,12 @@ public class AppMaster { List> postParams = new ArrayList<>(); postParams.add(new Pair("id", mCmdid)); postParams.add(new Pair("XyDev", "1")); + postParams.add(new Pair("bootTime", Long.toString(getBootTime()))); postParams.add(new Pair("i1Version", mService.getMpAppVersion())); postParams.add(new Pair("maintainVersion", mService.getMasterAppVersion())); - + // postParams(httpURLConnection.getOutputStream(), postParams); - buildParams(httpURLConnection.getOutputStream()); + buildParams(httpURLConnection.getOutputStream(), postParams); httpURLConnection.connect(); inputStream = httpURLConnection.getInputStream(); @@ -467,14 +473,15 @@ public class AppMaster { } } - private void buildParams(OutputStream output) { + private void buildParams(OutputStream output, List> params) { BufferedWriter bufferedWriter = null; OutputStreamWriter outputStreamWriter = null; try { JSONObject jsonObject = new JSONObject(); - jsonObject.put("id", mCmdid); - jsonObject.put("i1Version", mService.getMpAppVersion()); - jsonObject.put("maintainVersion", mService.getMasterAppVersion()); + + for (Pair pair : params) { + jsonObject.put(pair.first, pair.second); + } outputStreamWriter = new OutputStreamWriter(output, "UTF-8"); bufferedWriter = new BufferedWriter(outputStreamWriter);