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); } }
@Override public void onDestory() { mHandler.removeMessages(0); mEventListener.destroy(); FileUtil.write(StatConst.snifferPath, mLogData.getSnifferFail(), true); FileUtil.write(StatConst.playPath, mLogData.getPlayFail(), true); mLogData.appendStat(FileUtil.read(StatConst.statPath)); FileUtil.write(StatConst.statPath, mLogData.getStat(), false); }
@Override public void postLog() { Logger.flush(); mUploader.postLog(FileUtil.read(Logger.getFileName())); }