Search in sources :

Example 6 with AppSettingsData

use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project firebase-android-sdk by firebase.

the class SettingsV3JsonTransform method buildFromJson.

@Override
public SettingsData buildFromJson(CurrentTimeProvider currentTimeProvider, JSONObject json) throws JSONException {
    final int settingsVersion = json.optInt(SettingsJsonConstants.SETTINGS_VERSION, SettingsJsonConstants.SETTINGS_VERSION_DEFAULT);
    final int cacheDuration = json.optInt(SettingsJsonConstants.CACHE_DURATION_KEY, SettingsJsonConstants.SETTINGS_CACHE_DURATION_DEFAULT);
    final AppSettingsData appData = buildAppDataFrom(json.getJSONObject(SettingsJsonConstants.FABRIC_KEY), json.getJSONObject(SettingsJsonConstants.APP_KEY));
    final SessionSettingsData sessionData = defaultSessionData();
    final FeaturesSettingsData featureData = buildFeaturesSessionDataFrom(json.getJSONObject(SettingsJsonConstants.FEATURES_KEY));
    final long expiresAtMillis = getExpiresAtFrom(currentTimeProvider, cacheDuration, json);
    return new SettingsData(expiresAtMillis, appData, sessionData, featureData, settingsVersion, cacheDuration);
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData) SettingsData(com.google.firebase.crashlytics.internal.settings.model.SettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)

Example 7 with AppSettingsData

use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project GreenHouse by utsanjan.

the class DefaultSettingsJsonTransform method buildFromJson.

// com.google.firebase.crashlytics.internal.settings.SettingsJsonTransform
@Override
public SettingsData buildFromJson(CurrentTimeProvider currentTimeProvider, JSONObject json) throws JSONException {
    int settingsVersion = json.optInt("settings_version", 0);
    int cacheDuration = json.optInt("cache_duration", 3600);
    AppSettingsData appData = buildAppDataFrom(json.getJSONObject("app"));
    SessionSettingsData settingsData = buildSessionDataFrom(json.getJSONObject("session"));
    FeaturesSettingsData featureData = buildFeaturesSessionDataFrom(json.getJSONObject("features"));
    long expiresAtMillis = getExpiresAtFrom(currentTimeProvider, cacheDuration, json);
    return new SettingsData(expiresAtMillis, appData, settingsData, featureData, settingsVersion, cacheDuration);
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData) SettingsData(com.google.firebase.crashlytics.internal.settings.model.SettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)

Example 8 with AppSettingsData

use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project GreenHouse by utsanjan.

the class SettingsController method loadSettingsData.

public Task<Void> loadSettingsData(SettingsCacheBehavior cacheBehavior, Executor executor) {
    SettingsData cachedSettings;
    if (buildInstanceIdentifierChanged() || (cachedSettings = getCachedSettingsData(cacheBehavior)) == null) {
        SettingsData expiredSettings = getCachedSettingsData(SettingsCacheBehavior.IGNORE_CACHE_EXPIRATION);
        if (expiredSettings != null) {
            this.settings.set(expiredSettings);
            this.appSettingsData.get().trySetResult(expiredSettings.getAppSettingsData());
        }
        return this.dataCollectionArbiter.waitForDataCollectionPermission().onSuccessTask(executor, new // from class: com.google.firebase.crashlytics.internal.settings.SettingsController.1
        SuccessContinuation<Void, Void>() {

            public Task<Void> then(Void aVoid) throws Exception {
                JSONObject settingsJson = SettingsController.this.settingsSpiCall.invoke(SettingsController.this.settingsRequest, true);
                if (settingsJson != null) {
                    SettingsData fetchedSettings = SettingsController.this.settingsJsonParser.parseSettingsJson(settingsJson);
                    SettingsController.this.cachedSettingsIo.writeCachedSettings(fetchedSettings.getExpiresAtMillis(), settingsJson);
                    SettingsController.this.logSettings(settingsJson, "Loaded settings: ");
                    SettingsController settingsController = SettingsController.this;
                    settingsController.setStoredBuildInstanceIdentifier(settingsController.settingsRequest.instanceId);
                    SettingsController.this.settings.set(fetchedSettings);
                    ((TaskCompletionSource) SettingsController.this.appSettingsData.get()).trySetResult(fetchedSettings.getAppSettingsData());
                    TaskCompletionSource<AppSettingsData> fetchedAppSettings = new TaskCompletionSource<>();
                    fetchedAppSettings.trySetResult(fetchedSettings.getAppSettingsData());
                    SettingsController.this.appSettingsData.set(fetchedAppSettings);
                }
                return Tasks.forResult(null);
            }
        });
    }
    this.settings.set(cachedSettings);
    this.appSettingsData.get().trySetResult(cachedSettings.getAppSettingsData());
    return Tasks.forResult(null);
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) SettingsData(com.google.firebase.crashlytics.internal.settings.model.SettingsData) TaskCompletionSource(com.google.android.gms.tasks.TaskCompletionSource) Task(com.google.android.gms.tasks.Task) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException)

Example 9 with AppSettingsData

use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project GreenHouse by utsanjan.

the class SettingsV3JsonTransform method buildFromJson.

// com.google.firebase.crashlytics.internal.settings.SettingsJsonTransform
@Override
public SettingsData buildFromJson(CurrentTimeProvider currentTimeProvider, JSONObject json) throws JSONException {
    int settingsVersion = json.optInt("settings_version", 0);
    int cacheDuration = json.optInt("cache_duration", 3600);
    AppSettingsData appData = buildAppDataFrom(json.getJSONObject("fabric"), json.getJSONObject("app"));
    SessionSettingsData sessionData = defaultSessionData();
    FeaturesSettingsData featureData = buildFeaturesSessionDataFrom(json.getJSONObject("features"));
    long expiresAtMillis = getExpiresAtFrom(currentTimeProvider, cacheDuration, json);
    return new SettingsData(expiresAtMillis, appData, sessionData, featureData, settingsVersion, cacheDuration);
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData) SettingsData(com.google.firebase.crashlytics.internal.settings.model.SettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)

Example 10 with AppSettingsData

use of com.google.firebase.crashlytics.internal.settings.model.AppSettingsData in project firebase-android-sdk by firebase.

the class DefaultSettingsJsonTransform method buildFromJson.

@Override
public SettingsData buildFromJson(CurrentTimeProvider currentTimeProvider, JSONObject json) throws JSONException {
    final int settingsVersion = json.optInt(SettingsJsonConstants.SETTINGS_VERSION, SettingsJsonConstants.SETTINGS_VERSION_DEFAULT);
    final int cacheDuration = json.optInt(SettingsJsonConstants.CACHE_DURATION_KEY, SettingsJsonConstants.SETTINGS_CACHE_DURATION_DEFAULT);
    final AppSettingsData appData = buildAppDataFrom(json.getJSONObject(SettingsJsonConstants.APP_KEY));
    final SessionSettingsData settingsData = buildSessionDataFrom(json.getJSONObject(SettingsJsonConstants.SESSION_KEY));
    final FeaturesSettingsData featureData = buildFeaturesSessionDataFrom(json.getJSONObject(SettingsJsonConstants.FEATURES_KEY));
    final long expiresAtMillis = getExpiresAtFrom(currentTimeProvider, cacheDuration, json);
    return new SettingsData(expiresAtMillis, appData, settingsData, featureData, settingsVersion, cacheDuration);
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData) SettingsData(com.google.firebase.crashlytics.internal.settings.model.SettingsData) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)

Aggregations

AppSettingsData (com.google.firebase.crashlytics.internal.settings.model.AppSettingsData)10 SettingsData (com.google.firebase.crashlytics.internal.settings.model.SettingsData)7 FeaturesSettingsData (com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)5 SessionSettingsData (com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData)5 Task (com.google.android.gms.tasks.Task)4 JSONObject (org.json.JSONObject)3 NonNull (androidx.annotation.NonNull)2 TaskCompletionSource (com.google.android.gms.tasks.TaskCompletionSource)2 IOException (java.io.IOException)2 Executor (java.util.concurrent.Executor)2 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 JSONException (org.json.JSONException)2 SuccessContinuation (com.google.android.gms.tasks.SuccessContinuation)1 Logger (com.google.firebase.crashlytics.internal.Logger)1 NativeSessionFileProvider (com.google.firebase.crashlytics.internal.NativeSessionFileProvider)1 ReportUploader (com.google.firebase.crashlytics.internal.report.ReportUploader)1 CompositeCreateReportSpiCall (com.google.firebase.crashlytics.internal.report.network.CompositeCreateReportSpiCall)1 CreateReportSpiCall (com.google.firebase.crashlytics.internal.report.network.CreateReportSpiCall)1 DefaultCreateReportSpiCall (com.google.firebase.crashlytics.internal.report.network.DefaultCreateReportSpiCall)1