Beispiel #1
0
  private void upload() {
    String message = FileUtil.read(StatConst.snifferPath);
    if (!StringUtil.isEmpty(message)) {
      mUploader.postSnifferFail(message);
    }
    new File(StatConst.snifferPath).delete();
    message = FileUtil.read(StatConst.playPath);
    if (!StringUtil.isEmpty(message)) {
      mUploader.postPlayFail(message);
    }
    new File(StatConst.playPath).delete();
    message = FileUtil.read(StatConst.crashPath);
    if (!StringUtil.isEmpty(message)) {
      mUploader.postLog(message);
    }
    new File(StatConst.crashPath).delete();

    // 统计信息

    Configuration conf = (Configuration) mServiceFactory.getServiceProvider(Configuration.class);
    String format = conf.getStartActivateUrl();

    String start = "activate=1&install=0&";
    String install = "activate=1&install=1&";
    String messageStart = buildStat();
    String messageActivate = "";
    String statMessgae = FileUtil.read(StatConst.statPath);
    if (!StringUtil.isEmpty(statMessgae)) {
      messageStart += "&" + statMessgae;
    }
    new File(StatConst.statPath).delete();

    // 首次激活统计
    SharedPreferences preference =
        this.mContext.getSharedPreferences("stat", Context.MODE_WORLD_WRITEABLE);
    if (preference.getBoolean("isfirst", true)) {

      messageActivate = install + messageStart + buildActivate();

      DownloadServiceAdapter adapter =
          (DownloadServiceAdapter) mServiceFactory.getServiceProvider(DownloadServiceAdapter.class);
      adapter.statReport(
          "Device", StatId.Computer.Device + "=" + UrlUtil.encode(SystemUtil.getMobileInfo()));
      adapter.statReport(
          "Cpuinfo", StatId.Computer.CPUInfo + "=" + UrlUtil.encode(SystemUtil.getCPUInfo()));

      preference.edit().putBoolean("isfirst", false).commit();

      String url = String.format(format, messageActivate);
      new HttpComm().get(url, null);

    } else {
      messageStart = start + messageStart;
      String url = String.format(format, messageStart);
      new HttpComm().get(url, null);
    }
  }
Beispiel #2
0
 /** 构建首次激活上报信息 */
 private String buildActivate() {
   StringBuilder sb = new StringBuilder();
   sb.append(StatId.Device + "=" + UrlUtil.encode(SystemUtil.getMobileInfo()));
   sb.append(StatConst.LogSep);
   Turple<Integer, Integer> resolution = SystemUtil.getResolution(mContext);
   sb.append(StatId.Resolution + "=" + resolution.getX() + "," + resolution.getY());
   sb.append(StatConst.LogSep);
   sb.append(StatId.CPUInfo + "=" + UrlUtil.encode(SystemUtil.getCPUInfo()));
   return StatConst.LogSep + sb.toString();
 }