Skip to content

Instantly share code, notes, and snippets.

@adrianhall
Created September 26, 2018 23:15
Show Gist options
  • Save adrianhall/040f58fd455fc761a79a95d4438fa99a to your computer and use it in GitHub Desktop.
Save adrianhall/040f58fd455fc761a79a95d4438fa99a to your computer and use it in GitHub Desktop.
/**
* Load the data from the biometric store and populate the right fields
*/
private fun loadFromBiometricStore() {
if (whorlwind?.canStoreSecurely() == true) {
val disposable = whorlwind!!.read("password")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { result ->
when (result.readState) {
ReadResult.ReadState.NEEDS_AUTH -> {
toast("WHORLWIND - NEEDS_AUTH")
}
ReadResult.ReadState.UNRECOVERABLE_ERROR,
ReadResult.ReadState.AUTHORIZATION_ERROR,
ReadResult.ReadState.RECOVERABLE_ERROR -> {
toast("WHORLWIND - ERROR")
}
ReadResult.ReadState.READY -> {
Log.d(TAG, "WHORLWIND - READY - password = ${result.value?.utf8() ?: "null"}")
val password = result.value?.utf8() ?: ""
with (loginFormPasswordField.text) {
clear()
append(password)
}
}
else -> {
toast("WHORLWIND - EEEK!")
}
}
}
mDisposable.add(disposable)
} else {
toast("Biometric storage is not available")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment