package com.dlc.exam.camera

import com.arcsoft.face.ErrorInfo

/**
 * info
 *
 * @author ReiChin_
 */
object ArcSoftErrCode {

    private val errMap = mutableMapOf<Int, String>().apply {
        put(ErrorInfo.MOK, "成功")
        put(ErrorInfo.MERR_UNKNOWN, "错误原因不明")
        put(ErrorInfo.MERR_INVALID_PARAM, "无效的参数")
        put(ErrorInfo.MERR_UNSUPPORTED, "引擎不支持")
        put(ErrorInfo.MERR_NO_MEMORY, "内存不足")
        put(ErrorInfo.MERR_BAD_STATE, "状态错误")
        put(ErrorInfo.MERR_USER_CANCEL, "用户取消相关操作")
        put(ErrorInfo.MERR_EXPIRED, "操作时间过期")
        put(ErrorInfo.MERR_USER_PAUSE, "用户暂停操作")
        put(ErrorInfo.MERR_BUFFER_OVERFLOW, "缓冲上溢")
        put(ErrorInfo.MERR_BUFFER_UNDERFLOW, "缓冲下溢")
        put(ErrorInfo.MERR_NO_DISKSPACE, "存贮空间不足")
        put(ErrorInfo.MERR_COMPONENT_NOT_EXIST, "组件不存在")
        put(ErrorInfo.MERR_GLOBAL_DATA_NOT_EXIST, "全局数据不存在")
        put(ErrorInfo.MERR_FSDK_INVALID_APP_ID, "无效的AppId")
        put(ErrorInfo.MERR_FSDK_INVALID_SDK_ID, "无效的SDKkey")
        put(ErrorInfo.MERR_FSDK_INVALID_ID_PAIR, "AppId和SDKKey不匹配")
        put(
            ErrorInfo.MERR_FSDK_MISMATCH_ID_AND_SDK,
            "SDKKey和使用的SDK不匹配（注意：调用初始化引擎接口时，请确认激活接口传入的参数，并重新激活）"
        )
        put(ErrorInfo.MERR_FSDK_SYSTEM_VERSION_UNSUPPORTED, "系统版本不被当前SDK所支持")
        put(ErrorInfo.MERR_FSDK_FR_INVALID_MEMORY_INFO, "无效的输入内存")
        put(ErrorInfo.MERR_FSDK_FR_INVALID_IMAGE_INFO, "无效的输入图像参数")
        put(ErrorInfo.MERR_FSDK_FR_INVALID_FACE_INFO, "无效的脸部信息")
        put(ErrorInfo.MERR_FSDK_FR_NO_GPU_AVAILABLE, "当前设备无GPU可用")
        put(ErrorInfo.MERR_FSDK_FR_MISMATCHED_FEATURE_LEVEL, "待比较的两个人脸特征的版本不一致")
        put(ErrorInfo.MERR_FSDK_FACEFEATURE_UNKNOWN, "人脸特征检测错误未知")
        put(ErrorInfo.MERR_FSDK_FACEFEATURE_MEMORY, "人脸特征检测内存错误")
        put(ErrorInfo.MERR_FSDK_FACEFEATURE_INVALID_FORMAT, "人脸特征检测格式错误")
        put(ErrorInfo.MERR_FSDK_FACEFEATURE_INVALID_PARAM, "人脸特征检测参数错误")
        put(ErrorInfo.MERR_FSDK_FACEFEATURE_LOW_CONFIDENCE_LEVEL, "人脸特征检测结果置信度低")
        put(ErrorInfo.MERR_ASF_EX_FEATURE_UNSUPPORTED_ON_INIT, "Engine不支持的检测属性")
        put(ErrorInfo.MERR_ASF_EX_FEATURE_UNINITED, "需要检测的属性未初始化")
        put(ErrorInfo.MERR_ASF_EX_FEATURE_UNPROCESSED, "待获取的属性未在process中处理过")
        put(ErrorInfo.MERR_ASF_EX_FEATURE_UNSUPPORTED_ON_PROCESS, "PROCESS不支持的检测属性，例如FR，有自己独立的处理函数")
        put(ErrorInfo.MERR_ASF_EX_INVALID_IMAGE_INFO, "无效的输入图像")
        put(ErrorInfo.MERR_ASF_EX_INVALID_FACE_INFO, "无效的脸部信息")
        put(ErrorInfo.MERR_ASF_ACTIVATION_FAIL, "SDK激活失败，请打开读写权限")
        put(ErrorInfo.MERR_ASF_ALREADY_ACTIVATED, "SDK已激活")
        put(ErrorInfo.MERR_ASF_NOT_ACTIVATED, "SDK未激活")
        put(ErrorInfo.MERR_ASF_SCALE_NOT_SUPPORT, "detectFaceScaleVal不支持")
        put(ErrorInfo.MERR_ASF_ACTIVEFILE_SDKTYPE_MISMATCH, "激活文件与SDK类型不匹配，请确认使用的sdk")
        put(ErrorInfo.MERR_ASF_DEVICE_MISMATCH, "设备不匹配")
        put(ErrorInfo.MERR_ASF_UNIQUE_IDENTIFIER_ILLEGAL, "唯一标识不合法")
        put(ErrorInfo.MERR_ASF_PARAM_NULL, "参数为空")
        put(ErrorInfo.MERR_ASF_LIVENESS_EXPIRED, "活体已过期")
        put(ErrorInfo.MERR_ASF_VERSION_NOT_SUPPORT, "版本不支持")
        put(ErrorInfo.MERR_ASF_SIGN_ERROR, "签名错误")
        put(ErrorInfo.MERR_ASF_DATABASE_ERROR, "激活信息保存异常")
        put(ErrorInfo.MERR_ASF_UNIQUE_CHECKOUT_FAIL, "唯一标识符校验失败")
        put(ErrorInfo.MERR_ASF_COLOR_SPACE_NOT_SUPPORT, "颜色空间不支持")
        put(ErrorInfo.MERR_ASF_IMAGE_WIDTH_HEIGHT_NOT_SUPPORT, "图片宽高不支持，宽度需四字节对齐")
        put(ErrorInfo.MERR_ASF_READ_PHONE_STATE_DENIED, "android.permission.READ_PHONE_STATE权限被拒绝")
        put(ErrorInfo.MERR_ASF_ACTIVATION_DATA_DESTROYED, "激活数据被破坏,请删除激活文件，重新进行激活")
        put(ErrorInfo.MERR_ASF_SERVER_UNKNOWN_ERROR, "服务端未知错误")
        put(ErrorInfo.MERR_ASF_INTERNET_DENIED, "android.permission.INTERNET权限被拒绝")
        put(ErrorInfo.MERR_ASF_ACTIVEFILE_SDK_MISMATCH, "激活文件与SDK版本不匹配,请重新激活")
        put(ErrorInfo.MERR_ASF_DEVICEINFO_LESS, "设备信息太少，不足以生成设备指纹")
        put(ErrorInfo.MERR_ASF_LOCAL_TIME_NOT_CALIBRATED, "客户端时间与服务器时间（即北京时间）前后相差在30分钟以上")
        put(ErrorInfo.MERR_ASF_APPID_DATA_DECRYPT, "数据校验异常")
        put(ErrorInfo.MERR_ASF_APPID_APPKEY_SDK_MISMATCH, "传入的AppId和AppKey与使用的SDK版本不一致")
        put(ErrorInfo.MERR_ASF_NO_REQUEST, "短时间大量请求会被禁止请求,30分钟之后解封")
        put(ErrorInfo.MERR_ASF_ACTIVE_FILE_NO_EXIST, "激活文件不存在")
        put(ErrorInfo.MERR_ASF_CURRENT_DEVICE_TIME_INCORRECT, "当前设备时间不正确，请调整设备时间")
        put(ErrorInfo.MERR_ASF_DETECT_MODEL_UNSUPPORTED, "检测模型不支持，请查看对应接口说明，使用当前支持的检测模型")
        put(ErrorInfo.MERR_ASF_ACTIVATION_QUANTITY_OUT_OF_LIMIT, "年度激活数量超出限制，次年清零")
        put(ErrorInfo.MERR_ASF_IP_BLACK_LIST, "频繁请求，四个小时解禁")
        put(ErrorInfo.MERR_ASF_NETWORK_COULDNT_RESOLVE_HOST, "无法解析主机地址")
        put(ErrorInfo.MERR_ASF_NETWORK_COULDNT_CONNECT_SERVER, "无法连接服务器")
        put(ErrorInfo.MERR_ASF_NETWORK_CONNECT_TIMEOUT, "网络连接超时")
        put(ErrorInfo.MERR_ASF_NETWORK_UNKNOWN_ERROR, "网络未知错误")
    }

    fun decode(code: Int?) = code?.let { errMap[code] } ?: "未知错误：$code"

}