package defpackage;

import java.io.File;
import java.io.FileInputStream;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public class fr0 {
    public final File a;

    public fr0(oy2 oy2Var) {
        this.a = new File(oy2Var.c, "com.crashlytics.settings.json");
    }

    public final JSONObject a() throws Throwable {
        FileInputStream fileInputStream;
        Throwable th;
        JSONObject jSONObject;
        FileInputStream fileInputStream2 = null;
        try {
            File file = this.a;
            if (file.exists()) {
                fileInputStream = new FileInputStream(file);
                try {
                    try {
                        jSONObject = new JSONObject(c71.i(fileInputStream));
                        fileInputStream2 = fileInputStream;
                    } catch (Exception e) {
                        e = e;
                        hh5.a.a("Failed to fetch cached settings", e);
                        c71.b(fileInputStream, "Error while closing settings cache file.");
                        return null;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    c71.b(fileInputStream, "Error while closing settings cache file.");
                    throw th;
                }
            } else {
                jSONObject = null;
            }
            c71.b(fileInputStream2, "Error while closing settings cache file.");
            return jSONObject;
        } catch (Exception e2) {
            e = e2;
            fileInputStream = null;
        } catch (Throwable th3) {
            fileInputStream = null;
            th = th3;
            c71.b(fileInputStream, "Error while closing settings cache file.");
            throw th;
        }
    }
}
