| | |
| | | import com.basic.security.activity.MainActivity; |
| | | import com.basic.security.base.BaseApplication; |
| | | import com.basic.security.base.BaseFragment; |
| | | import com.basic.security.fragment.PersonManageFragment; |
| | | import com.basic.security.utils.Constants; |
| | | import com.basic.security.utils.DateUtil; |
| | | import com.basic.security.utils.FaceId; |
| | | import com.basic.security.utils.IdCard; |
| | |
| | | } |
| | | |
| | | public static void restart(Context activity) { |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | second += 2000; |
| | | Thread.sleep(second); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Intent i = new Intent(); |
| | | i.setPackage("com.basic.project.idcardservice"); |
| | | i.setAction("com.basic.read.IDCard"); |
| | | i.putExtra("type", "start_service"); |
| | | i.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| | | activity.startService(i); |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | | try { |
| | | second += 2000; |
| | | Thread.sleep(second); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | Intent intent = new Intent(); |
| | | intent.setPackage("com.basic.project.idcardservice"); |
| | | intent.setAction("com.basic.read.IDCard"); |
| | | intent.putExtra("type", "start_service"); |
| | | intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| | | activity.startService(intent); |
| | | }); |
| | | } |
| | | |
| | | public static void startReadIdCard() { |
| | | MainActivity activity = (MainActivity) BaseApplication.getApplication().activity; |
| | | if (!Constants.needIdCardModule) { |
| | | return; |
| | | } |
| | | MainActivity activity = BaseApplication.getApplication().activity; |
| | | |
| | | // Log.e("startReadIdCard", "startReadIdCard 只能出现一次。如果多次 要检查代码"); |
| | | |
| | |
| | | Log.e("OnReadCardListener", "onReadCardSucceed"); |
| | | if (activity != null) { |
| | | if (activity.currentFragment == activity.fragment_su_auto_ic_wait_idcard || activity.currentFragment == activity.fragment_su_logged_ic_wait_idcard |
| | | || (activity.currentFragment == activity.fragment_person_manage && ((PersonManageFragment) activity.fragment_person_manage).needIdCardInfo())) { |
| | | || (activity.currentFragment == activity.fragment_person_manage && activity.fragment_person_manage.needIdCardInfo())) { |
| | | |
| | | IdCard c = new IdCard(); |
| | | c.birthday = DateUtil.getTimeStamp(cardInfo.getBirthday(), "yyyyMMdd"); |
| | |
| | | if (activity.currentFragment == activity.fragment_su_auto_ic_wait_idcard |
| | | // || activity.currentFragment == activity.fragment_home |
| | | || activity.currentFragment == activity.fragment_su_logged_ic_wait_idcard |
| | | || (activity.currentFragment == activity.fragment_person_manage && ((PersonManageFragment) activity.fragment_person_manage).needIdCardInfo())) { |
| | | || (activity.currentFragment == activity.fragment_person_manage && activity.fragment_person_manage.needIdCardInfo())) { |
| | | |
| | | if (intent.getBooleanExtra("close", false)) { |
| | | Toast.makeText(activity, "身份证连接失败", Toast.LENGTH_SHORT).show(); |
| | |
| | | |
| | | |
| | | // } else { |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | | SystemClock.sleep(5 * 1000); |
| | | |
| | | |
| | | new Thread() { |
| | | @Override |
| | | public void run() { |
| | | |
| | | SystemClock.sleep(5 * 1000); |
| | | |
| | | while (true) { |
| | | try { |
| | | while (true) { |
| | | try { |
| | | |
| | | // Log.e("read_id_card", "score 33333333333333333333333333333333333333"); |
| | | // Thread.sleep(300); |
| | | |
| | | // if (activity != null) { |
| | | if (activity.currentFragment == activity.fragment_su_auto_ic_wait_idcard |
| | | if (activity.currentFragment == activity.fragment_su_auto_ic_wait_idcard |
| | | // || activity.currentFragment == activity.fragment_home |
| | | || activity.currentFragment == activity.fragment_su_logged_ic_wait_idcard |
| | | || (activity.currentFragment == activity.fragment_person_manage && ((PersonManageFragment) activity.fragment_person_manage).needIdCardInfo())) { |
| | | || activity.currentFragment == activity.fragment_su_logged_ic_wait_idcard |
| | | || (activity.currentFragment == activity.fragment_person_manage && activity.fragment_person_manage.needIdCardInfo())) { |
| | | |
| | | if (!inRead) { |
| | | inRead = true; |
| | | if (isNewIDCardReader) { |
| | | activity.readCardUtil.startReadCard(); |
| | | } else { |
| | | Intent intent = new Intent(); |
| | | intent.setPackage("com.basic.project.idcardservice"); |
| | | intent.setAction("com.basic.read.IDCard"); |
| | | intent.putExtra("type", "start_service"); |
| | | intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| | | activity.startService(intent); |
| | | } |
| | | if (!inRead) { |
| | | inRead = true; |
| | | if (isNewIDCardReader) { |
| | | activity.readCardUtil.startReadCard(); |
| | | } else { |
| | | Intent intent = new Intent(); |
| | | intent.setPackage("com.basic.project.idcardservice"); |
| | | intent.setAction("com.basic.read.IDCard"); |
| | | intent.putExtra("type", "start_service"); |
| | | intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| | | activity.startService(intent); |
| | | } |
| | | } |
| | | // else { |
| | | |
| | | // if (activity.readUtil.isPort()) { |
| | |
| | | // SystemClock.sleep(5000); |
| | | // } |
| | | // } |
| | | } else { |
| | | if (inRead) { |
| | | inRead = false; |
| | | if (isNewIDCardReader) { |
| | | activity.readCardUtil.stopReadCard(); |
| | | } else { |
| | | Intent intent = new Intent(); |
| | | intent.setPackage("com.basic.project.idcardservice"); |
| | | intent.setAction("com.basic.read.IDCard"); |
| | | intent.putExtra("type", "stop_service"); |
| | | intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| | | activity.startService(intent); |
| | | } |
| | | } else { |
| | | if (inRead) { |
| | | inRead = false; |
| | | if (isNewIDCardReader) { |
| | | activity.readCardUtil.stopReadCard(); |
| | | } else { |
| | | Intent intent = new Intent(); |
| | | intent.setPackage("com.basic.project.idcardservice"); |
| | | intent.setAction("com.basic.read.IDCard"); |
| | | intent.putExtra("type", "stop_service"); |
| | | intent.setFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); |
| | | activity.startService(intent); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | SystemClock.sleep(200); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | SystemClock.sleep(200); |
| | | } |
| | | }.start(); |
| | | }); |
| | | |
| | | } |
| | | |