package com.fri.idcread; import java.io.File; import java.io.FileWriter; import java.io.IOException; import android.util.Log; import android.widget.TextView; @SuppressWarnings("unused") public class idcread{ /** Called when the activity is first created. */ private TextView txtName; public static String databasepath = "/mnt/sdcard/"; public static String databasefn = "license.dat"; private static String filepath = "/mnt/sdcard/zp.bmp"; private static final String TAG = "idcread"; static File file = new File(filepath); public static File file1 = new File("/mnt/sdcard/wzuni.txt"); static { try { System.loadLibrary("idcread"); } catch (Exception e) { e.printStackTrace(); }catch (Throwable e) { e.printStackTrace(); } } public native static int InitComm(String port); // 打开串口,成功则返回1,失败其他 public native static int CloseComm(); public native static int ReadContent(String path); public native static int Authenticate(); public static boolean isIdcard(String port) { try { if (InitComm(port) == 1) { return true; } else { return false; } } catch (Exception e) { e.printStackTrace(); }catch (Throwable e){ e.printStackTrace(); } return false; } public static void init() { // setpower("/sys/class/gpio/gpio114/value", false);// 给二维码下电 setpower("/sys/class/gpio/gpio28/value", true); // copyDatabase(); // xxx = ""; /* 打开端口 */// if (InitComm("/dev/ttySAC1") == 1) { // xxx = "打开手机串口成功!"; } else { // xxx = "打开手机串口失败!"; } } public static void setpower(String path, boolean on) { File file; FileWriter fr; try { file = new File(path); fr = new FileWriter(file); if (on) fr.write("1"); else fr.write("0"); fr.close(); } catch (IOException e) { Log.e(TAG, e.toString()); } } }