diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java b/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java index 39e98e29..dcfcace2 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java @@ -113,6 +113,9 @@ public class AppMaster { List> postParams = new ArrayList<>(); postParams.add(new Pair("id", mCmdid)); + postParams.add(new Pair("i1Version", mService.getMpAppVersion())); + postParams.add(new Pair("maintainVersion", mService.getMasterAppVersion())); + // postParams(httpURLConnection.getOutputStream(), postParams); buildParams(httpURLConnection.getOutputStream()); httpURLConnection.connect(); @@ -312,16 +315,15 @@ public class AppMaster { } catch (Exception ex) { } - } - - private void buildParams(OutputStream output) { BufferedWriter bufferedWriter = null; try { JSONObject jsonObject = new JSONObject(); jsonObject.put("id", mCmdid); + jsonObject.put("i1Version", mService.getMpAppVersion()); + jsonObject.put("maintainVersion", mService.getMasterAppVersion()); bufferedWriter = new BufferedWriter(new OutputStreamWriter(output, "UTF-8")); bufferedWriter.write(jsonObject.toString()); diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java index e899b0fb..7d93158e 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java @@ -11,6 +11,8 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.os.BatteryManager; import android.os.Environment; @@ -109,6 +111,10 @@ public class MpMasterService extends Service { private String mModelName = null; + private String mMpAppVersion = null; + + private String mMpMasterVersion = null; + public MpMasterService() { } @Override @@ -120,6 +126,16 @@ public class MpMasterService extends Service { public void onCreate() { super.onCreate(); + mMpMasterVersion = MicroPhotoContext.getVersionName(getApplicationContext()); + PackageManager packageManager = getPackageManager(); + PackageInfo packageInfo = null; + try { + packageInfo = packageManager.getPackageInfo(MicroPhotoContext.PACKAGE_NAME_MPAPP, 0); + } catch (Exception ex) { + ex.printStackTrace(); + } + mMpAppVersion = packageInfo == null ? "" : packageInfo.versionName; + mHander = new ServiceHandler(); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); @@ -175,6 +191,14 @@ public class MpMasterService extends Service { return mCmdid; } + public String getMpAppVersion() { + return mMpAppVersion; + } + + public String getMasterAppVersion() { + return mMpMasterVersion; + } + public static void sendMessage(Context context, int what, int data) { Intent intent = new Intent(ACTION_MSG_BROADCAST); intent.putExtra("what", what);