Commit 5acca6a80410e0eb15a0f0175d0962117e60efca

Authored by 杜方
1 parent 72876d86

畅游通核销app: 1.补漏上次未上传

libs/android-logging-log4j-1.0.3.jar 0 → 100644
No preview for this file type
libs/armeabi-v7a/libPosApi.so 0 → 100644
No preview for this file type
libs/log4j-1.2.17.jar 0 → 100644
No preview for this file type
libs/zypos1.8.jar 0 → 100644
No preview for this file type
res/drawable-hdpi/black_idcard.jpg 0 → 100644

68.5 KB

res/drawable-xhdpi/black_idcard.jpg 0 → 100644

68.5 KB

res/layout/activity_black_idcard.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:orientation="vertical"
  6 + android:background="@color/white">
  7 +
  8 + <include layout="@layout/app_top_title" />
  9 +
  10 + <LinearLayout
  11 + android:id="@+id/llayout"
  12 + android:layout_width="match_parent"
  13 + android:layout_height="0dp"
  14 + android:layout_weight="1"
  15 + android:orientation="vertical"
  16 + android:weightSum="5">
  17 +
  18 + <ImageView
  19 + android:layout_width="wrap_content"
  20 + android:layout_height="wrap_content"
  21 + android:layout_gravity="center_horizontal"
  22 + android:layout_weight="4"
  23 + android:src="@drawable/black_idcard" />
  24 +
  25 + <TextView
  26 + android:layout_width="wrap_content"
  27 + android:layout_height="wrap_content"
  28 + android:layout_gravity="center_horizontal"
  29 + android:layout_marginBottom="10dp"
  30 + android:alpha="0.8"
  31 + android:text="@string/induction_zone"
  32 + android:textSize="20sp" />
  33 + </LinearLayout>
  34 +
  35 +</LinearLayout>
0 36 \ No newline at end of file
... ...
src/android_serialport_api/sample/SerialPortActivity.java 0 → 100644
  1 +/*
  2 + * Copyright 2009 Cedric Priscal
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package android_serialport_api.sample;
  18 +
  19 +import android.os.Bundle;
  20 +
  21 +import com.ectrip.cyt.config.DevicTool;
  22 +import com.ectrip.cyt.config.MyApp;
  23 +import com.ectrip.cyt.ui.BaseActivity;
  24 +import com.ectrip.trips.check.R;
  25 +
  26 +import java.io.IOException;
  27 +import java.io.InputStream;
  28 +import java.io.OutputStream;
  29 +import java.security.InvalidParameterException;
  30 +
  31 +import android_serialport_api.SerialPort;
  32 +
  33 +public abstract class SerialPortActivity extends BaseActivity {
  34 +
  35 + protected MyApp mApplication;
  36 + protected SerialPort mSerialPort;
  37 + protected OutputStream mOutputStream;
  38 + protected InputStream mInputStream;
  39 + protected ReadThread mReadThread;
  40 + protected int tempFlag = -1;
  41 +
  42 + private class ReadThread extends Thread {
  43 +
  44 + @Override
  45 + public void run() {
  46 + super.run();
  47 + while (!isInterrupted()) {
  48 + int size;
  49 + try {
  50 + byte[] buffer = new byte[1500];
  51 + if (mInputStream == null) {
  52 + return;
  53 + }
  54 +// if(tempFlag==-1){
  55 +// size = mInputStream.read(buffer);
  56 +// if (size > 0) {
  57 +// onDataReceived(buffer, size);
  58 +// }
  59 +// }
  60 + } catch (Exception e) {
  61 + e.printStackTrace();
  62 + return;
  63 + }
  64 + }
  65 + }
  66 + }
  67 +
  68 + private void DisplayError(int resourceId) {
  69 +// AlertDialog.Builder b = new AlertDialog.Builder(this);
  70 +// b.setTitle("Error");
  71 +// b.setMessage(resourceId);
  72 +// b.setPositiveButton("OK", new OnClickListener() {
  73 +// public void onClick(DialogInterface dialog, int which) {
  74 +//// SerialPortActivity.this.finish();
  75 +// }
  76 +// });
  77 +// b.show();
  78 + }
  79 +
  80 + @Override
  81 + protected void onCreate(Bundle savedInstanceState) {
  82 + super.onCreate(savedInstanceState);
  83 + mApplication = MyApp.getInstance();
  84 + }
  85 +
  86 + protected abstract void onDataReceived(final byte[] buffer, final int size);
  87 +
  88 + @Override
  89 + protected void onDestroy() {
  90 + if (DevicTool.isHiboryPos()) {
  91 + if (mReadThread != null)
  92 + mReadThread.interrupt();
  93 + mApplication.closeSerialPort();
  94 + mSerialPort = null;
  95 + }
  96 + super.onDestroy();
  97 + }
  98 +
  99 + @Override
  100 + protected void onResume() {
  101 + // TODO Auto-generated method stub
  102 + super.onResume();
  103 + try {
  104 + if (DevicTool.isHiboryPos()) {
  105 + mSerialPort = mApplication.getSerialPort();
  106 + mOutputStream = mSerialPort.getOutputStream();
  107 + mInputStream = mSerialPort.getInputStream();
  108 + /* Create a receiving thread */
  109 + if (mReadThread == null) {
  110 + mReadThread = new ReadThread();
  111 + mReadThread.start();
  112 + }
  113 + }
  114 +
  115 + } catch (SecurityException e) {
  116 + DisplayError(R.string.error_security);
  117 + } catch (IOException e) {
  118 + DisplayError(R.string.error_unknown);
  119 + } catch (InvalidParameterException e) {
  120 + DisplayError(R.string.error_configuration);
  121 + }
  122 + }
  123 +
  124 +}
... ...
src/com/ectrip/cyt/center/PosApiHandle.java 0 → 100644
  1 +package com.ectrip.cyt.center;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Build;
  5 +import android.os.Handler;
  6 +import android.posapi.PosApi;
  7 +import android.posapi.PrintQueue;
  8 +import android.widget.Toast;
  9 +
  10 +import com.ectrip.cyt.config.MyApp;
  11 +
  12 +import zyapi.CommonApi;
  13 +
  14 +
  15 +public class PosApiHandle {
  16 +
  17 + private PosApi mPosSDK = null;
  18 + private PrintQueue mPrintQueue = null;
  19 + CommonApi mCommonApi;
  20 + private static PosApiHandle posApiHandle;
  21 + public static PosApiHandle getInstance(){
  22 + if (posApiHandle==null){
  23 + posApiHandle = new PosApiHandle();
  24 + }
  25 + return posApiHandle;
  26 + }
  27 + private int mComFd = -1;
  28 + public PosApiHandle initIDread(){
  29 + mCommonApi = new CommonApi();
  30 + new Handler().postDelayed(new Runnable() {
  31 + @Override
  32 + public void run() {
  33 + // TODO Auto-generated method stub
  34 + mCommonApi.setGpioOut(53, 1);
  35 +
  36 + mCommonApi.setGpioOut(83, 1);
  37 +
  38 + int ret1 = mCommonApi.setGpioOut(68, 1);
  39 +
  40 + if (ret1 == 0) {
  41 + Toast.makeText(MyApp.getInstance(), "设置成功", Toast.LENGTH_SHORT).show();
  42 +
  43 + } else {
  44 + Toast.makeText(MyApp.getInstance(), "设置失败", Toast.LENGTH_SHORT).show();
  45 + }
  46 + }
  47 + }, 1000);
  48 + return posApiHandle;
  49 + }
  50 +
  51 + public PosApiHandle initSdk(Context context){
  52 + // 获取PosApi实例
  53 + mPosSDK = PosApi.getInstance(context);
  54 + mPrintQueue = new PrintQueue(context, mPosSDK);
  55 + // 打印队列初始化
  56 + mPrintQueue.init();
  57 + mPrintQueue.close();
  58 +
  59 + // 根据型号进行初始化mPosApi类
  60 + if (Build.MODEL.contains("LTE")
  61 + || Build.DISPLAY.contains("3508")
  62 + || Build.DISPLAY.contains("403")
  63 + || Build.DISPLAY.contains("35S09")) {
  64 + mPosSDK.initPosDev("ima35s09");
  65 + } else if (Build.MODEL.contains("5501")) {
  66 + mPosSDK.initPosDev("ima35s12");
  67 + } else {
  68 + mPosSDK.initPosDev(PosApi.PRODUCT_MODEL_IMA80M01);
  69 + }
  70 +
  71 + //监听初始化回调结果
  72 + mPosSDK.setOnComEventListener(mCommEventListener);
  73 + return posApiHandle;
  74 + }
  75 +
  76 + public PrintQueue getmPrintQueue() {
  77 + return mPrintQueue;
  78 + }
  79 +
  80 + public PosApi getPosApi(){
  81 + return mPosSDK;
  82 + }
  83 +
  84 + public void closeApi(){
  85 + // 关闭下层串口以及打印机
  86 + if (mPosSDK!=null)
  87 + mPosSDK.closeDev();
  88 + if (mCommonApi != null) {
  89 + mCommonApi.setGpioDir(83, 1);
  90 + mCommonApi.setGpioOut(83, 0);
  91 + //设置启用GPIO口为53,也就是使GPIO 53口生效
  92 + mCommonApi.setGpioDir(53, 1);
  93 + //拉低53口电压,断开对身份证模块的供电
  94 + mCommonApi.setGpioOut(53, 0);
  95 +// Toast.makeText(getApplicationContext(), "退出", 0).show();
  96 +// mCommonApi.setGpioDir(68,1);
  97 +// mCommonApi.setGpioOut(68,0);
  98 + //关闭mCommonApi类
  99 + mCommonApi.closeCom(mComFd);
  100 + }
  101 +
  102 + }
  103 +
  104 + public void openScan(){
  105 + // 必须延迟一秒,否则将会出现第一次扫描和打印延迟的现象
  106 + new Handler().postDelayed(new Runnable() {
  107 + @Override
  108 + public void run() {
  109 + // TODO Auto-generated method stub
  110 + // 打开GPIO,给扫描头上电
  111 + openDevice();
  112 +
  113 + }
  114 + }, 1000);
  115 + }
  116 +
  117 + // 打开串口以及GPIO口
  118 + private byte mGpioPower = 0x1E;// PB14
  119 + private int mCurSerialNo = 3; // usart3
  120 + private int mBaudrate = 4; // 9600
  121 + private void openDevice() {
  122 + // open power
  123 + mPosSDK.gpioControl(mGpioPower, 0, 1);
  124 +
  125 + mPosSDK.extendSerialInit(mCurSerialNo, mBaudrate, 1, 1, 1, 1);
  126 +
  127 + }
  128 +
  129 + /**
  130 + * 初始化
  131 + */
  132 + PosApi.OnCommEventListener mCommEventListener = new PosApi.OnCommEventListener() {
  133 + @Override
  134 + public void onCommState(int cmdFlag, int state, byte[] resp, int respLen) {
  135 + // TODO Auto-generated method stub
  136 + switch (cmdFlag) {
  137 + case PosApi.POS_INIT:
  138 + if (state == PosApi.COMM_STATUS_SUCCESS) {
  139 + Toast.makeText(MyApp.getInstance(), "设备初始化成功",
  140 + Toast.LENGTH_SHORT).show();
  141 + } else {
  142 + Toast.makeText(MyApp.getInstance(), "设备初始化失败",
  143 + Toast.LENGTH_SHORT).show();
  144 + }
  145 + break;
  146 + }
  147 + }
  148 + };
  149 +
  150 +
  151 +}
... ...
src/com/ectrip/cyt/config/AppConfig.java 0 → 100644
  1 +package com.ectrip.cyt.config;
  2 +
  3 +
  4 +import android.os.Environment;
  5 +
  6 +public class AppConfig {
  7 + /**
  8 + * 数据文件的根路径 目前定在外部存储卡中
  9 + */
  10 + public static final String BasePath= Environment.getExternalStorageDirectory().getAbsolutePath();
  11 + /**
  12 + * 数据库文件夹名称
  13 + */
  14 + private static final String DBDirectoryName = "wltlib";
  15 + /**
  16 + * 临时证据文件夹
  17 + */
  18 + public static final String DBDirectoryNameL = "clog";
  19 +
  20 + /**
  21 + * 总文件夹的路径
  22 + */
  23 + public static final String RootFile = BasePath+"/"+DBDirectoryName+"/";
  24 + /**
  25 + * 总文件夹的路径
  26 + */
  27 + public static final String RootFileL = BasePath+"/"+DBDirectoryNameL+"/";
  28 +
  29 + public static final String WITLIB = RootFile+"base.dat";
  30 +
  31 + public static final String LIC = RootFile+ "license.lic";
  32 +
  33 +}
... ...
src/com/ectrip/cyt/exceptionsave/debug/ConfigureLog4J.java 0 → 100644
  1 +package com.ectrip.cyt.exceptionsave.debug;
  2 +
  3 +/**
  4 + * Created by dc on 2017/3/27.
  5 + */
  6 +
  7 +import android.os.Environment;
  8 +
  9 +import org.apache.log4j.Level;
  10 +
  11 +import java.io.File;
  12 +import java.util.Date;
  13 +
  14 +import de.mindpipe.android.logging.log4j.LogConfigurator;
  15 +
  16 +/**
  17 + * 日志设置
  18 + */
  19 +
  20 +public class ConfigureLog4J {
  21 + //日志级别优先度从高到低:OFF(关闭),FATAL(致命),ERROR(错误),WARN(警告),INFO(信息),DEBUG(调试),ALL(打开所有的日志,我的理解与DEBUG级别好像没有什么区别得)
  22 +//Log4j建议只使用FATAL ,ERROR ,WARN ,INFO ,DEBUG这五个级别。
  23 + // "yyyy-MM-dd");// 日志的输出格式
  24 +
  25 + public static void configure() {
  26 + final LogConfigurator logConfigurator = new LogConfigurator();
  27 + Date nowtime = new Date();
  28 + // String needWriteMessage = myLogSdf.format(nowtime);
  29 + //日志文件路径地址:SD卡下myc文件夹log文件夹的test文件
  30 + String fileName = Environment.getExternalStorageDirectory()
  31 + + File.separator + "ectripLOG" + File.separator + "log"
  32 + + File.separator + "tdos.log";
  33 + //设置文件名
  34 + logConfigurator.setFileName(fileName);
  35 + //设置root日志输出级别 默认为DEBUG
  36 + logConfigurator.setRootLevel(Level.DEBUG);
  37 + // 设置日志输出级别
  38 + logConfigurator.setLevel("org.apache", Level.INFO);
  39 + //设置 输出到日志文件的文字格式 默认 %d %-5p [%c{2}]-[%L] %m%n
  40 + logConfigurator.setFilePattern("%d %-5p [%c{2}]-[%L] %m%n");
  41 + //设置输出到控制台的文字格式 默认%m%n
  42 + logConfigurator.setLogCatPattern("%m%n");
  43 + //设置总文件大小
  44 + logConfigurator.setMaxFileSize(1024 * 1024 * 5);
  45 + //设置最大产生的文件个数
  46 + logConfigurator.setMaxBackupSize(50);
  47 + //设置所有消息是否被立刻输出 默认为true,false 不输出
  48 + logConfigurator.setImmediateFlush(true);
  49 + //是否本地控制台打印输出 默认为true ,false不输出
  50 + logConfigurator.setUseLogCatAppender(true);
  51 + //设置是否启用文件附加,默认为true。false为覆盖文件
  52 + logConfigurator.setUseFileAppender(true);
  53 + //设置是否重置配置文件,默认为true
  54 + logConfigurator.setResetConfiguration(true);
  55 + //是否显示内部初始化日志,默认为false
  56 + logConfigurator.setInternalDebugging(false);
  57 +
  58 + logConfigurator.configure();
  59 +
  60 + }
  61 +
  62 +}
... ...
src/com/ectrip/cyt/ui/BlackIdCardActivity.java 0 → 100644
  1 +package com.ectrip.cyt.ui;
  2 +
  3 +import android.content.Intent;
  4 +import android.media.MediaPlayer;
  5 +import android.os.Bundle;
  6 +import android.os.Handler;
  7 +import android.os.Message;
  8 +import android.text.TextUtils;
  9 +import android.widget.Toast;
  10 +
  11 +import com.ectrip.cyt.config.DevicTool;
  12 +import com.ectrip.cyt.utils.CountDownTimer;
  13 +import com.ectrip.cyt.utils.LogUtil;
  14 +import com.ectrip.cyt.utils.NationDeal;
  15 +import com.ectrip.cyt.utils.SharedPreferences2Obj;
  16 +import com.ectrip.trips.check.R;
  17 +import com.ivsign.android.IDCReader.IDCReaderSDK;
  18 +
  19 +import java.io.IOException;
  20 +import java.util.Date;
  21 +
  22 +import android_serialport_api.sample.SerialPortActivity;
  23 +
  24 +/**
  25 + * 作者:dufang on 2023/11/10 10:45
  26 + */
  27 +public class BlackIdCardActivity extends SerialPortActivity {
  28 + private Integer type; // 类型
  29 + MediaPlayer player;
  30 +
  31 + /**
  32 + * 执行扫描,扫描后的结果会通过action为PosApi.ACTION_POS_COMM_STATUS的广播发回
  33 + */
  34 + Handler handler = new Handler() {
  35 + @Override
  36 + public void handleMessage(Message msg) {
  37 + super.handleMessage(msg);
  38 +
  39 + switch (msg.what) {
  40 + case 0:
  41 + try {
  42 + if (Readflage > 0) {
  43 + player.start();
  44 + Toast.makeText(BlackIdCardActivity.this, "身份号码:" + decodeInfo[5], Toast.LENGTH_SHORT).show();
  45 + Intent intent = new Intent(BlackIdCardActivity.this,
  46 + IDOrderListActivity.class);
  47 + CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除
  48 + intent.putExtra("mode", 0);
  49 + intent.putExtra("idcardNumber", decodeInfo[5]);
  50 + intent.putExtra("titleName", getString(R.string.order_list));
  51 + startActivity(intent);
  52 + } else if (Readflage == -2) {
  53 + Toast.makeText(BlackIdCardActivity.this, "连接异常:", Toast.LENGTH_SHORT).show();
  54 + } else if (Readflage == -3) {
  55 + Toast.makeText(BlackIdCardActivity.this, "无卡或卡片已读过-3:", Toast.LENGTH_SHORT).show();
  56 + } else if (Readflage == -4) {
  57 + Toast.makeText(BlackIdCardActivity.this, "无卡或卡片已读过-4:", Toast.LENGTH_SHORT).show();
  58 + } else if (Readflage == -5) {
  59 + Toast.makeText(BlackIdCardActivity.this, "读卡失败:", Toast.LENGTH_SHORT).show();
  60 + } else if (Readflage == -99) {
  61 + Toast.makeText(BlackIdCardActivity.this, "操作异常:", Toast.LENGTH_SHORT).show();
  62 + }
  63 +
  64 + Thread.sleep(100);
  65 + } catch (InterruptedException e) {
  66 + Toast.makeText(BlackIdCardActivity.this, "读取数据异常:", Toast.LENGTH_SHORT).show();
  67 + }
  68 + break;
  69 +
  70 + case 1:
  71 + Toast.makeText(BlackIdCardActivity.this, "发现身份证:", Toast.LENGTH_SHORT).show();
  72 + break;
  73 +
  74 + case 3:
  75 + try {
  76 + Bundle bundle = msg.getData();
  77 + String id = bundle.getString("id");
  78 + if (TextUtils.isEmpty(id)) return;
  79 + player.start();
  80 +// Toast.makeText(SelectActionActivity.this, "身份号码:" + id, Toast.LENGTH_SHORT).show();
  81 + Intent intent = new Intent(BlackIdCardActivity.this,
  82 + IDOrderListActivity.class);
  83 + CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除
  84 + intent.putExtra("mode", 0);
  85 + intent.putExtra("idcardNumber", id);
  86 + intent.putExtra("titleName", getString(R.string.order_list));
  87 + startActivity(intent);
  88 + } catch (IllegalStateException e) {
  89 + e.printStackTrace();
  90 + }
  91 + break;
  92 + default:
  93 + break;
  94 + }
  95 +
  96 +
  97 + }
  98 + };
  99 +
  100 + @Override
  101 + public void onCreate(Bundle savedInstanceState) {
  102 + super.onCreate(savedInstanceState);
  103 + setContentView(R.layout.activity_black_idcard);
  104 + initIDRead();
  105 + init();
  106 + }
  107 +
  108 + @Override
  109 + protected void onDataReceived(byte[] buffer, int size) {
  110 +
  111 + }
  112 +
  113 + private void init() {
  114 + type = SharedPreferences2Obj.getInstance(BlackIdCardActivity.this)
  115 + .setName("MachineType").getObject("type", Integer.class);
  116 + // 扫描提示音
  117 + player = MediaPlayer.create(getApplicationContext(),
  118 + R.raw.beep);
  119 + }
  120 +
  121 + private void initIDRead() {
  122 + new Thread(new ThreadRun()).start();
  123 + }
  124 +
  125 + /**
  126 + * 读取身份证线程
  127 + */
  128 + private boolean isRun = true;
  129 + private boolean isOpen = true;
  130 +
  131 + private class ThreadRun implements Runnable {
  132 + @Override
  133 + public void run() {
  134 + while (isRun) {
  135 + try {
  136 + Thread.sleep(200);
  137 + if (isOpen)
  138 + ReadCard();
  139 + } catch (InterruptedException e) {
  140 + // TODO Auto-generated catch block
  141 + e.printStackTrace();
  142 + }
  143 + }
  144 + }
  145 + }
  146 +
  147 + /**
  148 + * 读取身份证
  149 + */
  150 + private int Readflage = -99;
  151 + byte[] cmd_find = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x20, 0x01, 0x22};
  152 + byte[] cmd_selt = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x20, 0x02, 0x21};
  153 + byte[] cmd_read = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x30, 0x01, 0x32};
  154 + byte[] recData = new byte[1500];
  155 + String[] decodeInfo = new String[10];
  156 +
  157 + private void ReadCard() {
  158 + try {
  159 + LogUtil.d(TAG,"mInputStream"+mInputStream+"\n"+"mOutputStream"+mOutputStream);
  160 + if ((mInputStream == null) || (mOutputStream == null)) {
  161 + Readflage = -2;// 连接异常
  162 + return;
  163 + }
  164 + mOutputStream.write(cmd_find);
  165 + Thread.sleep(200);
  166 + int datalen = mInputStream.read(recData);
  167 + if (recData[9] == -97) {
  168 + mOutputStream.write(cmd_selt);
  169 + Thread.sleep(200);
  170 + datalen = mInputStream.read(recData);
  171 + if (recData[9] == -112) {
  172 + mOutputStream.write(cmd_read);
  173 + Thread.sleep(1000);
  174 + byte[] tempData = new byte[1500];
  175 + if (mInputStream.available() > 0) {
  176 + datalen = mInputStream.read(tempData);
  177 + } else {
  178 + Thread.sleep(500);
  179 + if (mInputStream.available() > 0) {
  180 + datalen = mInputStream.read(tempData);
  181 + }
  182 + }
  183 + int flag = 0;
  184 + if (datalen < 1294) {
  185 + for (int i = 0; i < datalen; i++, flag++) {
  186 + recData[flag] = tempData[i];
  187 + }
  188 + Thread.sleep(1000);
  189 + if (mInputStream.available() > 0) {
  190 + datalen = mInputStream.read(tempData);
  191 + } else {
  192 + Thread.sleep(500);
  193 + if (mInputStream.available() > 0) {
  194 + datalen = mInputStream.read(tempData);
  195 + }
  196 + }
  197 + for (int i = 0; i < datalen; i++, flag++) {
  198 + recData[flag] = tempData[i];
  199 + }
  200 + } else {
  201 + for (int i = 0; i < datalen; i++, flag++) {
  202 + recData[flag] = tempData[i];
  203 + }
  204 + }
  205 + tempData = null;
  206 + if (flag == 1295) {
  207 + if (recData[9] == -112) {
  208 +
  209 + byte[] dataBuf = new byte[256];
  210 + for (int i = 0; i < 256; i++) {
  211 + dataBuf[i] = recData[14 + i];
  212 + }
  213 + String TmpStr = new String(dataBuf, "UTF16-LE");
  214 + TmpStr = new String(TmpStr.getBytes("UTF-8"));
  215 + decodeInfo[0] = TmpStr.substring(0, 15);
  216 + decodeInfo[1] = TmpStr.substring(15, 16);
  217 + decodeInfo[2] = TmpStr.substring(16, 18);
  218 + decodeInfo[3] = TmpStr.substring(18, 26);
  219 + decodeInfo[4] = TmpStr.substring(26, 61);
  220 + decodeInfo[5] = TmpStr.substring(61, 79);
  221 + decodeInfo[6] = TmpStr.substring(79, 94);
  222 + decodeInfo[7] = TmpStr.substring(94, 102);
  223 + decodeInfo[8] = TmpStr.substring(102, 110);
  224 + decodeInfo[9] = TmpStr.substring(110, 128);
  225 + if (decodeInfo[1].equals("1"))
  226 + decodeInfo[1] = "男";
  227 + else
  228 + decodeInfo[1] = "女";
  229 + try {
  230 + int code = Integer.parseInt(decodeInfo[2]
  231 + .toString());
  232 + decodeInfo[2] = NationDeal.decodeNation(code);
  233 + } catch (Exception e) {
  234 + decodeInfo[2] = "";
  235 + }
  236 + // 照片解码
  237 + try {
  238 + int ret = IDCReaderSDK.Init();
  239 + if (ret == 0) {
  240 + byte[] datawlt = new byte[1384];
  241 + byte[] byLicData = {(byte) 0x05,
  242 + (byte) 0x00, (byte) 0x01,
  243 + (byte) 0x00, (byte) 0x5B,
  244 + (byte) 0x03, (byte) 0x33,
  245 + (byte) 0x01, (byte) 0x5A,
  246 + (byte) 0xB3, (byte) 0x1E,
  247 + (byte) 0x00};
  248 + for (int i = 0; i < 1295; i++) {
  249 + datawlt[i] = recData[i];
  250 + }
  251 + int t = IDCReaderSDK.unpack(datawlt,
  252 + byLicData);
  253 + if (t == 1) {
  254 + Readflage = 1;// 读卡成功
  255 + } else {
  256 + Readflage = 6;// 照片解码异常
  257 + }
  258 + } else {
  259 + Readflage = 6;// 照片解码异常
  260 + }
  261 + } catch (Exception e) {
  262 + Readflage = 6;// 照片解码异常
  263 + }
  264 + handler.sendEmptyMessage(0);
  265 + } else {
  266 + Readflage = -5;// 读卡失败!
  267 + }
  268 + } else {
  269 + Readflage = -5;// 读卡失败
  270 + }
  271 + } else {
  272 + Readflage = -4;// 选卡失败
  273 + }
  274 + } else {
  275 + Readflage = -3;// 寻卡失败
  276 + }
  277 + } catch (IOException e) {
  278 + // TODO Auto-generated catch block
  279 + Readflage = -99;// 读取数据异常
  280 + } catch (InterruptedException e) {
  281 + // TODO Auto-generated catch block
  282 + Readflage = -99;// 读取数据异常
  283 + }
  284 + }
  285 +
  286 + @Override
  287 + protected void onDestroy() {
  288 + // TODO Auto-generated method stub
  289 + super.onDestroy();
  290 + if (DevicTool.isHiboryPos()) {
  291 + isRun = false;
  292 + }
  293 + }
  294 +}
... ...
src/com/ectrip/cyt/utils/NationDeal.java 0 → 100644
  1 +package com.ectrip.cyt.utils;
  2 +
  3 +public class NationDeal {
  4 + public static String decodeNation(int code)
  5 + {
  6 + String nation;
  7 + switch (code)
  8 + {
  9 + case 1:
  10 + nation = "汉";
  11 + break;
  12 + case 2:
  13 + nation = "蒙古";
  14 + break;
  15 + case 3:
  16 + nation = "回";
  17 + break;
  18 + case 4:
  19 + nation = "藏";
  20 + break;
  21 + case 5:
  22 + nation = "维吾尔";
  23 + break;
  24 + case 6:
  25 + nation = "苗";
  26 + break;
  27 + case 7:
  28 + nation = "彝";
  29 + break;
  30 + case 8:
  31 + nation = "壮";
  32 + break;
  33 + case 9:
  34 + nation = "布依";
  35 + break;
  36 + case 10:
  37 + nation = "朝鲜";
  38 + break;
  39 + case 11:
  40 + nation = "满";
  41 + break;
  42 + case 12:
  43 + nation = "侗";
  44 + break;
  45 + case 13:
  46 + nation = "瑶";
  47 + break;
  48 + case 14:
  49 + nation = "白";
  50 + break;
  51 + case 15:
  52 + nation = "土家";
  53 + break;
  54 + case 16:
  55 + nation = "哈尼";
  56 + break;
  57 + case 17:
  58 + nation = "哈萨克";
  59 + break;
  60 + case 18:
  61 + nation = "傣";
  62 + break;
  63 + case 19:
  64 + nation = "黎";
  65 + break;
  66 + case 20:
  67 + nation = "傈僳";
  68 + break;
  69 + case 21:
  70 + nation = "佤";
  71 + break;
  72 + case 22:
  73 + nation = "畲";
  74 + break;
  75 + case 23:
  76 + nation = "高山";
  77 + break;
  78 + case 24:
  79 + nation = "拉祜";
  80 + break;
  81 + case 25:
  82 + nation = "水";
  83 + break;
  84 + case 26:
  85 + nation = "东乡";
  86 + break;
  87 + case 27:
  88 + nation = "纳西";
  89 + break;
  90 + case 28:
  91 + nation = "景颇";
  92 + break;
  93 + case 29:
  94 + nation = "柯尔克孜";
  95 + break;
  96 + case 30:
  97 + nation = "土";
  98 + break;
  99 + case 31:
  100 + nation = "达斡尔";
  101 + break;
  102 + case 32:
  103 + nation = "仫佬";
  104 + break;
  105 + case 33:
  106 + nation = "羌";
  107 + break;
  108 + case 34:
  109 + nation = "布朗";
  110 + break;
  111 + case 35:
  112 + nation = "撒拉";
  113 + break;
  114 + case 36:
  115 + nation = "毛南";
  116 + break;
  117 + case 37:
  118 + nation = "仡佬";
  119 + break;
  120 + case 38:
  121 + nation = "锡伯";
  122 + break;
  123 + case 39:
  124 + nation = "阿昌";
  125 + break;
  126 + case 40:
  127 + nation = "普米";
  128 + break;
  129 + case 41:
  130 + nation = "塔吉克";
  131 + break;
  132 + case 42:
  133 + nation = "怒";
  134 + break;
  135 + case 43:
  136 + nation = "乌孜别克";
  137 + break;
  138 + case 44:
  139 + nation = "俄罗斯";
  140 + break;
  141 + case 45:
  142 + nation = "鄂温克";
  143 + break;
  144 + case 46:
  145 + nation = "德昂";
  146 + break;
  147 + case 47:
  148 + nation = "保安";
  149 + break;
  150 + case 48:
  151 + nation = "裕固";
  152 + break;
  153 + case 49:
  154 + nation = "京";
  155 + break;
  156 + case 50:
  157 + nation = "塔塔尔";
  158 + break;
  159 + case 51:
  160 + nation = "独龙";
  161 + break;
  162 + case 52:
  163 + nation = "鄂伦春";
  164 + break;
  165 + case 53:
  166 + nation = "赫哲";
  167 + break;
  168 + case 54:
  169 + nation = "门巴";
  170 + break;
  171 + case 55:
  172 + nation = "珞巴";
  173 + break;
  174 + case 56:
  175 + nation = "基诺";
  176 + break;
  177 + case 97:
  178 + nation = "其他";
  179 + break;
  180 + case 98:
  181 + nation = "外国血统中国籍人士";
  182 + break;
  183 + default:
  184 + nation = "";
  185 + break;
  186 + }
  187 + return nation;
  188 + }
  189 +}
... ...
src/com/ivsign/android/IDCReader/IDCReaderSDK.java 0 → 100644
  1 +package com.ivsign.android.IDCReader;
  2 +
  3 +
  4 +import com.ectrip.cyt.config.AppConfig;
  5 +
  6 +public class IDCReaderSDK {
  7 +
  8 + private static final String TAG = "unpack";
  9 +
  10 + public IDCReaderSDK()
  11 + {
  12 + //if( 0==wltInit("") )
  13 + //Log.i(TAG, "wltInit success");
  14 + }
  15 + public static int Init()
  16 + {
  17 + return wltInit(AppConfig.RootFile);
  18 + }
  19 + public static int unpack(byte[] wltdata, byte[] licdata)
  20 + {
  21 + return wltGetBMP(wltdata, licdata);
  22 + }
  23 +
  24 + // native functin interface
  25 + public static native int wltInit(String workPath);
  26 +
  27 + public static native int wltGetBMP(byte[] wltdata, byte[] licdata);
  28 +
  29 + /* this is used to load the 'wltdecode' library on application
  30 + */
  31 + static {
  32 + System.loadLibrary("wltdecode");
  33 + }
  34 +}
... ...
src/zyapi/CommonApi.java 0 → 100644
  1 +package zyapi;
  2 +
  3 +
  4 +public class CommonApi {
  5 + private static CommonApi mMe = null;
  6 +
  7 + public CommonApi() {
  8 + }
  9 +
  10 + // gpio
  11 + public native int setGpioMode(int pin, int mode);
  12 + public native int setGpioDir(int pin, int dir);
  13 + public native int setGpioPullEnable(int pin, int enable);
  14 + public native int setGpioPullSelect(int pin, int select);
  15 + public native int setGpioOut(int pin, int out);
  16 + public native int getGpioIn(int pin);
  17 + //serialport
  18 + public native int openCom(String port, int baudrate, int bits, char event, int stop);
  19 + public native int openComEx(String port, int baudrate, int bits, char event, int stop, int flags);
  20 + public native int writeCom(int fd, byte[] buf, int sizes);
  21 + public native int readCom(int fd, byte[] buf, int sizes);
  22 + public native int readComEx(int fd, byte[] buf, int sizes, int sec, int usec);
  23 + public native void closeCom(int fd);
  24 +
  25 + static {
  26 + System.loadLibrary("zyapi_common");
  27 + }
  28 +
  29 +}
... ...