Overview
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
Prerequisites
- You have Set Up a BTP Account for Tutorials. Follow the instructions to get an account, and then to set up entitlements and service instances for the following BTP services.
- SAP Mobile Services
- You completed Try Out the SAP BTP SDK Wizard for Android.
- You completed Get Familiar with the Flows Component by a Wizard Generated Application.
Steps
Details
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
Open the project you previously created using the SAP BTP SDK Wizard for Android.
In Android Studio, on Windows, press
Ctrl+N, or, on a Mac, presscommand+O, and typeSettingsFragmentto openSettingsFragment.java.On Windows, press
Ctrl+F12, or, on a Mac, presscommand+F12, and typeonCreatePreferencesto move to theonCreatePreferencesmethod. To start the flow to change passcode, the flow type must beFlowType.CHANGEPASSCODEfor theFlowContextinstance. Upon starting the flow with thisFlowContextinstance, the entire process to change passcode will be handled automatically.!

Change passcode flow 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.
Open the project you previously created using the SAP BTP SDK Wizard for Android.
In Android Studio, on Windows, press
Ctrl+N, or, on a Mac, presscommand+O, and typeSettingsFragmentto openSettingsFragment.kt.On Windows, press
Ctrl+F12, or, on a Mac, presscommand+F12, and typeonCreatePreferencesto move to theonCreatePreferencesmethod. To start the flow to change passcode, the flow type must beFlowType.CHANGEPASSCODEfor theFlowContextinstance. Upon starting the flow with thisFlowContextinstance, the entire process to change passcode will be handled automatically.!

Change passcode flow 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.
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 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 To start a “forgot passcode” flow, set the flow type as
FlowType.FORGOT_PASSCODEand set the user ID who forgot the passcode for theFlowContextinstance, and then call thestartmethod of theFlowclass to start the flow.
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);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 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 To start a “forgot passcode” flow, set the flow type as
FlowType.FORGOT_PASSCODEand set the user ID who forgot the passcode for theFlowContextinstance, and then call thestartmethod of theFlowclass to start the flow.
val flowContext = FlowContextBuilder()
.setApplication(AppConfig.Builder().applicationId("app_id")
.addAuth(BasicAuth())
.build())
.setFlowType(FlowType.FORGOT_PASSCODE)
.setForgotPasscodeUserId("TestUser")
.build()
Flow.start(this, flowContext)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.
To start a “verify passcode” flow, set the flow type as
FlowType.VERIFY_PASSCODEand then call thestartmethod of theFlowclass to start the flow.
FlowContext flowContext = new FlowContextBuilder()
.setApplication(new AppConfig.Builder().applicationId("app_id").addAuth(
new BasicAuth()).build())
.setFlowType(FlowType.VERIFY_PASSCODE)
.build();
Flow.start(this, flowContext);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
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.
To start a “verify passcode” flow, set the flow type as
FlowType.VERIFY_PASSCODEand then call thestartmethod of theFlowclass to start the flow.
val flowContext = FlowContextBuilder()
.setApplication(AppConfig.Builder().applicationId("app_id")
.addAuth(BasicAuth())
.build())
.setFlowType(FlowType.VERIFY_PASSCODE)
.build()
Flow.start(this, flowContext)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!
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.