Biometric Android application for integrating Tech5's biometric technology with CommCare. This application supports three different biometric workflows:
- Enrollment (com.dimagi.biometric.ENROLL)
- Verification (com.dimagi.biometric.VERIFY)
- Identification (com.dimagi.biometric.SEARCH)
Please note the following:
- The biometric application will require an Internet connection the first time it is opened. This is to retrieve the Tech5 license. Thereafter, the biometric application is capable of running in an offline state.
- The biometric application is reliant on CommCare making the necessary app callout and passing in the required input parameters. As such, the biometric app is currently not functional as an independent app and should be started from CommCare.
There are three main activities for carrying out the different workflows. Specifically, these are the EnrollActivity
, VerifyActivity
, and SearchActivity
classes. These three activities all inherit from the BaseActivity
class, which holds shared functionality for setting up the activities (such as initializing the Tech5 SDK license and creating the relevant fragment). The sub-class activities themselves only contain code necessary for handling the captured biometric data and returning the relevant data back to CommCare, based on the selected workflow.
For the UI component, two fragments, FaceMatchFragment
and FingerMatchFragment
, have been created for both face and finger biometric capture, respectively. Both of these fragments inherit from the BaseMatchFragment
class, which holds common functionality for camera permission checking. These fragments are responsibile for starting the relevant Tech5 capture UI and handling the results of this capture. The latter involves converting the captured image to a record and letting the activity know that the capture was successful.
To faciliate communication between the activities and fragments, view models have been set up for both the face and finger fragments. These view models contain the necessary functions to convert captured images into records, as well as carry out various functions such as inserting or matching records. Both view models inherit from BaseTemplateViewModel
. This is done so that they can be referenced and used in BaseActivity
without explicitely knowing whether FaceMatchViewModel
or FingerMatchViewModel
was instantiated.
To set up an Android dev environment for the biometric app, do the following:
- Install Android Studio.
- Install Java 18 if you don't have it yet. For ease of test suite setup OpenJDK is preferred over Oracle's version of Java.
For the biometric application to work correctly, the necessary Tech5 dependencies will need to be set up first. These dependencies are responsible for the capture UI, creating biometric templates, and matching templates with each other. To set up the Tech5 dependencies:
- Download the Tech5 OmniMatch SDK (link available on 1Password under "Tech5 OmniMatch SDK".
- Create a folder
app/libs
to store Tech5.aar
files - In your
local.properties
file define a propertyTECH5_SDK_DIR=libs
- From the sample app of the downloaded SDK, copy the .aar files from the following folders to your
app/libs
folder -- AirsnapFaceCore
- AirsnapFaceUI
- AirsnapFinger
- AirsnapFingerUI
- OmniMatch
To build the biometric app and get it running on your phone, plug in an android phone that
- is in developer mode has USB debugging enabled.
- doesn't have the biometric app installed on it.
In Android Studio, hit the build button (a green "play" symbol in the toolbar). The first build will take a minute. Then it'll ask you what device to run it on.
- Make sure your screen is unlocked (or else you'll see something like this).
- select your device.
In order to comply with code style guidelines we follow, please use Commcare Coding Style file and Commcare Inspection Profile as your respective code style and inpection profile in Android Studio. To add these files into Android studio, please do the following:
- Navigate to File -> Settings -> Editor -> Inspections. You will then click on the gear icon next to "Profile" and import
CommCareInspectionProfile.xml
- Navigate to File -> Settings -> Editor -> Code Style. You will then click on the gear icon next to "Scheme" and import
CommCareCodingStyle.xml
This is an optional step to set up Firebase Crashlytics for the dev environment. A google-services.json
file will need to be added to the project root's app
folder. This file can be retrieved from Dimagi's Firebase console.