Created
September 26, 2018 23:15
-
-
Save adrianhall/040f58fd455fc761a79a95d4438fa99a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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