package com.bytedance.sdk.openadsdk;

import android.text.TextUtils;
import com.bytedance.sdk.component.utils.wsy;
import com.bytedance.sdk.openadsdk.core.gof;
import defpackage.e;
import e6.a;
import java.io.File;
import x5.b;

/* JADX INFO: loaded from: classes2.dex */
public class CacheDirFactory {
    public static volatile b MEDIA_CACHE_DIR = null;
    public static String ROOT_DIR = null;
    public static final int SPLASH_USE_INTERNAL_STORAGE = 1;
    private static String fm;

    private static b fm() {
        if (MEDIA_CACHE_DIR == null) {
            synchronized (CacheDirFactory.class) {
                try {
                    if (MEDIA_CACHE_DIR == null) {
                        a aVar = new a();
                        aVar.f25486a = "video_reward_full";
                        aVar.f25487b = "video_brand";
                        aVar.f25488c = "video_splash";
                        aVar.f25489d = "video_default";
                        aVar.f25490e = null;
                        aVar.f25491f = null;
                        aVar.f25492g = null;
                        aVar.f25493h = null;
                        aVar.f25494i = null;
                        MEDIA_CACHE_DIR = aVar;
                        aVar.f25490e = getRootDir();
                        ((a) MEDIA_CACHE_DIR).f();
                    }
                } catch (Throwable th) {
                    throw th;
                }
            }
        }
        return MEDIA_CACHE_DIR;
    }

    public static int getCacheType() {
        return 1;
    }

    public static String getDiskCacheDirPath(String str) {
        StringBuilder sb = new StringBuilder();
        sb.append(getRootDir());
        return e.o(sb, File.separator, str);
    }

    public static b getICacheDir(int i10) {
        return fm();
    }

    public static String getImageCacheDir(String str) {
        if (fm == null) {
            fm = getDiskCacheDirPath(str);
        }
        return fm;
    }

    public static String getRootDir() {
        if (!TextUtils.isEmpty(ROOT_DIR)) {
            return ROOT_DIR;
        }
        File fileFm = wsy.fm(gof.fm(), "tt_ad");
        if (fileFm.isFile()) {
            fileFm.delete();
        }
        if (!fileFm.exists()) {
            fileFm.mkdirs();
        }
        String absolutePath = fileFm.getAbsolutePath();
        ROOT_DIR = absolutePath;
        return absolutePath;
    }
}
