翰林优商.apk(点击下载) / c.java


package com.baidu.liantian.d;

import aegon.chrome.net.NetError;
import android.app.Activity;
import android.content.Context;
import android.content.pm.Signature;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.hardware.Camera;
import android.media.AudioManager;
import android.text.TextUtils;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.TextureView;
import androidx.constraintlayout.motion.widget.Key;
import com.baidu.idl.face.platform.FaceConfig;
import com.baidu.idl.face.platform.FaceEnvironment;
import com.baidu.idl.face.platform.FaceSDKManager;
import com.baidu.idl.face.platform.FaceStatusNewEnum;
import com.baidu.idl.face.platform.LivenessTypeEnum;
import com.baidu.idl.face.platform.listener.ISecurityCallback;
import com.baidu.idl.face.platform.model.FaceExtInfo;
import com.baidu.idl.face.platform.model.ImageInfo;
import com.baidu.idl.face.platform.utils.APIUtils;
import com.baidu.idl.face.platform.utils.BitmapUtils;
import com.baidu.idl.main.facesdk.FaceInfo;
import com.baidu.liantian.ac.FaceProcessCallback;
import com.baidu.liantian.ac.FaceProcessConfig;
import com.baidu.liantian.ac.FaceProcessType;
import com.baidu.liantian.ac.IFaceProcessInfo;
import com.baidu.liantian.ac.LH;
import com.baidu.liantian.ac.RequestInfo;
import com.baidu.liantian.utility.WbEncryptUtil;
import com.baidu.liantian.utility.e;
import com.baidu.liantian.utility.g;
import com.baidu.liantian.utility.h;
import com.baidu.liantian.utility.l;
import com.sigmob.sdk.base.mta.PointCategory;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;
import org.json.JSONArray;
import org.json.JSONObject;

/* compiled from: FaceTextureLivenessProcess */
public final class c implements Camera.ErrorCallback, TextureView.SurfaceTextureListener, ISecurityCallback, d {
    private Camera.Parameters A;
    private int B;
    private int C;
    private int D;
    private int E;
    private boolean F = false;
    private Bitmap G;
    private com.baidu.idl.face.platform.a H;
    private Map<Long, String> I;
    private int J = 1;

    /* renamed from: K  reason: collision with root package name */
    private long f96K = 0;
    private JSONObject L;
    private volatile boolean M = false;
    private int N = -1;
    private JSONArray O;
    private Map<Long, FaceInfo> P = new HashMap();
    private long Q;
    private long R = 0;
    private RequestInfo S;
    private Object T = new Object();
    private int U = 10;
    private a V;
    private com.baidu.liantian.f.c W;
    private String X;
    private String Y;
    private boolean Z;
    protected volatile boolean a = true;
    private long aa = 0;
    private boolean ab = false;
    private Timer ac = null;
    protected boolean b = false;
    protected boolean c = false;
    Rect d = new Rect();
    protected int e = 0;
    protected int f = 0;
    protected int g = 0;
    protected int h = 0;
    public volatile int i = 0;
    protected FaceConfig j;
    private Context k;
    private Activity l;
    private TextureView m;
    private FaceProcessCallback n;
    private b o;
    private C0014c p;
    private FaceProcessType q;
    private boolean r;
    private b s;
    private int t;
    private int u;
    private IFaceProcessInfo v;
    private boolean w;
    private boolean x = false;
    private Rect y = new Rect();
    private Camera z;

    public c(b bVar, Activity activity, TextureView textureView, FaceProcessCallback faceProcessCallback, FaceProcessType faceProcessType, boolean z2, int i2) {
        this.s = bVar;
        this.k = activity.getApplicationContext();
        this.l = activity;
        this.m = textureView;
        if (textureView != null) {
            this.t = textureView.getLayoutParams().height;
            this.u = this.m.getLayoutParams().width;
        }
        this.n = faceProcessCallback;
        this.v = null;
        this.q = faceProcessType;
        this.W = com.baidu.liantian.f.c.a(this.k);
        this.X = new File(this.k.getFilesDir(), "record_tmp_dir").getAbsolutePath();
        this.r = z2;
        this.J = i2;
    }

    @Override // com.baidu.liantian.d.d
    public final void a() {
        try {
            if (l.a().b(new Runnable() {
                /* class com.baidu.liantian.d.c.AnonymousClass1 */

                public final void run() {
                    try {
                        if (!c.this.w) {
                            if (!(c.this.n == null || c.this.l == null)) {
                                c.this.l.runOnUiThread(new Runnable() {
                                    /* class com.baidu.liantian.d.c.AnonymousClass1.AnonymousClass1 */

                                    public final void run() {
                                        if (c.this.n != null) {
                                            c.this.n.onBegin();
                                        }
                                    }
                                });
                            }
                            if (!c.this.w) {
                                c.d(c.this);
                                if (!c.this.w) {
                                    if (!(c.this.n == null || c.this.l == null)) {
                                        c.this.l.runOnUiThread(new Runnable() {
                                            /* class com.baidu.liantian.d.c.AnonymousClass1.AnonymousClass2 */

                                            public final void run() {
                                                if (c.this.n != null) {
                                                    c.this.n.onBeginCollectFaceInfo();
                                                }
                                            }
                                        });
                                    }
                                    if (!c.this.w && c.this.m.isAvailable()) {
                                        c.this.e();
                                    }
                                }
                            }
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                        c.this.a((c) -306);
                    }
                }
            }) != 1) {
                a(-304);
            }
            l.a().a(new Runnable() {
                /* class com.baidu.liantian.d.c.AnonymousClass2 */

                /* JADX WARNING: Code restructure failed: missing block: B:18:?, code lost:
                    com.baidu.liantian.utility.a.a();
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:20:0x0079, code lost:
                    monitor-enter(r6.a.T);
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:22:?, code lost:
                    r6.a.M = true;
                    r6.a.T.notifyAll();
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:24:0x0089, code lost:
                    return;
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:28:0x008d, code lost:
                    r0 = move-exception;
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:30:0x0094, code lost:
                    monitor-enter(r6.a.T);
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:32:?, code lost:
                    r6.a.M = true;
                    r6.a.T.notifyAll();
                 */
                /* JADX WARNING: Code restructure failed: missing block: B:34:0x00a4, code lost:
                    throw r0;
                 */
                /* JADX WARNING: Failed to process nested try/catch */
                /* JADX WARNING: Missing exception handler attribute for start block: B:17:0x0070 */
                public final void run() {
                    c cVar = c.this;
                    cVar.N = g.b(cVar.k);
                    c cVar2 = c.this;
                    cVar2.O = g.a(cVar2.k);
                    Pair<Integer, Object> linvokeSync = LH.linvokeSync(1, "fdrd", new Class[]{Integer.TYPE}, Integer.valueOf(c.this.U));
                    if (linvokeSync != null && ((Integer) linvokeSync.first).intValue() == 0) {
                        String str = (String) linvokeSync.second;
                        if (!TextUtils.isEmpty(str)) {
                            c.this.L = new JSONObject(str);
                        }
                    }
                    synchronized (c.this.T) {
                        c.this.M = true;
                        c.this.T.notifyAll();
                    }
                }
            });
        } catch (Throwable unused) {
            com.baidu.liantian.utility.a.a();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void d() {
        try {
            TextureView textureView = this.m;
            if (textureView != null) {
                textureView.setSurfaceTextureListener(this);
            }
        } catch (Throwable unused) {
            com.baidu.liantian.utility.a.a();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void e() {
        try {
            this.l.runOnUiThread(new Runnable() {
                /* class com.baidu.liantian.d.c.AnonymousClass3 */

                public final void run() {
                    try {
                        if (!c.this.w) {
                            if (c.this.z == null && !c.this.w) {
                                c cVar = c.this;
                                cVar.z = c.a(cVar, !cVar.j.isOpenBackCamera());
                            }
                            if (c.this.z != null) {
                                if (c.this.A == null) {
                                    c cVar2 = c.this;
                                    cVar2.A = cVar2.z.getParameters();
                                }
                                c.this.z.stopPreview();
                                c.this.F = false;
                                c.this.A.setPictureFormat(256);
                                int f = c.this.f();
                                c.this.z.setDisplayOrientation(f);
                                c.this.A.set(Key.ROTATION, f);
                                c.this.E = f;
                                Point a2 = com.baidu.liantian.e.a.a(c.this.A, c.this.t, c.this.u);
                                c.this.C = a2.x;
                                c.this.D = a2.y;
                                if (c.this.H != null) {
                                    c.this.H.a(f);
                                }
                                c.this.y.set(0, 0, c.this.D, c.this.C);
                                c cVar3 = c.this;
                                int i = cVar3.g;
                                int i2 = c.this.D;
                                int i3 = c.this.C;
                                float f2 = ((float) (i / 2)) - (((float) (i / 2)) * 0.33f);
                                float f3 = (float) (i2 / 2);
                                float f4 = ((float) (i3 / 2)) - (((float) (i3 / 2)) * 0.1f);
                                if (((float) (i2 / 2)) <= f2) {
                                    f2 = (float) (i2 / 2);
                                }
                                float f5 = (0.2f * f2) + f2;
                                cVar3.d.set((int) (f3 - f2), (int) (f4 - f5), (int) (f3 + f2), (int) (f4 + f5));
                                c.this.A.setPreviewSize(c.this.C, c.this.D);
                                c.this.z.setParameters(c.this.A);
                                if (c.this.n != null) {
                                    c.this.n.onConfigCamera(c.this.z, c.this.y, c.this.d);
                                }
                                c cVar4 = c.this;
                                cVar4.A = cVar4.z.getParameters();
                                c cVar5 = c.this;
                                cVar5.C = cVar5.A.getPreviewSize().width;
                                c cVar6 = c.this;
                                cVar6.D = cVar6.A.getPreviewSize().height;
                                c.this.z.setErrorCallback(c.this);
                                if (c.this.m != null && c.this.m.isAvailable()) {
                                    c.this.d();
                                    c.this.z.setPreviewTexture(c.this.m.getSurfaceTexture());
                                }
                                if (!c.this.w) {
                                    c.this.z.startPreview();
                                    c.this.F = true;
                                    if (c.this.i > 0) {
                                        c.this.i = 0;
                                    }
                                    c.this.V = new a(c.this, (byte) 0);
                                    c.this.V.start();
                                    if (c.this.r) {
                                        c.this.g();
                                        if (c.this.ac == null) {
                                            c.this.ac = new Timer();
                                        }
                                        c.this.ac.schedule(new TimerTask() {
                                            /* class com.baidu.liantian.d.c.AnonymousClass3.AnonymousClass1 */

                                            public final void run() {
                                                c.this.h();
                                            }
                                        }, c.this.j.getRecordVideoTime());
                                    }
                                    boolean unused = c.this.w;
                                }
                            }
                        }
                    } catch (Throwable th) {
                        th.printStackTrace();
                        c.this.a((c) NetError.ERR_TOO_MANY_REDIRECTS);
                    }
                }
            });
        } catch (Throwable th) {
            th.printStackTrace();
            a(NetError.ERR_TOO_MANY_REDIRECTS);
        }
    }

    public final void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i2, int i3) {
        this.b = true;
        if (!this.w && surfaceTexture != null) {
            TextureView textureView = this.m;
            if (textureView != null) {
                this.t = textureView.getHeight();
                this.u = this.m.getWidth();
            }
            e();
            Camera camera = this.z;
            if (camera != null) {
                try {
                    camera.setPreviewTexture(surfaceTexture);
                } catch (Throwable unused) {
                    com.baidu.liantian.utility.a.a();
                }
            }
        }
    }

    public final void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i2, int i3) {
        this.e = i2;
        this.f = i3;
        if (!this.w && surfaceTexture != null && this.F) {
            e();
        }
    }

    public final boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
        this.b = false;
        return false;
    }

    public final void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
        TextureView textureView;
        try {
            if (this.c) {
                return;
            }
            if (!this.w) {
                if (this.i <= 0 && (textureView = this.m) != null) {
                    this.G = textureView.getBitmap();
                    if (this.H == null && !this.c && !this.w) {
                        if (this.p == null) {
                            this.p = new C0014c(this, (byte) 0);
                        }
                        int i2 = AnonymousClass8.a[this.q.ordinal()];
                        if (i2 == 1) {
                            this.H = FaceSDKManager.getInstance().getActionLiveStrategyModule(this.p);
                        } else if (i2 == 2) {
                            this.H = FaceSDKManager.getInstance().getSilenceLiveStrategyModule(this.p);
                        } else if (i2 == 3) {
                            this.H = FaceSDKManager.getInstance().getColorLiveStrategyModule(this.p);
                        }
                        this.H.b(FaceProcessConfig.isFrameExtraction());
                        this.H.a(this);
                        this.H.a(this.E);
                        this.H.a(this.a);
                        this.H.a(this.j.getLivenessTypeList(FaceProcessConfig.getActionLists(), FaceProcessConfig.getRandomCount()), this.j.getLivenessColorTypeList(), this.y, this.d, this.o);
                        this.H.a(FaceProcessConfig.getLiveScoreThreshold());
                    }
                    this.i++;
                }
            }
        } catch (Throwable th) {
            th.printStackTrace();
            a(-308);
        }
    }

    /* renamed from: com.baidu.liantian.d.c$8  reason: invalid class name */
    /* compiled from: FaceTextureLivenessProcess */
    static /* synthetic */ class AnonymousClass8 {
        static final /* synthetic */ int[] a;

        /* JADX WARNING: Can't wrap try/catch for region: R(6:0|1|2|3|4|(3:5|6|8)) */
        /* JADX WARNING: Failed to process nested try/catch */
        /* JADX WARNING: Missing exception handler attribute for start block: B:3:0x0012 */
        /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x001d */
        static {
            int[] iArr = new int[FaceProcessType.values().length];
            a = iArr;
            iArr[FaceProcessType.ACTION_LIVENESS.ordinal()] = 1;
            a[FaceProcessType.SILENCE_LIVENESS.ordinal()] = 2;
            try {
                a[FaceProcessType.COLOR_LIVENESS.ordinal()] = 3;
            } catch (NoSuchFieldError unused) {
            }
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: FaceTextureLivenessProcess */
    public class a extends Thread {
        private volatile boolean b;

        private a() {
            this.b = true;
        }

        /* synthetic */ a(c cVar, byte b2) {
            this();
        }

        public final void run() {
            while (this.b) {
                if (c.this.i > 0) {
                    if (c.this.c || !this.b) {
                        return;
                    }
                    if (!(c.this.G == null || c.this.H == null)) {
                        c.this.G = FaceSDKManager.getInstance().scaleImage(c.this.G, c.this.D, c.this.C);
                        c.this.H.a(c.this.G);
                        c.this.G.recycle();
                        c cVar = c.this;
                        cVar.i--;
                    }
                }
            }
        }
    }

    public final void onError(int i2, Camera camera) {
        if (!this.ab) {
            a(NetError.ERR_TOO_MANY_REDIRECTS);
        }
    }

    @Override // com.baidu.liantian.d.d
    public final void b() {
        try {
            if (!this.w) {
                this.w = true;
                a(-102);
            }
        } catch (Throwable unused) {
            com.baidu.liantian.utility.a.a();
        }
    }

    @Override // com.baidu.liantian.d.d
    public final void a(boolean z2) {
        try {
            com.baidu.idl.face.platform.a aVar = this.H;
            if (aVar != null) {
                aVar.a(z2);
            }
        } catch (Throwable unused) {
            com.baidu.liantian.utility.a.a();
        }
    }

    @Override // com.baidu.idl.face.platform.listener.ISecurityCallback
    public final void getFaceInfoForSecurity(FaceInfo[] faceInfoArr) {
        Map<Long, FaceInfo> map;
        if (faceInfoArr != null) {
            try {
                if (faceInfoArr.length != 0) {
                    if (this.Q != 0) {
                        long currentTimeMillis = System.currentTimeMillis();
                        if (currentTimeMillis - this.R >= this.Q && (map = this.P) != null) {
                            map.put(Long.valueOf(currentTimeMillis), faceInfoArr[0]);
                            this.R = currentTimeMillis;
                        }
                    }
                }
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
            }
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: FaceTextureLivenessProcess */
    public class b implements com.baidu.idl.face.platform.b {
        private b() {
        }

        /* synthetic */ b(c cVar, byte b) {
            this();
        }

        @Override // com.baidu.idl.face.platform.b
        public final void a(FaceStatusNewEnum faceStatusNewEnum, String str, HashMap<String, ImageInfo> hashMap, HashMap<String, ImageInfo> hashMap2, int i) {
            try {
                if (c.this.c) {
                    return;
                }
                if (!c.this.w) {
                    if (faceStatusNewEnum == FaceStatusNewEnum.OK) {
                        c.this.c = true;
                        Map b = c.this.b((c) hashMap, (HashMap) hashMap2);
                        if (b != null) {
                            c.this.I = b;
                        } else {
                            c.this.a((c) -305);
                        }
                        if (c.this.n != null) {
                            c.a(hashMap, hashMap2);
                            c.this.n.onCollectCompletion(faceStatusNewEnum, str, hashMap, hashMap2, i);
                        }
                        c.this.h();
                        if (l.a().b(new d(c.this, (byte) 0)) != 1) {
                            c.this.a((c) -304);
                        }
                    } else if (faceStatusNewEnum == FaceStatusNewEnum.DetectRemindCodeTimeout) {
                        if (c.this.n != null) {
                            c.this.n.onCollectCompletion(faceStatusNewEnum, str, null, null, i);
                        }
                        c.this.a((c) NetError.ERR_CACHE_READ_FAILURE);
                    } else if (faceStatusNewEnum == FaceStatusNewEnum.AuraColorError) {
                        if (c.this.n != null) {
                            c.this.n.onCollectCompletion(faceStatusNewEnum, str, null, null, i);
                        }
                        c.this.a((c) -402);
                    } else if (faceStatusNewEnum == FaceStatusNewEnum.AuraLivenessScoreError) {
                        if (c.this.n != null) {
                            c.this.n.onCollectCompletion(faceStatusNewEnum, str, null, null, i);
                        }
                        c.this.a((c) -403);
                    } else if (faceStatusNewEnum == FaceStatusNewEnum.FaceLivenessSilentNoPass) {
                        if (c.this.n != null) {
                            c.this.n.onCollectCompletion(faceStatusNewEnum, str, null, null, i);
                        }
                        c.this.a((c) -404);
                    } else if (c.this.n != null) {
                        c.this.n.onCollectCompletion(faceStatusNewEnum, str, null, null, i);
                    }
                }
            } catch (Throwable th) {
                th.printStackTrace();
                c.this.a((c) -307);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void a(final int i2) {
        try {
            this.c = true;
            this.w = true;
            this.l.runOnUiThread(new Runnable() {
                /* class com.baidu.liantian.d.c.AnonymousClass4 */

                public final void run() {
                    if (c.this.n != null) {
                        if (i2 == 1) {
                            c.this.n.onEnd(i2, c.this.S);
                        } else {
                            c.this.n.onEnd(i2, null);
                        }
                        c.this.n = null;
                    }
                }
            });
            com.baidu.liantian.f.c cVar = this.W;
            if (cVar != null && this.Z) {
                cVar.b();
            }
            Timer timer = this.ac;
            if (timer != null) {
                timer.cancel();
                this.ac = null;
            }
            try {
                this.l.runOnUiThread(new Runnable() {
                    /* class com.baidu.liantian.d.c.AnonymousClass5 */

                    /* JADX WARNING: Code restructure failed: missing block: B:16:?, code lost:
                        com.baidu.liantian.utility.a.a();
                     */
                    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0055, code lost:
                        com.baidu.liantian.e.b.a(r3.a.z);
                     */
                    /* JADX WARNING: Code restructure failed: missing block: B:18:0x005f, code lost:
                        r0 = move-exception;
                     */
                    /* JADX WARNING: Code restructure failed: missing block: B:19:0x0060, code lost:
                        com.baidu.liantian.e.b.a(r3.a.z);
                        r3.a.z = null;
                     */
                    /* JADX WARNING: Code restructure failed: missing block: B:20:0x006e, code lost:
                        throw r0;
                     */
                    /* JADX WARNING: Failed to process nested try/catch */
                    /* JADX WARNING: Missing exception handler attribute for start block: B:15:0x0052 */
                    public final void run() {
                        try {
                            c.this.F = false;
                            if (c.this.z != null) {
                                if (c.this.r && com.baidu.liantian.f.c.a) {
                                    try {
                                        c.this.z.lock();
                                    } catch (Throwable unused) {
                                        com.baidu.liantian.utility.a.a();
                                    }
                                }
                                c.this.z.setErrorCallback(null);
                                c.this.z.setPreviewCallback(null);
                                c.this.z.stopPreview();
                                com.baidu.liantian.e.b.a(c.this.z);
                                c.this.z = null;
                            }
                            if (c.this.m != null) {
                                c.this.m.setSurfaceTextureListener(null);
                            }
                            if (c.this.H != null) {
                                c.this.H.a();
                                c.this.H = null;
                            }
                            if (c.this.V != null) {
                                c.this.V.b = false;
                                c.this.V.interrupt();
                                c.this.V = null;
                            }
                        } catch (Throwable unused2) {
                            com.baidu.liantian.utility.a.a();
                        }
                    }
                });
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
            }
            TextureView textureView = this.m;
            if (textureView != null) {
                textureView.setSurfaceTextureListener(null);
                this.m = null;
            }
            this.l = null;
            b bVar = this.s;
            if (bVar != null) {
                bVar.a(this);
                this.s = null;
            }
        } catch (Throwable unused2) {
            com.baidu.liantian.utility.a.a();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    /* JADX WARNING: Removed duplicated region for block: B:16:0x0031 A[Catch:{ all -> 0x0051 }] */
    /* JADX WARNING: Removed duplicated region for block: B:24:? A[RETURN, SYNTHETIC] */
    private int f() {
        int i2;
        try {
            int rotation = this.l.getWindowManager().getDefaultDisplay().getRotation();
            if (rotation != 0) {
                if (rotation == 1) {
                    i2 = 90;
                } else if (rotation == 2) {
                    i2 = 180;
                } else if (rotation == 3) {
                    i2 = BitmapUtils.ROTATE270;
                }
                int i3 = ((0 - i2) + BitmapUtils.ROTATE360) % BitmapUtils.ROTATE360;
                if (APIUtils.hasGingerbread()) {
                    return i3;
                }
                Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
                Camera.getCameraInfo(this.B, cameraInfo);
                if (cameraInfo.facing == 1) {
                    return (360 - ((cameraInfo.orientation + i2) % BitmapUtils.ROTATE360)) % BitmapUtils.ROTATE360;
                }
                return ((cameraInfo.orientation - i2) + BitmapUtils.ROTATE360) % BitmapUtils.ROTATE360;
            }
            i2 = 0;
            int i32 = ((0 - i2) + BitmapUtils.ROTATE360) % BitmapUtils.ROTATE360;
            if (APIUtils.hasGingerbread()) {
            }
        } catch (Throwable unused) {
            com.baidu.liantian.utility.a.a();
            return 0;
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private Map<Long, String> b(HashMap<String, ImageInfo> hashMap, HashMap<String, ImageInfo> hashMap2) {
        long j2;
        try {
            if (this.j.getOutputImageType() == 0) {
                hashMap = hashMap2;
            }
            if (hashMap == null || hashMap.size() <= 0) {
                return null;
            }
            ArrayList arrayList = new ArrayList(hashMap.entrySet());
            Collections.sort(arrayList, new Comparator<Map.Entry<String, ImageInfo>>() {
                /* class com.baidu.liantian.d.c.AnonymousClass6 */

                /* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
                @Override // java.util.Comparator
                public final /* synthetic */ int compare(Map.Entry<String, ImageInfo> entry, Map.Entry<String, ImageInfo> entry2) {
                    return Float.valueOf(entry2.getKey().split("_")[2]).compareTo(Float.valueOf(entry.getKey().split("_")[2]));
                }
            });
            if (arrayList.size() <= 0) {
                return null;
            }
            int i2 = this.J;
            if (i2 < 0) {
                i2 = 1;
            }
            if (i2 > arrayList.size()) {
                i2 = arrayList.size();
            }
            HashMap hashMap3 = new HashMap();
            for (int i3 = 0; i3 < i2; i3++) {
                String[] split = ((String) ((Map.Entry) arrayList.get(i3)).getKey()).split("_");
                if (split.length > 3) {
                    j2 = Long.valueOf(split[3]).longValue();
                } else {
                    j2 = System.currentTimeMillis();
                }
                if (this.f96K == 0) {
                    this.f96K = j2;
                }
                String secBase64 = ((ImageInfo) ((Map.Entry) arrayList.get(i3)).getValue()).getSecBase64();
                if (!TextUtils.isEmpty(secBase64)) {
                    secBase64 = secBase64.replace("\n", "").replace("\t", "").replace("\r", "");
                }
                hashMap3.put(Long.valueOf(j2), secBase64);
            }
            return hashMap3;
        } catch (Throwable unused) {
            com.baidu.liantian.utility.a.a();
            return null;
        }
    }

    /* compiled from: FaceTextureLivenessProcess */
    private class d implements Runnable {
        private d() {
        }

        /* synthetic */ d(c cVar, byte b) {
            this();
        }

        public final void run() {
            try {
                if (!c.this.w) {
                    if (!(c.this.n == null || c.this.l == null)) {
                        c.this.l.runOnUiThread(new Runnable() {
                            /* class com.baidu.liantian.d.c.d.AnonymousClass1 */

                            public final void run() {
                                if (c.this.n != null) {
                                    c.this.n.onBeginBuildData();
                                }
                            }
                        });
                    }
                    if (!c.this.w) {
                        c cVar = c.this;
                        cVar.a((c) cVar.c());
                    }
                }
            } catch (Throwable th) {
                th.printStackTrace();
                c.this.a((c) -309);
            }
        }
    }

    /* JADX WARNING: Exception block dominator not found, dom blocks: [] */
    /* JADX WARNING: Missing exception handler attribute for start block: B:69:0x017c */
    public final int c() {
        byte[] bArr;
        try {
            JSONObject jSONObject = new JSONObject();
            JSONObject jSONObject2 = new JSONObject();
            JSONObject jSONObject3 = null;
            if (this.r) {
                try {
                    if (!TextUtils.isEmpty(this.Y)) {
                        File file = new File(this.Y);
                        if (file.exists()) {
                            byte[][] a2 = com.baidu.liantian.f.b.a(com.baidu.liantian.f.d.a(file));
                            try {
                                file.delete();
                            } catch (Throwable unused) {
                                com.baidu.liantian.utility.a.a();
                            }
                            if (a2 == null || a2.length != 2) {
                                throw new RuntimeException("transformResult unexpected");
                            }
                            bArr = a2[1];
                            byte[] bArr2 = a2[0];
                            if (bArr2 == null || bArr2.length == 0) {
                                throw new RuntimeException("empty mediaSafeInfo");
                            } else if (bArr == null || bArr.length == 0) {
                                throw new RuntimeException("empty mediaData");
                            } else {
                                JSONObject jSONObject4 = new JSONObject();
                                jSONObject4.put("transcheckdata", Base64.encodeToString(WbEncryptUtil.wbEncrypt(this.k, bArr2), 8).replace("\n", "").replace("\t", "").replace("\r", ""));
                                jSONObject2.put("video", jSONObject4);
                            }
                        } else {
                            throw new RuntimeException("MediaFile not exists.");
                        }
                    } else if (this.x) {
                        throw new RuntimeException("Record time too short.");
                    } else {
                        throw new RuntimeException("MediaFile not exists.");
                    }
                } catch (Throwable th) {
                    th.printStackTrace();
                    return NetError.ERR_INVALID_REDIRECT;
                }
            } else {
                bArr = null;
            }
            jSONObject2.put("t_c", this.f96K);
            IFaceProcessInfo iFaceProcessInfo = this.v;
            if (iFaceProcessInfo != null) {
                jSONObject3 = iFaceProcessInfo.buildJson();
            }
            if (jSONObject3 == null) {
                jSONObject3 = new JSONObject();
            }
            if (this.I.size() <= 0) {
                return NetError.ERR_DISALLOWED_URL_SCHEME;
            }
            JSONArray jSONArray = new JSONArray();
            for (String str : this.I.values()) {
                jSONArray.put(str);
            }
            jSONObject3.put("images", jSONArray);
            jSONObject3.put("image_type", "BASE64");
            jSONObject3.put("image_sec", true);
            jSONObject3.put("risk_identify", true);
            jSONObject3.put(PointCategory.APP, FaceEnvironment.OS);
            jSONObject2.put("face", jSONObject3);
            JSONObject jSONObject5 = new JSONObject();
            jSONObject5.put("face_auth_id", e.a("4"));
            jSONObject5.put("ev", "face");
            jSONObject5.put("ns", this.N);
            jSONObject5.put("ts", System.currentTimeMillis());
            TimeZone timeZone = TimeZone.getDefault();
            if (timeZone != null) {
                jSONObject5.put("tz", timeZone.getID());
            }
            jSONObject5.put("t_c", this.f96K);
            JSONArray jSONArray2 = this.O;
            if (jSONArray2 != null) {
                jSONObject5.put("ce", jSONArray2);
            }
            jSONObject2.put("r", jSONObject5);
            if (!this.M) {
                synchronized (this.T) {
                    if (!this.M) {
                        this.T.wait(((long) this.U) * 1000);
                    }
                }
            }
            Object obj = this.L;
            if (obj == null) {
                return NetError.ERR_SSL_PROTOCOL_ERROR;
            }
            jSONObject2.put("f", obj);
            String str2 = b.c;
            try {
                if (!TextUtils.isEmpty(str2)) {
                    String[] split = str2.split("-");
                    if (split.length >= 3) {
                        StringBuilder sb = new StringBuilder();
                        for (int i2 = 0; i2 < split.length - 3; i2++) {
                            sb.append(split[i2]);
                            sb.append("-");
                        }
                        sb.append(split[split.length - 3]);
                        str2 = sb.toString();
                    }
                }
            } catch (Throwable unused2) {
                com.baidu.liantian.utility.a.a();
            }
            jSONObject.put("licenseId", str2);
            jSONObject.put("data", Base64.encodeToString(WbEncryptUtil.wbEncrypt(this.k, jSONObject2.toString().getBytes()), 8).replace("\n", "").replace("\t", "").replace("\r", ""));
            String packageName = this.k.getPackageName();
            if (packageName != null) {
                jSONObject.put("pkg", packageName);
                try {
                    Signature[] signatureArr = this.k.getPackageManager().getPackageInfo(packageName, 64).signatures;
                    if (signatureArr != null && signatureArr.length > 0) {
                        jSONObject.put("sign", h.a(signatureArr[0].toByteArray()));
                    }
                } catch (Throwable unused3) {
                    com.baidu.liantian.utility.a.a();
                }
            }
            this.S = com.baidu.liantian.utility.c.a(this.k, jSONObject.toString(), bArr, this.X);
            return 1;
        } catch (Throwable th2) {
            th2.printStackTrace();
            return NetError.ERR_DISALLOWED_URL_SCHEME;
        }
    }

    /* renamed from: com.baidu.liantian.d.c$c  reason: collision with other inner class name */
    /* compiled from: FaceTextureLivenessProcess */
    private class C0014c implements com.baidu.idl.face.platform.c {
        private C0014c() {
        }

        /* synthetic */ C0014c(c cVar, byte b) {
            this();
        }

        @Override // com.baidu.idl.face.platform.c
        public final void a(LivenessTypeEnum livenessTypeEnum) {
            try {
                if (c.this.n != null) {
                    c.this.n.setCurrentLiveType(livenessTypeEnum);
                }
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
            }
        }

        @Override // com.baidu.idl.face.platform.c
        public final void a() {
            try {
                if (c.this.n != null) {
                    c.this.n.viewReset();
                }
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
            }
        }

        @Override // com.baidu.idl.face.platform.c
        public final void b() {
            try {
                if (c.this.n != null) {
                    c.this.n.animStop();
                }
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
            }
        }

        @Override // com.baidu.idl.face.platform.c
        public final void a(FaceExtInfo faceExtInfo) {
            try {
                if (c.this.n != null) {
                    c.this.n.setFaceInfo(faceExtInfo);
                }
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
            }
        }

        @Override // com.baidu.idl.face.platform.c
        public final void a(int i, int i2) {
            if (c.this.n != null) {
                c.this.n.setBackgroundColor(i, i2);
            }
        }

        @Override // com.baidu.idl.face.platform.c
        public final void a(float f) {
            if (c.this.n != null) {
                c.this.n.setLiveScore(f);
            }
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int g() {
        if (this.Z) {
            return -2;
        }
        Camera camera = this.z;
        if (camera == null) {
            return -4;
        }
        if (this.W.a(camera, this.X, this.B, new com.baidu.liantian.f.a() {
            /* class com.baidu.liantian.d.c.AnonymousClass7 */

            @Override // com.baidu.liantian.f.a
            public final void a() {
                c.this.a((c) NetError.ERR_INVALID_REDIRECT);
            }
        }) < 0) {
            a(NetError.ERR_INVALID_REDIRECT);
        } else {
            this.aa = System.currentTimeMillis();
        }
        this.Z = true;
        return 1;
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private int h() {
        if (!this.Z) {
            return -3;
        }
        this.Z = false;
        if (System.currentTimeMillis() - this.aa < 2000) {
            this.W.b();
            this.x = true;
            return -7;
        }
        this.x = false;
        String a2 = this.W.a();
        this.Y = a2;
        if (TextUtils.isEmpty(a2) || !new File(this.Y).exists()) {
            a(-304);
            this.ab = false;
            return -8;
        }
        this.ab = true;
        return 1;
    }

    static /* synthetic */ void d(c cVar) {
        cVar.j = FaceSDKManager.getInstance().getFaceConfig();
        cVar.a = ((AudioManager) cVar.k.getSystemService("audio")).getStreamVolume(3) > 0 ? cVar.j.isSound() : false;
        if (cVar.o == null) {
            cVar.o = new b(cVar, (byte) 0);
        }
        DisplayMetrics displayMetrics = new DisplayMetrics();
        cVar.l.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        cVar.g = displayMetrics.widthPixels;
        cVar.h = displayMetrics.heightPixels;
        cVar.d();
    }

    static /* synthetic */ Camera a(c cVar, boolean z2) {
        int numberOfCameras;
        if (cVar.w || (numberOfCameras = Camera.getNumberOfCameras()) == 0) {
            return null;
        }
        int i2 = 0;
        while (i2 < numberOfCameras) {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(i2, cameraInfo);
            if ((z2 && cameraInfo.facing == 1) || (!z2 && cameraInfo.facing == 0)) {
                break;
            }
            i2++;
        }
        if (i2 < numberOfCameras) {
            Camera open = Camera.open(i2);
            cVar.B = i2;
            return open;
        }
        Camera open2 = Camera.open(0);
        cVar.B = 0;
        return open2;
    }

    static /* synthetic */ void a(HashMap hashMap, HashMap hashMap2) {
        if (hashMap != null) {
            try {
                if (hashMap.size() > 0) {
                    for (ImageInfo imageInfo : hashMap.values()) {
                        imageInfo.setBase64("");
                    }
                }
            } catch (Throwable unused) {
                com.baidu.liantian.utility.a.a();
                return;
            }
        }
        if (hashMap2 != null && hashMap2.size() > 0) {
            for (ImageInfo imageInfo2 : hashMap2.values()) {
                imageInfo2.setBase64("");
            }
        }
    }
}