运维请求增加版本信息

serial
BlueMatthew 2 years ago
parent cdf0e9d268
commit 54f80698d1

@ -113,6 +113,9 @@ 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>("i1Version", mService.getMpAppVersion()));
postParams.add(new Pair<String, String>("maintainVersion", mService.getMasterAppVersion()));
// postParams(httpURLConnection.getOutputStream(), postParams); // postParams(httpURLConnection.getOutputStream(), postParams);
buildParams(httpURLConnection.getOutputStream()); buildParams(httpURLConnection.getOutputStream());
httpURLConnection.connect(); httpURLConnection.connect();
@ -312,16 +315,15 @@ public class AppMaster {
} catch (Exception ex) { } catch (Exception ex) {
} }
} }
private void buildParams(OutputStream output) { private void buildParams(OutputStream output) {
BufferedWriter bufferedWriter = null; BufferedWriter bufferedWriter = null;
try { try {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("id", mCmdid); jsonObject.put("id", mCmdid);
jsonObject.put("i1Version", mService.getMpAppVersion());
jsonObject.put("maintainVersion", mService.getMasterAppVersion());
bufferedWriter = new BufferedWriter(new OutputStreamWriter(output, "UTF-8")); bufferedWriter = new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));
bufferedWriter.write(jsonObject.toString()); bufferedWriter.write(jsonObject.toString());

@ -11,6 +11,8 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Environment; import android.os.Environment;
@ -109,6 +111,10 @@ public class MpMasterService extends Service {
private String mModelName = null; private String mModelName = null;
private String mMpAppVersion = null;
private String mMpMasterVersion = null;
public MpMasterService() { public MpMasterService() {
} }
@Override @Override
@ -120,6 +126,16 @@ public class MpMasterService extends Service {
public void onCreate() { public void onCreate() {
super.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(); mHander = new ServiceHandler();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
@ -175,6 +191,14 @@ public class MpMasterService extends Service {
return mCmdid; return mCmdid;
} }
public String getMpAppVersion() {
return mMpAppVersion;
}
public String getMasterAppVersion() {
return mMpMasterVersion;
}
public static void sendMessage(Context context, int what, int data) { public static void sendMessage(Context context, int what, int data) {
Intent intent = new Intent(ACTION_MSG_BROADCAST); Intent intent = new Intent(ACTION_MSG_BROADCAST);
intent.putExtra("what", what); intent.putExtra("what", what);

Loading…
Cancel
Save