1、更改部分下载类,未完成

2、@#&@*#
This commit is contained in:
CsHeng
2017-06-29 11:17:01 +08:00
parent 5cbf06f6a6
commit f97ccd5c5d
126 changed files with 454 additions and 6379 deletions

View File

@ -5,15 +5,15 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
import com.gh.common.constant.Config;
import com.lightgame.utils.AppManager;
import com.gh.common.util.DataCollectionUtils;
import com.gh.common.util.FileUtils;
import com.gh.gamecenter.SplashScreenActivity;
import com.lightgame.download.FileUtils;
import com.lightgame.utils.AppManager;
import com.lightgame.utils.RuntimeUtils;
import com.tencent.stat.StatService;
import java.io.File;
@ -27,12 +27,12 @@ import java.util.Locale;
public class AppUncaughtHandler implements UncaughtExceptionHandler {
private UncaughtExceptionHandler mDefaultHandler;
private AppController mAppController;
private Context mContext;
public AppUncaughtHandler(AppController appController) {
public AppUncaughtHandler(Context context) {
// 获取系统默认的UncaughtException处理器
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
mAppController = appController;
mContext = context;
}
@Override
@ -41,13 +41,11 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
// 如果用户没有处理则让系统默认的异常处理器来处理
mDefaultHandler.uncaughtException(thread, ex);
} else {
AppController.MAIN_EXECUTOR.execute(new Runnable() {
RuntimeUtils.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
Looper.prepare();
Toast.makeText(mAppController.getApplicationContext(),
Toast.makeText(mContext.getApplicationContext(),
"\"光环助手\"发生错误", Toast.LENGTH_SHORT).show();
Looper.loop();
}
});
try {
@ -57,19 +55,17 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
}
// 防止重复奔溃导致助手一直重启20秒内不做处理
SharedPreferences sp = mAppController.getApplicationContext().getSharedPreferences(
Config.PREFERENCE, Context.MODE_PRIVATE);
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
long time = sp.getLong("last_restart_time", 0);
if (System.currentTimeMillis() - time > 20 * 1000) {
sp.edit().putLong("last_restart_time", System.currentTimeMillis()).apply();
Intent intent = new Intent(mAppController.getApplicationContext(), SplashScreenActivity.class);
Intent intent = new Intent(mContext, SplashScreenActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent restartIntent = PendingIntent.getActivity(
mAppController.getApplicationContext(), 0, intent,
PendingIntent restartIntent = PendingIntent.getActivity(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
// 退出程序并重启
AlarmManager mgr = (AlarmManager) mAppController.getSystemService(Context.ALARM_SERVICE);
AlarmManager mgr = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent); // 1秒钟后重启应用
}
AppManager.getInstance().finishAllActivity();
@ -95,15 +91,15 @@ public class AppUncaughtHandler implements UncaughtExceptionHandler {
String errorMsg = Log.getStackTraceString(ex);
// MTA主动上传错误
// StatService.reportError(mAppController.getApplicationContext(), errorMsg);
StatService.reportException(mAppController, ex);
// StatService.reportError(mContext.getApplicationContext(), errorMsg);
StatService.reportException(mContext, ex);
// 上传错误数据
DataCollectionUtils.uploadError(mAppController, errorMsg);
DataCollectionUtils.uploadError(mContext, errorMsg);
// 保存到本地
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.getDefault());
File file = new File(FileUtils.getLogPath(mAppController.getApplicationContext(),
File file = new File(FileUtils.getLogPath(mContext.getApplicationContext(),
format.format(new Date()) + "_gh_assist" + ".log"));
FileWriter writer = null;
try {