Skip to Content

Handle Passcode with the Flows Component

Learn how to use the Flows component of SAP BTP SDK for Android to handle passcode change, forgetting passcode and passcode verification scenarios.
You will learn
  • How to change passcode with the Flows component
  • How to handle forgetting passcode scenario with the Flows Component
  • How to verify passcode with the Flows component
FengHaoyueHaoyue FengSeptember 22, 2021
Created by
FengHaoyue
June 21, 2021
Contributors
FengHaoyue
FengHaoyue

Prerequisites

  • Step 1
    1. Open the project you previously created using the SAP BTP SDK Wizard for Android.

    2. In Android Studio, on Windows, press Ctrl+N, or, on a Mac, press command+O, and type SettingsFragment to open SettingsFragment.java.

    3. On Windows, press Ctrl+F12, or, on a Mac, press command+F12, and type onCreatePreferences to move to the onCreatePreferences method. To start the flow to change passcode, the flow type must be FlowType.CHANGEPASSCODE for the FlowContext instance. Upon starting the flow with this FlowContext instance, the entire process to change passcode will be handled automatically.

      Change passcode flow
    4. The “change passcode” flow will firstly display the sign-in screen for user to input current passcode. When sign-in is successful with correct passcode, the flow will open “Create Passcode” and “Verify Passcode” screens for user to input and verify the new passcode. The subsequent step is optional, when biometric authentication is enabled in the passcode policy and is also supported on the device, the “Enable Biometric” screen will be displayed. User can decide whether or not to enable biometric authentication for this app. Then the flow is finished and the new passcode will take effect.

      Change passcode screens

      Notice that in the sign-in screen of a “change passcode” flow, the FORGOT PASSCODE? button is invisible and the SWTICH OR ADD USER button in multi-user mode is also invisible.

    Which of the following statements are correct?

    Log in to complete tutorial
  • Step 2
    1. In the app generated from the SAP BTP SDK Wizard for Android, there is a FORGOT PASSCODE? button on the sign-in screen. When the app is locked and user forgot the passcode to unlock the app, user can click this button to start a “forgot passcode” flow and reset the passcode.

      Forgot passcode button
    2. The “forgot passcode” flow actually starts an onboarding flow. The differences between a “forgot passcode” flow and a standard onboarding flow are:

      • The EULA screen is always excluded in the “forgot passcode” flow.

      • The “forgot passcode” flow remembers the user ID that is performing the “forgot passcode” action and if the user tries to onboard with another user ID, the flow will terminate with a warning dialog.

      Forgot passcode warning
    3. To start a “forgot passcode” flow, set the flow type as FlowType.FORGOT_PASSCODE and set the user ID who forgot the passcode for the FlowContext instance, and then call the start method of the Flow class to start the flow.

      Java
      Copy
      FlowContext flowContext = new FlowContextBuilder()
                  .setApplication(new AppConfig.Builder().applicationId("app_id").addAuth(
                          new BasicAuth()).build())
                  .setFlowType(FlowType.FORGOT_PASSCODE)
                  .setForgotPasscodeUserId("TestUser")
                  .build();
      Flow.start(this, flowContext);
      

    Which of the following statements are correct?

    Log in to complete tutorial
  • Step 3
    1. Users might be asked to enter passcode or authenticate with biometric again before modifying some sensitive information in the app. The “verify passcode” flow is designed for this purpose.

    2. To start a “verify passcode” flow, set the flow type as FlowType.VERIFY_PASSCODE and then call the start method of the Flow class to start the flow.

      Java
      Copy
      FlowContext flowContext = new FlowContextBuilder()
                  .setApplication(new AppConfig.Builder().applicationId("app_id").addAuth(
                          new BasicAuth()).build())
                  .setFlowType(FlowType.VERIFY_PASSCODE)
                  .build();
      Flow.start(this, flowContext);
      
    3. When biometric authentication is enabled by the user, the flow will display the “Sign In with Biometric” screen for user to authenticate with biometric information.

      Unlock with biometric

      Otherwise, the flow will display the sign-in screen for user to input passcode. Notice that unlike the sign-in screen used for app unlock, the FORGOT PASSCODE button and the SWITH OR ADD USER button in multi-user mode are always invisible for the sign-in screen of a “verify passcode” flow.

      Passcode verification

    Congratulations! You now have learned how to handle your passcode with the Flows component!

    Log in to complete tutorial
Back to top