Fix link device crash.

This commit is contained in:
mtang-signal
2024-10-01 13:50:59 -04:00
committed by Greyson Parrelli
parent 4dba584913
commit 9d0aef8dbc
2 changed files with 10 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms package org.thoughtcrime.securesms
import android.app.Activity import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Build import android.os.Build
@@ -51,7 +52,12 @@ class BiometricDeviceAuthentication(
return if (!DISALLOWED_BIOMETRIC_VERSIONS.contains(Build.VERSION.SDK_INT) && biometricManager.canAuthenticate(ALLOWED_AUTHENTICATORS) == BiometricManager.BIOMETRIC_SUCCESS) { return if (!DISALLOWED_BIOMETRIC_VERSIONS.contains(Build.VERSION.SDK_INT) && biometricManager.canAuthenticate(ALLOWED_AUTHENTICATORS) == BiometricManager.BIOMETRIC_SUCCESS) {
if (force) { if (force) {
Log.i(TAG, "Listening for biometric authentication...") Log.i(TAG, "Listening for biometric authentication...")
biometricPrompt.authenticate(biometricPromptInfo) try {
biometricPrompt.authenticate(biometricPromptInfo)
} catch (e: ActivityNotFoundException) {
Log.w(TAG, "Failed to launch confirm device credential settings", e)
return false
}
} else { } else {
Log.i(TAG, "Skipping show system biometric or device lock dialog unless forced") Log.i(TAG, "Skipping show system biometric or device lock dialog unless forced")
} }

View File

@@ -135,7 +135,9 @@ class LinkDeviceFragment : ComposeFragment() {
LaunchedEffect(state.seenEducationSheet) { LaunchedEffect(state.seenEducationSheet) {
if (state.seenEducationSheet) { if (state.seenEducationSheet) {
biometricAuth.authenticate(requireContext(), true) { biometricDeviceLockLauncher.launch(getString(R.string.LinkDeviceFragment__unlock_to_link)) } if (!biometricAuth.authenticate(requireContext(), true) { biometricDeviceLockLauncher.launch(getString(R.string.LinkDeviceFragment__unlock_to_link)) }) {
navController.safeNavigate(R.id.action_linkDeviceFragment_to_addLinkDeviceFragment)
}
viewModel.markEducationSheetSeen(false) viewModel.markEducationSheetSeen(false)
} }
} }