SecureAreaProvider
class SecureAreaProvider<out T : SecureArea>(context: CoroutineContext = Dispatchers.Main, provider: suspend CoroutineScope.() -> T)
Lazily creates a SecureArea.
SecureArea creation is typically asynchronous and cannot be completed in a synchronous scopes (such as at static initialization or callbacks like onCreate
). This class provides a wrapper to hold an asynchronously-created SecureArea. To create a SecureArea in synchronous context, use
// synchronous initialization code
val fooSecureAreaProvider = SecureAreaProvider { FooSecureArea.create(storage, ...) }
Content copied to clipboard
Then when using secure area in an asynchronous context (which is required as SecureArea APIs are asynchronous):
// asynchronous code
val fooSecureArea = fooSecureAreaProvider.get()
fooSecureArea.someApiCall()
Content copied to clipboard