Skip to content

Commit

Permalink
Merge pull request #653 from F43nd1r/issue_652
Browse files Browse the repository at this point in the history
StrictMode compatibility
  • Loading branch information
F43nd1r committed Mar 21, 2018
2 parents d491743 + d14bacf commit 22ea442
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 22ea442

Please sign in to comment.