package com.ss.android.medialib;

import X.7lW;
import X.8XX;
import X.C0347IDi;
import android.content.Context;
import android.content.res.AssetManager;
import com.bef.effectsdk.FileResourceFinder;
import com.bef.effectsdk.ResourceFinder;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;

public final class VideoSdkCore {
    public static Context APPLICATION_CONTEXT = null;
    public static final String TAG = VideoSdkCore.class.getSimpleName();
    public static boolean inited = false;
    public static ResourceFinder sFinder = new FileResourceFinder("");

    public static native String nativeGetString(String str);

    public static native void nativeSetAssertManagerFromJava(AssetManager assetManager);

    public static native void nativeSetBoolean(String str, boolean z);

    public static native void nativeSetInt(String str, int i);

    public static native void nativeSetString(String str, String str2);

    public static String getSdkVersionCode() {
        MethodCollector.i(17643);
        String nativeGetString = nativeGetString("VersionCode");
        MethodCollector.o(17643);
        return nativeGetString;
    }

    public static String getSdkVersionName() {
        MethodCollector.i(17642);
        String nativeGetString = nativeGetString("VersionName");
        MethodCollector.o(17642);
        return nativeGetString;
    }

    static {
        Covode.recordClassIndex(48506);
        8XX.LIZLLL();
    }

    public static Context INVOKEVIRTUAL_com_ss_android_medialib_VideoSdkCore_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(Context context) {
        Context applicationContext = context.getApplicationContext();
        if (7lW.LIZJ && applicationContext == null) {
            return 7lW.LIZ;
        }
        return applicationContext;
    }

    public static void enableEffectAudioManagerCallback(boolean z) {
        MethodCollector.i(17638);
        nativeSetBoolean("enableEffectAudioManagerCallback", z);
        MethodCollector.o(17638);
    }

    public static void enableGLES3(boolean z) {
        MethodCollector.i(17316);
        nativeSetBoolean("GLES3", z);
        MethodCollector.o(17316);
    }

    public static void enableMakeupSegmentation(boolean z) {
        MethodCollector.i(17637);
        nativeSetBoolean("enableMakeupSegmentation", z);
        MethodCollector.o(17637);
    }

    public static void setABbUseBuildinAmazing(boolean z) {
        MethodCollector.i(17640);
        nativeSetBoolean("ABbUseBuildinAmazing", z);
        MethodCollector.o(17640);
    }

    public static void setAmazingShareDir(String str) {
        MethodCollector.i(17318);
        nativeSetString("AmazingShareDir", str);
        MethodCollector.o(17318);
    }

    public static void setEffectJsonConfig(String str) {
        MethodCollector.i(17639);
        nativeSetString("EffectJsonConfig", str);
        MethodCollector.o(17639);
    }

    public static void setEffectLogLevel(int i) {
        MethodCollector.i(17635);
        nativeSetInt("EffectLogLevel", i);
        MethodCollector.o(17635);
    }

    public static void setEffectMaxMemoryCache(int i) {
        MethodCollector.i(17636);
        nativeSetInt("EffectMaxMemoryCache", i);
        MethodCollector.o(17636);
    }

    public static void setEnableAssetManager(boolean z) {
        MethodCollector.i(17641);
        nativeSetBoolean("AssertManagerEnable", z);
        MethodCollector.o(17641);
    }

    public static void setProduct(int i) {
        MethodCollector.i(17315);
        nativeSetInt("Product", i);
        MethodCollector.o(17315);
    }

    public static long getNativeFinder(long j) {
        if (j == 0) {
            C0347IDi.LIZLLL(TAG, "getNativeFinder effectHandler is null");
            return 0;
        }
        ResourceFinder resourceFinder = sFinder;
        if (resourceFinder != null) {
            return resourceFinder.createNativeResourceFinder(j);
        }
        C0347IDi.LIZLLL(TAG, "Error call finder related interface.");
        return 0;
    }

    public static void releaseNativeFinder(long j) {
        if (j == 0) {
            C0347IDi.LIZLLL(TAG, "getNativeFinder effectHandler is null");
            return;
        }
        ResourceFinder resourceFinder = sFinder;
        if (resourceFinder == null) {
            C0347IDi.LIZLLL(TAG, "Error call finder related interface.");
        } else {
            resourceFinder.release(j);
        }
    }

    public static void setResourceFinder(ResourceFinder resourceFinder) {
        MethodCollector.i(17317);
        sFinder = resourceFinder;
        nativeSetBoolean("ResourceFinderEnable", true);
        MethodCollector.o(17317);
    }

    public static void init(Context context) {
        MethodCollector.i(17219);
        if (!inited) {
            synchronized (VideoSdkCore.class) {
                try {
                    if (!inited) {
                        APPLICATION_CONTEXT = INVOKEVIRTUAL_com_ss_android_medialib_VideoSdkCore_com_ss_android_ugc_aweme_lancet_launch_ApplicationContextLancet_getApplicationContext(context);
                        nativeSetAssertManagerFromJava(context.getAssets());
                        inited = true;
                    }
                } finally {
                    MethodCollector.o(17219);
                }
            }
            return;
        }
        MethodCollector.o(17219);
    }
}
