导航菜单

页面标题

页面副标题

Mabilis Cash v1.19.4 - FacePPV5Manager.java 源代码

正在查看: Mabilis Cash v1.19.4 应用的 FacePPV5Manager.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.fintopia.face.v5;

import android.media.AudioManager;
import com.fintopia.face.R;
import com.fintopia.face.common.FaceStatisticsEvents;
import com.fintopia.face.models.FaceIdCard;
import com.fintopia.face.models.RecognitionSource;
import com.lingyue.supertoolkit.statistics.TrackingUtil;
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.widgets.ToastCompat;
import com.megvii.lv5.sdk.bean.MegliveLocalFileInfo;
import com.megvii.lv5.sdk.manager.MegLiveDetectConfig;
import com.megvii.lv5.sdk.manager.MegLiveDetectListener;
import com.megvii.lv5.sdk.manager.MegLiveManager;
import com.megvii.lv5.sdk.manager.TipsShowMode;
import com.veda.android.bananalibrary.infrastructure.BaseActivity;
import io.sentry.ITransaction;
import io.sentry.Sentry;
import io.sentry.SpanStatus;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Locale;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;

@Metadata
@SourceDebugExtension
public final class FacePPV5Manager {

    @NotNull
    public static final Companion f3515g = new Companion(null);

    @NotNull
    private final BaseActivity f3516a;

    @NotNull
    private final String f3517b;

    @NotNull
    private String f3518c;

    @NotNull
    private FaceIdCard f3519d;

    private boolean f3520e;

    @NotNull
    private final ITransaction f3521f;

    @Metadata
    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        private Companion() {
        }
    }

    public FacePPV5Manager(@NotNull BaseActivity baseActivity, @NotNull String str) {
        Intrinsics.checkNotNullParameter(baseActivity, "hostActivity");
        Intrinsics.checkNotNullParameter(str, "purpose");
        this.f3516a = baseActivity;
        this.f3517b = str;
        String g2 = g("facelivemodel.bin", "model");
        this.f3518c = g2 == null ? "" : g2;
        this.f3519d = new FaceIdCard();
        ITransaction B = Sentry.B("FacePPCheck", "facepp_v5_check");
        Intrinsics.checkNotNullExpressionValue(B, "startTransaction(...)");
        this.f3521f = B;
    }

    private final boolean f() {
        try {
            Object systemService = this.f3516a.getSystemService("audio");
            Intrinsics.c(systemService, "null cannot be cast to non-null type android.media.AudioManager");
            int ringerMode = ((AudioManager) systemService).getRingerMode();
            return ringerMode == 0 || ringerMode == 1;
        } catch (Exception e2) {
            CrashReporter.a(e2);
            return false;
        }
    }

    private final String g(String str, String str2) {
        File file = new File(this.f3516a.getExternalFilesDir("megvii"), str2);
        if (!file.exists() && !file.mkdirs()) {
            return null;
        }
        File file2 = new File(file, str);
        try {
            byte[] bArr = new byte[1024];
            FileOutputStream fileOutputStream = new FileOutputStream(file2);
            InputStream open = this.f3516a.getAssets().open(str);
            Intrinsics.checkNotNullExpressionValue(open, "open(...)");
            while (true) {
                int read = open.read(bArr);
                if (read == -1) {
                    fileOutputStream.close();
                    open.close();
                    return file2.getAbsolutePath();
                }
                fileOutputStream.write(bArr, 0, read);
            }
        } catch (Exception e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public final void h(String str, int i2, String str2, SpanStatus spanStatus) {
        this.f3521f.a("faceV5DetectResult", str);
        this.f3521f.a("faceV5DetectResultCode", String.valueOf(i2));
        this.f3521f.a("faceV5DetectToken", str2);
        this.f3521f.i(spanStatus);
    }

    @NotNull
    public final BaseActivity e() {
        return this.f3516a;
    }

    public final void i(@NotNull final String str, int i2, @NotNull final LivingDetectCallback livingDetectCallback) {
        Intrinsics.checkNotNullParameter(str, "token");
        Intrinsics.checkNotNullParameter(livingDetectCallback, "callback");
        MegLiveDetectConfig megLiveDetectConfig = new MegLiveDetectConfig();
        megLiveDetectConfig.setBizToken(str);
        megLiveDetectConfig.setHost("https://api-idn.megvii.com");
        megLiveDetectConfig.setLanguage(Locale.getDefault().getLanguage());
        megLiveDetectConfig.setModelPath(this.f3518c);
        megLiveDetectConfig.setTipsMode(TipsShowMode.MODE_SHORT);
        megLiveDetectConfig.setMute(f());
        if (i2 > 0) {
            megLiveDetectConfig.setUploadTimeout(i2);
        }
        MegLiveManager.getInstance().startDetect(this.f3516a, megLiveDetectConfig, new MegLiveDetectListener() {
            public void onDetectFinish(int i3, String str2, String str3) {
                FaceIdCard faceIdCard;
                FaceIdCard faceIdCard2;
                FaceIdCard faceIdCard3;
                String str4;
                Intrinsics.checkNotNullParameter(str2, "errorMessage");
                Intrinsics.checkNotNullParameter(str3, "bizToken");
                Logger.c().b("faceidv5+onDetectFinish : errorCode=" + i3 + ",errorMessage=" + str2);
                if (i3 == 1000) {
                    FacePPV5Manager.this.f3520e = true;
                    faceIdCard = FacePPV5Manager.this.f3519d;
                    faceIdCard.bizToken = str3;
                    faceIdCard2 = FacePPV5Manager.this.f3519d;
                    faceIdCard2.source = RecognitionSource.FACEPP_V5;
                    LivingDetectCallback livingDetectCallback2 = livingDetectCallback;
                    faceIdCard3 = FacePPV5Manager.this.f3519d;
                    livingDetectCallback2.a(faceIdCard3);
                    FacePPV5Manager.this.h("OK", i3, str, SpanStatus.OK);
                } else if (i3 == 1011) {
                    FacePPV5Manager.this.f3520e = false;
                    FacePPV5Manager.this.h(str2, i3, str, SpanStatus.INTERNAL_ERROR);
                } else if (i3 != 1016) {
                    FacePPV5Manager.this.h(str2, i3, str, SpanStatus.INTERNAL_ERROR);
                    FacePPV5Manager.this.f3520e = false;
                    ToastCompat.e(FacePPV5Manager.this.e(), FacePPV5Manager.this.e().getString(R.string.live_detection_failed));
                } else {
                    FacePPV5Manager.this.f3520e = false;
                    ToastCompat.e(FacePPV5Manager.this.e(), FacePPV5Manager.this.e().getString(R.string.live_detection_failed));
                    FacePPV5Manager.this.h(str2, i3, str, SpanStatus.INTERNAL_ERROR);
                }
                JsonParamsBuilder.SemiData c2 = new JsonParamsBuilder().c("sdk").a(MegLiveManager.getInstance().getVersion()).c("code").a(String.valueOf(i3)).c("purpose");
                str4 = FacePPV5Manager.this.f3517b;
                TrackingUtil.j(FacePPV5Manager.this.e(), FaceStatisticsEvents.f3446a, c2.a(str4).c("error_message").a(str2).b());
            }

            public void onLivenessFileCallback(String str2) {
                FaceIdCard faceIdCard;
                Intrinsics.checkNotNullParameter(str2, "livenessFilePath");
                Logger.c().b("faceidv5, onLivenessFileCallback : livenessFilePath=" + str2);
                faceIdCard = FacePPV5Manager.this.f3519d;
                faceIdCard.livenessFilePath = str2;
            }

            public void onLivenessLocalFileCallBack(MegliveLocalFileInfo megliveLocalFileInfo) {
                Intrinsics.checkNotNullParameter(megliveLocalFileInfo, "megliveLocalFileInfo");
            }

            public void onPreDetectFinish(int i3, String str2) {
                String str3;
                Intrinsics.checkNotNullParameter(str2, "errorMessage");
                FacePPV5Manager.this.e().dismissLoadingDialog();
                Logger.c().b("faceidv5+onPreDetectFinish : errorCode=" + i3 + ",errorMessage=" + str2);
                FacePPV5Manager.this.e().dismissLoadingDialog();
                if (i3 != 1000) {
                    FacePPV5Manager.this.h(str2, i3, str, SpanStatus.INTERNAL_ERROR);
                    FacePPV5Manager.this.f3520e = false;
                    ToastCompat.e(FacePPV5Manager.this.e(), FacePPV5Manager.this.e().getString(R.string.live_auth_exception_tips_v5));
                }
                JsonParamsBuilder.SemiData c2 = new JsonParamsBuilder().c("sdk").a(MegLiveManager.getInstance().getVersion()).c("code").a(String.valueOf(i3)).c("error_message").a(str2).c("purpose");
                str3 = FacePPV5Manager.this.f3517b;
                TrackingUtil.j(FacePPV5Manager.this.e(), FaceStatisticsEvents.f3447b, c2.a(str3).b());
            }
        });
    }
}