auto unlock on correct pin

This commit is contained in:
2026-05-22 06:39:59 +05:00
parent fd7fcb41a6
commit 27270f1b7a
6 changed files with 67 additions and 4 deletions
@@ -31,6 +31,15 @@ class SettingsSecurityFragment : Fragment() {
)
}
// Auto unlock on correct PIN (only for pin method)
if (prefs.getString("security_method", null) == "pin") {
binding.rowAutoUnlockPin.visibility = View.VISIBLE
binding.switchAutoUnlockPin.isChecked = prefs.getBoolean("auto_unlock_pin", false)
binding.switchAutoUnlockPin.setOnCheckedChangeListener { _, isChecked ->
prefs.edit().putBoolean("auto_unlock_pin", isChecked).apply()
}
}
// Biometrics
val canUseBiometrics = BiometricManager.from(requireContext())
.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_WEAK) == BiometricManager.BIOMETRIC_SUCCESS
@@ -215,9 +215,10 @@ class SecuritySetupFragment : Fragment() {
val salt = ByteArray(16).also { SecureRandom().nextBytes(it) }
val saltB64 = Base64.encodeToString(salt, Base64.NO_WRAP)
val hash = pbkdf2(input, salt)
requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE).edit()
val edit = requireContext().getSharedPreferences("prefs", Context.MODE_PRIVATE).edit()
.putString("security_method", method)
.apply()
if (method == "pin") edit.putInt("pin_length", input.length)
edit.apply()
CredentialStore(requireContext()).saveSecurityHash(saltB64, hash)
}