Search in sources :

Example 11 with SettingsData

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

the class DefaultSettingsJsonTransform method defaultSettings.

/* JADX INFO: Access modifiers changed from: package-private */
public static Settings defaultSettings(CurrentTimeProvider currentTimeProvider) {
    JSONObject empty = new JSONObject();
    SessionSettingsData settingsData = buildSessionDataFrom(empty);
    FeaturesSettingsData featureData = buildFeaturesSessionDataFrom(empty);
    long expiresAtMillis = getExpiresAtFrom(currentTimeProvider, 3600L, empty);
    return new SettingsData(expiresAtMillis, null, settingsData, featureData, 0, 3600);
}
Also used : 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) JSONObject(org.json.JSONObject) SessionSettingsData(com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData) FeaturesSettingsData(com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)

Example 12 with SettingsData

use of com.google.firebase.crashlytics.internal.settings.model.SettingsData 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 13 with SettingsData

use of com.google.firebase.crashlytics.internal.settings.model.SettingsData 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 14 with SettingsData

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

the class SettingsController method getCachedSettingsData.

private SettingsData getCachedSettingsData(SettingsCacheBehavior cacheBehavior) {
    SettingsData toReturn = null;
    try {
        if (!SettingsCacheBehavior.SKIP_CACHE_LOOKUP.equals(cacheBehavior)) {
            JSONObject settingsJson = this.cachedSettingsIo.readCachedSettings();
            if (settingsJson != null) {
                SettingsData settingsData = this.settingsJsonParser.parseSettingsJson(settingsJson);
                if (settingsData != null) {
                    logSettings(settingsJson, "Loaded cached settings: ");
                    long currentTimeMillis = this.currentTimeProvider.getCurrentTimeMillis();
                    if (!SettingsCacheBehavior.IGNORE_CACHE_EXPIRATION.equals(cacheBehavior) && settingsData.isExpired(currentTimeMillis)) {
                        Logger.getLogger().d("Cached settings have expired.");
                    }
                    toReturn = settingsData;
                    Logger.getLogger().d("Returning cached settings.");
                } else {
                    Logger.getLogger().e("Failed to parse cached settings data.", null);
                }
            } else {
                Logger.getLogger().d("No cached settings data found.");
            }
        }
    } catch (Exception e) {
        Logger.getLogger().e("Failed to get cached settings", e);
    }
    return toReturn;
}
Also used : AppSettingsData(com.google.firebase.crashlytics.internal.settings.model.AppSettingsData) SettingsData(com.google.firebase.crashlytics.internal.settings.model.SettingsData) JSONObject(org.json.JSONObject) JSONException(org.json.JSONException)

Example 15 with SettingsData

use of com.google.firebase.crashlytics.internal.settings.model.SettingsData 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)

Aggregations

SettingsData (com.google.firebase.crashlytics.internal.settings.model.SettingsData)19 AppSettingsData (com.google.firebase.crashlytics.internal.settings.model.AppSettingsData)18 FeaturesSettingsData (com.google.firebase.crashlytics.internal.settings.model.FeaturesSettingsData)15 SessionSettingsData (com.google.firebase.crashlytics.internal.settings.model.SessionSettingsData)15 JSONObject (org.json.JSONObject)15 JSONException (org.json.JSONException)3 Task (com.google.android.gms.tasks.Task)2 TaskCompletionSource (com.google.android.gms.tasks.TaskCompletionSource)2 NonNull (androidx.annotation.NonNull)1