package com.tencent.mm.plugin.facedetectlight.ui;

import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.compatible.e.t;
import com.tencent.mm.plugin.facedetect.model.p;
import com.tencent.mm.plugin.facedetectlight.Utils.YTAGFaceReflectResult;
import com.tencent.mm.plugin.facedetectlight.ui.a.b;
import com.tencent.mm.protocal.protobuf.ju;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.smtt.sdk.TbsMediaPlayer$TbsMediaPlayerListener;
import com.tencent.youtu.ytagreflectlivecheck.YTAGReflectLiveCheckInterface;
import com.tencent.youtu.ytagreflectlivecheck.requester.UploadVideoRequester.UploadVideoResponse;
import com.tencent.youtu.ytfacetrace.YTFaceTraceInterface.FaceTraceingNotice;
import com.tencent.ytcommon.BuildConfig;

public final class c {
    int hGq;
    byte[] lWX;
    String mAppId;
    Context mContext;
    int mDesiredPreviewHeight;
    int mDesiredPreviewWidth;
    public int mState;
    TextView mbZ;
    Rect mcb;
    Rect mcc;
    int mcd;
    int mce;
    FaceTraceingNotice mch;
    String mdC;
    public b mdI;
    int mdQ;
    Point mdR;
    float mdS;
    float mdT;
    UploadVideoResponse mdU;
    t mdw;
    FaceReflectMask mdz;

    public static class a {
        private static c mdY = new c();

        static {
            AppMethodBeat.i(799);
            AppMethodBeat.o(799);
        }
    }

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

    private c() {
        this.mState = 0;
    }

    static String a(YTAGFaceReflectResult yTAGFaceReflectResult) {
        AppMethodBeat.i(800);
        if (yTAGFaceReflectResult == null || yTAGFaceReflectResult.result != 0) {
            ab.e("MicroMsg.FaceReflectLogic", "carson  face result is null or result code not 0");
            AppMethodBeat.o(800);
            return null;
        }
        try {
            String bsS = p.bsS();
            ju juVar = new ju();
            juVar.vMj = com.tencent.mm.bt.b.bI(yTAGFaceReflectResult.sidedata);
            juVar.vMk = com.tencent.mm.bt.b.bI(yTAGFaceReflectResult.data);
            p.d(juVar.toByteArray(), bsS);
            AppMethodBeat.o(800);
            return bsS;
        } catch (Exception e) {
            ab.printErrStackTrace("MicroMsg.FaceReflectLogic", e, BuildConfig.FLAVOR, new Object[0]);
            AppMethodBeat.o(800);
            return null;
        }
    }

    public final void onBackPressed() {
        AppMethodBeat.i(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_NOT_SEEKABLE);
        if (this.mState == 0 || this.mState == 1) {
            this.mdI.aB(90004, "user cancelled in processing");
            AppMethodBeat.o(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_NOT_SEEKABLE);
        } else if (this.mState == 2) {
            this.mdI.aB(90025, "user cancelled in intermediate page");
            AppMethodBeat.o(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_NOT_SEEKABLE);
        } else {
            if (this.mState == 3) {
                this.mdI.aB(90006, "cancel with on stop");
            }
            AppMethodBeat.o(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_NOT_SEEKABLE);
        }
    }

    public final void release() {
        AppMethodBeat.i(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_METADATA_UPDATE);
        try {
            if (this.mState == 0 || this.mState == 1) {
                YTAGReflectLiveCheckInterface.cancel();
                AppMethodBeat.o(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_METADATA_UPDATE);
                return;
            }
            YTAGReflectLiveCheckInterface.releaseModel();
            AppMethodBeat.o(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_METADATA_UPDATE);
        } catch (Exception e) {
            ab.printErrStackTrace("MicroMsg.FaceReflectLogic", e, "release error, e: %s", new Object[]{e.getMessage()});
            AppMethodBeat.o(TbsMediaPlayer$TbsMediaPlayerListener.MEDIA_INFO_METADATA_UPDATE);
        }
    }
}
