package com.bytedance.common.jato.fdio;

import X.C22708a5;
import X.C22718a6;
import X.C22728a7;
import X.C22738a8;
import X.C22878aM;
import X.C22968aV;
import android.os.Build;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import java.util.HashMap;
import java.util.Map;

public class FDIOPreloaderManager {
    public static Map<String, C22878aM> sCacheMap = new HashMap();

    public static native void nativePreloadAll(String str);

    static {
        Covode.recordClassIndex(24737);
    }

    public static void nativeIsMincoreValid(int i) {
        C22968aV.LIZIZ().execute(new C22738a8(i));
    }

    public static void nativePreloadCost(int i) {
        C22968aV.LIZIZ().execute(new C22728a7(i));
    }

    public static synchronized void preloadAll(String str) {
        synchronized (FDIOPreloaderManager.class) {
            MethodCollector.i(12943);
            nativePreloadAll(str);
            MethodCollector.o(12943);
        }
    }

    public static synchronized C22878aM getAndRemove(String str) {
        synchronized (FDIOPreloaderManager.class) {
            MethodCollector.i(12942);
            if (!sCacheMap.containsKey(str)) {
                MethodCollector.o(12942);
                return null;
            }
            C22878aM r1 = sCacheMap.get(str);
            sCacheMap.remove(str);
            MethodCollector.o(12942);
            return r1;
        }
    }

    public static synchronized FDIOCollector getCollector(String str) {
        synchronized (FDIOPreloaderManager.class) {
            MethodCollector.i(12450);
            if (Build.VERSION.SDK_INT <= 22) {
                MethodCollector.o(12450);
                return null;
            } else if (sCacheMap.containsKey(str)) {
                FDIOCollector fDIOCollector = (FDIOCollector) sCacheMap.get(str);
                MethodCollector.o(12450);
                return fDIOCollector;
            } else {
                FDIOCollector fDIOCollector2 = new FDIOCollector();
                sCacheMap.put(str, fDIOCollector2);
                MethodCollector.o(12450);
                return fDIOCollector2;
            }
        }
    }

    public static synchronized C22878aM getPreloader(String str) {
        synchronized (FDIOPreloaderManager.class) {
            MethodCollector.i(12712);
            if (Build.VERSION.SDK_INT <= 22) {
                MethodCollector.o(12712);
                return null;
            } else if (sCacheMap.containsKey(str)) {
                C22878aM r0 = sCacheMap.get(str);
                MethodCollector.o(12712);
                return r0;
            } else {
                FDIOPreloader fDIOPreloader = new FDIOPreloader();
                sCacheMap.put(str, fDIOPreloader);
                MethodCollector.o(12712);
                return fDIOPreloader;
            }
        }
    }

    public static void nativeCollectPageSize(int i, int i2) {
        C22968aV.LIZIZ().execute(new C22708a5(i, i2));
    }

    public static void nativePreloadPageSize(int i, int i2) {
        C22968aV.LIZIZ().execute(new C22718a6(i, i2));
    }
}
