光环助手更新数据统计

This commit is contained in:
khy
2016-11-01 09:59:03 +08:00
parent 6e196262a5
commit 7862426144
2 changed files with 66 additions and 6 deletions

View File

@ -20,17 +20,20 @@ import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.gh.base.AppController;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DeviceUtils;
import com.gh.common.util.DialogUtils;
import com.gh.common.util.FileUtils;
import com.gh.common.util.MD5Utils;
import com.gh.common.util.PackageUtils;
import com.gh.common.util.SpeedUtils;
import com.gh.common.util.TokenUtils;
import com.gh.common.util.Utils;
import com.gh.download.DataWatcher;
import com.gh.download.DownloadEntity;
@ -41,12 +44,15 @@ import com.gh.gamecenter.entity.GameUpdateEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.manager.PackageManager;
import com.gh.gamecenter.volley.extended.JsonObjectExtendedRequest;
import com.gh.gamecenter.volley.extended.StringExtendedRequest;
import com.google.gson.Gson;
import com.kyleduo.switchbutton.SwitchButton;
import org.json.JSONObject;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import de.greenrobot.event.EventBus;
@ -428,6 +434,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
}
private void showUpdateDialog(final String md5) {
uploadUpgradeLog("notice"); //上传更新通知弹窗数据
final Dialog updateDialog = new Dialog(this);
View view = View.inflate(this, R.layout.app_update_hint_dialog, null);
@ -463,6 +470,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
"光环助手V" + appEntity.getVersion() + "_" + md5 + ".apk");
File file = new File(path);
if (file.exists() && file.length() > 0) {
uploadUpgradeLog("install");//上传更新安装数据
startActivity(PackageUtils.getInstallIntent(path));
} else {
DataUtils.onEvent(SettingActivity.this, "软件更新", "下载开始");
@ -538,6 +546,30 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
DownloadManager.getInstance(getApplicationContext()).add(downloadEntity);
}
private void uploadUpgradeLog(String step) {
Map<String, Object> map = new HashMap<>();
String version = PackageUtils.getVersion(this);
String user = DeviceUtils.getDeviceID(this);
String channel = (String) PackageUtils.getMetaData(this,
getPackageName(), "TD_CHANNEL_ID");
map.put("step", step);
map.put("version", version);
map.put("user", user);
map.put("device_id", TokenUtils.getDeviceId(this));
map.put("channel", channel);
String url = "http://data.ghzhushou.com/api/v1d0/log";
Map<String, String> params = new HashMap<>();
params.put("topic", "upgrade");
params.put("source", "GH-ASSIST-Client");
params.put("time", String.valueOf(Utils.getTime(this)));
params.put("content", new JSONObject(map).toString());
StringExtendedRequest request = new StringExtendedRequest(Request.Method.POST, url, null, null);
request.setParams(params);
request.setShouldCache(false);
AppController.addToRequestQueue(request, TAG);
Utils.log("提交更新数据" + new JSONObject(params).toString());
}
@Override
public void onResume() {
super.onResume();