package com.ayl.ces.jni

import android.content.Context
import android.util.Log

/**
 * Created by gaoleichao on 2018/7/13.
 */
class CesCore {
    lateinit var mContext: Context
    var isInit: Boolean = false

    init {
        System.loadLibrary("native-lib")

    }

    companion object {
        /**
         * @param
         */
        @Volatile
        var mCesCore: CesCore? = null

        fun getInstance(): CesCore {
            if (mCesCore == null) {
                synchronized(CesCore::class.java) {
                    if (mCesCore == null) {
                        mCesCore = CesCore()
                    }
                }
            }
            return mCesCore!!
        }
    }

    fun init(context: Context) {
        mContext = context
        native_init(mContext)
    }

    fun SmData(): String {
        return sm_work(mContext)
    }

    fun setData(strS: String) {
        SetData(strS)
        isInit = true
        Log.d("splash", "isInit:" + isInit)
    }

    fun getIsInit(): Boolean {
        return isInit
    }

    private external fun native_init(context: Context?)

    private external fun sm_work(context: Context?): String

    /////////////////////////////////////
    external fun SetData(strSource: String): Boolean

    external fun Dowork(src: String, client_no: String): String

    external fun Dework(src: String, client_no: String): String

    external fun Sgwork(src: String): String

    external fun Ckwork(client_no: String): String

    external fun Version(): String

}