Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c2f77c0e authored by Arpan Kaphle's avatar Arpan Kaphle Committed by Android (Google) Code Review
Browse files

Merge "Biometric Credman Layered UI Bugfix" into main

parents 2d1f2179 0cc43597
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -98,7 +98,8 @@ fun runBiometricFlow(
    context: Context,
    openMoreOptionsPage: () -> Unit,
    sendDataToProvider: (EntryInfo, BiometricPrompt.AuthenticationResult) -> Unit,
    onCancelFlowAndFinish: (String) -> Unit,
    onCancelFlowAndFinish: () -> Unit,
    onIllegalStateAndFinish: (String) -> Unit,
    getRequestDisplayInfo: RequestDisplayInfo? = null,
    getProviderInfoList: List<ProviderInfo>? = null,
    getProviderDisplayInfo: ProviderDisplayInfo? = null,
@@ -131,7 +132,7 @@ fun runBiometricFlow(

    val callback: BiometricPrompt.AuthenticationCallback =
        setupBiometricAuthenticationCallback(sendDataToProvider, biometricEntry,
            onCancelFlowAndFinish)
            onCancelFlowAndFinish, onIllegalStateAndFinish)

    val cancellationSignal = CancellationSignal()
    cancellationSignal.setOnCancelListener {
@@ -211,7 +212,8 @@ private fun removeDeviceCredential(requestAllowedAuthenticators: Int): Int {
private fun setupBiometricAuthenticationCallback(
    sendDataToProvider: (EntryInfo, BiometricPrompt.AuthenticationResult) -> Unit,
    selectedEntry: EntryInfo,
    onCancelFlowAndFinish: (String) -> Unit
    onCancelFlowAndFinish: () -> Unit,
    onIllegalStateAndFinish: (String) -> Unit,
): BiometricPrompt.AuthenticationCallback {
    val callback: BiometricPrompt.AuthenticationCallback =
        object : BiometricPrompt.AuthenticationCallback() {
@@ -224,14 +226,12 @@ private fun setupBiometricAuthenticationCallback(
                    if (authResult != null) {
                        sendDataToProvider(selectedEntry, authResult)
                    } else {
                        onCancelFlowAndFinish("The biometric flow succeeded but unexpectedly " +
                        onIllegalStateAndFinish("The biometric flow succeeded but unexpectedly " +
                                "returned a null value.")
                        // TODO(b/326243754) : Propagate to provider
                    }
                } catch (e: Exception) {
                    onCancelFlowAndFinish("The biometric flow succeeded but failed on handling " +
                    onIllegalStateAndFinish("The biometric flow succeeded but failed on handling " +
                            "the result. See: \n$e\n")
                    // TODO(b/326243754) : Propagate to provider
                }
            }

@@ -245,6 +245,12 @@ private fun setupBiometricAuthenticationCallback(
            override fun onAuthenticationError(errorCode: Int, errString: CharSequence?) {
                super.onAuthenticationError(errorCode, errString)
                Log.d(TAG, "Authentication error-ed out: $errorCode and $errString")
                if (errorCode == BiometricPrompt.BIOMETRIC_ERROR_USER_CANCELED) {
                    // Note that because the biometric prompt is imbued directly
                    // into the selector, parity applies to the selector's cancellation instead
                    // of the provider's biometric prompt cancellation.
                    onCancelFlowAndFinish()
                }
                // TODO(b/326243754) : Propagate to provider
            }

+5 −2
Original line number Diff line number Diff line
@@ -148,7 +148,8 @@ fun GetCredentialScreen(
                                // activeEntry will always be what represents the single tap flow
                                biometricEntry = getCredentialUiState.activeEntry,
                                onMoreOptionSelected = viewModel::getFlowOnMoreOptionSelected,
                                onCancelFlowAndFinish = viewModel::onIllegalUiState,
                                onCancelFlowAndFinish = viewModel::onUserCancel,
                                onIllegalStateAndFinish = viewModel::onIllegalUiState,
                                requestDisplayInfo = getCredentialUiState.requestDisplayInfo,
                                providerInfoList = getCredentialUiState.providerInfoList,
                                providerDisplayInfo = getCredentialUiState.providerDisplayInfo,
@@ -212,7 +213,8 @@ fun GetCredentialScreen(
@Composable
internal fun BiometricSelectionPage(
    biometricEntry: EntryInfo?,
    onCancelFlowAndFinish: (String) -> Unit,
    onCancelFlowAndFinish: () -> Unit,
    onIllegalStateAndFinish: (String) -> Unit,
    onMoreOptionSelected: () -> Unit,
    requestDisplayInfo: RequestDisplayInfo,
    providerInfoList: List<ProviderInfo>,
@@ -230,6 +232,7 @@ internal fun BiometricSelectionPage(
        openMoreOptionsPage = onMoreOptionSelected,
        sendDataToProvider = onBiometricEntrySelected,
        onCancelFlowAndFinish = onCancelFlowAndFinish,
        onIllegalStateAndFinish = onIllegalStateAndFinish,
        getRequestDisplayInfo = requestDisplayInfo,
        getProviderInfoList = providerInfoList,
        getProviderDisplayInfo = providerDisplayInfo,