运维请求增加版本信息

serial
BlueMatthew 2 years ago
parent cdf0e9d268
commit 54f80698d1

@ -113,6 +113,9 @@ public class AppMaster {
List<Pair<String, String>> postParams = new ArrayList<>();
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);
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());

@ -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);

Loading…
Cancel
Save