|
|
@@ -6,11 +6,9 @@ import android.os.Build
|
|
|
import android.os.CancellationSignal
|
|
|
import android.security.keystore.KeyGenParameterSpec
|
|
|
import android.security.keystore.KeyProperties
|
|
|
-import android.util.Log
|
|
|
import androidx.biometric.BiometricManager
|
|
|
import androidx.biometric.BiometricPrompt
|
|
|
import androidx.fragment.app.FragmentActivity
|
|
|
-import com.iscs.bozzys.utils.Storage.saveTokenIv
|
|
|
import java.security.KeyStore
|
|
|
import javax.crypto.Cipher
|
|
|
import javax.crypto.KeyGenerator
|
|
|
@@ -48,14 +46,13 @@ object SystemUtil {
|
|
|
*
|
|
|
* @param act
|
|
|
*/
|
|
|
- fun showFingerAuth(act: Activity) {
|
|
|
+ @OptIn(ExperimentalStdlibApi::class)
|
|
|
+ fun showFingerAuth(act: Activity, cipher: Cipher, value: ByteArray, done: (doFinalValue: ByteArray) -> Unit) {
|
|
|
if (act is FragmentActivity) {
|
|
|
val bp = BiometricPrompt(act, act.mainExecutor, object : BiometricPrompt.AuthenticationCallback() {
|
|
|
|
|
|
})
|
|
|
} else {
|
|
|
- BiometricKeyStore.createKeyIfNeeded()
|
|
|
- val cipher = BiometricKeyStore.encryptCipher()
|
|
|
val bp = android.hardware.biometrics.BiometricPrompt.Builder(act)
|
|
|
.setTitle("请验证")
|
|
|
.setNegativeButton("取消", act.mainExecutor) { _, _ ->
|
|
|
@@ -69,16 +66,13 @@ object SystemUtil {
|
|
|
object : android.hardware.biometrics.BiometricPrompt.AuthenticationCallback() {
|
|
|
|
|
|
override fun onAuthenticationSucceeded(result: android.hardware.biometrics.BiometricPrompt.AuthenticationResult) {
|
|
|
+ LogUtil.i("SystemUtil -> showFingerAuth", "Auth succeeded")
|
|
|
val cipher = result.cryptoObject?.cipher
|
|
|
- cipher?.doFinal(Storage.readToken().toByteArray())?.let {
|
|
|
- (it + cipher.iv).saveTokenIv()
|
|
|
- }
|
|
|
- // val = BiometricKeyStore.decryptCipher(Storage.readTokenIv())
|
|
|
- // Log.d("xiaoming", "验证成功 ${String(Storage.readTokenIv())}")
|
|
|
+ cipher?.doFinal(value)?.let { done(it) }
|
|
|
}
|
|
|
|
|
|
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
|
|
- Log.d("xiaoming", "验证失败")
|
|
|
+ LogUtil.i("SystemUtil -> showFingerAuth", "Auth error code : $errorCode msg : $errString")
|
|
|
}
|
|
|
}
|
|
|
)
|