jimu-decompiled/sources/io/fabric/sdk/android/services/settings/DefaultCachedSettingsIo.java
2025-05-13 19:24:51 +02:00

99 lines
3.9 KiB
Java

package io.fabric.sdk.android.services.settings;
import io.fabric.sdk.android.Fabric;
import io.fabric.sdk.android.Kit;
import io.fabric.sdk.android.services.common.CommonUtils;
import io.fabric.sdk.android.services.persistence.FileStoreImpl;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import org.json.JSONObject;
/* loaded from: classes2.dex */
class DefaultCachedSettingsIo implements CachedSettingsIo {
private final Kit a;
public DefaultCachedSettingsIo(Kit kit) {
this.a = kit;
}
/* JADX WARN: Not initialized variable reg: 4, insn: 0x005a: MOVE (r1 I:??[OBJECT, ARRAY]) = (r4 I:??[OBJECT, ARRAY]), block:B:20:0x0059 */
@Override // io.fabric.sdk.android.services.settings.CachedSettingsIo
public JSONObject a() {
FileInputStream fileInputStream;
FileInputStream fileInputStream2;
JSONObject jSONObject;
Fabric.g().d("Fabric", "Reading cached settings...");
FileInputStream fileInputStream3 = null;
try {
try {
File file = new File(new FileStoreImpl(this.a).a(), "com.crashlytics.settings.json");
if (file.exists()) {
fileInputStream = new FileInputStream(file);
try {
jSONObject = new JSONObject(CommonUtils.b(fileInputStream));
fileInputStream3 = fileInputStream;
} catch (Exception e) {
e = e;
Fabric.g().b("Fabric", "Failed to fetch cached settings", e);
CommonUtils.a((Closeable) fileInputStream, "Error while closing settings cache file.");
return null;
}
} else {
Fabric.g().d("Fabric", "No cached settings found.");
jSONObject = null;
}
CommonUtils.a((Closeable) fileInputStream3, "Error while closing settings cache file.");
return jSONObject;
} catch (Exception e2) {
e = e2;
fileInputStream = null;
} catch (Throwable th) {
th = th;
CommonUtils.a((Closeable) fileInputStream3, "Error while closing settings cache file.");
throw th;
}
} catch (Throwable th2) {
th = th2;
fileInputStream3 = fileInputStream2;
CommonUtils.a((Closeable) fileInputStream3, "Error while closing settings cache file.");
throw th;
}
}
@Override // io.fabric.sdk.android.services.settings.CachedSettingsIo
public void a(long j, JSONObject jSONObject) {
Fabric.g().d("Fabric", "Writing settings to cache file...");
if (jSONObject == null) {
return;
}
FileWriter fileWriter = null;
try {
try {
jSONObject.put("expires_at", j);
FileWriter fileWriter2 = new FileWriter(new File(new FileStoreImpl(this.a).a(), "com.crashlytics.settings.json"));
try {
fileWriter2.write(jSONObject.toString());
fileWriter2.flush();
CommonUtils.a(fileWriter2, "Failed to close settings writer.");
} catch (Exception e) {
e = e;
fileWriter = fileWriter2;
Fabric.g().b("Fabric", "Failed to cache settings", e);
CommonUtils.a(fileWriter, "Failed to close settings writer.");
} catch (Throwable th) {
th = th;
fileWriter = fileWriter2;
CommonUtils.a(fileWriter, "Failed to close settings writer.");
throw th;
}
} catch (Exception e2) {
e = e2;
}
} catch (Throwable th2) {
th = th2;
}
}
}