what-the-bank/sources/com/google/firebase/crashlytics/internal/settings/CachedSettingsIo.java

103 lines
4.0 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.crashlytics.internal.settings;
import android.content.Context;
import com.google.firebase.crashlytics.internal.Logger;
import com.google.firebase.crashlytics.internal.common.CommonUtils;
import com.google.firebase.crashlytics.internal.persistence.FileStoreImpl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import org.json.JSONObject;
/* loaded from: classes2.dex */
public class CachedSettingsIo {
private static final String SETTINGS_CACHE_FILENAME = "com.crashlytics.settings.json";
private final Context context;
public CachedSettingsIo(Context context) {
this.context = context;
}
private File getSettingsFile() {
return new File(new FileStoreImpl(this.context).getFilesDir(), SETTINGS_CACHE_FILENAME);
}
/* JADX WARN: Not initialized variable reg: 3, insn: 0x004a: MOVE (r1 I:??[OBJECT, ARRAY]) = (r3 I:??[OBJECT, ARRAY]), block:B:20:0x0049 */
public JSONObject readCachedSettings() {
FileInputStream fileInputStream;
FileInputStream fileInputStream2;
JSONObject jSONObject;
Logger.getLogger().d("Reading cached settings...");
FileInputStream fileInputStream3 = null;
try {
try {
File settingsFile = getSettingsFile();
if (settingsFile.exists()) {
fileInputStream = new FileInputStream(settingsFile);
try {
jSONObject = new JSONObject(CommonUtils.streamToString(fileInputStream));
fileInputStream3 = fileInputStream;
} catch (Exception e) {
e = e;
Logger.getLogger().e("Failed to fetch cached settings", e);
CommonUtils.closeOrLog(fileInputStream, "Error while closing settings cache file.");
return null;
}
} else {
Logger.getLogger().d("No cached settings found.");
jSONObject = null;
}
CommonUtils.closeOrLog(fileInputStream3, "Error while closing settings cache file.");
return jSONObject;
} catch (Throwable th) {
th = th;
fileInputStream3 = fileInputStream2;
CommonUtils.closeOrLog(fileInputStream3, "Error while closing settings cache file.");
throw th;
}
} catch (Exception e2) {
e = e2;
fileInputStream = null;
} catch (Throwable th2) {
th = th2;
CommonUtils.closeOrLog(fileInputStream3, "Error while closing settings cache file.");
throw th;
}
}
public void writeCachedSettings(long j, JSONObject jSONObject) {
Throwable th;
FileWriter fileWriter;
Exception e;
Logger.getLogger().d("Writing settings to cache file...");
if (jSONObject != null) {
FileWriter fileWriter2 = null;
try {
try {
jSONObject.put("expires_at", j);
fileWriter = new FileWriter(getSettingsFile());
} catch (Exception e2) {
e = e2;
}
} catch (Throwable th2) {
th = th2;
fileWriter = fileWriter2;
}
try {
fileWriter.write(jSONObject.toString());
fileWriter.flush();
CommonUtils.closeOrLog(fileWriter, "Failed to close settings writer.");
} catch (Exception e3) {
e = e3;
fileWriter2 = fileWriter;
Logger.getLogger().e("Failed to cache settings", e);
CommonUtils.closeOrLog(fileWriter2, "Failed to close settings writer.");
} catch (Throwable th3) {
th = th3;
CommonUtils.closeOrLog(fileWriter, "Failed to close settings writer.");
throw th;
}
}
}
}