乐健体育 v3.9.1版本的 MD5 值为:87ae8a64955cdd0e43f3559ee8984d75

以下内容为反编译后的 FaceAuth.java 源代码,内容仅作参考


package com.baidu.idl.main.facesdk;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.baidu.idl.main.facesdk.callback.Callback;
import com.baidu.idl.main.facesdk.license.BDFaceLicenseAuthInfo;
import com.baidu.idl.main.facesdk.license.BDFaceLicenseLocalInfo;
import com.baidu.idl.main.facesdk.model.BDFaceSDKCommon;
import com.baidu.idl.main.facesdk.statistic.PostDeviceInfo;
import com.baidu.idl.main.facesdk.utils.PreferencesUtil;
import com.baidu.vis.unified.license.AndroidLicenser;
import com.baidu.vis.unified.license.BDLicenseAuthInfo;
import com.baidu.vis.unified.license.BDLicenseLocalInfo;
import com.baidu.vis.unified.license.HttpStatus;
import com.baidu.vis.unified.license.HttpUtils;
import io.dcloud.common.DHInterface.IApp;
import org.json.JSONException;
import org.json.JSONObject;
public class FaceAuth {
    private static int ALGORITHM_ID = 3;
    private static final String LICENSE_FILE_NAME = "idl-license.face-android";
    private static final String TAG = "FaceSDK";

    static {
        try {
            System.loadLibrary("bdface_sdk");
            System.loadLibrary("bd_unifylicense");
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }

    public native int nativeCreatInstance();

    private native void nativeSetActiveLog(int i2, int i3);

    private native void nativeSetCoreConfigure(int i2, int i3);

    public BDFaceLicenseAuthInfo getAuthInfo(Context context) {
        BDLicenseAuthInfo authGetAuthInfo = AndroidLicenser.getInstance().authGetAuthInfo(context, ALGORITHM_ID);
        BDFaceLicenseAuthInfo bDFaceLicenseAuthInfo = new BDFaceLicenseAuthInfo();
        bDFaceLicenseAuthInfo.algorithmId = authGetAuthInfo.algorithmId;
        bDFaceLicenseAuthInfo.deviceId = authGetAuthInfo.deviceId;
        bDFaceLicenseAuthInfo.expireTime = authGetAuthInfo.expireTime;
        bDFaceLicenseAuthInfo.functionList = authGetAuthInfo.functionList;
        bDFaceLicenseAuthInfo.licenseKey = authGetAuthInfo.licenseKey;
        bDFaceLicenseAuthInfo.md5 = authGetAuthInfo.md5;
        bDFaceLicenseAuthInfo.packageName = authGetAuthInfo.packageName;
        return bDFaceLicenseAuthInfo;
    }

    public String getDeviceId(Context context) {
        return AndroidLicenser.getDeviceId(context.getApplicationContext());
    }

    public BDFaceLicenseLocalInfo getLocalInfo(Context context) {
        BDLicenseLocalInfo authGetLocalInfo = AndroidLicenser.getInstance().authGetLocalInfo(context, ALGORITHM_ID);
        BDFaceLicenseLocalInfo bDFaceLicenseLocalInfo = new BDFaceLicenseLocalInfo();
        bDFaceLicenseLocalInfo.algorithmId = authGetLocalInfo.algorithmId;
        bDFaceLicenseLocalInfo.deviceId = authGetLocalInfo.deviceId;
        bDFaceLicenseLocalInfo.fingerVersion = authGetLocalInfo.fingerVersion;
        bDFaceLicenseLocalInfo.licenseSdkVersion = authGetLocalInfo.licenseSdkVersion;
        bDFaceLicenseLocalInfo.licenseKey = authGetLocalInfo.licenseKey;
        bDFaceLicenseLocalInfo.md5 = authGetLocalInfo.md5;
        bDFaceLicenseLocalInfo.packageName = authGetLocalInfo.packageName;
        return bDFaceLicenseLocalInfo;
    }

    public void initLicense(final Context context, final String str, final String str2, final boolean z, final Callback callback) {
        FaceQueue.getInstance().execute(new Runnable() {
            @Override
            public void run() {
                if (context == null) {
                    callback.onResponse(1, "没有初始化上下文");
                } else if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
                    AndroidLicenser androidLicenser = AndroidLicenser.getInstance();
                    AndroidLicenser.ErrorCode authFromFile = androidLicenser.authFromFile(context, str, str2, z, FaceAuth.ALGORITHM_ID);
                    if (authFromFile != AndroidLicenser.ErrorCode.SUCCESS) {
                        BDLicenseLocalInfo authGetLocalInfo = androidLicenser.authGetLocalInfo(context, FaceAuth.ALGORITHM_ID);
                        if (authGetLocalInfo != null) {
                            Log.i(FaceAuth.TAG, authGetLocalInfo.toString());
                        }
                    } else {
                        int nativeCreatInstance = FaceAuth.this.nativeCreatInstance();
                        Log.v(FaceAuth.TAG, "bdface_create_instance status " + nativeCreatInstance);
                    }
                    callback.onResponse(authFromFile.ordinal(), androidLicenser.getErrorMsg(FaceAuth.ALGORITHM_ID));
                } else {
                    callback.onResponse(2, "license 关键字为空");
                }
            }
        });
    }

    public void initLicenseBatchLine(final Context context, final String str, final Callback callback) {
        FaceQueue.getInstance().execute(new Runnable() {
            @Override
            public void run() {
                Context context2 = context;
                if (context2 == null) {
                    callback.onResponse(1, "没有初始化上下文");
                    return;
                }
                PreferencesUtil.initPrefs(context2);
                if (TextUtils.isEmpty(PreferencesUtil.getString("statics", ""))) {
                    PostDeviceInfo.uploadDeviceInfo(context, new Callback() {
                        @Override
                        public void onResponse(int i2, String str2) {
                            if (i2 == 0) {
                                PreferencesUtil.putString("statics", "ok");
                            }
                        }
                    });
                }
                if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(FaceAuth.LICENSE_FILE_NAME)) {
                    AndroidLicenser androidLicenser = AndroidLicenser.getInstance();
                    AndroidLicenser.ErrorCode authFromFile = androidLicenser.authFromFile(context, str, FaceAuth.LICENSE_FILE_NAME, true, FaceAuth.ALGORITHM_ID);
                    if (authFromFile != AndroidLicenser.ErrorCode.SUCCESS) {
                        BDLicenseLocalInfo authGetLocalInfo = androidLicenser.authGetLocalInfo(context, FaceAuth.ALGORITHM_ID);
                        if (authGetLocalInfo != null) {
                            Log.i(FaceAuth.TAG, authGetLocalInfo.toString());
                        }
                    } else {
                        int nativeCreatInstance = FaceAuth.this.nativeCreatInstance();
                        Log.v(FaceAuth.TAG, "bdface_create_instance status " + nativeCreatInstance);
                    }
                    callback.onResponse(authFromFile.ordinal(), androidLicenser.getErrorMsg(FaceAuth.ALGORITHM_ID));
                    return;
                }
                callback.onResponse(2, "license 关键字为空");
            }
        });
    }

    public void initLicenseOnLine(final Context context, final String str, final Callback callback) {
        FaceQueue.getInstance().execute(new Runnable() {
            @Override
            public void run() {
                String[] split;
                Context context2 = context;
                if (context2 == null) {
                    callback.onResponse(1, "没有初始化上下文");
                    return;
                }
                PreferencesUtil.initPrefs(context2);
                if (TextUtils.isEmpty(PreferencesUtil.getString("statics", ""))) {
                    PostDeviceInfo.uploadDeviceInfo(context, new Callback() {
                        @Override
                        public void onResponse(int i2, String str2) {
                            if (i2 == 0) {
                                PreferencesUtil.putString("statics", "ok");
                            }
                        }
                    });
                }
                if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(FaceAuth.LICENSE_FILE_NAME)) {
                    AndroidLicenser androidLicenser = AndroidLicenser.getInstance();
                    AndroidLicenser.ErrorCode authFromFile = androidLicenser.authFromFile(context, str, FaceAuth.LICENSE_FILE_NAME, false, FaceAuth.ALGORITHM_ID);
                    Log.e(FaceAuth.TAG, "errCode = " + authFromFile);
                    if (authFromFile == AndroidLicenser.ErrorCode.SUCCESS) {
                        int nativeCreatInstance = FaceAuth.this.nativeCreatInstance();
                        Log.v(FaceAuth.TAG, "bdface_create_instance status " + nativeCreatInstance);
                        callback.onResponse(authFromFile.ordinal(), androidLicenser.getErrorMsg(FaceAuth.ALGORITHM_ID));
                        return;
                    }
                    String deviceId = AndroidLicenser.getDeviceId(context.getApplicationContext());
                    String str2 = null;
                    try {
                        JSONObject jSONObject = new JSONObject();
                        jSONObject.put("deviceId", deviceId);
                        jSONObject.put("key", str);
                        jSONObject.put("platformType", 2);
                        jSONObject.put("version", 5);
                        str2 = jSONObject.toString();
                    } catch (JSONException e2) {
                        e2.printStackTrace();
                    }
                    HttpStatus requestPost = HttpUtils.requestPost("https://ai.baidu.com/activation/key/activate", str2, "application/json", FaceAuth.TAG);
                    if (requestPost == null) {
                        callback.onResponse(-1, "在线激活失败");
                        return;
                    }
                    String str3 = requestPost.responseStr;
                    try {
                        JSONObject jSONObject2 = new JSONObject(str3);
                        if (jSONObject2.optInt("error_code") != 0) {
                            String optString = jSONObject2.optString("error_msg");
                            Log.i(FaceAuth.TAG, "error_msg->" + optString);
                            callback.onResponse(-1, optString);
                        } else {
                            JSONObject optJSONObject = jSONObject2.optJSONObject("result");
                            if (optJSONObject != null) {
                                String optString2 = optJSONObject.optString(IApp.ConfigProperty.CONFIG_LICENSE);
                                if (!TextUtils.isEmpty(optString2) && (split = optString2.split(",")) != null && split.length == 2) {
                                    PreferencesUtil.putString("activate_online_key", str);
                                    AndroidLicenser.ErrorCode authFromMemory = androidLicenser.authFromMemory(context, str, split, FaceAuth.LICENSE_FILE_NAME, FaceAuth.ALGORITHM_ID);
                                    if (authFromMemory != AndroidLicenser.ErrorCode.SUCCESS) {
                                        BDLicenseLocalInfo authGetLocalInfo = androidLicenser.authGetLocalInfo(context, FaceAuth.ALGORITHM_ID);
                                        if (authGetLocalInfo != null) {
                                            Log.i(FaceAuth.TAG, authGetLocalInfo.toString());
                                        }
                                    } else {
                                        int nativeCreatInstance2 = FaceAuth.this.nativeCreatInstance();
                                        Log.v(FaceAuth.TAG, "bdface_create_instance status " + nativeCreatInstance2);
                                    }
                                    callback.onResponse(authFromMemory.ordinal(), androidLicenser.getErrorMsg(FaceAuth.ALGORITHM_ID));
                                }
                            }
                        }
                    } catch (JSONException e3) {
                        e3.printStackTrace();
                    }
                    Log.i(FaceAuth.TAG, "netRequest->" + str3);
                    return;
                }
                callback.onResponse(2, "license 关键字为空");
            }
        });
    }

    public void setActiveLog(BDFaceSDKCommon.BDFaceLogInfo bDFaceLogInfo, int i2) {
        nativeSetActiveLog(bDFaceLogInfo.ordinal(), i2);
    }

    public void setCoreConfigure(BDFaceSDKCommon.BDFaceCoreRunMode bDFaceCoreRunMode, int i2) {
        nativeSetCoreConfigure(bDFaceCoreRunMode.ordinal(), i2);
    }
}