正在查看: Mabilis Cash v1.19.4 应用的 FaceCheckNetWarrantyUtil.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Mabilis Cash v1.19.4 应用的 FaceCheckNetWarrantyUtil.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.fintopia.face.tools;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.webkit.internal.AssetHelper;
import com.fintopia.face.R;
import com.fintopia.face.tools.FaceCheckNetWarrantyUtil;
import com.google.gson.Gson;
import com.lingyue.supertoolkit.tools.customtools.CrashReporter;
import com.lingyue.supertoolkit.tools.customtools.JsonParamsBuilder;
import com.lingyue.supertoolkit.tools.customtools.Logger;
import com.lingyue.supertoolkit.tools.phonetools.DeviceUtils;
import com.lingyue.supertoolkit.widgets.ToastCompat;
import com.megvii.livenessdetection.LivenessLicenseManager;
import com.veda.android.bananalibrary.infrastructure.BaseActivity;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import java.net.ConnectException;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class FaceCheckNetWarrantyUtil {
public interface ICallBack {
void a();
void b();
void onStart();
void onSuccess();
}
private static String e() {
String str = Build.CPU_ABI;
return TextUtils.isEmpty(str) ? Build.CPU_ABI2 : str;
}
public static boolean f(String str, SSLSession sSLSession) {
Logger.c().b(new Gson().t(sSLSession.getValueNames()));
return true;
}
public static LivenessLicenseManager g(Context context) throws Exception {
LivenessLicenseManager livenessLicenseManager;
try {
livenessLicenseManager = new LivenessLicenseManager(context);
} catch (Error unused) {
JsonParamsBuilder jsonParamsBuilder = new JsonParamsBuilder();
jsonParamsBuilder.c("cpuApi").a(e());
CrashReporter.a(new UnsatisfiedLinkError("cpuApi: " + jsonParamsBuilder.b()));
livenessLicenseManager = null;
}
OkHttpClient.Builder hostnameVerifier = new OkHttpClient.Builder().hostnameVerifier(new HostnameVerifier() {
@Override
public final boolean verify(String str, SSLSession sSLSession) {
boolean f2;
f2 = FaceCheckNetWarrantyUtil.f(str, sSLSession);
return f2;
}
});
TimeUnit timeUnit = TimeUnit.SECONDS;
OkHttpClient build = hostnameVerifier.connectTimeout(15L, timeUnit).readTimeout(15L, timeUnit).build();
if (livenessLicenseManager == null) {
throw new ConnectException();
}
Response execute = build.newCall(new Request.Builder().url("https://api-sgp.megvii.com/faceid/v1/sdk/auth").addHeader("Content-type", AssetHelper.DEFAULT_MIME_TYPE).post(RequestBody.create(MediaType.parse("text/plan; charset=utf-8"), livenessLicenseManager.getContext(DeviceUtils.l(context)))).build()).execute();
if (!execute.isSuccessful()) {
throw new ConnectException();
}
livenessLicenseManager.setLicense(execute.body().string());
return livenessLicenseManager;
}
public static void h(ICallBack iCallBack, LivenessLicenseManager livenessLicenseManager) throws Exception {
try {
if (livenessLicenseManager.checkCachedLicense() > 0) {
iCallBack.onSuccess();
} else {
iCallBack.b();
}
} catch (Exception unused) {
} catch (Throwable th) {
iCallBack.a();
throw th;
}
iCallBack.a();
}
public static void i(ICallBack iCallBack, Throwable th) throws Exception {
try {
iCallBack.b();
} catch (Exception unused) {
} catch (Throwable th2) {
iCallBack.a();
throw th2;
}
iCallBack.a();
}
@SuppressLint({"CheckResult"})
public static void j(Context context, @NonNull final ICallBack iCallBack) {
iCallBack.onStart();
Flowable.w(context).Q(Schedulers.b()).x(new Function() {
public final Object apply(Object obj) {
LivenessLicenseManager g2;
g2 = FaceCheckNetWarrantyUtil.g((Context) obj);
return g2;
}
}).z(AndroidSchedulers.a()).M(new Consumer() {
public final void accept(Object obj) {
FaceCheckNetWarrantyUtil.h(FaceCheckNetWarrantyUtil.ICallBack.this, (LivenessLicenseManager) obj);
}
}, new Consumer() {
public final void accept(Object obj) {
FaceCheckNetWarrantyUtil.i(FaceCheckNetWarrantyUtil.ICallBack.this, (Throwable) obj);
}
});
}
public static class DefaultCallBack implements ICallBack {
BaseActivity f3503a;
public DefaultCallBack(@NonNull BaseActivity baseActivity) {
this.f3503a = baseActivity;
}
@Override
public void a() {
if (c()) {
this.f3503a.dismissLoadingDialog();
}
}
@Override
public void b() {
if (c()) {
BaseActivity baseActivity = this.f3503a;
ToastCompat.f(baseActivity, baseActivity.getResources().getString(R.string.live_auth_exception_tips));
}
}
public boolean c() {
BaseActivity baseActivity = this.f3503a;
return (baseActivity == null || baseActivity.isFinishing() || this.f3503a.isDestroyed()) ? false : true;
}
@Override
public void onStart() {
if (c()) {
this.f3503a.showLoadingDialog();
}
}
@Override
public void onSuccess() {
}
}
}