Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Handle some more strictmode violations #658

Merged
merged 1 commit into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ public final void execute(@NonNull final ReportBuilder reportBuilder) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
final File reportFile = getReportFileName(crashReportData);
saveCrashReportFile(reportFile, crashReportData);
StrictMode.setThreadPolicy(oldPolicy);

final ReportInteractionExecutor executor = new ReportInteractionExecutor(context, config);
StrictMode.setThreadPolicy(oldPolicy);
if (reportBuilder.isSendSilently()) {
//if size == 0 we have no interaction and can send all reports
startSendingReports(executor.hasInteractions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected void init(@Nullable Bundle savedInstanceState) {
* Cancel any pending crash reports.
*/
protected final void cancelReports() {
new BulkReportDeleter(getApplicationContext()).deleteReports(false, 0);
new Thread(() -> new BulkReportDeleter(this).deleteReports(false, 0)).start();
}


Expand All @@ -121,20 +121,22 @@ protected final void cancelReports() {
* @param userEmail Email address (may be null) provided by the client.
*/
protected final void sendCrash(@Nullable String comment, @Nullable String userEmail) {
final CrashReportPersister persister = new CrashReportPersister();
try {
if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Add user comment to " + reportFile);
final CrashReportData crashData = persister.load(reportFile);
crashData.put(USER_COMMENT, comment == null ? "" : comment);
crashData.put(USER_EMAIL, userEmail == null ? "" : userEmail);
persister.store(crashData, reportFile);
} catch (IOException | JSONException e) {
ACRA.log.w(LOG_TAG, "User comment not added: ", e);
}

// Start the report sending task
final SenderServiceStarter starter = new SenderServiceStarter(getApplicationContext(), config);
starter.startService(false, true);
new Thread(() -> {
final CrashReportPersister persister = new CrashReportPersister();
try {
if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Add user comment to " + reportFile);
final CrashReportData crashData = persister.load(reportFile);
crashData.put(USER_COMMENT, comment == null ? "" : comment);
crashData.put(USER_EMAIL, userEmail == null ? "" : userEmail);
persister.store(crashData, reportFile);
} catch (IOException | JSONException e) {
ACRA.log.w(LOG_TAG, "User comment not added: ", e);
}

// Start the report sending task
final SenderServiceStarter starter = new SenderServiceStarter(this, config);
starter.startService(false, true);
}).start();
}

/**
Expand Down