Skip to content

Wait for DataTransport callback task at crash time #1479

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

Merged
merged 1 commit into from
May 19, 2020
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 @@ -435,9 +435,10 @@ public Task<Void> then(@Nullable AppSettingsData appSettingsData)
// Data collection is enabled, so it's safe to send the report.
boolean dataCollectionToken = true;
sendSessionReports(appSettingsData, dataCollectionToken);
reportingCoordinator.sendReports(
executor, DataTransportState.getState(appSettingsData));
return recordFatalFirebaseEventTask;
return Tasks.whenAll(
reportingCoordinator.sendReports(
executor, DataTransportState.getState(appSettingsData)),
recordFatalFirebaseEventTask);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.crashlytics.internal.Logger;
import com.google.firebase.crashlytics.internal.log.LogFileManager;
import com.google.firebase.crashlytics.internal.model.CrashlyticsReport;
Expand Down Expand Up @@ -170,16 +171,17 @@ public void removeAllReports() {
* sent.
* @param dataTransportState used to determine whether to send the report before cleaning it up.
*/
public void sendReports(
Task<Void> sendReports(
@NonNull Executor reportSendCompleteExecutor,
@NonNull DataTransportState dataTransportState) {
if (dataTransportState == DataTransportState.NONE) {
Logger.getLogger().d("Send via DataTransport disabled. Removing DataTransport reports.");
reportPersistence.deleteAllReports();
return;
return Tasks.forResult(null);
}
final List<CrashlyticsReportWithSessionId> reportsToSend =
reportPersistence.loadFinalizedReports();
final List<Task<Boolean>> sendTasks = new ArrayList<>();
for (CrashlyticsReportWithSessionId reportToSend : reportsToSend) {
if (reportToSend.getReport().getType() == CrashlyticsReport.Type.NATIVE
&& dataTransportState != DataTransportState.ALL) {
Expand All @@ -189,10 +191,12 @@ public void sendReports(
continue;
}

reportsSender
.sendReport(reportToSend)
.continueWith(reportSendCompleteExecutor, this::onReportSendComplete);
sendTasks.add(
reportsSender
.sendReport(reportToSend)
.continueWith(reportSendCompleteExecutor, this::onReportSendComplete));
}
return Tasks.whenAll(sendTasks);
}

private void persistEvent(
Expand Down