idcread.java
1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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());
}
}
}