start

suspend fun start(context: Context, block: LegacyAuthenticationConfig.() -> Unit = {})

Executes the full authenticator migration pipeline.

The pipeline consists of three sequential steps:

  1. Import legacy data — calls LegacyStorageProvider.isMigrationRequired; aborts if false. If migration is required, calls LegacyStorageProvider.getMigrationData.

  2. Migrate mechanisms — converts legacy OATH and Push mechanisms to the new storage format.

  3. Cleanup — calls LegacyStorageProvider.cleanUp passing the LegacyAuthenticationConfig.backup callback so the provider can persist data before clearing it.

This function suspends until the migration is fully complete (or cleanly aborted). It is safe to call multiple times — the kotlinx.coroutines.sync.Mutex prevents concurrent runs, and the pipeline exits early if there is nothing to migrate.

Parameters

context

The Android application context used to access storage, SharedPreferences, and the AndroidKeyStore.

block

Optional DSL block to configure LegacyAuthenticationConfig. If omitted, all properties use their default values, which is suitable for standard FR Authenticator installations using the default StorageClientProvider.

Example — default migration (no configuration needed)

lifecycleScope.launch {
AuthMigration.start(applicationContext)
}

Example — custom storage provider

lifecycleScope.launch {
AuthMigration.start(applicationContext) {
legacyStorageProvider = MyCustomStorageProvider(applicationContext)
}
}

Example — backup before cleanup

lifecycleScope.launch {
AuthMigration.start(applicationContext) {
backup = { ctx -> MyBackupHelper.backup(ctx) }
}
}

See also