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

StrictMode compatibility #653

Merged
merged 2 commits into from
Mar 21, 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
3 changes: 3 additions & 0 deletions acra-core/src/main/java/org/acra/builder/ReportExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.content.Context;
import android.os.Debug;
import android.os.Looper;
import android.os.StrictMode;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Toast;
Expand Down Expand Up @@ -162,8 +163,10 @@ public final void execute(@NonNull final ReportBuilder reportBuilder) {
processFinisher.finishLastActivity(reportBuilder.getUncaughtExceptionThread());
}
if (blockingAdministrator == null) {
StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
final File reportFile = getReportFileName(crashReportData);
saveCrashReportFile(reportFile, crashReportData);
StrictMode.setThreadPolicy(oldPolicy);

final ReportInteractionExecutor executor = new ReportInteractionExecutor(context, config);
if (reportBuilder.isSendSilently()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.content.pm.PackageInfo;
import android.os.Handler;
import android.support.annotation.NonNull;

import org.acra.ACRA;
import org.acra.config.CoreConfiguration;
import org.acra.file.BulkReportDeleter;
Expand Down Expand Up @@ -49,8 +50,8 @@ public ApplicationStartupProcessor(@NonNull Context context, @NonNull CoreConfig
}

public void checkReports(boolean enableAcra) {
//application is not ready in onAttachBaseContext, so delay this
new Handler(context.getMainLooper()).post(() -> {
//application is not ready in onAttachBaseContext, so delay this. also run it on a background thread because we're doing disk I/O
new Handler(context.getMainLooper()).post(() -> new Thread(() -> {
if (config.deleteOldUnsentReportsOnApplicationStart()) {
deleteUnsentReportsFromOldAppVersion();
}
Expand All @@ -61,7 +62,7 @@ public void checkReports(boolean enableAcra) {
sendApprovedReports();
approveOneReport();
}
});
}).start());
}

private void approveOneReport() {
Expand Down