mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-24 03:16:00 +00:00
Skip authentication if it is unavailable
Disable dependency info (#89) Remove unused permissions Use millisecond in security logs GitHub action: upload artifacts to Telegram only on dev branch
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.bintianqi.owndroid
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.biometric.BiometricManager
|
||||
import androidx.biometric.BiometricPrompt
|
||||
@@ -18,6 +19,7 @@ import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
@@ -26,6 +28,7 @@ import kotlinx.coroutines.delay
|
||||
|
||||
@Composable
|
||||
fun Authenticate(activity: FragmentActivity, navCtrl: NavHostController) {
|
||||
val context = LocalContext.current
|
||||
BackHandler { activity.moveTaskToBack(true) }
|
||||
var status by rememberSaveable { mutableIntStateOf(0) } // 0:Prompt automatically, 1:Authenticating, 2:Prompt manually
|
||||
val onAuthSucceed = { navCtrl.navigateUp() }
|
||||
@@ -37,7 +40,11 @@ fun Authenticate(activity: FragmentActivity, navCtrl: NavHostController) {
|
||||
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
|
||||
super.onAuthenticationError(errorCode, errString)
|
||||
when(errorCode) {
|
||||
BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL -> onAuthSucceed()
|
||||
BiometricPrompt.ERROR_NO_DEVICE_CREDENTIAL, BiometricPrompt.ERROR_NO_SPACE, BiometricPrompt.ERROR_HW_NOT_PRESENT,
|
||||
BiometricPrompt.ERROR_VENDOR, BiometricPrompt.ERROR_NO_BIOMETRICS -> {
|
||||
Toast.makeText(context, R.string.skipped_authentication, Toast.LENGTH_SHORT).show()
|
||||
onAuthSucceed()
|
||||
}
|
||||
else -> status = 2
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user