summaryrefslogtreecommitdiff
path: root/org.ifaa.android.manager/lib
diff options
context:
space:
mode:
Diffstat (limited to 'org.ifaa.android.manager/lib')
-rw-r--r--org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManager.java58
-rw-r--r--org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerFactory.java9
-rw-r--r--org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerImpl.java180
-rw-r--r--org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV2.java7
-rw-r--r--org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV3.java12
-rw-r--r--org.ifaa.android.manager/lib/org/ifaa/android/manager/IIFAAService.aidl5
6 files changed, 271 insertions, 0 deletions
diff --git a/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManager.java b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManager.java
new file mode 100644
index 0000000..d7ffc5a
--- /dev/null
+++ b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManager.java
@@ -0,0 +1,58 @@
+package org.ifaa.android.manager;
+
+import android.content.Context;
+import android.os.Build.VERSION;
+import android.os.SystemProperties;
+
+public abstract class IFAAManager {
+ private static final int IFAA_VERSION_V2 = 2;
+ private static final int IFAA_VERSION_V3 = 3;
+ static int sIfaaVer;
+ static boolean sIsFod = SystemProperties.getBoolean("ro.hardware.fp.fod", false);
+
+ /**
+ * 返回手机系统上支持的校验方式,目前IFAF协议1.0版本指纹为0x01、虹膜为0x02
+ */
+ public abstract int getSupportBIOTypes(Context context);
+
+ /**
+ * 启动系统的指纹/虹膜管理应用界面,让用户进行指纹录入。指纹录入是在系统的指纹管理应用中实现的,
+ * 本函数的作用只是将指纹管理应用运行起来,直接进行页面跳转,方便用户录入。
+ * @param context
+ * @param authType 生物特征识别类型,指纹为1,虹膜为2
+ * @return 0,成功启动指纹管理应用;-1,启动指纹管理应用失败。
+ */
+ public abstract int startBIOManager(Context context, int authType);
+
+ /**
+ * 通过ifaateeclient的so文件实现REE到TA的通道
+ * @param context
+ * @param param 用于传输到IFAA TA的数据buffer
+ * @return IFAA TA返回给REE数据buffer
+ */
+ public native byte[] processCmd(Context context, byte[] param);
+
+ /**
+ * 获取设备型号,同一款机型型号需要保持一致
+ */
+ public abstract String getDeviceModel();
+
+ /**
+ * 获取IFAAManager接口定义版本,目前为1
+ */
+ public abstract int getVersion();
+
+ /**
+ * load so to communicate from REE to TEE
+ */
+ static {
+ sIfaaVer = 1;
+ if (sIsFod) {
+ sIfaaVer = 3;
+ } else if (VERSION.SDK_INT >= 24) {
+ sIfaaVer = 2;
+ } else {
+ System.loadLibrary("teeclientjni");//teeclientjni for TA test binary //ifaateeclient
+ }
+ }
+}
diff --git a/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerFactory.java b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerFactory.java
new file mode 100644
index 0000000..97a948a
--- /dev/null
+++ b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerFactory.java
@@ -0,0 +1,9 @@
+package org.ifaa.android.manager;
+
+import android.content.Context;
+
+public class IFAAManagerFactory {
+ public static IFAAManager getIFAAManager(Context context, int authType) {
+ return IFAAManagerImpl.getInstance(context);
+ }
+}
diff --git a/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerImpl.java b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerImpl.java
new file mode 100644
index 0000000..34dd9d8
--- /dev/null
+++ b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerImpl.java
@@ -0,0 +1,180 @@
+package org.ifaa.android.manager;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.Build;
+import android.os.Build.VERSION;
+import android.os.IBinder;
+import android.os.IBinder.DeathRecipient;
+import android.os.Parcel;
+import android.os.RemoteException;
+import android.os.SystemProperties;
+import android.util.Slog;
+import java.util.ArrayList;
+import java.util.Arrays;
+import org.json.JSONObject;
+
+public class IFAAManagerImpl extends IFAAManagerV3 {
+ private static final boolean DEBUG = false;
+
+ private static final int IFAA_TYPE_FINGER = 1;
+ private static final int IFAA_TYPE_IRIS = (1 << 1);
+ private static final int IFAA_TYPE_SENSOR_FOD = (1 << 4);
+
+ private static final int ACTIVITY_START_SUCCESS = 0;
+ private static final int ACTIVITY_START_FAILED = -1;
+
+ private static volatile IFAAManagerImpl INSTANCE = null;
+
+ private static final String TAG = "IfaaManagerImpl";
+
+ private static ServiceConnection ifaaconn = new ServiceConnection() {
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mService = IIFAAService.Stub.asInterface(service);
+ try {
+ mService.asBinder().linkToDeath(mDeathRecipient, 0);
+ } catch (RemoteException e) {
+ if (DEBUG) Slog.e(TAG, "linkToDeath fail.", e);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+ if (mContext != null) {
+ if (DEBUG) Slog.i(TAG, "re-bind the service.");
+ initService();
+ }
+ }
+ };
+
+ private static Context mContext = null;
+ private static DeathRecipient mDeathRecipient = new DeathRecipient() {
+ @Override
+ public void binderDied() {
+ if (mService != null) {
+ if (DEBUG) Slog.d(TAG, "binderDied, unlink the service.");
+ mService.asBinder().unlinkToDeath(mDeathRecipient, 0);
+ }
+ }
+ };
+
+ private static final String mIfaaActName = "org.ifaa.android.manager.IFAAService";
+ private static final String mIfaaPackName = "org.ifaa.android.manager";
+ private static IIFAAService mService = null;
+ private static final String seperate = ",";
+ private String mDevModel = null;
+
+ public static IFAAManagerV3 getInstance(Context context) {
+ if (INSTANCE == null) {
+ synchronized (IFAAManagerImpl.class) {
+ if (INSTANCE == null) {
+ INSTANCE = new IFAAManagerImpl();
+ if (VERSION.SDK_INT >= 28) {
+ mContext = context;
+ initService();
+ }
+ }
+ }
+ }
+ return INSTANCE;
+ }
+
+ private String initExtString() {
+ String str = "";
+ JSONObject location = new JSONObject();
+ JSONObject fullView = new JSONObject();
+ String xy = SystemProperties.get("persist.sys.fp.fod.location.X_Y", "");
+ String wh = SystemProperties.get("persist.sys.fp.fod.size.width_height", "");
+
+ try {
+ if (validateVal(xy) && validateVal(wh)) {
+ String[] splitXy = xy.split(seperate);
+ String[] splitWh = wh.split(seperate);
+ fullView.put("startX", Integer.parseInt(splitXy[0]));
+ fullView.put("startY", Integer.parseInt(splitXy[1]));
+ fullView.put("width", Integer.parseInt(splitWh[0]));
+ fullView.put("height", Integer.parseInt(splitWh[1]));
+ fullView.put("navConflict", true);
+ location.put("type", 0);
+ location.put("fullView", fullView);
+ str = location.toString();
+ } else {
+ if (DEBUG) Slog.e(TAG, "initExtString invalidate, xy:" + xy + " wh:" + wh);
+ }
+ } catch (Exception e) {
+ if (DEBUG) Slog.e(TAG, "Exception , xy:" + xy + " wh:" + wh, e);
+ }
+ return str;
+ }
+
+ private static void initService() {
+ Intent intent = new Intent();
+ intent.setClassName(mIfaaPackName, mIfaaActName);
+ if (!mContext.bindService(intent, ifaaconn, Context.BIND_AUTO_CREATE)) {
+ if (DEBUG) Slog.e(TAG, "cannot bind service org.ifaa.android.manager.IFAAService");
+ }
+ }
+
+ private boolean validateVal(String str) {
+ return !"".equalsIgnoreCase(str) && str.contains(",");
+ }
+
+ public String getDeviceModel() {
+ if (mDevModel == null) {
+ mDevModel ="xiaomi" + "-" + "wayne";
+ }
+ if (DEBUG) Slog.i(TAG, "getDeviceModel devcieModel:" + mDevModel);
+ return mDevModel;
+ }
+
+ public String getExtInfo(int authType, String keyExtInfo) {
+ return initExtString();
+ }
+
+ public int getSupportBIOTypes(Context context) {
+ int ifaaType = SystemProperties.getInt("persist.sys.ifaa", 0);
+ String fpVendor = SystemProperties.get("persist.sys.fp.vendor", "");
+ int supportBIOTypes = "none".equalsIgnoreCase(fpVendor) ? ifaaType & IFAA_TYPE_IRIS :
+ ifaaType & (IFAA_TYPE_FINGER | IFAA_TYPE_IRIS);
+ if ((supportBIOTypes & IFAA_TYPE_FINGER) == IFAA_TYPE_FINGER && sIsFod) {
+ supportBIOTypes |= IFAA_TYPE_SENSOR_FOD;
+ }
+ if (DEBUG) Slog.i(TAG, "getSupportBIOTypes:" + ifaaType + " " + sIsFod + " " + fpVendor +
+ " res:" + supportBIOTypes);
+ return supportBIOTypes;
+ }
+
+ public int getVersion() {
+ if (DEBUG) Slog.i(TAG, "getVersion sdk:" + VERSION.SDK_INT + " ifaaVer:" + sIfaaVer);
+ return sIfaaVer;
+ }
+
+ public byte[] processCmdV2(Context context, byte[] data) {
+ if (DEBUG) Slog.i(TAG, "processCmdV2 sdk:" + VERSION.SDK_INT);
+
+ try {
+ return mService.processCmd_v2(data);
+ } catch (RemoteException e) {
+ if (DEBUG) Slog.e(TAG, "processCmdV2 transact failed. " + e);
+ }
+ return null;
+ }
+
+ public void setExtInfo(int authType, String keyExtInfo, String valExtInfo) {
+ }
+
+ public int startBIOManager(Context context, int authType) {
+ int res = ACTIVITY_START_FAILED;
+ if (authType == IFAA_TYPE_FINGER) {
+ Intent intent = new Intent("android.settings.SECURITY_SETTINGS");
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(intent);
+ res = ACTIVITY_START_SUCCESS;
+ }
+ if (DEBUG) Slog.i(TAG, "startBIOManager authType:" + authType + " res:" + res);
+ return res;
+ }
+}
diff --git a/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV2.java b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV2.java
new file mode 100644
index 0000000..2d7e3f5
--- /dev/null
+++ b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV2.java
@@ -0,0 +1,7 @@
+package org.ifaa.android.manager;
+
+import android.content.Context;
+
+public abstract class IFAAManagerV2 extends IFAAManager {
+ public abstract byte[] processCmdV2(Context paramContext, byte[] paramArrayOfByte);
+}
diff --git a/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV3.java b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV3.java
new file mode 100644
index 0000000..50e677d
--- /dev/null
+++ b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IFAAManagerV3.java
@@ -0,0 +1,12 @@
+package org.ifaa.android.manager;
+
+public abstract class IFAAManagerV3 extends IFAAManagerV2 {
+ public static final String KEY_FINGERPRINT_FULLVIEW = "org.ifaa.ext.key.CUSTOM_VIEW";
+ public static final String KEY_GET_SENSOR_LOCATION = "org.ifaa.ext.key.GET_SENSOR_LOCATION";
+ public static final String VALUE_FINGERPRINT_DISABLE = "disable";
+ public static final String VLAUE_FINGERPRINT_ENABLE = "enable";
+
+ public abstract String getExtInfo(int authType, String keyExtInfo);
+
+ public abstract void setExtInfo(int authType, String keyExtInfo, String valExtInfo);
+}
diff --git a/org.ifaa.android.manager/lib/org/ifaa/android/manager/IIFAAService.aidl b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IIFAAService.aidl
new file mode 100644
index 0000000..8dadb55
--- /dev/null
+++ b/org.ifaa.android.manager/lib/org/ifaa/android/manager/IIFAAService.aidl
@@ -0,0 +1,5 @@
+package org.ifaa.android.manager;
+
+interface IIFAAService {
+ byte[] processCmd_v2(in byte[] param);
+}