From 5acca6a80410e0eb15a0f0175d0962117e60efca Mon Sep 17 00:00:00 2001 From: 杜方 Date: Mon, 13 Nov 2023 14:17:14 +0800 Subject: [PATCH] 畅游通核销app: 1.补漏上次未上传 --- libs/android-logging-log4j-1.0.3.jar | Bin 0 -> 7275 bytes libs/armeabi-v7a/libPosApi.so | Bin 0 -> 315332 bytes libs/log4j-1.2.17.jar | Bin 0 -> 489883 bytes libs/zypos1.8.jar | Bin 0 -> 32181 bytes res/drawable-hdpi/black_idcard.jpg | Bin 0 -> 70132 bytes res/drawable-xhdpi/black_idcard.jpg | Bin 0 -> 70132 bytes res/layout/activity_black_idcard.xml | 35 +++++++++++++++++++++++++++++++++++ src/android_serialport_api/sample/SerialPortActivity.java | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/com/ectrip/cyt/center/PosApiHandle.java | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/com/ectrip/cyt/config/AppConfig.java | 33 +++++++++++++++++++++++++++++++++ src/com/ectrip/cyt/exceptionsave/debug/ConfigureLog4J.java | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/com/ectrip/cyt/ui/BlackIdCardActivity.java | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/com/ectrip/cyt/utils/NationDeal.java | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/com/ivsign/android/IDCReader/IDCReaderSDK.java | 34 ++++++++++++++++++++++++++++++++++ src/zyapi/CommonApi.java | 29 +++++++++++++++++++++++++++++ 15 files changed, 951 insertions(+), 0 deletions(-) create mode 100644 libs/android-logging-log4j-1.0.3.jar create mode 100644 libs/armeabi-v7a/libPosApi.so create mode 100644 libs/log4j-1.2.17.jar create mode 100644 libs/zypos1.8.jar create mode 100644 res/drawable-hdpi/black_idcard.jpg create mode 100644 res/drawable-xhdpi/black_idcard.jpg create mode 100644 res/layout/activity_black_idcard.xml create mode 100644 src/android_serialport_api/sample/SerialPortActivity.java create mode 100644 src/com/ectrip/cyt/center/PosApiHandle.java create mode 100644 src/com/ectrip/cyt/config/AppConfig.java create mode 100644 src/com/ectrip/cyt/exceptionsave/debug/ConfigureLog4J.java create mode 100644 src/com/ectrip/cyt/ui/BlackIdCardActivity.java create mode 100644 src/com/ectrip/cyt/utils/NationDeal.java create mode 100644 src/com/ivsign/android/IDCReader/IDCReaderSDK.java create mode 100644 src/zyapi/CommonApi.java diff --git a/libs/android-logging-log4j-1.0.3.jar b/libs/android-logging-log4j-1.0.3.jar new file mode 100644 index 0000000..7d4146f Binary files /dev/null and b/libs/android-logging-log4j-1.0.3.jar differ diff --git a/libs/armeabi-v7a/libPosApi.so b/libs/armeabi-v7a/libPosApi.so new file mode 100644 index 0000000..c1ab64d Binary files /dev/null and b/libs/armeabi-v7a/libPosApi.so differ diff --git a/libs/log4j-1.2.17.jar b/libs/log4j-1.2.17.jar new file mode 100644 index 0000000..068867e Binary files /dev/null and b/libs/log4j-1.2.17.jar differ diff --git a/libs/zypos1.8.jar b/libs/zypos1.8.jar new file mode 100644 index 0000000..4c495fa Binary files /dev/null and b/libs/zypos1.8.jar differ diff --git a/res/drawable-hdpi/black_idcard.jpg b/res/drawable-hdpi/black_idcard.jpg new file mode 100644 index 0000000..eb5c638 Binary files /dev/null and b/res/drawable-hdpi/black_idcard.jpg differ diff --git a/res/drawable-xhdpi/black_idcard.jpg b/res/drawable-xhdpi/black_idcard.jpg new file mode 100644 index 0000000..eb5c638 Binary files /dev/null and b/res/drawable-xhdpi/black_idcard.jpg differ diff --git a/res/layout/activity_black_idcard.xml b/res/layout/activity_black_idcard.xml new file mode 100644 index 0000000..f65aa9b --- /dev/null +++ b/res/layout/activity_black_idcard.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/android_serialport_api/sample/SerialPortActivity.java b/src/android_serialport_api/sample/SerialPortActivity.java new file mode 100644 index 0000000..4619ca0 --- /dev/null +++ b/src/android_serialport_api/sample/SerialPortActivity.java @@ -0,0 +1,124 @@ +/* + * Copyright 2009 Cedric Priscal + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android_serialport_api.sample; + +import android.os.Bundle; + +import com.ectrip.cyt.config.DevicTool; +import com.ectrip.cyt.config.MyApp; +import com.ectrip.cyt.ui.BaseActivity; +import com.ectrip.trips.check.R; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.InvalidParameterException; + +import android_serialport_api.SerialPort; + +public abstract class SerialPortActivity extends BaseActivity { + + protected MyApp mApplication; + protected SerialPort mSerialPort; + protected OutputStream mOutputStream; + protected InputStream mInputStream; + protected ReadThread mReadThread; + protected int tempFlag = -1; + + private class ReadThread extends Thread { + + @Override + public void run() { + super.run(); + while (!isInterrupted()) { + int size; + try { + byte[] buffer = new byte[1500]; + if (mInputStream == null) { + return; + } +// if(tempFlag==-1){ +// size = mInputStream.read(buffer); +// if (size > 0) { +// onDataReceived(buffer, size); +// } +// } + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + } + } + + private void DisplayError(int resourceId) { +// AlertDialog.Builder b = new AlertDialog.Builder(this); +// b.setTitle("Error"); +// b.setMessage(resourceId); +// b.setPositiveButton("OK", new OnClickListener() { +// public void onClick(DialogInterface dialog, int which) { +//// SerialPortActivity.this.finish(); +// } +// }); +// b.show(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mApplication = MyApp.getInstance(); + } + + protected abstract void onDataReceived(final byte[] buffer, final int size); + + @Override + protected void onDestroy() { + if (DevicTool.isHiboryPos()) { + if (mReadThread != null) + mReadThread.interrupt(); + mApplication.closeSerialPort(); + mSerialPort = null; + } + super.onDestroy(); + } + + @Override + protected void onResume() { + // TODO Auto-generated method stub + super.onResume(); + try { + if (DevicTool.isHiboryPos()) { + mSerialPort = mApplication.getSerialPort(); + mOutputStream = mSerialPort.getOutputStream(); + mInputStream = mSerialPort.getInputStream(); + /* Create a receiving thread */ + if (mReadThread == null) { + mReadThread = new ReadThread(); + mReadThread.start(); + } + } + + } catch (SecurityException e) { + DisplayError(R.string.error_security); + } catch (IOException e) { + DisplayError(R.string.error_unknown); + } catch (InvalidParameterException e) { + DisplayError(R.string.error_configuration); + } + } + +} diff --git a/src/com/ectrip/cyt/center/PosApiHandle.java b/src/com/ectrip/cyt/center/PosApiHandle.java new file mode 100644 index 0000000..6cef580 --- /dev/null +++ b/src/com/ectrip/cyt/center/PosApiHandle.java @@ -0,0 +1,151 @@ +package com.ectrip.cyt.center; + +import android.content.Context; +import android.os.Build; +import android.os.Handler; +import android.posapi.PosApi; +import android.posapi.PrintQueue; +import android.widget.Toast; + +import com.ectrip.cyt.config.MyApp; + +import zyapi.CommonApi; + + +public class PosApiHandle { + + private PosApi mPosSDK = null; + private PrintQueue mPrintQueue = null; + CommonApi mCommonApi; + private static PosApiHandle posApiHandle; + public static PosApiHandle getInstance(){ + if (posApiHandle==null){ + posApiHandle = new PosApiHandle(); + } + return posApiHandle; + } + private int mComFd = -1; + public PosApiHandle initIDread(){ + mCommonApi = new CommonApi(); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + // TODO Auto-generated method stub + mCommonApi.setGpioOut(53, 1); + + mCommonApi.setGpioOut(83, 1); + + int ret1 = mCommonApi.setGpioOut(68, 1); + + if (ret1 == 0) { + Toast.makeText(MyApp.getInstance(), "设置成功", Toast.LENGTH_SHORT).show(); + + } else { + Toast.makeText(MyApp.getInstance(), "设置失败", Toast.LENGTH_SHORT).show(); + } + } + }, 1000); + return posApiHandle; + } + + public PosApiHandle initSdk(Context context){ + // 获取PosApi实例 + mPosSDK = PosApi.getInstance(context); + mPrintQueue = new PrintQueue(context, mPosSDK); + // 打印队列初始化 + mPrintQueue.init(); + mPrintQueue.close(); + + // 根据型号进行初始化mPosApi类 + if (Build.MODEL.contains("LTE") + || Build.DISPLAY.contains("3508") + || Build.DISPLAY.contains("403") + || Build.DISPLAY.contains("35S09")) { + mPosSDK.initPosDev("ima35s09"); + } else if (Build.MODEL.contains("5501")) { + mPosSDK.initPosDev("ima35s12"); + } else { + mPosSDK.initPosDev(PosApi.PRODUCT_MODEL_IMA80M01); + } + + //监听初始化回调结果 + mPosSDK.setOnComEventListener(mCommEventListener); + return posApiHandle; + } + + public PrintQueue getmPrintQueue() { + return mPrintQueue; + } + + public PosApi getPosApi(){ + return mPosSDK; + } + + public void closeApi(){ + // 关闭下层串口以及打印机 + if (mPosSDK!=null) + mPosSDK.closeDev(); + if (mCommonApi != null) { + mCommonApi.setGpioDir(83, 1); + mCommonApi.setGpioOut(83, 0); + //设置启用GPIO口为53,也就是使GPIO 53口生效 + mCommonApi.setGpioDir(53, 1); + //拉低53口电压,断开对身份证模块的供电 + mCommonApi.setGpioOut(53, 0); +// Toast.makeText(getApplicationContext(), "退出", 0).show(); +// mCommonApi.setGpioDir(68,1); +// mCommonApi.setGpioOut(68,0); + //关闭mCommonApi类 + mCommonApi.closeCom(mComFd); + } + + } + + public void openScan(){ + // 必须延迟一秒,否则将会出现第一次扫描和打印延迟的现象 + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + // TODO Auto-generated method stub + // 打开GPIO,给扫描头上电 + openDevice(); + + } + }, 1000); + } + + // 打开串口以及GPIO口 + private byte mGpioPower = 0x1E;// PB14 + private int mCurSerialNo = 3; // usart3 + private int mBaudrate = 4; // 9600 + private void openDevice() { + // open power + mPosSDK.gpioControl(mGpioPower, 0, 1); + + mPosSDK.extendSerialInit(mCurSerialNo, mBaudrate, 1, 1, 1, 1); + + } + + /** + * 初始化 + */ + PosApi.OnCommEventListener mCommEventListener = new PosApi.OnCommEventListener() { + @Override + public void onCommState(int cmdFlag, int state, byte[] resp, int respLen) { + // TODO Auto-generated method stub + switch (cmdFlag) { + case PosApi.POS_INIT: + if (state == PosApi.COMM_STATUS_SUCCESS) { + Toast.makeText(MyApp.getInstance(), "设备初始化成功", + Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(MyApp.getInstance(), "设备初始化失败", + Toast.LENGTH_SHORT).show(); + } + break; + } + } + }; + + +} diff --git a/src/com/ectrip/cyt/config/AppConfig.java b/src/com/ectrip/cyt/config/AppConfig.java new file mode 100644 index 0000000..04af6cd --- /dev/null +++ b/src/com/ectrip/cyt/config/AppConfig.java @@ -0,0 +1,33 @@ +package com.ectrip.cyt.config; + + +import android.os.Environment; + +public class AppConfig { + /** + * 数据文件的根路径 目前定在外部存储卡中 + */ + public static final String BasePath= Environment.getExternalStorageDirectory().getAbsolutePath(); + /** + * 数据库文件夹名称 + */ + private static final String DBDirectoryName = "wltlib"; + /** + * 临时证据文件夹 + */ + public static final String DBDirectoryNameL = "clog"; + + /** + * 总文件夹的路径 + */ + public static final String RootFile = BasePath+"/"+DBDirectoryName+"/"; + /** + * 总文件夹的路径 + */ + public static final String RootFileL = BasePath+"/"+DBDirectoryNameL+"/"; + + public static final String WITLIB = RootFile+"base.dat"; + + public static final String LIC = RootFile+ "license.lic"; + +} diff --git a/src/com/ectrip/cyt/exceptionsave/debug/ConfigureLog4J.java b/src/com/ectrip/cyt/exceptionsave/debug/ConfigureLog4J.java new file mode 100644 index 0000000..6e796ba --- /dev/null +++ b/src/com/ectrip/cyt/exceptionsave/debug/ConfigureLog4J.java @@ -0,0 +1,62 @@ +package com.ectrip.cyt.exceptionsave.debug; + +/** + * Created by dc on 2017/3/27. + */ + +import android.os.Environment; + +import org.apache.log4j.Level; + +import java.io.File; +import java.util.Date; + +import de.mindpipe.android.logging.log4j.LogConfigurator; + +/** + * 日志设置 + */ + +public class ConfigureLog4J { + //日志级别优先度从高到低:OFF(关闭),FATAL(致命),ERROR(错误),WARN(警告),INFO(信息),DEBUG(调试),ALL(打开所有的日志,我的理解与DEBUG级别好像没有什么区别得) +//Log4j建议只使用FATAL ,ERROR ,WARN ,INFO ,DEBUG这五个级别。 + // "yyyy-MM-dd");// 日志的输出格式 + + public static void configure() { + final LogConfigurator logConfigurator = new LogConfigurator(); + Date nowtime = new Date(); + // String needWriteMessage = myLogSdf.format(nowtime); + //日志文件路径地址:SD卡下myc文件夹log文件夹的test文件 + String fileName = Environment.getExternalStorageDirectory() + + File.separator + "ectripLOG" + File.separator + "log" + + File.separator + "tdos.log"; + //设置文件名 + logConfigurator.setFileName(fileName); + //设置root日志输出级别 默认为DEBUG + logConfigurator.setRootLevel(Level.DEBUG); + // 设置日志输出级别 + logConfigurator.setLevel("org.apache", Level.INFO); + //设置 输出到日志文件的文字格式 默认 %d %-5p [%c{2}]-[%L] %m%n + logConfigurator.setFilePattern("%d %-5p [%c{2}]-[%L] %m%n"); + //设置输出到控制台的文字格式 默认%m%n + logConfigurator.setLogCatPattern("%m%n"); + //设置总文件大小 + logConfigurator.setMaxFileSize(1024 * 1024 * 5); + //设置最大产生的文件个数 + logConfigurator.setMaxBackupSize(50); + //设置所有消息是否被立刻输出 默认为true,false 不输出 + logConfigurator.setImmediateFlush(true); + //是否本地控制台打印输出 默认为true ,false不输出 + logConfigurator.setUseLogCatAppender(true); + //设置是否启用文件附加,默认为true。false为覆盖文件 + logConfigurator.setUseFileAppender(true); + //设置是否重置配置文件,默认为true + logConfigurator.setResetConfiguration(true); + //是否显示内部初始化日志,默认为false + logConfigurator.setInternalDebugging(false); + + logConfigurator.configure(); + + } + +} diff --git a/src/com/ectrip/cyt/ui/BlackIdCardActivity.java b/src/com/ectrip/cyt/ui/BlackIdCardActivity.java new file mode 100644 index 0000000..642ff76 --- /dev/null +++ b/src/com/ectrip/cyt/ui/BlackIdCardActivity.java @@ -0,0 +1,294 @@ +package com.ectrip.cyt.ui; + +import android.content.Intent; +import android.media.MediaPlayer; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.widget.Toast; + +import com.ectrip.cyt.config.DevicTool; +import com.ectrip.cyt.utils.CountDownTimer; +import com.ectrip.cyt.utils.LogUtil; +import com.ectrip.cyt.utils.NationDeal; +import com.ectrip.cyt.utils.SharedPreferences2Obj; +import com.ectrip.trips.check.R; +import com.ivsign.android.IDCReader.IDCReaderSDK; + +import java.io.IOException; +import java.util.Date; + +import android_serialport_api.sample.SerialPortActivity; + +/** + * 作者:dufang on 2023/11/10 10:45 + */ +public class BlackIdCardActivity extends SerialPortActivity { + private Integer type; // 类型 + MediaPlayer player; + + /** + * 执行扫描,扫描后的结果会通过action为PosApi.ACTION_POS_COMM_STATUS的广播发回 + */ + Handler handler = new Handler() { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + + switch (msg.what) { + case 0: + try { + if (Readflage > 0) { + player.start(); + Toast.makeText(BlackIdCardActivity.this, "身份号码:" + decodeInfo[5], Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(BlackIdCardActivity.this, + IDOrderListActivity.class); + CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除 + intent.putExtra("mode", 0); + intent.putExtra("idcardNumber", decodeInfo[5]); + intent.putExtra("titleName", getString(R.string.order_list)); + startActivity(intent); + } else if (Readflage == -2) { + Toast.makeText(BlackIdCardActivity.this, "连接异常:", Toast.LENGTH_SHORT).show(); + } else if (Readflage == -3) { + Toast.makeText(BlackIdCardActivity.this, "无卡或卡片已读过-3:", Toast.LENGTH_SHORT).show(); + } else if (Readflage == -4) { + Toast.makeText(BlackIdCardActivity.this, "无卡或卡片已读过-4:", Toast.LENGTH_SHORT).show(); + } else if (Readflage == -5) { + Toast.makeText(BlackIdCardActivity.this, "读卡失败:", Toast.LENGTH_SHORT).show(); + } else if (Readflage == -99) { + Toast.makeText(BlackIdCardActivity.this, "操作异常:", Toast.LENGTH_SHORT).show(); + } + + Thread.sleep(100); + } catch (InterruptedException e) { + Toast.makeText(BlackIdCardActivity.this, "读取数据异常:", Toast.LENGTH_SHORT).show(); + } + break; + + case 1: + Toast.makeText(BlackIdCardActivity.this, "发现身份证:", Toast.LENGTH_SHORT).show(); + break; + + case 3: + try { + Bundle bundle = msg.getData(); + String id = bundle.getString("id"); + if (TextUtils.isEmpty(id)) return; + player.start(); +// Toast.makeText(SelectActionActivity.this, "身份号码:" + id, Toast.LENGTH_SHORT).show(); + Intent intent = new Intent(BlackIdCardActivity.this, + IDOrderListActivity.class); + CountDownTimer.firstTime = new Date().getTime();// 不必要的可以删除 + intent.putExtra("mode", 0); + intent.putExtra("idcardNumber", id); + intent.putExtra("titleName", getString(R.string.order_list)); + startActivity(intent); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + break; + default: + break; + } + + + } + }; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_black_idcard); + initIDRead(); + init(); + } + + @Override + protected void onDataReceived(byte[] buffer, int size) { + + } + + private void init() { + type = SharedPreferences2Obj.getInstance(BlackIdCardActivity.this) + .setName("MachineType").getObject("type", Integer.class); + // 扫描提示音 + player = MediaPlayer.create(getApplicationContext(), + R.raw.beep); + } + + private void initIDRead() { + new Thread(new ThreadRun()).start(); + } + + /** + * 读取身份证线程 + */ + private boolean isRun = true; + private boolean isOpen = true; + + private class ThreadRun implements Runnable { + @Override + public void run() { + while (isRun) { + try { + Thread.sleep(200); + if (isOpen) + ReadCard(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + /** + * 读取身份证 + */ + private int Readflage = -99; + byte[] cmd_find = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x20, 0x01, 0x22}; + byte[] cmd_selt = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x20, 0x02, 0x21}; + byte[] cmd_read = {(byte) 0xAA, (byte) 0xAA, (byte) 0xAA, (byte) 0x96, 0x69, 0x00, 0x03, 0x30, 0x01, 0x32}; + byte[] recData = new byte[1500]; + String[] decodeInfo = new String[10]; + + private void ReadCard() { + try { + LogUtil.d(TAG,"mInputStream"+mInputStream+"\n"+"mOutputStream"+mOutputStream); + if ((mInputStream == null) || (mOutputStream == null)) { + Readflage = -2;// 连接异常 + return; + } + mOutputStream.write(cmd_find); + Thread.sleep(200); + int datalen = mInputStream.read(recData); + if (recData[9] == -97) { + mOutputStream.write(cmd_selt); + Thread.sleep(200); + datalen = mInputStream.read(recData); + if (recData[9] == -112) { + mOutputStream.write(cmd_read); + Thread.sleep(1000); + byte[] tempData = new byte[1500]; + if (mInputStream.available() > 0) { + datalen = mInputStream.read(tempData); + } else { + Thread.sleep(500); + if (mInputStream.available() > 0) { + datalen = mInputStream.read(tempData); + } + } + int flag = 0; + if (datalen < 1294) { + for (int i = 0; i < datalen; i++, flag++) { + recData[flag] = tempData[i]; + } + Thread.sleep(1000); + if (mInputStream.available() > 0) { + datalen = mInputStream.read(tempData); + } else { + Thread.sleep(500); + if (mInputStream.available() > 0) { + datalen = mInputStream.read(tempData); + } + } + for (int i = 0; i < datalen; i++, flag++) { + recData[flag] = tempData[i]; + } + } else { + for (int i = 0; i < datalen; i++, flag++) { + recData[flag] = tempData[i]; + } + } + tempData = null; + if (flag == 1295) { + if (recData[9] == -112) { + + byte[] dataBuf = new byte[256]; + for (int i = 0; i < 256; i++) { + dataBuf[i] = recData[14 + i]; + } + String TmpStr = new String(dataBuf, "UTF16-LE"); + TmpStr = new String(TmpStr.getBytes("UTF-8")); + decodeInfo[0] = TmpStr.substring(0, 15); + decodeInfo[1] = TmpStr.substring(15, 16); + decodeInfo[2] = TmpStr.substring(16, 18); + decodeInfo[3] = TmpStr.substring(18, 26); + decodeInfo[4] = TmpStr.substring(26, 61); + decodeInfo[5] = TmpStr.substring(61, 79); + decodeInfo[6] = TmpStr.substring(79, 94); + decodeInfo[7] = TmpStr.substring(94, 102); + decodeInfo[8] = TmpStr.substring(102, 110); + decodeInfo[9] = TmpStr.substring(110, 128); + if (decodeInfo[1].equals("1")) + decodeInfo[1] = "男"; + else + decodeInfo[1] = "女"; + try { + int code = Integer.parseInt(decodeInfo[2] + .toString()); + decodeInfo[2] = NationDeal.decodeNation(code); + } catch (Exception e) { + decodeInfo[2] = ""; + } + // 照片解码 + try { + int ret = IDCReaderSDK.Init(); + if (ret == 0) { + byte[] datawlt = new byte[1384]; + byte[] byLicData = {(byte) 0x05, + (byte) 0x00, (byte) 0x01, + (byte) 0x00, (byte) 0x5B, + (byte) 0x03, (byte) 0x33, + (byte) 0x01, (byte) 0x5A, + (byte) 0xB3, (byte) 0x1E, + (byte) 0x00}; + for (int i = 0; i < 1295; i++) { + datawlt[i] = recData[i]; + } + int t = IDCReaderSDK.unpack(datawlt, + byLicData); + if (t == 1) { + Readflage = 1;// 读卡成功 + } else { + Readflage = 6;// 照片解码异常 + } + } else { + Readflage = 6;// 照片解码异常 + } + } catch (Exception e) { + Readflage = 6;// 照片解码异常 + } + handler.sendEmptyMessage(0); + } else { + Readflage = -5;// 读卡失败! + } + } else { + Readflage = -5;// 读卡失败 + } + } else { + Readflage = -4;// 选卡失败 + } + } else { + Readflage = -3;// 寻卡失败 + } + } catch (IOException e) { + // TODO Auto-generated catch block + Readflage = -99;// 读取数据异常 + } catch (InterruptedException e) { + // TODO Auto-generated catch block + Readflage = -99;// 读取数据异常 + } + } + + @Override + protected void onDestroy() { + // TODO Auto-generated method stub + super.onDestroy(); + if (DevicTool.isHiboryPos()) { + isRun = false; + } + } +} diff --git a/src/com/ectrip/cyt/utils/NationDeal.java b/src/com/ectrip/cyt/utils/NationDeal.java new file mode 100644 index 0000000..3ad063c --- /dev/null +++ b/src/com/ectrip/cyt/utils/NationDeal.java @@ -0,0 +1,189 @@ +package com.ectrip.cyt.utils; + +public class NationDeal { + public static String decodeNation(int code) + { + String nation; + switch (code) + { + case 1: + nation = "汉"; + break; + case 2: + nation = "蒙古"; + break; + case 3: + nation = "回"; + break; + case 4: + nation = "藏"; + break; + case 5: + nation = "维吾尔"; + break; + case 6: + nation = "苗"; + break; + case 7: + nation = "彝"; + break; + case 8: + nation = "壮"; + break; + case 9: + nation = "布依"; + break; + case 10: + nation = "朝鲜"; + break; + case 11: + nation = "满"; + break; + case 12: + nation = "侗"; + break; + case 13: + nation = "瑶"; + break; + case 14: + nation = "白"; + break; + case 15: + nation = "土家"; + break; + case 16: + nation = "哈尼"; + break; + case 17: + nation = "哈萨克"; + break; + case 18: + nation = "傣"; + break; + case 19: + nation = "黎"; + break; + case 20: + nation = "傈僳"; + break; + case 21: + nation = "佤"; + break; + case 22: + nation = "畲"; + break; + case 23: + nation = "高山"; + break; + case 24: + nation = "拉祜"; + break; + case 25: + nation = "水"; + break; + case 26: + nation = "东乡"; + break; + case 27: + nation = "纳西"; + break; + case 28: + nation = "景颇"; + break; + case 29: + nation = "柯尔克孜"; + break; + case 30: + nation = "土"; + break; + case 31: + nation = "达斡尔"; + break; + case 32: + nation = "仫佬"; + break; + case 33: + nation = "羌"; + break; + case 34: + nation = "布朗"; + break; + case 35: + nation = "撒拉"; + break; + case 36: + nation = "毛南"; + break; + case 37: + nation = "仡佬"; + break; + case 38: + nation = "锡伯"; + break; + case 39: + nation = "阿昌"; + break; + case 40: + nation = "普米"; + break; + case 41: + nation = "塔吉克"; + break; + case 42: + nation = "怒"; + break; + case 43: + nation = "乌孜别克"; + break; + case 44: + nation = "俄罗斯"; + break; + case 45: + nation = "鄂温克"; + break; + case 46: + nation = "德昂"; + break; + case 47: + nation = "保安"; + break; + case 48: + nation = "裕固"; + break; + case 49: + nation = "京"; + break; + case 50: + nation = "塔塔尔"; + break; + case 51: + nation = "独龙"; + break; + case 52: + nation = "鄂伦春"; + break; + case 53: + nation = "赫哲"; + break; + case 54: + nation = "门巴"; + break; + case 55: + nation = "珞巴"; + break; + case 56: + nation = "基诺"; + break; + case 97: + nation = "其他"; + break; + case 98: + nation = "外国血统中国籍人士"; + break; + default: + nation = ""; + break; + } + return nation; + } +} diff --git a/src/com/ivsign/android/IDCReader/IDCReaderSDK.java b/src/com/ivsign/android/IDCReader/IDCReaderSDK.java new file mode 100644 index 0000000..41b4e85 --- /dev/null +++ b/src/com/ivsign/android/IDCReader/IDCReaderSDK.java @@ -0,0 +1,34 @@ +package com.ivsign.android.IDCReader; + + +import com.ectrip.cyt.config.AppConfig; + +public class IDCReaderSDK { + + private static final String TAG = "unpack"; + + public IDCReaderSDK() + { + //if( 0==wltInit("") ) + //Log.i(TAG, "wltInit success"); + } + public static int Init() + { + return wltInit(AppConfig.RootFile); + } + public static int unpack(byte[] wltdata, byte[] licdata) + { + return wltGetBMP(wltdata, licdata); + } + + // native functin interface + public static native int wltInit(String workPath); + + public static native int wltGetBMP(byte[] wltdata, byte[] licdata); + + /* this is used to load the 'wltdecode' library on application + */ + static { + System.loadLibrary("wltdecode"); + } +} diff --git a/src/zyapi/CommonApi.java b/src/zyapi/CommonApi.java new file mode 100644 index 0000000..ecebce1 --- /dev/null +++ b/src/zyapi/CommonApi.java @@ -0,0 +1,29 @@ +package zyapi; + + +public class CommonApi { + private static CommonApi mMe = null; + + public CommonApi() { + } + + // gpio + public native int setGpioMode(int pin, int mode); + public native int setGpioDir(int pin, int dir); + public native int setGpioPullEnable(int pin, int enable); + public native int setGpioPullSelect(int pin, int select); + public native int setGpioOut(int pin, int out); + public native int getGpioIn(int pin); + //serialport + public native int openCom(String port, int baudrate, int bits, char event, int stop); + public native int openComEx(String port, int baudrate, int bits, char event, int stop, int flags); + public native int writeCom(int fd, byte[] buf, int sizes); + public native int readCom(int fd, byte[] buf, int sizes); + public native int readComEx(int fd, byte[] buf, int sizes, int sec, int usec); + public native void closeCom(int fd); + + static { + System.loadLibrary("zyapi_common"); + } + +} -- libgit2 0.21.4