const classJavaName = "com/anythink/cocosjs/ATJSBridge";

const ATAndroidJS = {
    printJsLog(msg: string | undefined | null): void {
        if (msg !== undefined && msg !== null) {
            jsb.reflection.callStaticMethod(
                "android/util/Log",
                "i",
                "(Ljava/lang/String;Ljava/lang/String;)I",
                "AT-Cocos-JS",
                msg
            );  
        }
    },

    initSDK(appid: string, appkey: string): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "initSDK",
            "(Ljava/lang/String;Ljava/lang/String;)V",
            appid,
            appkey
        );
    },

    initCustomMap(customMap: string): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "initCustomMap",
            "(Ljava/lang/String;)V",
            customMap
        );
    },

    setPlacementCustomMap(placementId: string, customMap: string): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "setPlacementCustomMap",
            "(Ljava/lang/String;Ljava/lang/String;)V",
            placementId,
            customMap
        );
    },

    setGDPRLevel(level: number): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "setGDPRLevel",
            "(I)V",
            level
        );
    },

    getGDPRLevel(): number {
        return jsb.reflection.callStaticMethod(
            classJavaName,
            "getGDPRLevel",
            "()I"
        );
    },

    getUserLocation(callbackMethod: string): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "getUserLocation",
            "(Ljava/lang/String;)V",
            callbackMethod
        );
    },

    showGDPRAuth(): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "showGDPRAuth",
            "()V"
        );
    },

    setLogDebug(debug: boolean): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "setLogDebug",
            "(Z)V",
            debug
        );
    },

    deniedUploadDeviceInfo(deniedInfo: string): void {
        jsb.reflection.callStaticMethod(
            classJavaName,
            "deniedUploadDeviceInfo",
            "(Ljava/lang/String;)V",
            deniedInfo
        );
    }
};

export default ATAndroidJS;
