use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project GreenHouse by utsanjan.
the class CrashlyticsController method defaultReportUploader.
private ReportUploader.Provider defaultReportUploader() {
return new // from class: com.google.firebase.crashlytics.internal.common.CrashlyticsController.9
ReportUploader.Provider() {
// com.google.firebase.crashlytics.internal.report.ReportUploader.Provider
@Override
public ReportUploader createReportUploader(AppSettingsData appSettingsData) {
String reportsUrl = appSettingsData.reportsUrl;
String ndkReportsUrl = appSettingsData.ndkReportsUrl;
String organizationId = appSettingsData.organizationId;
CreateReportSpiCall call = CrashlyticsController.this.getCreateReportSpiCall(reportsUrl, ndkReportsUrl);
return new ReportUploader(organizationId, CrashlyticsController.this.appData.googleAppId, DataTransportState.getState(appSettingsData), CrashlyticsController.this.reportManager, call, CrashlyticsController.this.handlingExceptionCheck);
}
};
}
use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project GreenHouse by utsanjan.
the class CrashlyticsController method handleUncaughtException.
synchronized void handleUncaughtException(final SettingsDataProvider settingsDataProvider, final Thread thread, final Throwable ex) {
Logger logger = Logger.getLogger();
logger.d("Crashlytics is handling uncaught exception \"" + ex + "\" from thread " + thread.getName());
final Date time = new Date();
final Task<Void> recordFatalFirebaseEventTask = recordFatalFirebaseEvent(time.getTime());
Task<Void> handleUncaughtExceptionTask = this.backgroundWorker.submitTask(new // from class: com.google.firebase.crashlytics.internal.common.CrashlyticsController.6
Callable<Task<Void>>() {
/* JADX WARN: Can't rename method to resolve collision */
// java.util.concurrent.Callable
@Override
public Task<Void> call() throws Exception {
CrashlyticsController.this.crashMarker.create();
long timestampSeconds = CrashlyticsController.getTimestampSeconds(time);
CrashlyticsController.this.reportingCoordinator.persistFatalEvent(ex, thread, timestampSeconds);
CrashlyticsController.this.writeFatal(thread, ex, timestampSeconds);
Settings settings = settingsDataProvider.getSettings();
int maxCustomExceptionEvents = settings.getSessionData().maxCustomExceptionEvents;
int maxCompleteSessionsCount = settings.getSessionData().maxCompleteSessionsCount;
CrashlyticsController.this.doCloseSessions(maxCustomExceptionEvents);
CrashlyticsController.this.doOpenSession();
CrashlyticsController.this.trimSessionFiles(maxCompleteSessionsCount);
if (!CrashlyticsController.this.dataCollectionArbiter.isAutomaticDataCollectionEnabled()) {
return Tasks.forResult(null);
}
final Executor executor = CrashlyticsController.this.backgroundWorker.getExecutor();
return settingsDataProvider.getAppSettings().onSuccessTask(executor, new // from class: com.google.firebase.crashlytics.internal.common.CrashlyticsController.6.1
SuccessContinuation<AppSettingsData, Void>() {
public Task<Void> then(AppSettingsData appSettingsData) throws Exception {
if (appSettingsData == null) {
Logger.getLogger().w("Received null app settings, cannot send reports at crash time.");
return Tasks.forResult(null);
}
CrashlyticsController.this.sendSessionReports(appSettingsData, true);
return Tasks.whenAll(CrashlyticsController.this.reportingCoordinator.sendReports(executor, DataTransportState.getState(appSettingsData)), recordFatalFirebaseEventTask);
}
});
}
});
try {
Utils.awaitEvenIfOnMainThread(handleUncaughtExceptionTask);
} catch (Exception e) {
}
}
use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project firebase-android-sdk by firebase.
the class CrashlyticsController method submitAllReports.
Task<Void> submitAllReports(Task<AppSettingsData> appSettingsDataTask) {
if (!reportingCoordinator.hasReportsToSend()) {
// Just notify the user that there are no reports and stop.
Logger.getLogger().v("No crash reports are available to be sent.");
unsentReportsAvailable.trySetResult(false);
return Tasks.forResult(null);
}
Logger.getLogger().v("Crash reports are available to be sent.");
return waitForReportAction().onSuccessTask(new SuccessContinuation<Boolean, Void>() {
@NonNull
@Override
public Task<Void> then(@Nullable Boolean send) throws Exception {
return backgroundWorker.submitTask(new Callable<Task<Void>>() {
@Override
public Task<Void> call() throws Exception {
if (!send) {
Logger.getLogger().v("Deleting cached crash reports...");
deleteFiles(listAppExceptionMarkerFiles());
reportingCoordinator.removeAllReports();
unsentReportsHandled.trySetResult(null);
return Tasks.forResult(null);
}
Logger.getLogger().d("Sending cached crash reports...");
// waitForReportAction guarantees we got user permission.
boolean dataCollectionToken = send;
// Signal to the settings fetch and onboarding that we have explicit
// permission.
dataCollectionArbiter.grantDataCollectionPermission(dataCollectionToken);
Executor executor = backgroundWorker.getExecutor();
return appSettingsDataTask.onSuccessTask(executor, new SuccessContinuation<AppSettingsData, Void>() {
@NonNull
@Override
public Task<Void> then(@Nullable AppSettingsData appSettingsData) throws Exception {
if (appSettingsData == null) {
Logger.getLogger().w("Received null app settings at app startup. Cannot send cached reports");
return Tasks.forResult(null);
}
logAnalyticsAppExceptionEvents();
reportingCoordinator.sendReports(executor);
unsentReportsHandled.trySetResult(null);
return Tasks.forResult(null);
}
});
}
});
}
});
}
use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project firebase-android-sdk by firebase.
the class DefaultSettingsJsonTransform method defaultSettings.
/**
* Creates a new Settings with reasonable default values.
*/
static Settings defaultSettings(CurrentTimeProvider currentTimeProvider) {
final int settingsVersion = SettingsJsonConstants.SETTINGS_VERSION_DEFAULT;
final int cacheDuration = SettingsJsonConstants.SETTINGS_CACHE_DURATION_DEFAULT;
JSONObject empty = new JSONObject();
final AppSettingsData appData = null;
final SessionSettingsData settingsData = buildSessionDataFrom(empty);
final FeaturesSettingsData featureData = buildFeaturesSessionDataFrom(empty);
final long expiresAtMillis = getExpiresAtFrom(currentTimeProvider, cacheDuration, empty);
return new SettingsData(expiresAtMillis, appData, settingsData, featureData, settingsVersion, cacheDuration);
}
use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project firebase-android-sdk by firebase.
the class SettingsController method loadSettingsData.
/**
* Kicks off loading settings either from the cache or the network.
*
* @return a task that is resolved when loading is completely finished.
*/
public Task<Void> loadSettingsData(SettingsCacheBehavior cacheBehavior, Executor executor) {
// backend will know about it.
if (!buildInstanceIdentifierChanged()) {
final SettingsData cachedSettings = getCachedSettingsData(cacheBehavior);
if (cachedSettings != null) {
settings.set(cachedSettings);
appSettingsData.get().trySetResult(cachedSettings.getAppSettingsData());
return Tasks.forResult(null);
}
}
// SKIP_CACHE doesn't actually skip the cache completely; it just skips the first lookup, since
// we are doing the cache lookup again here with IGNORE_CACHE_EXPIRATION.
// This has been true in production for some time, though, so no rush to "fix" it.
// The cached settings are too old, so if there are expired settings, use those for now.
final SettingsData expiredSettings = getCachedSettingsData(SettingsCacheBehavior.IGNORE_CACHE_EXPIRATION);
if (expiredSettings != null) {
settings.set(expiredSettings);
appSettingsData.get().trySetResult(expiredSettings.getAppSettingsData());
}
// Kick off fetching fresh settings.
return dataCollectionArbiter.waitForDataCollectionPermission(executor).onSuccessTask(executor, new SuccessContinuation<Void, Void>() {
@NonNull
@Override
public Task<Void> then(@Nullable Void aVoid) throws Exception {
// Waited for data collection permission, so this is safe.
final boolean dataCollectionToken = true;
final JSONObject settingsJson = settingsSpiCall.invoke(settingsRequest, dataCollectionToken);
if (settingsJson != null) {
final SettingsData fetchedSettings = settingsJsonParser.parseSettingsJson(settingsJson);
cachedSettingsIo.writeCachedSettings(fetchedSettings.getExpiresAtMillis(), settingsJson);
logSettings(settingsJson, "Loaded settings: ");
setStoredBuildInstanceIdentifier(settingsRequest.instanceId);
// Update the regular settings.
settings.set(fetchedSettings);
// Signal the app settings on any Tasks that already exist, and then replace the
// task so
// that any new callers get the new app settings instead of any old ones.
appSettingsData.get().trySetResult(fetchedSettings.getAppSettingsData());
TaskCompletionSource<AppSettingsData> fetchedAppSettings = new TaskCompletionSource<>();
fetchedAppSettings.trySetResult(fetchedSettings.getAppSettingsData());
appSettingsData.set(fetchedAppSettings);
}
return Tasks.forResult(null);
}
});
}
Aggregations