Skip to content

Commit

Permalink
Draft of possible api change
Browse files Browse the repository at this point in the history
  • Loading branch information
mrober committed Aug 6, 2024
1 parent 0605925 commit 26338c7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
5 changes: 3 additions & 2 deletions firebase-crashlytics/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package com.google.firebase.crashlytics {
public class FirebaseCrashlytics {
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Boolean> checkForUnsentReports();
method public void deleteUnsentReports();
method public boolean didCrashOnPreviousExecution();
method @Deprecated @Discouraged(message="May not be current. Use didCrashOnPreviousRun instead.") public boolean didCrashOnPreviousExecution();
method public com.google.android.gms.tasks.Task<java.lang.Boolean> didCrashOnPreviousRun();
method @NonNull public static com.google.firebase.crashlytics.FirebaseCrashlytics getInstance();
method public com.google.android.gms.tasks.Task<java.lang.Boolean> isCrashlyticsCollectionEnabled();
method public void log(@NonNull String);
method public void recordException(@NonNull Throwable);
method public void sendUnsentReports();
method public boolean isCrashlyticsCollectionEnabled();
method public void setCrashlyticsCollectionEnabled(boolean);
method public void setCrashlyticsCollectionEnabled(@Nullable Boolean);
method public void setCustomKey(@NonNull String, boolean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import android.content.Context;
import android.content.pm.PackageManager;
import androidx.annotation.Discouraged;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
Expand Down Expand Up @@ -430,23 +431,35 @@ public void deleteUnsentReports() {
/**
* Checks whether the app crashed on its previous run.
*
* @return true if a crash was recorded during the previous run of the app.
* @return true if a crash was recorded during the previous run of the app. May not be current.
* @deprecated May not be current. Use didCrashOnPreviousRun instead. Will be removed in Q2 2025.
*/
@Discouraged(message = "May not be current. Use didCrashOnPreviousRun instead.")
@Deprecated
public boolean didCrashOnPreviousExecution() {
return core.didCrashOnPreviousExecution();
}

/**
* Checks whether the app crashed on its previous run.
*
* @return A Task that resolves to true if a crash was recorded during the previous run of the app
*/
public Task<Boolean> didCrashOnPreviousRun() {
return core.didCrashOnPreviousRun();
}

/**
* Indicates whether or not automatic data collection is enabled
*
* @return In order of priority:
* @return A Task that resolved in order of priority:
* <p>If {@link #setCrashlyticsCollectionEnabled(boolean)} is called with a value, use it
* <p>If the <b>firebase_crashlytics_collection_enabled</b> key is in your app’s
* AndroidManifest.xml, use it
* <p>Otherwise, use the default {@link FirebaseApp#isDataCollectionDefaultEnabled()} in
* FirebaseApp
*/
public boolean isCrashlyticsCollectionEnabled() {
public Task<Boolean> isCrashlyticsCollectionEnabled() {
return core.isCrashlyticsCollectionEnabled();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ private Task<Void> doBackgroundInitialization(SettingsProvider settingsProvider)

// endregion

public boolean isCrashlyticsCollectionEnabled() {
return dataCollectionArbiter.isAutomaticDataCollectionEnabled();
public Task<Boolean> isCrashlyticsCollectionEnabled() {
// TODO(mrober): Does Unity or Flutter call this method?
return Tasks.forResult(dataCollectionArbiter.isAutomaticDataCollectionEnabled());
}

public void setCrashlyticsCollectionEnabled(@Nullable Boolean enabled) {
Expand Down Expand Up @@ -514,10 +515,16 @@ private void checkForPreviousCrash() {
didCrashOnPreviousExecution = Boolean.TRUE.equals(result);
}

@Deprecated
public boolean didCrashOnPreviousExecution() {
// TODO(mrober): Is this boolean always accurate?
return didCrashOnPreviousExecution;
}

public Task<Boolean> didCrashOnPreviousRun() {
return Tasks.forResult(didCrashOnPreviousExecution);
}

// endregion

// region Static utilities
Expand Down

0 comments on commit 26338c7

Please sign in to comment.