导航菜单

页面标题

页面副标题

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

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

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


package com.loans.mabiliscash.auth.living;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import com.fintopia.face.living.faceDetector.SensorUtil;
import com.fintopia.face.models.FaceIdCard;
import com.fintopia.face.models.event.LiveDetectionEvent;
import com.fintopia.libCommon.common.CommonActivity;
import com.fintopia.libCommon.common.CommonResult;
import com.lingyue.supertoolkit.tools.BaseUtils;
import com.lingyue.supertoolkit.widgets.ToastCompat;
import com.lingyue.tracklib.ThirdPartTrackLib;
import com.lingyue.tracklib.TrackEventParamsConfigurator;
import com.loans.mabiliscash.R;
import com.loans.mabiliscash.auth.IAuthProcessTracker;
import com.loans.mabiliscash.auth.helper.AuthUtils;
import com.loans.mabiliscash.auth.helper.QuitAuthHelper;
import com.loans.mabiliscash.auth.living.PHLiveRecognitionResultActivity;
import com.loans.mabiliscash.common.BindClickCall;
import com.loans.mabiliscash.common.PHViewBindingActivity;
import com.loans.mabiliscash.databinding.ActivityAuthLivenessRecognitionResultBinding;
import com.loans.mabiliscash.models.GravityParamsRequest;
import com.loans.mabiliscash.models.LivingInfo;
import com.loans.mabiliscash.models.response.GetQiNiuUploadTokenResponse;
import com.loans.mabiliscash.models.response.UploadLivingInfoResponse;
import com.loans.mabiliscash.net.ECObserver;
import com.loans.mabiliscash.net.IApiRoutes;
import com.loans.mabiliscash.sentry.sentrybusiness.ISentryBusinessEventAutoFinish;
import com.loans.mabiliscash.sentry.sentrybusiness.SentryBusiness;
import com.loans.mabiliscash.thirdpart.AppsFlyerUtil;
import com.qiniu.android.common.FixedZone;
import com.qiniu.android.http.ResponseInfo;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UpCancellationSignal;
import com.qiniu.android.storage.UpCompletionHandler;
import com.qiniu.android.storage.UploadManager;
import com.qiniu.android.storage.UploadOptions;
import com.veda.android.bananalibrary.net.ICallBack;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import io.sentry.ITransaction;
import io.sentry.SpanStatus;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;

public class PHLiveRecognitionResultActivity extends PHViewBindingActivity<ActivityAuthLivenessRecognitionResultBinding> implements ISentryBusinessEventAutoFinish {
    private FaceIdCard p;
    private LivingInfo q;

    private UploadManager f121t;

    private SensorUtil f124w;

    private String f125x;

    private ITransaction f126y;
    private boolean r = false;
    private volatile boolean s = false;

    private List<LiveUploadData> f122u = new ArrayList();

    private List<String> f123v = new ArrayList();

    @SuppressLint({"HandlerLeak"})
    private Handler f127z = new Handler() {
        @Override
        public void handleMessage(Message message) {
            super.handleMessage(message);
            int i = message.what;
            if (i != 11) {
                if (i != 12) {
                    return;
                }
                ?? r3 = PHLiveRecognitionResultActivity.this;
                r3.authUtil.h(r3, new AuthUtils.DefaultAuthCallBack(r3));
                return;
            }
            if (PHLiveRecognitionResultActivity.this.n0()) {
                return;
            }
            CommonActivity commonActivity = PHLiveRecognitionResultActivity.this;
            ToastCompat.g(commonActivity, commonActivity.getString(R.string.net_work_exception));
            PHLiveRecognitionResultActivity.this.C0();
        }
    };
    UpCompletionHandler A = new UpCompletionHandler() {
        int a = 0;
        int b = 3;

        @Override
        public void complete(String str, ResponseInfo responseInfo, JSONObject jSONObject) {
            LiveUploadData o0 = PHLiveRecognitionResultActivity.this.o0(str);
            if (o0 == null) {
                PHLiveRecognitionResultActivity.this.C0();
                return;
            }
            if (!responseInfo.isOK()) {
                int i = this.a + 1;
                this.a = i;
                if (i <= this.b) {
                    PHLiveRecognitionResultActivity.this.f121t.put(o0.b, str, PHLiveRecognitionResultActivity.this.f125x, this, PHLiveRecognitionResultActivity.this.B);
                    return;
                } else {
                    ToastCompat.g(PHLiveRecognitionResultActivity.this.getApplicationContext(), PHLiveRecognitionResultActivity.this.getString(R.string.net_work_exception));
                    PHLiveRecognitionResultActivity.this.C0();
                    return;
                }
            }
            int i2 = this.a;
            if (i2 > 0) {
                this.a = i2 - 1;
            }
            o0.d = true;
            PHLiveRecognitionResultActivity.this.f123v.add(jSONObject.toString());
            if (PHLiveRecognitionResultActivity.this.n0()) {
                PHLiveRecognitionResultActivity.this.B0();
            }
        }
    };
    UploadOptions B = new UploadOptions(null, null, true, null, new UpCancellationSignal() {
        @Override
        public boolean isCancelled() {
            return PHLiveRecognitionResultActivity.this.s;
        }
    });

    class AnonymousClass3 extends ECObserver<UploadLivingInfoResponse> {
        AnonymousClass3(ICallBack iCallBack) {
            super(iCallBack);
        }

        public static void h(UploadLivingInfoResponse uploadLivingInfoResponse, Map map) {
            map.put("is_v5", String.valueOf(false));
            map.put("api_code", uploadLivingInfoResponse != null ? uploadLivingInfoResponse.getStatusCodeString() : "");
            map.put("is_success", String.valueOf(false));
        }

        public static void i(Map map) {
            map.put("is_v5", String.valueOf(false));
            map.put("is_success", String.valueOf(true));
        }

        @Override
        public void e(Throwable th, final UploadLivingInfoResponse uploadLivingInfoResponse) {
            super.e(th, uploadLivingInfoResponse);
            ThirdPartTrackLib.d(PHLiveRecognitionResultActivity.this, "auth_living_info_result", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHLiveRecognitionResultActivity.AnonymousClass3.h(UploadLivingInfoResponse.this, map);
                }
            });
            IAuthProcessTracker.c(PHLiveRecognitionResultActivity.this, "活体结果", false, th != null ? th.getMessage() : uploadLivingInfoResponse != null ? uploadLivingInfoResponse.getStatusCodeString() : "");
            PHLiveRecognitionResultActivity.this.f126y.b(SpanStatus.INTERNAL_ERROR);
            PHLiveRecognitionResultActivity.this.C0();
            PHLiveRecognitionResultActivity.this.Q();
            ToastCompat.g(PHLiveRecognitionResultActivity.this, ((CommonResult) uploadLivingInfoResponse).status.detail);
        }

        @Override
        public void c(UploadLivingInfoResponse uploadLivingInfoResponse) {
            PHLiveRecognitionResultActivity.this.dismissLoadingDialog();
            ThirdPartTrackLib.d(PHLiveRecognitionResultActivity.this, "auth_living_info_result", new TrackEventParamsConfigurator() {
                @Override
                public final void a(Map map) {
                    PHLiveRecognitionResultActivity.AnonymousClass3.i(map);
                }
            });
            IAuthProcessTracker.b(PHLiveRecognitionResultActivity.this, "活体结果", true);
            PHLiveRecognitionResultActivity.this.f126y.i(SpanStatus.OK);
            PHLiveRecognitionResultActivity.this.w0();
            PHLiveRecognitionResultActivity.this.Q();
        }
    }

    static class LiveUploadData {
        String a;
        byte[] b;
        String c;
        boolean d = false;

        public LiveUploadData(String str, byte[] bArr, String str2) {
            this.a = str;
            this.b = bArr;
            this.c = str2;
        }
    }

    private void A0() {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("livingImageList", this.q.livingImageList);
        hashMap.put("delta", this.q.delta);
        AppsFlyerUtil.Companion companion = AppsFlyerUtil.b;
        hashMap.put("appsflyerId", companion.b().e(this));
        hashMap.put("appsFlyerInfo", companion.b().f(this));
        this.apiHelper.a().w0(hashMap).w(AndroidSchedulers.a()).a(new AnonymousClass3(this));
    }

    public void B0() {
        SentryBusiness.e().f("Image_Upload_Qiniu").i(SpanStatus.OK);
        this.r = false;
        this.s = true;
        A0();
        E0();
    }

    public void C0() {
        SentryBusiness.e().f("Image_Upload_Qiniu").i(SpanStatus.INTERNAL_ERROR);
        dismissLoadingDialog();
        this.s = true;
        this.r = false;
        this.f123v.clear();
        ((ActivityAuthLivenessRecognitionResultBinding) this.o).b.setVisibility(0);
    }

    private void D0() {
        if (this.r) {
            return;
        }
        this.s = false;
        this.f127z.removeCallbacksAndMessages(null);
        this.f127z.sendEmptyMessageDelayed(11, 120000L);
        this.r = true;
        List<LiveUploadData> list = this.f122u;
        if (list == null || list.isEmpty()) {
            return;
        }
        for (LiveUploadData liveUploadData : this.f122u) {
            liveUploadData.d = false;
            this.f121t.put(liveUploadData.b, liveUploadData.c, this.f125x, this.A, this.B);
        }
    }

    private void E0() {
        if (this.f124w == null) {
            return;
        }
        IApiRoutes a = this.apiHelper.a();
        SensorUtil sensorUtil = this.f124w;
        a.M(new GravityParamsRequest(sensorUtil.c, sensorUtil.d, sensorUtil.e)).w(AndroidSchedulers.a()).K(Schedulers.b()).a(new ECObserver<CommonResult>(this) {
            @Override
            public void c(CommonResult commonResult) {
            }

            @Override
            public void e(Throwable th, CommonResult commonResult) {
            }
        });
    }

    public boolean n0() {
        if (this.f122u.isEmpty()) {
            return false;
        }
        int size = this.f122u.size();
        Iterator<LiveUploadData> it = this.f122u.iterator();
        int i = 0;
        while (it.hasNext()) {
            if (it.next().d) {
                i++;
            }
        }
        return i == size;
    }

    public LiveUploadData o0(String str) {
        if (!TextUtils.isEmpty(str) && !this.f122u.isEmpty()) {
            for (LiveUploadData liveUploadData : this.f122u) {
                if (str.equals(liveUploadData.c)) {
                    return liveUploadData;
                }
            }
        }
        return null;
    }

    private UploadManager p0(String str, String str2) {
        return new UploadManager((TextUtils.isEmpty(str) && TextUtils.isEmpty(str2)) ? new Configuration.Builder().zone(FixedZone.zoneAs0).build() : new Configuration.Builder().useHttps(true).zone(new FixedZone(new String[]{str, str2})).build());
    }

    private void q0() {
        AuthUtils authUtils = this.authUtil;
        T t2 = this.o;
        authUtils.q(this, ((ActivityAuthLivenessRecognitionResultBinding) t2).c, R.drawable.ic_auth_personal_info, ((ActivityAuthLivenessRecognitionResultBinding) t2).e.d, ((ActivityAuthLivenessRecognitionResultBinding) t2).e.c);
    }

    private void r0() {
        V(((ActivityAuthLivenessRecognitionResultBinding) this.o).b, new BindClickCall() {
            @Override
            public final void onClick(View view) {
                PHLiveRecognitionResultActivity.this.s0(view);
            }
        });
    }

    public void s0(View view) {
        x0();
    }

    public static void start(Activity activity, FaceIdCard faceIdCard) {
        Intent intent = new Intent(activity, (Class<?>) PHLiveRecognitionResultActivity.class);
        intent.putExtra("faceIdCard", (Serializable) faceIdCard);
        activity.startActivity(intent);
    }

    public static void t0() {
        EventBus.c().k(new LiveDetectionEvent());
    }

    public static void u0(Map map) {
        map.put("is_v5", String.valueOf(false));
    }

    public void v0(GetQiNiuUploadTokenResponse getQiNiuUploadTokenResponse) {
        GetQiNiuUploadTokenResponse.UploadToken uploadToken = getQiNiuUploadTokenResponse.body;
        if (uploadToken == null || TextUtils.isEmpty(uploadToken.uploadToken)) {
            ToastCompat.g(this, getString(R.string.net_work_exception));
            C0();
            return;
        }
        GetQiNiuUploadTokenResponse.UploadToken uploadToken2 = getQiNiuUploadTokenResponse.body;
        this.f125x = uploadToken2.uploadToken;
        if (this.f121t == null) {
            this.f121t = p0(y0(uploadToken2.url), y0(getQiNiuUploadTokenResponse.body.backUrl));
        }
        D0();
    }

    public void w0() {
        EventBus.c().k(new LiveDetectionEvent());
        T t2 = this.o;
        if (((ActivityAuthLivenessRecognitionResultBinding) t2).g != null) {
            ((ActivityAuthLivenessRecognitionResultBinding) t2).g.setVisibility(0);
        }
        this.f127z.sendEmptyMessageDelayed(12, 1200L);
    }

    private void x0() {
        if (BaseUtils.a()) {
            return;
        }
        showLoadingDialog();
        if (n0()) {
            A0();
        } else {
            z0();
        }
    }

    private String y0(String str) {
        return str.replace("https://", "").replace("http://", "");
    }

    private void z0() {
        SentryBusiness.e().f("Image_Upload_Qiniu");
        this.apiHelper.a().m0().w(AndroidSchedulers.a()).a(new ECObserver<GetQiNiuUploadTokenResponse>(this) {
            @Override
            protected boolean d() {
                return false;
            }

            @Override
            public void e(Throwable th, GetQiNiuUploadTokenResponse getQiNiuUploadTokenResponse) {
                super.e(th, getQiNiuUploadTokenResponse);
                ToastCompat.g(PHLiveRecognitionResultActivity.this, ((CommonResult) getQiNiuUploadTokenResponse).status.detail);
                ITransaction f = SentryBusiness.e().f("Image_Upload_Qiniu");
                if (((CommonResult) getQiNiuUploadTokenResponse).status != null) {
                    f.a("rail_ties_finish_code", ((CommonResult) getQiNiuUploadTokenResponse).status.code + "");
                    f.a("rail_ties_finish_error_msg", ((CommonResult) getQiNiuUploadTokenResponse).status.detail + "");
                }
                f.i(SpanStatus.INTERNAL_ERROR);
                PHLiveRecognitionResultActivity.this.C0();
            }

            @Override
            public void c(GetQiNiuUploadTokenResponse getQiNiuUploadTokenResponse) {
                PHLiveRecognitionResultActivity.this.v0(getQiNiuUploadTokenResponse);
            }
        });
    }

    protected void init() {
        super.init();
        this.f124w = new SensorUtil(this);
    }

    protected void j() {
        super.j();
        showLoadingDialog();
        z0();
    }

    @Override
    protected void k(@NonNull Bundle bundle) {
        super.k(bundle);
        FaceIdCard serializable = bundle.getSerializable("faceIdCard");
        this.p = serializable;
        if (serializable == null) {
            finish();
            return;
        }
        LivingInfo livingInfo = new LivingInfo();
        this.q = livingInfo;
        livingInfo.livingImageList = new ArrayList();
        LivingInfo livingInfo2 = this.q;
        FaceIdCard faceIdCard = this.p;
        livingInfo2.delta = faceIdCard.delta;
        Map map = faceIdCard.liveImageDatum;
        String str = this.userSession.c() != null ? this.userSession.c().mobileNumber : "";
        for (String str2 : map.keySet()) {
            byte[] bArr = (byte[]) map.get(str2);
            String format = String.format(Locale.CHINA, "%s_living_%s_%d.jpg", str, str2, Long.valueOf(System.currentTimeMillis()));
            LiveUploadData liveUploadData = new LiveUploadData(str2, bArr, format);
            this.q.livingImageList.add(format);
            this.f122u.add(liveUploadData);
        }
    }

    @Override
    public ActivityAuthLivenessRecognitionResultBinding bindingInflater() {
        return ActivityAuthLivenessRecognitionResultBinding.c(getLayoutInflater());
    }

    protected void o() {
        q0();
        r0();
    }

    @Override
    public void onBackPressed() {
        QuitAuthHelper.p(this, new Runnable() {
            @Override
            public final void run() {
                PHLiveRecognitionResultActivity.t0();
            }
        });
    }

    @Override
    protected void onCreate(Bundle bundle) {
        ThirdPartTrackLib.d(this, "auth_living_info_enter", new TrackEventParamsConfigurator() {
            @Override
            public final void a(Map map) {
                PHLiveRecognitionResultActivity.u0(map);
            }
        });
        ITransaction f = SentryBusiness.e().f("UserAuthOrder");
        this.f126y = f;
        f.a("liveDetectWay", "FACEPP");
        super.onCreate(bundle);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.f124w.c();
    }

    protected void s(@NonNull Bundle bundle) {
        super.s(bundle);
        bundle.putSerializable("faceIdCard", this.p);
    }
}