Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature/crash loop detection #80

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Some PR comments resolved
  • Loading branch information
konst-sauce committed Jan 26, 2023
commit 483f630f340c8fafedcbf71d3dd1b9d205c21e92
5 changes: 1 addition & 4 deletions backtrace-library/src/main/cpp/backends/crashpad-backend.cpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ static crashpad::CrashpadClient *client;
static std::unique_ptr<crashpad::CrashReportDatabase> database;

static int consecutive_crashes_count = 0;

bool InitializeCrashpad(jstring url,
jstring database_path,
jstring handler_path,
@@ -21,7 +20,6 @@ bool InitializeCrashpad(jstring url,
jobjectArray attachmentPaths,
jboolean enableClientSideUnwinding,
jint unwindingMode) {

// avoid multi initialization
if (initialized) {
__android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad is already initialized");
@@ -225,8 +223,7 @@ void ReEnableCrashpad() {
// Re-enable uploads if disabled
if (disabled) {
if (database == nullptr) {
__android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android",
"Crashpad database is null, this should not happen");
__android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad database is null, this should not happen");
return;
}
database->GetSettings()->SetUploadsEnabled(true);
Original file line number Diff line number Diff line change
@@ -52,22 +52,23 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

// Set this value in your local.properties
String BACKTRACE_SUBMISSION_URL = "https://submit.backtrace.io/yolo/2dd86e8e779d1fc7e22e7b19a9489abeedec3b1426abe7e2209888e92362fba4/json";
if (BACKTRACE_SUBMISSION_URL != null) {
backtraceClient = initializeBacktrace(BACKTRACE_SUBMISSION_URL);
}

// Crash Loop Detector example
boolean isCLSafeModeReq = BacktraceDatabase.IsSafeModeRequired();
int crashesCount = BacktraceDatabase.ConsecutiveCrashesCount();
Log.i("BacktraceAndroid", "ConsecutiveCrashesCount: " + crashesCount);
Log.i("BacktraceAndroid", String.format("ConsecutiveCrashesCount: %d", crashesCount));

View viewBackground = findViewById(R.id.viewBackground);
if(viewBackground != null) {
viewBackground.setBackgroundColor(isCLSafeModeReq
? getResources().getColor(R.color.colorAccent)
: getResources().getColor(R.color.colorWhite));
}

symlinkAndWriteFile();
}