From 8ff90d87687b6d38158809aae776b6c709d7b60a Mon Sep 17 00:00:00 2001
From: weimingfei <fei_gaming@sina.com>
Date: 星期四, 04 十二月 2025 12:01:41 +0800
Subject: [PATCH] 指纹钥匙柜

---
 keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java |  332 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 216 insertions(+), 116 deletions(-)

diff --git a/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java b/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
index 2584140..52a2407 100644
--- a/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
+++ b/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
@@ -14,6 +14,7 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.serialport.SerialPortFinder;
 import android.text.SpannableString;
 import android.text.Spanned;
 import android.text.TextUtils;
@@ -69,6 +70,7 @@
 import com.doumee.keyCabinet.event.OpenGridOneResultEvent;
 import com.doumee.keyCabinet.event.TimeClockEvent;
 import com.doumee.keyCabinet.ui.face.ActivationActivity;
+import com.doumee.keyCabinet.ui.face.ChoseActivationActivity;
 import com.doumee.keyCabinet.ui.face.FaceActivity;
 import com.doumee.keyCabinet.ui.keyCabinet.ChangeUrlActivity;
 import com.doumee.keyCabinet.ui.keyCabinet.KeyCabinetActivity;
@@ -84,6 +86,7 @@
 import com.doumee.keyCabinet.utils.CircularQueue;
 import com.doumee.keyCabinet.utils.CrashHandler;
 import com.doumee.keyCabinet.utils.LMobileInfo;
+import com.doumee.keyCabinet.utils.MCUtils;
 import com.doumee.keyCabinet.utils.TimeUtils;
 import com.doumee.keyCabinet.utils.face.FaceSDKManager;
 import com.doumee.keyCabinet.utils.face.FaceUtils;
@@ -107,13 +110,16 @@
 import com.doumee.lib_coremodel.util.StringUtil;
 import com.doumee.lib_coremodel.view.ToastView;
 import com.example.datalibrary.api.FaceApi;
+import com.example.datalibrary.db.DBManager;
 import com.example.datalibrary.listener.DBLoadListener;
 import com.example.datalibrary.listener.SdkInitListener;
 import com.example.datalibrary.model.ImportFeatureResult;
 import com.example.datalibrary.model.User;
 import com.example.datalibrary.utils.ToastUtils;
 import com.example.datalibrary.view.PreviewTexture;
-import com.innohi.YNHAPI;
+import com.mc.enjoysdk.McHome;
+import com.mc.enjoysdk.McSystemUi;
+import com.mc.enjoysdk.transform.McSystemUiFlag;
 import com.yanzhenjie.permission.runtime.Permission;
 
 import org.greenrobot.eventbus.EventBus;
@@ -160,6 +166,8 @@
     private int downCount = 0;
     private Long lastDownTime;
     private Long showTime;
+    private McSystemUi mcSystemUi;
+    private McHome mcHome;
 
     private Handler handler = new Handler(){
         @Override
@@ -219,6 +227,8 @@
         startService(intent2);*/
         getPermission();
         Timber.tag("====>").d(LMobileInfo.getDeviceUniqueId());
+        mcSystemUi = McSystemUi.getInstance(this);
+        mcHome = McHome.getInstance(this);
     }
 
     private void initM(){
@@ -253,6 +263,7 @@
             @Override
             public void onChanged(List<FaceUserBean> beans) {
                 //鏇存柊浜鸿劯鏁版嵁
+                getVM().addInfo("鏇存柊浜鸿劯鏁版嵁======銆媌eans = "+beans);
                 if(beans!=null&&beans.size()>0){
                     initModel(beans);
                 }
@@ -324,8 +335,10 @@
                 }else {
                     getDB().nsv.setVisibility(View.VISIBLE);
                 }
-                YNHAPI mAPI = YNHAPI.getInstance();
-                mAPI.setNavigationBarVisibility(YNHAPI.NavigationBarVisibility.VISIBLE);
+                //鏄剧ず鐘舵�佹爮
+                mcSystemUi.temporarilySwitchStatusBar(true);
+                //鏄剧ず瀵艰埅鏍�
+                mcSystemUi.temporarilySwitchNavigation(true);
             }
         });
         upErrInfo();
@@ -340,6 +353,7 @@
                     }
                     setJiuConfig();
                     initPort();
+                    EventBus.getDefault().post(new GetFacesEvent());
                 }
             }
         });
@@ -458,6 +472,12 @@
 
     private SpannableString getErrPhoneText(){
         String phone = MApplication.getConfigBean().getLinkPhone();
+        if(phone==null){
+            String text = "濡傛湁闂璇疯仈绯荤鐞嗗憳";
+            SpannableString styledText = new SpannableString(text);
+            styledText.setSpan(new TextAppearanceSpan(this, R.style.style_tip3), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+            return styledText;
+        }
         String text = "濡傛湁闂璇疯仈绯荤鐞嗗憳"+phone;
         SpannableString styledText = new SpannableString(text);
         styledText.setSpan(new TextAppearanceSpan(this, R.style.style_tip3), 0, text.length()-phone.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@@ -470,9 +490,9 @@
     protected void onResume() {
         super.onResume();
         isShowing = true;
-        YNHAPI mAPI = YNHAPI.getInstance();
-        mAPI.setNavigationBarVisibility(YNHAPI.NavigationBarVisibility.ALWAYS_INVISIBLE);
-        mAPI.setBootLaunchApk("com.doumee.keyCabinet", true);
+        getVM().setSubmit(true);
+        MCUtils.hind(mcSystemUi);
+        mcHome.setHomePackage("com.doumee.keyCabinet");
         showTime = System.currentTimeMillis();
         if(!isFaceOk) {
             initLicense();
@@ -512,7 +532,10 @@
         if (future != null && !future.isDone()) {
             future.cancel(true);
         }
-        FaceApi.getInstance().cleanRecords();
+        if(isFaceOk) {
+            //婵�娲讳簡鎵嶅鐞�
+            FaceApi.getInstance().cleanRecords();
+        }
         handler.removeCallbacksAndMessages(null);
         handler = null;
         faceHandler.removeCallbacksAndMessages(null);
@@ -543,7 +566,9 @@
 
     @Subscribe
     public void GetFacesEvent(GetFacesEvent event){
+        getVM().addInfo("鏌ヨ浜鸿劯鏁版嵁======銆�");
         if(!isFinishing()&&!isUpdatingFace){
+            getVM().addInfo("鏌ヨ浜鸿劯鏁版嵁======銆媔sDBLoad = "+isDBLoad);
             if(isDBLoad){
                 isNeedUpdateFace = false;
                 //鏌ヨ浜鸿劯
@@ -577,7 +602,7 @@
                         /*
                          *瑕佹墽琛岀殑鎿嶄綔*/
 
-                        startActivity(new Intent(mContext, ActivationActivity.class));
+                        startActivity(new Intent(mContext, ChoseActivationActivity.class));
                     }
                 };
                 Timer timer = new Timer();
@@ -639,10 +664,10 @@
                             @Override
                             public void run() {
                                 FaceApi.getInstance().setUsers(users);
+                                isDBLoad = true;
                                 initFaceSDKManager(null);
                                 if (successCount > 5000 || successCount == 0) {
                                     getDB().progressGroup.setVisibility(View.GONE);
-                                    isDBLoad = true;
                                     isFaceOk = true;
                                 }
                             }
@@ -688,8 +713,10 @@
 
     private void initModel(List<FaceUserBean> userBeans) {
         if (com.example.datalibrary.manager.FaceSDKManager.initStatus == com.example.datalibrary.manager.FaceSDKManager.SDK_MODEL_LOAD_SUCCESS) {
+            getVM().addInfo("鏇存柊浜鸿劯===銆嬪紑濮嬫洿鏂�");
             waitUpdate(userBeans);
         }else {
+            getVM().addInfo("鏇存柊浜鸿劯===銆嬪垵濮嬪寲");
             initFaceSDKManager(userBeans);
         }
     }
@@ -745,6 +772,7 @@
         super.onPause();
         showTime = null;
         isShowing = false;
+        getVM().setSubmit(false);
     }
 
     private int finishCount;
@@ -778,11 +806,9 @@
         }
     };
 
-    private void waitUpdate(List<FaceUserBean> userBeans){
-        if(isUpdatingFace){
-            //姝e湪鏇存柊
-            waitBeans.addAll(userBeans);
-        }else {
+    private UserInfoManager.UserInfoListener mUserListListener = new UserInfoManager.UserInfoListener(){
+        @Override
+        public void userListQuerySuccess(String userName, List<User> listUserInfo) {
             selectBeans.clear();
             selectBeans.addAll(waitBeans);
             waitBeans.clear();
@@ -800,25 +826,37 @@
             //鍒犻櫎涓嶅瓨鍦ㄧ敤鎴�
             List<User> users = FaceApi.getInstance().getAllUserList();
             List<User> dels = new ArrayList<>();
+            StringBuilder sb = new StringBuilder();
             for(User u:users){
                 String key = u.getUserId()+"_"+u.getGroupId();
                 if(!uMap.containsKey(key)){
+                    u.setChecked(true);
                     dels.add(u);
+                    if(sb.length()>0){
+                        sb.append(",");
+                    }
+                    sb.append(u.getUserName());
                 }
             }
+            getVM().addInfo("鏇存柊浜鸿劯銆嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨��");
             if(dels.size()>0){
-                UserInfoManager.getInstance().deleteUserListInfo(dels,
-                        "", new UserInfoManager.UserInfoListener() {
+                getVM().addInfo("鍑嗗鍒犻櫎鐢ㄦ埛锛�"+sb.toString());
+                UserInfoManager.getInstance().deleteUserListInfo(users,
+                        "1", new UserInfoManager.UserInfoListener() {
                             @Override
                             public void userListDeleteSuccess() {
                                 // 鐢ㄦ埛鍒楄〃鍒犻櫎鎴愬姛
                                 faceHandler.sendEmptyMessage(0);
+                                getVM().addInfo("鍒犻櫎鐢ㄦ埛鎴愬姛锛�");
                             }
 
                             @Override
                             public void userListDeleteFailure(String message) {
                                 // 鐢ㄦ埛鍒楄〃鍒犻櫎澶辫触
                                 faceHandler.sendEmptyMessage(0);
+                                getVM().addInfo("鍒犻櫎鐢ㄦ埛澶辫触锛�"+message);
+
+                                getVM().addInfo("鍒犻櫎鐢ㄦ埛鍒楄〃锛�"+sb.toString());
                             }
                         },
                         new DBLoadListener() {
@@ -846,11 +884,41 @@
                 faceHandler.sendEmptyMessage(0);
             }
         }
+
+        @Override
+        public void userListQueryFailure(String message) {
+
+        }
+
+        @Override
+        public void userListDeleteSuccess() {
+
+        }
+
+        @Override
+        public void userListDeleteFailure(String message) {
+
+        }
+    };
+
+    private List<FaceUserBean> userBeans = new ArrayList<>();
+    private void waitUpdate(List<FaceUserBean> userBeans){
+        if(isUpdatingFace){
+            //姝e湪鏇存柊
+            waitBeans.addAll(userBeans);
+            getVM().addInfo("姝e湪鏇存柊銆佺瓑寰� 銆娿�娿�娿�娿�娿�娿�娿��");
+        }else {
+            getVM().addInfo("鍒濆鍖栦汉鑴稿簱 銆娿�娿�娿�娿�娿�娿�娿��");
+            com.example.datalibrary.manager.FaceSDKManager.getInstance().initDataBases(MainActivity.this);
+            this.userBeans.clear();
+            this.userBeans.addAll(userBeans);
+            UserInfoManager.getInstance().getUserListInfo(null, mUserListListener);
+        }
     }
 
     private int repeatCount = 0;
     private void updateFace(FaceUserBean bean){
-        Timber.d("==UpdatingFace==>瀹屾垚鏁伴噺 "+finishCount);
+        //getVM().addInfo("==UpdatingFace==>瀹屾垚鏁伴噺 " + finishCount);
         if (TextUtils.isEmpty(bean.getFaceImg())||bean.getFaceImg().endsWith("null")) {
             finishCount++;
             faceHandler.sendEmptyMessage(0);
@@ -959,12 +1027,14 @@
             isSave = FaceApi.getInstance().registerUserIntoDBmanager(newDo.getGroupId(),
                     newDo.getUserId(), newDo.getUserName(), newDo.getImageName(), newDo.getUserInfo(), newDo.getFeature());
             //System.out.println("==isOk==>淇濆瓨鎴愬姛");
+            //getVM().addInfo("鏂板浜鸿劯==銆�"+newDo.getUserName()+"   缁撴灉锛�"+isSave);
         } else {
             //鏇存柊
             user.setUserName(newDo.getUserName());
             user.setImageName(newDo.getImageName());
             user.setFeature(newDo.getFeature());
             isSave = FaceApi.getInstance().userUpdateOnly(user);
+            //getVM().addInfo("鏇存柊浜鸿劯==銆�"+newDo.getUserName()+"   缁撴灉锛�"+isSave);
             //System.out.println("==isOk==>鏇存柊鎴愬姛");
         }
 
@@ -1088,7 +1158,7 @@
         SingleBaseConfig.getBaseConfig().setRBGCameraId(index);
         SingleBaseConfig.getBaseConfig().setRgbRevert(true);
         SingleBaseConfig.getBaseConfig().setRgbDetectDirection(90);
-        SingleBaseConfig.getBaseConfig().setRgbVideoDirection(270);
+        SingleBaseConfig.getBaseConfig().setRgbVideoDirection(90);
         GateConfigUtils.modityJson();
         RegisterConfigUtils.modityJson();
     }
@@ -1178,7 +1248,6 @@
                 getVM().devLogin();
                 getPermission();
                 getVM().devHeart();
-                EventBus.getDefault().post(new GetFacesEvent());
             }else {
                 loopDownCount--;
             }
@@ -1546,7 +1615,7 @@
         }
 
         getVM().updateGrids(updateList);
-        EventBus.getDefault().post(new KeyResultEvent());
+        EventBus.getDefault().post(new KeyResultEvent(bh+""));
     }
 
     private SerialPortModel jiuPort;
@@ -1610,20 +1679,28 @@
                 return;
             }
             runOnUiThread(() -> {
-                getVM().addInfo("鑾峰彇鍒伴棬鏁版嵁:" + SportUtils.bytesToHexSimple(bytes));
+                getVM().addInfo("鑾峰彇鍒版暟鎹�:" + SportUtils.bytesToHexSimple(bytes));
             });
+            String data = SportUtils.bytesToHexSimple(bytes);
             if(startIndex==1){
-                gridPath = path;
-                getVM().addInfo("璁剧疆闂ㄤ覆鍙h矾寰�:" + path);
-                SpUtil.saveString("port_grid",path);
+                if(data.toLowerCase().startsWith("80")){
+                    gridPath = path;
+                    getVM().addInfo("璁剧疆闂ㄤ覆鍙h矾寰�:=====XXXXX===>" + path);
+                    SpUtil.saveString("port_grid",path);
+                }
             }else if(startIndex==2){
-                keyPath = path;
-                getVM().addInfo("璁剧疆閽ュ寵涓插彛璺緞:" + path);
-                SpUtil.saveString("port_key",path);
+                if(data.toLowerCase().startsWith("cc")){
+                    keyPath = path;
+                    getVM().addInfo("璁剧疆閽ュ寵涓插彛璺緞:====XXXX====>" + path);
+                    SpUtil.saveString("port_key",path);
+                }
             }else if(startIndex==3){
-                jiuPath = path;
-                getVM().addInfo("璁剧疆閰掔簿涓插彛璺緞:" + path);
-                SpUtil.saveString("port_jiu",path);
+                String data2 = new String(bytes);
+                if(data2.toLowerCase().startsWith("mic")) {
+                    jiuPath = path;
+                    getVM().addInfo("璁剧疆閰掔簿涓插彛璺緞:====XXXX====>" + path);
+                    SpUtil.saveString("port_jiu", path);
+                }
             }
         }
     };
@@ -1642,8 +1719,8 @@
             switch (msg.what){
                 case 0:
                     if(index>=1&&!checkEnd()){
-                        path = ports.get(index);
                         index--;
+                        path = ports.get(index);
                         portHandler.sendEmptyMessage(4);
                     }else if(checkEnd()){
                         initPort();
@@ -1747,90 +1824,97 @@
     private boolean isInitPort;
     //鍒濆鍖栦覆鍙�
     private void initPort(){
-        //SpUtil.setString("port_grid","/dev/ttyS7");
-        //SpUtil.setString("port_key","/dev/ttyS1");
-        //SpUtil.setString("port_jiu","/dev/ttyS2");
-        gridPath = SpUtil.getString("port_grid");
-        getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+gridPath);
-        keyPath = SpUtil.getString("port_key");
-        getVM().addInfo("閽ュ寵涓插彛閾炬帴锛�"+keyPath);
-        jiuPath = SpUtil.getString("port_jiu");
-        getVM().addInfo("閰掔簿涓插彛閾炬帴锛�"+jiuPath);
-        if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))&&
-                !TextUtils.isEmpty(SpUtil.getString("port_key"))&&
-                !TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
-            if(isInitPort){
-                return;
-            }
-            xhCount=0;
-            closePort(chosePort);
-            if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))){
-                String path = SpUtil.getString("port_grid");
-                closePort(gridPort);
-                getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+path);
-                gridPort = new SerialPortModel(path,9600 ,8
-                        ,1 , 0,gridReadObserver);
-                boolean isSucc = gridPort.open();
-                if(isSucc) {
-                    isInitPort = true;
-                    getVM().addInfo("闂ㄤ覆鍙i摼鎺ユ垚鍔燂細"+path);
-                    String msg = isSucc ? "鎴愬姛" : "澶辫触";
-                    //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
-                    gridPort.startRead();
-                    //鏌ヨ鎵�鏈夋煖鏍奸棬淇℃伅
-                   checkGridStatus(300);
-                }else {
-                    getVM().addInfo("闂ㄤ覆鍙i摼鎺ュけ璐ワ細"+path);
+        try {
+            /*SpUtil.setString("port_grid","/dev/ttyS0");
+            SpUtil.setString("port_key","/dev/ttyS4");
+            SpUtil.setString("port_jiu","/dev/ttyS9");*/
+
+            gridPath = SpUtil.getString("port_grid");
+            getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+gridPath);
+            keyPath = SpUtil.getString("port_key");
+            getVM().addInfo("閽ュ寵涓插彛閾炬帴锛�"+keyPath);
+            jiuPath = SpUtil.getString("port_jiu");
+            getVM().addInfo("閰掔簿涓插彛閾炬帴锛�"+jiuPath);
+            if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))&&
+                    !TextUtils.isEmpty(SpUtil.getString("port_key"))&&
+                    !TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
+                if(isInitPort){
+                    return;
                 }
-            }
-            if(!TextUtils.isEmpty(SpUtil.getString("port_key"))){
-                String path = SpUtil.getString("port_key");
-                closePort(keyPort);
-                keyPort = new SerialPortModel(path,115200 ,8
-                        ,1 , 0,keyReadObserver);
-                boolean isSucc = keyPort.open();
-                if(isSucc) {
-                    isInitPort = true;
-                    getVM().addInfo("閽ュ寵涓插彛閾炬帴鎴愬姛锛�"+path);
-                    String msg = isSucc ? "鎴愬姛" : "澶辫触";
-                    //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
-                    keyPort.startRead();
-                    checkKeyStatus(1500);
-                }else {
-                    getVM().addInfo("閽ュ寵涓插彛閾炬帴澶辫触锛�"+path);
+                xhCount=0;
+                closePort(chosePort);
+                if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))){
+                    String path = SpUtil.getString("port_grid");
+                    closePort(gridPort);
+                    getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+path);
+                    gridPort = new SerialPortModel(path,9600 ,8
+                            ,1 , 0,gridReadObserver);
+                    boolean isSucc = gridPort.open();
+                    if(isSucc) {
+                        isInitPort = true;
+                        getVM().addInfo("闂ㄤ覆鍙i摼鎺ユ垚鍔燂細"+path);
+                        String msg = isSucc ? "鎴愬姛" : "澶辫触";
+                        //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
+                        gridPort.startRead();
+                        //鏌ヨ鎵�鏈夋煖鏍奸棬淇℃伅
+                        checkGridStatus(300);
+                    }else {
+                        getVM().addInfo("闂ㄤ覆鍙i摼鎺ュけ璐ワ細"+path);
+                    }
                 }
-            }
-            if(!TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
-                String path = SpUtil.getString("port_jiu");
-                closePort(jiuPort);
-                jiuPort = new SerialPortModel(path,9600 ,8
-                        ,1 , 0,jiuReadObserver);
-                boolean isSucc = jiuPort.open();
-                if(isSucc) {
-                    isInitPort = true;
-                    getVM().addInfo("閰掔簿涓插彛閾炬帴鎴愬姛锛�"+path);
-                    String msg = isSucc ? "鎴愬姛" : "澶辫触";
-                    //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
-                    jiuPort.startRead();
-                }else {
-                    getVM().addInfo("閰掔簿涓插彛閾炬帴澶辫触锛�"+path);
+                if(!TextUtils.isEmpty(SpUtil.getString("port_key"))){
+                    String path = SpUtil.getString("port_key");
+                    closePort(keyPort);
+                    keyPort = new SerialPortModel(path,115200 ,8
+                            ,1 , 0,keyReadObserver);
+                    boolean isSucc = keyPort.open();
+                    if(isSucc) {
+                        isInitPort = true;
+                        getVM().addInfo("閽ュ寵涓插彛閾炬帴鎴愬姛锛�"+path);
+                        String msg = isSucc ? "鎴愬姛" : "澶辫触";
+                        //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
+                        keyPort.startRead();
+                        checkKeyStatus(1500);
+                    }else {
+                        getVM().addInfo("閽ュ寵涓插彛閾炬帴澶辫触锛�"+path);
+                    }
                 }
-            }
-        }else {
-            if(xhCount>2){
-                return;
-            }
-            xhCount++;
-            ports = SportUtils.getSerialPortPaths(this);
-            if(ports==null){
-                getVM().addInfo("鏈煡璇㈠埌涓插彛鍒楄〃");
+                if(!TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
+                    String path = SpUtil.getString("port_jiu");
+                    closePort(jiuPort);
+                    jiuPort = new SerialPortModel(path,9600 ,8
+                            ,1 , 0,jiuReadObserver);
+                    boolean isSucc = jiuPort.open();
+                    if(isSucc) {
+                        isInitPort = true;
+                        getVM().addInfo("閰掔簿涓插彛閾炬帴鎴愬姛锛�"+path);
+                        String msg = isSucc ? "鎴愬姛" : "澶辫触";
+                        //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
+                        jiuPort.startRead();
+                    }else {
+                        getVM().addInfo("閰掔簿涓插彛閾炬帴澶辫触锛�"+path);
+                    }
+                }
             }else {
-                getVM().addInfo("涓插彛鍒楄〃锛�"+ports.size());
+                if(xhCount>2){
+                    return;
+                }
+                xhCount++;
+                ports = SportUtils.getSerialPortPaths(this);
+                if(ports==null){
+                    getVM().addInfo("鏈煡璇㈠埌涓插彛鍒楄〃");
+                }else {
+                    getVM().addInfo("涓插彛鍒楄〃锛�"+ports.size());
+                }
+                if(ports.size()>0){
+                    index = ports.size();
+                    portHandler.sendEmptyMessage(0);
+                }
             }
-            if(ports.size()>0){
-                index = ports.size()-1;
-                portHandler.sendEmptyMessage(0);
-            }
+        }catch (RuntimeException e){
+            Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show();
+        }catch (Exception e){
+            Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show();
         }
     }
 
@@ -1948,17 +2032,17 @@
 
     private boolean checkEnd(){
         if(TextUtils.isEmpty(gridPath)){
-            getVM().addInfo("闂ㄩ敊璇�");
+            getVM().addInfo("闂ㄩ敊璇�<<<<<<<<<<<<<<<<<<<");
             startIndex=0;
             return false;
         }
         if(TextUtils.isEmpty(keyPath)){
-            getVM().addInfo("閽ュ寵閿欒");
+            getVM().addInfo("閽ュ寵閿欒<<<<<<<<<<<<<<<<<<<");
             startIndex=1;
             return false;
         }
         if(TextUtils.isEmpty(jiuPath)){
-            getVM().addInfo("閰掔簿閿欒");
+            getVM().addInfo("閰掔簿閿欒<<<<<<<<<<<<<<<<<<<");
             startIndex=2;
             return false;
         }
@@ -2034,7 +2118,6 @@
             if(handler.hasMessages(2)){
                 handler.removeMessages(2);
             }
-
             HashMap<String,String> copyMap = new HashMap<>();
             copyMap.putAll(closeMap);
             closeMap.clear();
@@ -2071,8 +2154,25 @@
                     }
                     if(!isFail){
                         //鍏抽棬鎴愬姛
-                        EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"闂ㄥ叧闂垚鍔�***************************>鐩爣锛�"+gridDo.getKeyCode()+",褰撳墠锛�"+gridDo.getCurKeyCode()));
-                        getVM().closeGrid(gridDo);
+                        boolean isSend = false;
+                        String bh = gridDo.getGridKey().substring(0,2);
+                        if("1".equals(e.getType())){
+                            //1鍙锋澘
+                            if("01".equals(bh)){
+                                isSend = true;
+                            }
+                        }else if("2".equals(e.getType())){
+                            //2鍙锋澘
+                            if("02".equals(bh)){
+                                isSend = true;
+                            }
+                        }else {
+                            isSend = true;
+                        }
+                        if(isSend) {
+                            EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date()) + "闂ㄥ叧闂垚鍔�***************************>鐩爣锛�" + gridDo.getKeyCode() + ",褰撳墠锛�" + gridDo.getCurKeyCode()));
+                            getVM().closeGrid(gridDo);
+                        }
                     }
                 }
             }

--
Gitblit v1.9.3