package com.bytedance.sdk.component.adexpress.fm.ro;

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

/* JADX INFO: loaded from: classes.dex */
public class wu {
    private static com.bytedance.sdk.component.adexpress.fm.lb.fm fm;

    public static void fm() {
        FileInputStream fileInputStream = null;
        try {
            File file = new File(jnr.wu(), "temp_pkg_info.json");
            Long lValueOf = Long.valueOf(file.length());
            if (lValueOf.longValue() > 0 && file.exists() && file.isFile()) {
                byte[] bArr = new byte[lValueOf.intValue()];
                FileInputStream fileInputStream2 = new FileInputStream(file);
                try {
                    fileInputStream2.read(bArr);
                    com.bytedance.sdk.component.adexpress.fm.lb.fm fmVarFm = com.bytedance.sdk.component.adexpress.fm.lb.fm.fm(new JSONObject(new String(bArr, "utf-8")));
                    if (fmVarFm != null) {
                        fm = fmVarFm;
                        fmVarFm.lb();
                    }
                    fileInputStream = fileInputStream2;
                } catch (Throwable unused) {
                    fileInputStream = fileInputStream2;
                    if (fileInputStream != null) {
                        try {
                            fileInputStream.close();
                            return;
                        } catch (IOException unused2) {
                            return;
                        }
                    }
                    return;
                }
            }
            if (fileInputStream != null) {
                try {
                    fileInputStream.close();
                } catch (IOException unused3) {
                }
            }
        } catch (Throwable unused4) {
        }
    }

    public static void lb() {
        lb.fm(jnr.wu(), ro(), "temp_pkg_info.json");
    }

    public static synchronized com.bytedance.sdk.component.adexpress.fm.lb.fm ro() {
        return fm;
    }

    public static void yz() {
        lb.ro(jnr.wu(), ro(), "temp_pkg_info.json");
        fm = null;
    }

    public static boolean ro(com.bytedance.sdk.component.adexpress.fm.lb.fm fmVar) {
        return lb.lb(ro(), fmVar);
    }

    public static synchronized void fm(com.bytedance.sdk.component.adexpress.fm.lb.fm fmVar) {
        if (fmVar != null) {
            if (fmVar.wu()) {
                fm = fmVar;
            }
        }
    }

    public static boolean fm(String str) {
        return lb.fm(ro(), str);
    }
}
