Skip to content

Commit

Permalink
Merge pull request #2701 from dimagi/tech5-support-library-update
Browse files Browse the repository at this point in the history
Tech5 Integration - Enrollment updates
  • Loading branch information
avazirna authored Oct 3, 2023
2 parents 88185fd + 891b338 commit c0340d4
Show file tree
Hide file tree
Showing 16 changed files with 379 additions and 88 deletions.
3 changes: 3 additions & 0 deletions app/assets/locales/android_translatable_strings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,9 @@ intent.callout.unable.to.process=Unable to process callout result
intent.callout.activity.missing=Couldn't find intent for callout!
intent.callout.not.supported=This intent callout is not supported on this device
fingerprints.scanned=Fingerprints scanned: ${0}
intent.callout.biometrics.capture.result.success=All data stored successfully
intent.callout.biometrics.capture.result.fail=No data was stored
intent.callout.biometrics.capture.result.partialfail=Failed to store some data

settings.developer.options=Developer Options
settings.developer.title=Developer Options
Expand Down
33 changes: 30 additions & 3 deletions app/src/org/commcare/provider/IdentityCalloutHandler.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package org.commcare.provider;

import android.content.Intent;
import android.util.Base64;

import org.commcare.android.javarosa.IntentCallout;
import org.commcare.commcaresupportlibrary.identity.BiometricIdentifier;
import org.commcare.commcaresupportlibrary.identity.IdentityResponseBuilder;
import org.commcare.commcaresupportlibrary.identity.model.IdentificationMatch;
import org.commcare.commcaresupportlibrary.identity.model.MatchResult;
Expand All @@ -23,6 +25,7 @@
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import androidx.annotation.StringDef;
Expand All @@ -37,13 +40,11 @@ public class IdentityCalloutHandler {

public static final String GENERALIZED_IDENTITY_PROVIDER = "generalized_identity_provider";


@StringDef({GENERALIZED_IDENTITY_PROVIDER, SimprintsCalloutProcessing.SIMPRINTS_IDENTITY_PROVIDER})
@Retention(RetentionPolicy.SOURCE)
public @interface IdentityProvider {
}


public static boolean isIdentityCalloutResponse(Intent intent) {
return isRegistrationResponse(intent) || isVerificationResponse(intent) || isIdentificationResponse(intent);
}
Expand Down Expand Up @@ -109,8 +110,34 @@ private static boolean processRegistrationReponse(FormDef formDef,
Hashtable<String, Vector<TreeReference>> responseToRefMap) {
RegistrationResult registrationResult = intent.getParcelableExtra(IdentityResponseBuilder.REGISTRATION);
String guid = registrationResult.getGuid();

storeValueFromCalloutInForm(formDef, responseToRefMap, intentQuestionRef, REF_GUID, guid);
IntentCallout.setNodeValue(formDef, intentQuestionRef, guid);

int numOfTemplatesStored = 0;
int numOfTemplates = 0;
for (Map.Entry<BiometricIdentifier, byte[]> template : registrationResult.getTemplates().entrySet()) {
boolean success = storeValueFromCalloutInForm(formDef, responseToRefMap,
intentQuestionRef,
template.getKey().getCalloutResponseKey(),
Base64.encodeToString(template.getValue(), Base64.DEFAULT));
if (success) {
numOfTemplatesStored++;
}
numOfTemplates++;
}

String result = "";
if (registrationResult.getTemplates().isEmpty() || (numOfTemplates == numOfTemplatesStored)) {
result = Localization.get("intent.callout.biometrics.capture.result.success");
} else if (numOfTemplates > 0) {
if (numOfTemplatesStored == 0) {
result = Localization.get("intent.callout.biometrics.capture.result.fail");
} else {
result = Localization.get("intent.callout.biometrics.capture.result.partialfail");
}
}

IntentCallout.setNodeValue(formDef, intentQuestionRef, result);

// Empty out any references present for duplicate handling
storeValueFromCalloutInForm(formDef, responseToRefMap, intentQuestionRef, REF_MATCH_GUID, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ case_autoload.raw.case_missing=Unable to find case referenced by auto-select cas
case_autoload.raw.property_missing=The custom xpath expression specified for case auto-selecting could not be found: ${0}
case_autoload.user.case_missing=Unable to find case referenced by auto-select case ID.
case_autoload.user.property_missing=The user data key specified for case auto-selecting could not be found: ${0}
case_autoload.usercase.case_missing=Unable to find case referenced by auto-select case ID.
case_autoload.usercase.case_missing=This form affects the user case, but no user case id was found. Please contact your supervisor.
case_autoload.usercase.property_missing=The user case specified for case auto-selecting could not be found: ${0}
case_search.claimed_case.case_missing=Unable to find the selected case after performing a sync. Please try again.
case_sharing.exactly_one_group=The case sharing settings for your user are incorrect. This user must be in exactly one case sharing group. Please contact your supervisor.
cchq.case=Case
cchq.referral=Referral
Expand All @@ -23,9 +24,9 @@ cchq.report_name_header=Report Name
cchq.reports_last_updated_on=Reports last updated on
en=English
forms.m0f0=Registration Form
forms.m0f1=Registration with Templates
homescreen.title=Identity Integration Test
lang.current=en
m0.case_long.case_name_1.header=Name
m0.case_short.case_name_1.header=Name
modules.m0=Case List
usercase.missing_id=This form affects the user case, but no user case id was found. Please contact your supervisor.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ cchq.report_menu=Reports
cchq.report_name_header=Report Name
cchq.reports_last_updated_on=Reports last updated on
forms.m0f0=Registration Form
forms.m0f1=Registration with Templates
homescreen.title=Identity Integration Test
lang.current=en
m0.case_long.case_name_1.header=Name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<suite version="10" descriptor="Media Suite File"/>
<suite version="24" descriptor="Media Suite File"/>
Original file line number Diff line number Diff line change
@@ -1,58 +1,91 @@
<h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns:orx="http://openrosa.org/jr/xforms" xmlns="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:vellum="http://commcarehq.org/xforms/vellum">
<h:head>
<h:title>Registration Form</h:title>
<model>
<instance>
<data xmlns:jrm="http://dev.commcarehq.org/jr/xforms" xmlns="http://openrosa.org/formdesigner/39BBDBB3-7C04-472E-9D8F-DB640E63F466" uiVersion="1" version="15" name="Registration Form">
<question2/>
<duplicate_guid/>
<duplicate_score/>
<duplicate_strength/>
<identity_guid/>
<verification/>
<verify_guid/>
<verify_score/>
<verify_strength/>
<case xmlns="http://commcarehq.org/case/transaction/v2" case_id="" date_modified="" user_id=""><create><case_name/><owner_id/><case_type>case</case_type></create></case><orx:meta xmlns:cc="http://commcarehq.org/xforms"><orx:deviceID/><orx:timeStart/><orx:timeEnd/><orx:username/><orx:userID/><orx:instanceID/><cc:appVersion/><orx:drift/></orx:meta></data>
</instance><instance id="commcaresession" src="jr://instance/session"/>
<bind nodeset="/data/question2" type="intent"/>
<bind nodeset="/data/duplicate_guid"/>
<bind nodeset="/data/duplicate_score"/>
<bind nodeset="/data/duplicate_strength"/>
<bind nodeset="/data/identity_guid"/>
<bind nodeset="/data/verification" type="intent"/>
<bind nodeset="/data/verify_guid"/>
<bind nodeset="/data/verify_score"/>
<bind nodeset="/data/verify_strength"/>
<itext>
<translation lang="en" default="">
<text id="question2-label">
<value>Registration</value>
</text>
<text id="verification-label">
<value>Verification</value>
</text>
</translation>
</itext>
<bind calculate="/data/meta/timeEnd" nodeset="/data/case/@date_modified" type="xsd:dateTime"/><bind calculate="/data/meta/userID" nodeset="/data/case/@user_id"/><setvalue event="xforms-ready" ref="/data/case/@case_id" value="instance('commcaresession')/session/data/case_id_new_case_0"/><bind calculate="/data/question2" nodeset="/data/case/create/case_name"/><bind calculate="/data/meta/userID" nodeset="/data/case/create/owner_id"/><setvalue event="xforms-ready" ref="/data/meta/deviceID" value="instance('commcaresession')/session/context/deviceid"/><setvalue event="xforms-ready" ref="/data/meta/timeStart" value="now()"/><bind nodeset="/data/meta/timeStart" type="xsd:dateTime"/><setvalue event="xforms-revalidate" ref="/data/meta/timeEnd" value="now()"/><bind nodeset="/data/meta/timeEnd" type="xsd:dateTime"/><setvalue event="xforms-ready" ref="/data/meta/username" value="instance('commcaresession')/session/context/username"/><setvalue event="xforms-ready" ref="/data/meta/userID" value="instance('commcaresession')/session/context/userid"/><setvalue event="xforms-ready" ref="/data/meta/instanceID" value="uuid()"/><setvalue event="xforms-ready" ref="/data/meta/appVersion" value="instance('commcaresession')/session/context/appversion"/><setvalue event="xforms-revalidate" ref="/data/meta/drift" value="if(count(instance('commcaresession')/session/context/drift) = 1, instance('commcaresession')/session/context/drift, '')"/></model>
<odkx:intent xmlns:odkx="http://opendatakit.org/xforms" id="question2" class="org.commcare.identity.bioenroll">
<response key="guid" ref="/data/identity_guid"/>
<response key="match_guid" ref="/data/duplicate_guid"/>
<response key="match_confidence" ref="/data/duplicate_score"/>
<response key="match_strength" ref="/data/duplicate_strength"/>
</odkx:intent>
<odkx:intent xmlns:odkx="http://opendatakit.org/xforms" id="verification" class="org.commcare.identity.bioverify">
<response key="match_guid" ref="/data/verify_guid"/>
<response key="match_confidence" ref="/data/verify_score"/>
<response key="match_strength" ref="/data/verify_strength"/>
</odkx:intent>
</h:head>
<h:body>
<input ref="/data/question2" appearance="intent:question2">
<label ref="jr:itext('question2-label')"/>
</input>
<input ref="/data/verification" appearance="intent:verification">
<label ref="jr:itext('verification-label')"/>
</input>
</h:body>
</h:html>
<h:head>
<h:title>Registration Form</h:title>
<model>
<instance>
<data xmlns:jrm="http://dev.commcarehq.org/jr/xforms" xmlns="http://openrosa.org/formdesigner/39BBDBB3-7C04-472E-9D8F-DB640E63F466" uiVersion="1" version="24" name="Registration Form">
<question2/>
<duplicate_guid/>
<duplicate_score/>
<duplicate_strength/>
<identity_guid/>
<verification/>
<verify_guid/>
<verify_score/>
<verify_strength/>
<case xmlns="http://commcarehq.org/case/transaction/v2" case_id="" date_modified="" user_id="">
<create>
<case_name/>
<owner_id/>
<case_type>case</case_type>
</create>
</case>
<orx:meta xmlns:cc="http://commcarehq.org/xforms">
<orx:deviceID/>
<orx:timeStart/>
<orx:timeEnd/>
<orx:username/>
<orx:userID/>
<orx:instanceID/>
<cc:appVersion/>
<orx:drift/>
</orx:meta>
</data>
</instance>
<instance id="commcaresession" src="jr://instance/session"/>
<bind nodeset="/data/question2" type="intent" required="true()"/>
<bind nodeset="/data/duplicate_guid"/>
<bind nodeset="/data/duplicate_score"/>
<bind nodeset="/data/duplicate_strength"/>
<bind nodeset="/data/identity_guid"/>
<bind nodeset="/data/verification" type="intent"/>
<bind nodeset="/data/verify_guid"/>
<bind nodeset="/data/verify_score"/>
<bind nodeset="/data/verify_strength"/>
<itext>
<translation lang="en" default="">
<text id="question2-label">
<value>Register</value>
</text>
<text id="verification-label">
<value>Verification</value>
</text>
</translation>
</itext>
<bind nodeset="/data/case/@date_modified" type="xsd:dateTime" calculate="/data/meta/timeEnd"/>
<bind nodeset="/data/case/@user_id" calculate="/data/meta/userID"/>
<setvalue ref="/data/case/@case_id" value="instance('commcaresession')/session/data/case_id_new_case_0" event="xforms-ready"/>
<bind nodeset="/data/case/create/case_name" calculate="/data/question2"/>
<bind nodeset="/data/case/create/owner_id" calculate="/data/meta/userID"/>
<setvalue ref="/data/meta/deviceID" value="instance('commcaresession')/session/context/deviceid" event="xforms-ready"/>
<setvalue ref="/data/meta/timeStart" value="now()" event="xforms-ready"/>
<bind nodeset="/data/meta/timeStart" type="xsd:dateTime"/>
<setvalue ref="/data/meta/timeEnd" value="now()" event="xforms-revalidate"/>
<bind nodeset="/data/meta/timeEnd" type="xsd:dateTime"/>
<setvalue ref="/data/meta/username" value="instance('commcaresession')/session/context/username" event="xforms-ready"/>
<setvalue ref="/data/meta/userID" value="instance('commcaresession')/session/context/userid" event="xforms-ready"/>
<setvalue ref="/data/meta/instanceID" value="uuid()" event="xforms-ready"/>
<setvalue ref="/data/meta/appVersion" value="instance('commcaresession')/session/context/appversion" event="xforms-ready"/>
<setvalue ref="/data/meta/drift" value="if(count(instance('commcaresession')/session/context/drift) = 1, instance('commcaresession')/session/context/drift, '')" event="xforms-revalidate"/>
</model>
<odkx:intent xmlns:odkx="http://opendatakit.org/xforms" id="question2" class="org.commcare.identity.bioenroll">
<response key="guid" ref="/data/identity_guid"/>
<response key="match_guid" ref="/data/duplicate_guid"/>
<response key="match_confidence" ref="/data/duplicate_score"/>
<response key="match_strength" ref="/data/duplicate_strength"/>
</odkx:intent>
<odkx:intent xmlns:odkx="http://opendatakit.org/xforms" id="verification" class="org.commcare.identity.bioverify">
<response key="match_guid" ref="/data/verify_guid"/>
<response key="match_confidence" ref="/data/verify_score"/>
<response key="match_strength" ref="/data/verify_strength"/>
</odkx:intent>
</h:head>
<h:body>
<input ref="/data/question2" appearance="intent:question2">
<label ref="jr:itext('question2-label')"/>
</input>
<input ref="/data/verification" appearance="intent:verification">
<label ref="jr:itext('verification-label')"/>
</input>
</h:body>
</h:html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns:orx="http://openrosa.org/jr/xforms" xmlns="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:jr="http://openrosa.org/javarosa" xmlns:vellum="http://commcarehq.org/xforms/vellum">
<h:head>
<h:title>Registration with Templates</h:title>
<model>
<instance>
<data xmlns:jrm="http://dev.commcarehq.org/jr/xforms" xmlns="http://openrosa.org/formdesigner/E3900AF4-43AC-435A-B0BB-E043AD9608A1" uiVersion="1" version="24" name="Registration with Templates">
<register/>
<guid/>
<left_index_finger_template/>
<left_middle_finger_template/>
<case xmlns="http://commcarehq.org/case/transaction/v2" case_id="" date_modified="" user_id="">
<create>
<case_name/>
<owner_id/>
<case_type>case</case_type>
</create>
</case>
<orx:meta xmlns:cc="http://commcarehq.org/xforms">
<orx:deviceID/>
<orx:timeStart/>
<orx:timeEnd/>
<orx:username/>
<orx:userID/>
<orx:instanceID/>
<cc:appVersion/>
<orx:drift/>
</orx:meta>
</data>
</instance>
<instance id="commcaresession" src="jr://instance/session"/>
<bind nodeset="/data/register" type="intent" required="true()"/>
<bind nodeset="/data/guid"/>
<bind nodeset="/data/left_index_finger_template"/>
<bind nodeset="/data/left_middle_finger_template"/>
<itext>
<translation lang="en" default="">
<text id="register-label">
<value>Register</value>
</text>
</translation>
</itext>
<bind nodeset="/data/case/@date_modified" type="xsd:dateTime" calculate="/data/meta/timeEnd"/>
<bind nodeset="/data/case/@user_id" calculate="/data/meta/userID"/>
<setvalue ref="/data/case/@case_id" value="instance('commcaresession')/session/data/case_id_new_case_0" event="xforms-ready"/>
<bind nodeset="/data/case/create/case_name" calculate="/data/register"/>
<bind nodeset="/data/case/create/owner_id" calculate="/data/meta/userID"/>
<setvalue ref="/data/meta/deviceID" value="instance('commcaresession')/session/context/deviceid" event="xforms-ready"/>
<setvalue ref="/data/meta/timeStart" value="now()" event="xforms-ready"/>
<bind nodeset="/data/meta/timeStart" type="xsd:dateTime"/>
<setvalue ref="/data/meta/timeEnd" value="now()" event="xforms-revalidate"/>
<bind nodeset="/data/meta/timeEnd" type="xsd:dateTime"/>
<setvalue ref="/data/meta/username" value="instance('commcaresession')/session/context/username" event="xforms-ready"/>
<setvalue ref="/data/meta/userID" value="instance('commcaresession')/session/context/userid" event="xforms-ready"/>
<setvalue ref="/data/meta/instanceID" value="uuid()" event="xforms-ready"/>
<setvalue ref="/data/meta/appVersion" value="instance('commcaresession')/session/context/appversion" event="xforms-ready"/>
<setvalue ref="/data/meta/drift" value="if(count(instance('commcaresession')/session/context/drift) = 1, instance('commcaresession')/session/context/drift, '')" event="xforms-revalidate"/>
</model>
<odkx:intent xmlns:odkx="http://opendatakit.org/xforms" id="register" class="org.commcare.identity.bioenroll">
<response key="guid" ref="/data/guid"/>
<response key="left_index_finger_template" ref="/data/left_index_finger_template"/>
<response key="left_middle_finger_template" ref="/data/left_middle_finger_template"/>
</odkx:intent>
</h:head>
<h:body>
<input ref="/data/register" appearance="intent:register">
<label ref="jr:itext('register-label')"/>
</input>
</h:body>
</h:html>
Loading

0 comments on commit c0340d4

Please sign in to comment.