Offline Mode Flow for Android

casan141saas
During a transaction, the user opts for the Offline Mode flow if her mobile does not have network coverage. This flow enables the user to use the app to generate an OTP (in offline mode) and submit the OTP for authentication.
This section covers the following topics:
For information about the APIs mentioned in these topics, see API Reference for Android.
Steps in the Offline Mode Flow
The following steps take place when the user uses the Offline Mode flow:
  1. The user opens the app.
  2. The user taps the ACTION ON ACCOUNT button.
  3. The app displays the accounts.
  4. The user long-taps the account that she wants to use for the transaction.
  5. The app displays the Generate OTP and Delete Account options.
    Offline_Mode_01_Account_Menu.png
  6. The user taps the Generate OTP option.
  7. The app displays the authentication types that are enabled.
  8. The user selects an authentication type. For example, the user select PIN authentication.
  9. The app prompts the user to submit the PIN. If transaction data signing is enabled, then the app also prompts the user to submit the transaction data parameters along with the PIN.
    Offline_Mode_03_Submit_PIN.png
  10. The app displays an OTP. The user notes down this OTP and submits it in the application that is prompting for authentication.
    Offline_Mode_04_OTP_Displayed.png
Offline Mode Flow Diagram
The following flow diagram shows the sequence of API calls that take place when the user uses the Offline Mode flow.
Android - Offline Mode Authentication
Android - Offline Mode Authentication
Sample Code for the Offline Mode Flow
The following is sample code for the Offline Mode flow:
// User clicks the Generate OTP button.
...
// Get the enabled authentication types
AuthenticationHandler handler = new AuthenticationHandler(this);
ArrayList<AuthenticationType> authenticationTypes = handler.getEnabledAuthenticationTypes();
//Display the authentication types. Collect user's choice of authentication type.
// If user's choice is BIOMETRIC_AUTH...
if(userSelectedAuthType == BIOMETRIC_AUTH) {
//Create fingerprint authenticator object
FingerPrintAuthenticator fingerPrintAuthenticator = new FingerPrintAuthenticator(generateOTPCallbackObject, activityContext, accountDetailsObject);

fingerPrintAuthenticator.authenticate();
//Handle the OTPResponse object in callback methods in the class in which the GenerateOTPCallback interface is implemented.
} else {
//Prompt the user for the user PIN.
//Call generateOTP() using the user PIN
OTPResponse otpResponse = handler.generateOTP(accountSelectedByUser, userPin);
}