Skip to content

Commit

Permalink
feat: Improve crash handling logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Feb 3, 2025
1 parent fc1db41 commit d1403ac
Showing 1 changed file with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
*/
package com.sevtinge.hyperceiler.ui.app.crash;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;

import androidx.annotation.Nullable;

import com.hchen.hooktool.log.AndroidLog;
import com.sevtinge.hyperceiler.BuildConfig;
import com.sevtinge.hyperceiler.ui.app.main.HyperCeilerTabActivity;
import com.sevtinge.hyperceiler.utils.KillApp;
import com.sevtinge.hyperceiler.utils.shell.ShellInit;

import fan.appcompat.app.AlertDialog;
import fan.appcompat.app.AppCompatActivity;
Expand All @@ -39,25 +38,20 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String crashInfo = getIntent().getStringExtra("crashInfo");

AlertDialog dialog = new AlertDialog.Builder(this)
new AlertDialog.Builder(this)
.setTitle("错误")
.setMessage("模块发生致命崩溃事件,无法继续运行!请携带以下报错信息进行反馈!\n" + crashInfo)
.setPositiveButton("重启程序", (d, w) -> {
AndroidLog.logI(TAG, "restart myself!!");
Intent intent = new Intent(this, HyperCeilerTabActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);

finish();
})
.setNegativeButton("结束进程", (d, w) -> {
.setPositiveButton("结束进程", (d, w) -> {
AndroidLog.logI(TAG, "kill myself!!");
moveTaskToBack(true);
KillApp.killApps(BuildConfig.APPLICATION_ID);
})
.create();
finish();

dialog.setCancelable(false);
dialog.show();
new Handler(Looper.getMainLooper()).postDelayed(() -> {
ShellInit.getShell().run("am force-stop com.sevtinge.hyperceiler").sync();
}, 500);
})
.setCancelable(false)
.setHapticFeedbackEnabled(true)
.show();
}
}

0 comments on commit d1403ac

Please sign in to comment.