| | |
| | | |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.Color; |
| | | import android.hardware.Camera; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | |
| | | import android.text.Spanned; |
| | | import android.text.TextUtils; |
| | | import android.text.TextWatcher; |
| | | import android.text.format.DateUtils; |
| | | import android.text.style.TextAppearanceSpan; |
| | | import android.view.View; |
| | | import android.view.ViewTreeObserver; |
| | |
| | | import com.doumee.keyCabinet.dao.DaoManager; |
| | | import com.doumee.keyCabinet.dao.FingerPrintDo; |
| | | import com.doumee.keyCabinet.databinding.FaceActivityBinding; |
| | | import com.doumee.keyCabinet.event.FaceCheckResultEvent; |
| | | import com.doumee.keyCabinet.event.FaceStatusChangeEvent; |
| | | import com.doumee.keyCabinet.event.HttpEvent; |
| | | import com.doumee.keyCabinet.event.JiujinBeginEvent; |
| | |
| | | import com.doumee.keyCabinet.event.TimeClockEvent; |
| | | import com.doumee.keyCabinet.ui.keyCabinet.KeyCabinetActivity; |
| | | import com.doumee.keyCabinet.utils.BraceletLogUtils; |
| | | import com.doumee.keyCabinet.utils.CrashHandler; |
| | | import com.doumee.keyCabinet.utils.face.FaceUtils; |
| | | import com.doumee.keyCabinet.utils.face.model.SingleBaseConfig; |
| | | import com.doumee.keyCabinet.utils.usb.DevComm; |
| | |
| | | import com.example.datalibrary.model.LivenessModel; |
| | | import com.example.datalibrary.model.User; |
| | | import com.example.datalibrary.utils.FaceOnDrawTexturViewUtil; |
| | | import com.example.datalibrary.utils.FileUtils; |
| | | import com.example.datalibrary.utils.ToastUtils; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | import org.greenrobot.eventbus.ThreadMode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | |
| | | switch (type){ |
| | | case 1: |
| | | if(flag==0){ |
| | | //切换到管理员刷卡 |
| | | //Toast.makeText(mContext, "status:" + status, Toast.LENGTH_SHORT).show(); |
| | | if(status==0||status==10){ |
| | | //切换到管理员刷卡 |
| | | statusFsm(1); |
| | | }else if(status==2||status==11){ |
| | | //切换到司机刷卡 |
| | | statusFsm(3); |
| | | } |
| | | }else { |
| | |
| | | break; |
| | | case 9: |
| | | //指纹验证 |
| | | if(status==0) { |
| | | statusFsm(10); |
| | | if(flag==0){ |
| | | if(status==0) { |
| | | statusFsm(10); |
| | | }else { |
| | | statusFsm(11); |
| | | } |
| | | }else { |
| | | statusFsm(12); |
| | | } |
| | |
| | | case 4: |
| | | //切换到人脸 |
| | | if(flag==0){ |
| | | //Toast.makeText(mContext, "status:" + status, Toast.LENGTH_SHORT).show(); |
| | | if(status==1||status==10){ |
| | | statusFsm(0); |
| | | }else if(status==3||status==11){ |
| | |
| | | handler.sendEmptyMessageDelayed(1,4000); |
| | | glMantleSurfacView.setFrame(); |
| | | bdFaceImageConfig.setData(data); |
| | | FaceSDKManager.getInstance().onDetectCheck(bdFaceImageConfig, null, null, |
| | | bdFaceCheckConfig, faceDetectCallBack); |
| | | try { |
| | | FaceSDKManager.getInstance().onDetectCheck(bdFaceImageConfig, null, null, |
| | | bdFaceCheckConfig, faceDetectCallBack); |
| | | }catch (RuntimeException e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错0:"+e.getMessage()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错0:"+e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | }; |
| | |
| | | if(handler.hasMessages(1)){ |
| | | handler.removeMessages(1); |
| | | } |
| | | checkOpenDebugResult(livenessModel); |
| | | EventBus.getDefault().post(new FaceCheckResultEvent(livenessModel)); |
| | | } |
| | | }); |
| | | }catch (RuntimeException e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错2:"+e.getMessage()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错2:"+e.getMessage()); |
| | |
| | | |
| | | @Override |
| | | public void onTip(int code, String msg) { |
| | | if(1==code) { |
| | | SpUtil.saveString(CrashHandler.FILE_NAME + StringUtil.DateToStr(new Date()), msg); |
| | | } |
| | | if(isToChose){ |
| | | return; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @Subscribe(threadMode = ThreadMode.MAIN) |
| | | public void FaceCheckResultEvent(FaceCheckResultEvent e){ |
| | | if(!isFinishing()){ |
| | | checkOpenDebugResult(e.getLivenessModel()); |
| | | } |
| | | } |
| | | |
| | | private int resultCount = 0; |
| | | // ***************开发模式结果输出************* |
| | | private void checkOpenDebugResult(final LivenessModel livenessModel) { |
| | |
| | | return; |
| | | } |
| | | if (livenessModel == null) { |
| | | if (isCompareCheck) { |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(getString(R.string.face_tip2)); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | } |
| | | //System.out.println("======>人脸识别失败"); |
| | | |
| | | return; |
| | | } |
| | | if (livenessModel.isQualityCheck()) { |
| | | //是否通过质量检测 |
| | | if (isCompareCheck) { |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(getString(R.string.face_tip2)); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | } |
| | | |
| | | } else { |
| | | User user = livenessModel.getUser(); |
| | | if (user == null) { |
| | | mUser = null; |
| | | //EventBus.getDefault().post(new HttpEvent("人脸用户检测失败------->"+(status==0?"管理员人脸检测:":"司机人脸检测:"))); |
| | | if (isCompareCheck) { |
| | | /*getDB().clFail.setVisibility(View.VISIBLE); |
| | | getDB().tv4.setText(getString(R.string.face_tip2)); |
| | | handler.sendEmptyMessageDelayed(0,1000);*/ |
| | | } |
| | | |
| | | } else { |
| | | mUser = user; |
| | | /*EventBus.getDefault().post(new HttpEvent("人脸用户------->"+(status==0?"管理员人脸检测:":"司机人脸检测:") |
| | | +(user.getGroupId().equals("0")?"管理员":"司机")));*/ |
| | | //EventBus.getDefault().post(new HttpEvent("人脸用户------->"+(status==0?"管理员人脸检测:":"司机人脸检测:")+(user.getGroupId().equals("0")?"管理员":"司机"))); |
| | | if (isCompareCheck) { |
| | | getDB().clFail.setVisibility(View.GONE); |
| | | if (handler.hasMessages(0)) { |
| | | handler.removeMessages(0); |
| | | } |
| | | /*textHuanying.setVisibility(View.GONE); |
| | | userNameLayout.setVisibility(View.VISIBLE); |
| | | nameImage.setImageResource(R.mipmap.ic_tips_gate_success); |
| | | nameText.setTextColor(Color.parseColor("#0dc6ff")); |
| | | nameText.setText(FileUtils.spotString(user.getUserName()) + " 欢迎您");*/ |
| | | } |
| | | isToChose = true; |
| | | //识别成功,跳转 |
| | |
| | | } |
| | | } |
| | | } |
| | | }catch (RuntimeException e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错:"+e.getMessage()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | ToastView.show(MApplication.mContext,"人脸报错:"+e.getMessage()); |
| | |
| | | EventBus.getDefault().post(new HttpEvent("连接设备失败3," + mDevComm.Run_GetDeviceInfo(w_strInfo))); |
| | | } |
| | | } else { |
| | | runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | EventBus.getDefault().post(new HttpEvent("连接设备失败4,"+mDevComm.Run_TestConnection())); |
| | | } |
| | | }); |
| | | EventBus.getDefault().post(new HttpEvent("连接设备失败4,"+mDevComm.Run_TestConnection())); |
| | | mDevComm.CloseComm(); |
| | | } |
| | | } |