package com.bytedance.sdk.openadsdk.component;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bykv.vk.openvk.fm.fm.fm.lb.b;
import com.bytedance.sdk.component.jnr.irt;
import com.bytedance.sdk.component.jnr.ku;
import com.bytedance.sdk.component.jnr.vt;
import com.bytedance.sdk.component.jnr.wu;
import com.bytedance.sdk.component.utils.wey;
import com.bytedance.sdk.openadsdk.AdSlot;
import com.bytedance.sdk.openadsdk.CacheDirFactory;
import com.bytedance.sdk.openadsdk.common.ro;
import com.bytedance.sdk.openadsdk.core.fhx;
import com.bytedance.sdk.openadsdk.core.gof;
import com.bytedance.sdk.openadsdk.core.lse;
import com.bytedance.sdk.openadsdk.core.maa;
import com.bytedance.sdk.openadsdk.core.model.mq;
import com.bytedance.sdk.openadsdk.core.model.wbw;
import com.bytedance.sdk.openadsdk.utils.gof;
import com.bytedance.sdk.openadsdk.utils.mon;
import com.bytedance.sdk.openadsdk.utils.xgn;
import com.bytedance.sdk.openadsdk.utils.zan;
import defpackage.e;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONObject;
import u.a;

/* JADX INFO: loaded from: classes2.dex */
public class ajl {
    private static String fm = "openad_image_cache";
    private static volatile ajl ro;
    private final Context jnr;

    /* JADX INFO: renamed from: lb, reason: collision with root package name */
    private final com.bytedance.sdk.openadsdk.ro.ro f6864lb;
    private final lse<com.bytedance.sdk.openadsdk.yz.fm> yz;
    private final Map<String, AtomicInteger> ajl = new ConcurrentHashMap();
    private final Map<String, String> wsy = new ConcurrentHashMap();

    public interface fm {
        void fm();

        void fm(@Nullable com.bytedance.sdk.openadsdk.wey.fm.ro roVar);
    }

    public interface lb {
        void fm(Object obj);
    }

    public interface ro {
        void fm();

        void fm(int i10, String str);
    }

    private ajl(Context context) {
        if (context != null) {
            this.jnr = context.getApplicationContext();
        } else {
            this.jnr = gof.fm();
        }
        this.f6864lb = new com.bytedance.sdk.openadsdk.ro.ro(10, 8, true);
        this.yz = gof.lb();
        fm = e.o(new StringBuilder(), fm, "_p");
        com.bytedance.sdk.openadsdk.common.ro.fm("tt_openad_materialMeta_new", new ro.fm("tt_openad_materialMeta_new") { // from class: com.bytedance.sdk.openadsdk.component.ajl.1
            @Override // com.bytedance.sdk.openadsdk.common.ro.fm
            public String fm(String str) {
                return "tt_openad_materialMeta_new";
            }

            @Override // com.bytedance.sdk.openadsdk.common.ro.fm
            public String ro(String str) {
                return com.bytedance.sdk.openadsdk.gqi.yz.fm.ro("tt_openad_materialMeta_new", "material".concat(String.valueOf(str)), (String) null);
            }

            @Override // com.bytedance.sdk.openadsdk.common.ro.fm
            public void fm(AdSlot adSlot, String str, String str2) {
                com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad_materialMeta_new", "material".concat(String.valueOf(adSlot.getCodeId())), str);
            }
        });
    }

    private void ro(@NonNull final com.bytedance.sdk.openadsdk.core.model.lse lseVar, final AdSlot adSlot, final wbw wbwVar, final com.bytedance.sdk.openadsdk.core.model.fm fmVar) {
        if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr()) {
            fm(lseVar, adSlot, wbwVar, fmVar);
        }
        fm(lseVar, adSlot, wbwVar, new ro() { // from class: com.bytedance.sdk.openadsdk.component.ajl.7
            @Override // com.bytedance.sdk.openadsdk.component.ajl.ro
            public void fm() {
                if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr()) {
                    return;
                }
                ajl.this.fm(lseVar, adSlot, wbwVar, fmVar);
            }

            @Override // com.bytedance.sdk.openadsdk.component.ajl.ro
            public void fm(int i10, String str) {
                ajl.this.lb(adSlot);
            }
        });
    }

    private int yz(AdSlot adSlot) {
        StringBuilder sb = new StringBuilder("material_expiration_time");
        sb.append(adSlot.getCodeId());
        return com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", sb.toString(), -1L) == -1 ? 0 : 1;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void lb(AdSlot adSlot) {
        AtomicInteger atomicInteger = this.ajl.get(adSlot.getCodeId());
        if (atomicInteger == null) {
            atomicInteger = new AtomicInteger(0);
        } else {
            atomicInteger.decrementAndGet();
        }
        this.ajl.put(adSlot.getCodeId(), atomicInteger);
    }

    public static ajl fm(Context context) {
        if (ro == null) {
            synchronized (ajl.class) {
                try {
                    if (ro == null) {
                        ro = new ajl(context);
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        return ro;
    }

    public void ro(int i10) {
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "image_has_cached".concat(String.valueOf(i10)), Boolean.TRUE);
    }

    public boolean ro(AdSlot adSlot) {
        if (!com.bytedance.sdk.openadsdk.component.wsy.fm.jnr() && adSlot != null) {
            String codeId = adSlot.getCodeId();
            if (com.bytedance.sdk.openadsdk.component.wsy.fm.fm(adSlot) && !TextUtils.isEmpty(codeId)) {
                return this.wsy.containsKey(codeId);
            }
        }
        return false;
    }

    public static void fm(com.bytedance.sdk.openadsdk.core.model.lse lseVar, lb lbVar) {
        fm(lseVar, lbVar, 0);
    }

    private void lb(@NonNull final com.bytedance.sdk.openadsdk.core.model.lse lseVar, final AdSlot adSlot, final wbw wbwVar, final com.bytedance.sdk.openadsdk.core.model.fm fmVar) {
        if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr()) {
            fm(lseVar, adSlot, wbwVar, fmVar);
        }
        fm(lseVar, wbwVar, new fm() { // from class: com.bytedance.sdk.openadsdk.component.ajl.8
            @Override // com.bytedance.sdk.openadsdk.component.ajl.fm
            public void fm(com.bytedance.sdk.openadsdk.wey.fm.ro roVar) {
                if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr()) {
                    return;
                }
                ajl.this.fm(lseVar, adSlot, wbwVar, fmVar);
            }

            @Override // com.bytedance.sdk.openadsdk.component.ajl.fm
            public void fm() {
                ajl.this.lb(adSlot);
            }
        });
    }

    public static void fm(com.bytedance.sdk.openadsdk.core.model.lse lseVar, final lb lbVar, final int i10) {
        String str = lseVar.ex().f5926f;
        if (TextUtils.isEmpty(str)) {
            return;
        }
        vt vtVarYz = com.bytedance.sdk.openadsdk.vt.yz.fm(str).fm(lseVar.ex().f5922b).ro(lseVar.ex().f5921a).jnr(zan.jnr(gof.fm())).yz(zan.lb(gof.fm()));
        if (i10 > 0 && Build.VERSION.SDK_INT >= 26) {
            vtVarYz.lb(2).fm(new wu() { // from class: com.bytedance.sdk.openadsdk.component.ajl.4
                @Override // com.bytedance.sdk.component.jnr.wu
                public Bitmap fm(Bitmap bitmap) {
                    return com.bytedance.sdk.component.adexpress.yz.fm.fm(gof.fm(), bitmap, i10);
                }
            });
        } else {
            vtVarYz.lb(1);
        }
        vtVarYz.fm(new com.bytedance.sdk.openadsdk.vt.ro(lseVar, str, new irt() { // from class: com.bytedance.sdk.openadsdk.component.ajl.5
            @Override // com.bytedance.sdk.component.jnr.irt
            public void fm(int i11, String str2, @Nullable Throwable th) {
            }

            @Override // com.bytedance.sdk.component.jnr.irt
            public void fm(ku kuVar) {
                lb lbVar2;
                if (kuVar == null || kuVar.ro() == null || kuVar.lb() == null || (lbVar2 = lbVar) == null) {
                    return;
                }
                lbVar2.fm(kuVar.ro());
            }
        }));
    }

    private void ro(String str) {
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad_materialMeta_new", "material".concat(String.valueOf(str)));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad_materialMeta", "material".concat(String.valueOf(str)));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "material_expiration_time".concat(String.valueOf(str)));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "video_has_cached".concat(String.valueOf(str)));
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "image_has_cached".concat(String.valueOf(str)));
    }

    public String lb(int i10) {
        String strRo = com.bytedance.sdk.openadsdk.common.ro.fm("tt_openad_materialMeta_new").ro(String.valueOf(i10));
        long jFm = com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "material_expiration_time".concat(String.valueOf(i10)), -1L);
        if (System.currentTimeMillis() / 1000 < jFm) {
            return strRo;
        }
        if (jFm != -1) {
            fm(i10, (String) null);
            fm(strRo);
        }
        return null;
    }

    public File ro() {
        StringBuilder sbD = a.d(new File(CacheDirFactory.getRootDir()).getName(), "/");
        sbD.append(fm);
        return com.bytedance.sdk.component.utils.wsy.ro(gof.fm(), sbD.toString());
    }

    public void fm(final AdSlot adSlot) {
        Objects.toString(adSlot);
        if (adSlot == null || !TextUtils.isEmpty(adSlot.getBidAdm())) {
            return;
        }
        AtomicInteger atomicInteger = this.ajl.get(adSlot.getCodeId());
        if (atomicInteger == null) {
            atomicInteger = new AtomicInteger(0);
        }
        if (!com.bytedance.sdk.openadsdk.common.gof.fm().fm(adSlot.getCodeId(), atomicInteger.get(), atomicInteger.get() + yz(adSlot))) {
            com.bytedance.sdk.openadsdk.component.wsy.fm.wu();
            return;
        }
        atomicInteger.incrementAndGet();
        this.ajl.put(adSlot.getCodeId(), atomicInteger);
        final wbw wbwVar = new wbw();
        wbwVar.fm(mon.ro());
        wbwVar.ro(com.bytedance.sdk.openadsdk.component.wsy.fm.ro());
        wbwVar.ro(com.bytedance.sdk.openadsdk.component.wsy.fm.lb());
        mq mqVar = new mq();
        mqVar.ku = wbwVar;
        mqVar.yz = 2;
        mqVar.f7209ef = 2;
        this.yz.fm(adSlot, mqVar, 3, new maa() { // from class: com.bytedance.sdk.openadsdk.component.ajl.6
            @Override // com.bytedance.sdk.openadsdk.core.maa, com.bytedance.sdk.openadsdk.core.lse.fm
            public void fm(int i10, String str) {
                ajl.this.lb(adSlot);
                com.bytedance.sdk.openadsdk.component.yz.ro.fm(wbwVar, 100, 2);
            }

            @Override // com.bytedance.sdk.openadsdk.core.maa, com.bytedance.sdk.openadsdk.core.lse.fm
            public void fm(com.bytedance.sdk.openadsdk.core.model.fm fmVar, com.bytedance.sdk.openadsdk.core.model.lb lbVar) {
                ajl.this.fm(fmVar, lbVar, adSlot, wbwVar);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void fm(com.bytedance.sdk.openadsdk.core.model.fm fmVar, com.bytedance.sdk.openadsdk.core.model.lb lbVar, AdSlot adSlot, wbw wbwVar) {
        com.bytedance.sdk.openadsdk.component.yz.ro.fm(wbwVar, 100, 1);
        if (fmVar != null && fmVar.jnr() != null && !fmVar.jnr().isEmpty()) {
            com.bytedance.sdk.openadsdk.core.model.lse lseVar = fmVar.jnr().get(0);
            if (lseVar == null) {
                return;
            }
            if (lseVar.ol()) {
                fm(lseVar, adSlot, wbwVar, fmVar);
                return;
            } else if (com.bytedance.sdk.openadsdk.core.model.lse.jnr(lseVar)) {
                ro(lseVar, adSlot, wbwVar, fmVar);
                return;
            } else {
                lb(lseVar, adSlot, wbwVar, fmVar);
                return;
            }
        }
        lbVar.fm(-3);
        lbVar.lb(2);
        com.bytedance.sdk.openadsdk.core.model.lb.fm(lbVar);
    }

    public void fm(@NonNull com.bytedance.sdk.openadsdk.core.model.lse lseVar, AdSlot adSlot, wbw wbwVar, com.bytedance.sdk.openadsdk.core.model.fm fmVar) {
        if (wbwVar != null) {
            lseVar.lb(wbwVar.vt());
        }
        fm(new com.bytedance.sdk.openadsdk.component.jnr.fm(lseVar.pg(), lseVar, fmVar));
        com.bytedance.sdk.openadsdk.component.yz.ro.fm(lseVar, 1, wbwVar);
        lb(adSlot);
    }

    public void fm(@NonNull final com.bytedance.sdk.openadsdk.core.model.lse lseVar, AdSlot adSlot, final wbw wbwVar, final ro roVar) {
        final mon monVarRo = mon.ro();
        final int iPg = lseVar.pg();
        b bVarEx = lseVar.ex();
        String str = bVarEx.f5927g;
        String strC = bVarEx.c();
        if (TextUtils.isEmpty(strC)) {
            strC = com.bytedance.sdk.component.utils.jnr.fm(str);
        }
        final File fileFm = com.bytedance.sdk.openadsdk.component.wsy.fm.fm(strC);
        if (fileFm.exists()) {
            com.bytedance.sdk.openadsdk.component.wsy.fm.fm(fileFm);
            fm(iPg);
            long jYz = monVarRo.yz();
            if (wbwVar != null) {
                wbwVar.fm(jYz);
                wbwVar.fm(1);
            }
            roVar.fm();
            fm(lseVar, (lb) null);
            return;
        }
        if (gof.yz().nt(String.valueOf(iPg)) && !com.bytedance.sdk.component.utils.gof.yz(gof.fm())) {
            roVar.fm(100, "OnlyWifi");
            return;
        }
        com.bytedance.sdk.openadsdk.core.fhx.fm.ro roVarFm = com.bytedance.sdk.openadsdk.core.model.lse.fm(fileFm.getParent(), lseVar);
        roVarFm.fm("material_meta", lseVar);
        roVarFm.fm("ad_slot", adSlot);
        com.bytedance.sdk.openadsdk.core.fhx.jnr.fm.fm(roVarFm, new y5.a() { // from class: com.bytedance.sdk.openadsdk.component.ajl.9
            @Override // y5.a
            public void fm(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar, int i10) {
                ajl.this.fm(iPg);
                long jYz2 = monVarRo.yz();
                com.bytedance.sdk.openadsdk.component.yz.ro.ro(lseVar, jYz2, true);
                wbw wbwVar2 = wbwVar;
                if (wbwVar2 != null) {
                    wbwVar2.fm(jYz2);
                    wbwVar.fm(2);
                }
                roVar.fm();
                ajl.fm(lseVar, (lb) null);
            }

            @Override // y5.a
            public void ro(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar, int i10) {
            }

            @Override // y5.a
            public void fm(com.bykv.vk.openvk.fm.fm.fm.lb.lb lbVar, int i10, String str2) {
                long jYz2 = monVarRo.yz();
                com.bytedance.sdk.openadsdk.component.yz.ro.ro(lseVar, jYz2, false);
                wbw wbwVar2 = wbwVar;
                if (wbwVar2 != null) {
                    wbwVar2.fm(jYz2);
                }
                roVar.fm(i10, str2);
                try {
                    if (fileFm.exists() && fileFm.isFile()) {
                        com.bytedance.sdk.component.utils.wsy.lb(fileFm);
                    }
                } catch (Throwable unused) {
                }
            }
        });
    }

    public void fm(final com.bytedance.sdk.openadsdk.core.model.lse lseVar, final wbw wbwVar, final fm fmVar) {
        final mon monVarRo = mon.ro();
        final int iPg = lseVar.pg();
        com.bytedance.sdk.openadsdk.core.model.gof gofVar = lseVar.pyj().get(0);
        String strWsy = gofVar.wsy();
        String strFm = gofVar.fm();
        int iRo = gofVar.ro();
        int iLb = gofVar.lb();
        String strFm2 = TextUtils.isEmpty(strWsy) ? com.bytedance.sdk.component.utils.jnr.fm(strFm) : strWsy;
        if (TextUtils.isEmpty(strFm2) || strFm2.contains("../") || strFm2.contains("/") || strFm2.contains("..")) {
            if (fmVar != null) {
                fmVar.fm();
                return;
            }
            return;
        }
        File fileRo = com.bytedance.sdk.openadsdk.component.wsy.fm.ro(strFm2);
        String parent = fileRo != null ? fileRo.getParent() : null;
        if (fm(strFm, strWsy)) {
            ro(iPg);
            long jYz = monVarRo.yz();
            if (wbwVar != null) {
                wbwVar.fm(jYz);
                wbwVar.fm(1);
            }
            fmVar.fm(null);
            return;
        }
        com.bytedance.sdk.openadsdk.utils.gof.fm(new com.bytedance.sdk.openadsdk.wey.fm(strFm, gofVar.wsy()), iRo, iLb, new gof.fm() { // from class: com.bytedance.sdk.openadsdk.component.ajl.10
            @Override // com.bytedance.sdk.openadsdk.utils.gof.fm
            @MainThread
            public void fm(@NonNull com.bytedance.sdk.openadsdk.wey.fm.ro roVar) {
                if (!roVar.jnr()) {
                    com.bytedance.sdk.openadsdk.component.yz.ro.fm(lseVar, monVarRo.yz(), false);
                    fmVar.fm();
                    return;
                }
                ajl.this.ro(iPg);
                long jYz2 = monVarRo.yz();
                com.bytedance.sdk.openadsdk.component.yz.ro.fm(lseVar, jYz2, true);
                wbw wbwVar2 = wbwVar;
                if (wbwVar2 != null) {
                    wbwVar2.fm(jYz2);
                    wbwVar.fm(2);
                }
                fmVar.fm(roVar);
            }

            @Override // com.bytedance.sdk.openadsdk.utils.gof.fm
            @MainThread
            public void fm() {
                com.bytedance.sdk.openadsdk.component.yz.ro.fm(lseVar, monVarRo.yz(), false);
                fmVar.fm();
            }
        }, parent);
    }

    public void fm(int i10) {
        com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "video_has_cached".concat(String.valueOf(i10)), Boolean.TRUE);
    }

    public void fm(final com.bytedance.sdk.openadsdk.component.jnr.fm fmVar) {
        fhx.ro().post(new Runnable() { // from class: com.bytedance.sdk.openadsdk.component.ajl.11
            @Override // java.lang.Runnable
            public void run() {
                try {
                    com.bytedance.sdk.openadsdk.core.model.lse lseVarRo = fmVar.ro();
                    if (lseVarRo == null || com.bytedance.sdk.openadsdk.core.model.lse.ajl(lseVarRo) || lseVarRo.emt()) {
                        return;
                    }
                    if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr()) {
                        com.bytedance.sdk.openadsdk.common.gof.fm().fm(lseVarRo, fmVar.lb());
                        return;
                    }
                    if (ajl.this.ro(lseVarRo.cpu())) {
                        return;
                    }
                    ajl.this.fm(lseVarRo.cpu(), lseVarRo.ss());
                    com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad", "material_expiration_time" + fmVar.fm(), Long.valueOf(lseVarRo.cc()));
                    com.bytedance.sdk.openadsdk.common.ro.fm("tt_openad_materialMeta_new").fm(fmVar.ro().cpu(), fmVar.lb());
                } catch (Throwable unused) {
                }
            }
        });
    }

    public void fm(final String str) {
        xgn.fm(new com.bytedance.sdk.component.wu.ro.lb("opencache") { // from class: com.bytedance.sdk.openadsdk.component.ajl.2
            @Override // java.lang.Runnable
            public void run() {
                com.bytedance.sdk.openadsdk.core.model.fm fmVarRo;
                try {
                    if (TextUtils.isEmpty(str)) {
                        return;
                    }
                    JSONObject jSONObject = new JSONObject(str);
                    if (jSONObject.has("cypher")) {
                        jSONObject = com.bytedance.sdk.openadsdk.core.gof.lb().fm(jSONObject);
                    }
                    if (jSONObject == null || !jSONObject.has("creatives") || (fmVarRo = com.bytedance.sdk.openadsdk.core.model.fm.ro(jSONObject)) == null || !fmVarRo.ajl()) {
                        return;
                    }
                    com.bytedance.sdk.openadsdk.component.yz.ro.fm(fmVarRo.wsy());
                } catch (Throwable unused) {
                }
            }
        });
    }

    @Nullable
    public String fm(com.bytedance.sdk.openadsdk.core.model.lse lseVar) {
        if (lseVar != null && lseVar.ex() != null && !TextUtils.isEmpty(lseVar.ex().f5927g)) {
            String str = lseVar.ex().f5927g;
            String strC = lseVar.ex().c();
            if (TextUtils.isEmpty(strC)) {
                strC = com.bytedance.sdk.component.utils.jnr.fm(str);
            }
            File fileFm = com.bytedance.sdk.openadsdk.component.wsy.fm.fm(strC);
            if (fileFm.exists() && fileFm.isFile()) {
                return fileFm.getAbsolutePath();
            }
        }
        return null;
    }

    public boolean fm(String str, String str2) {
        boolean z10;
        String parent;
        String path;
        try {
            if (TextUtils.isEmpty(str2)) {
                str2 = com.bytedance.sdk.component.utils.jnr.fm(str);
            }
            if (!TextUtils.isEmpty(str2) && !str2.contains("../") && !str2.contains("/") && !str2.contains("..")) {
                File fileRo = com.bytedance.sdk.openadsdk.component.wsy.fm.ro(str2);
                InputStream inputStreamFm = com.bytedance.sdk.openadsdk.vt.yz.fm(str, str2);
                if (inputStreamFm != null) {
                    try {
                        inputStreamFm.close();
                    } catch (IOException e10) {
                        wey.lb("TTAppOpenAdCacheManager", e10.getMessage());
                    }
                    z10 = true;
                } else {
                    z10 = false;
                }
                if (!z10) {
                    if (fileRo != null) {
                        parent = fileRo.getParent();
                        path = fileRo.getPath();
                    } else {
                        parent = null;
                        path = null;
                    }
                    if (com.bytedance.sdk.openadsdk.vt.yz.fm(str, str2, parent)) {
                        return true;
                    }
                    if (!TextUtils.isEmpty(path)) {
                        if (new File(path).exists()) {
                            return true;
                        }
                    }
                }
                return z10;
            }
            return false;
        } catch (Exception e11) {
            wey.lb("TTAppOpenAdCacheManager", e11.getMessage());
            return false;
        }
    }

    public void fm(AdSlot adSlot, String str) {
        if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr() || adSlot == null || TextUtils.isEmpty(str)) {
            return;
        }
        String codeId = adSlot.getCodeId();
        boolean z10 = adSlot.getCacheScene() != 0;
        if (!com.bytedance.sdk.openadsdk.component.wsy.fm.fm(adSlot) || z10 || TextUtils.isEmpty(codeId)) {
            return;
        }
        this.wsy.put(codeId, str);
    }

    public void fm(int i10, String str) {
        String strValueOf = String.valueOf(i10);
        if (com.bytedance.sdk.openadsdk.component.wsy.fm.jnr()) {
            com.bytedance.sdk.openadsdk.common.gof.fm().fm(strValueOf, str);
            return;
        }
        if (this.wsy.size() != 0 && !TextUtils.isEmpty(str) && this.wsy.containsKey(strValueOf)) {
            if (this.wsy.containsValue(str)) {
                this.wsy.remove(strValueOf);
                ro(strValueOf);
                return;
            }
            return;
        }
        ro(strValueOf);
    }

    public void fm() {
        File[] fileArrListFiles;
        try {
            com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad_materialMeta");
            com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad_materialMeta_new");
            com.bytedance.sdk.openadsdk.gqi.yz.fm.fm("tt_openad");
        } catch (Throwable unused) {
        }
        try {
            File file = new File(CacheDirFactory.getRootDir());
            if (file.exists() && file.isDirectory() && (fileArrListFiles = file.listFiles(new FileFilter() { // from class: com.bytedance.sdk.openadsdk.component.ajl.3
                @Override // java.io.FileFilter
                public boolean accept(File file2) {
                    if (file2 == null) {
                        return false;
                    }
                    String name = file2.getName();
                    return name.contains(ajl.fm) || name.contains("openad_video_cache");
                }
            })) != null) {
                for (File file2 : fileArrListFiles) {
                    try {
                        com.bytedance.sdk.component.utils.wsy.lb(file2);
                    } catch (Throwable unused2) {
                    }
                }
            }
        } catch (Throwable unused3) {
        }
    }
}
