collectPin
Collects an application PIN from the user via a Jetpack Compose dialog.
This suspending function displays a modal dialog that prompts the user to enter their application PIN. The dialog is displayed as an overlay on top of the provided activity using a ComposeView, ensuring a consistent Material Design UI experience.
The function suspends until the user either:
Enters a PIN and confirms it (returns the PIN as a CharArray)
Cancels the dialog (throws a RuntimeException)
Usage
This function is typically used by the Application PIN authenticator when signing operations require user authentication:
Security Considerations
The PIN is returned as a CharArray rather than a String to allow the caller to clear the sensitive data from memory after use by calling charArray.fill('0'). This reduces the window of opportunity for sensitive data to be compromised.
UI Lifecycle
The dialog is implemented using Jetpack Compose and is added to the activity's content view hierarchy. When the user completes or cancels PIN entry, the dialog is automatically removed from the view hierarchy. If the coroutine is cancelled externally, the cleanup is handled automatically via kotlinx.coroutines.CancellableContinuation.invokeOnCancellation.
Return
A CharArray containing the PIN entered by the user. The caller is responsible for clearing this array after use to ensure security.
Parameters
The Android Activity that will host the PIN collection dialog. This activity's UI thread is used for view operations.
The main title text to display in the dialog.
Secondary text providing context for the PIN request.
Detailed explanatory text about the PIN request.
See also
Throws
if the user cancels the PIN entry dialog.