From 4232b91c98485a1817a6ece0060ace2b2553709a Mon Sep 17 00:00:00 2001 From: Craig Russell <1336281+CDRussell@users.noreply.github.com> Date: Mon, 28 Apr 2025 13:46:54 +0100 Subject: [PATCH] Add pixel where auth indicates a hardware missing error --- .../autofill/impl/deviceauth/AuthLauncher.kt | 20 +++++++++++++++++++ .../autofill/impl/pixel/AutofillPixelNames.kt | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/deviceauth/AuthLauncher.kt b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/deviceauth/AuthLauncher.kt index e8c476df122d..e9cc9e09b0b9 100644 --- a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/deviceauth/AuthLauncher.kt +++ b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/deviceauth/AuthLauncher.kt @@ -24,11 +24,14 @@ import androidx.biometric.BiometricPrompt import androidx.core.content.ContextCompat import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity +import com.duckduckgo.app.statistics.pixels.Pixel +import com.duckduckgo.app.statistics.pixels.Pixel.PixelType import com.duckduckgo.appbuildconfig.api.AppBuildConfig import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult.Error import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult.Success import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult.UserCancelled +import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesBinding import javax.inject.Inject @@ -55,6 +58,7 @@ class RealAuthLauncher @Inject constructor( private val context: Context, private val appBuildConfig: AppBuildConfig, private val autofillAuthorizationGracePeriod: AutofillAuthorizationGracePeriod, + private val pixel: Pixel, ) : AuthLauncher { override fun launch( @@ -101,6 +105,7 @@ class RealAuthLauncher @Inject constructor( onResult(UserCancelled) } else { onResult(Error(String.format("(%d) %s", errorCode, errString))) + sendErrorPixel(errorCode) } } @@ -115,6 +120,21 @@ class RealAuthLauncher @Inject constructor( super.onAuthenticationFailed() Timber.v("onAuthenticationFailed") } + + private fun sendErrorPixel(errorCode: Int) { + when (errorCode) { + BiometricPrompt.ERROR_HW_NOT_PRESENT -> { + val params = mapOf( + "manufacturer" to appBuildConfig.manufacturer, + "model" to appBuildConfig.model, + ) + pixel.fire(AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE, parameters = params, type = PixelType.Unique()) + } + else -> { + // no-op + } + } + } } private fun getPromptInfo(titleText: Int, featureAuthText: Int): BiometricPrompt.PromptInfo { diff --git a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/pixel/AutofillPixelNames.kt b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/pixel/AutofillPixelNames.kt index 657fcd805c4a..56e3cde640ee 100644 --- a/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/pixel/AutofillPixelNames.kt +++ b/autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/pixel/AutofillPixelNames.kt @@ -19,6 +19,7 @@ package com.duckduckgo.autofill.impl.pixel import com.duckduckgo.app.statistics.pixels.Pixel import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DECLINE_PROMPT_TO_DISABLE_AUTOFILL_SNACKBAR_OPEN_SETTINGS import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DECLINE_PROMPT_TO_DISABLE_AUTOFILL_SNACKBAR_SHOWN +import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_ENGAGEMENT_ACTIVE_USER import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_ENGAGEMENT_ENABLED_USER import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_ENGAGEMENT_ONBOARDED_USER @@ -145,6 +146,7 @@ enum class AutofillPixelNames(override val pixelName: String) : Pixel.PixelName "m_autofill_device_capability_secure_storage_unavailable_and_device_auth_disabled", ), AUTOFILL_DEVICE_CAPABILITY_UNKNOWN_ERROR("m_autofill_device_capability_unknown"), + AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE("autofill_device_auth_error_hardware_unavailable"), AUTOFILL_SURVEY_AVAILABLE_PROMPT_DISPLAYED("m_autofill_management_screen_visit_survey_available"), @@ -256,6 +258,8 @@ object AutofillPixelsRequiringDataCleaning : PixelParamRemovalPlugin { AUTOFILL_SERVICE_PASSWORDS_SEARCH.pixelName to PixelParameter.removeAtb(), AUTOFILL_SERVICE_PASSWORDS_SEARCH_INPUT.pixelName to PixelParameter.removeAtb(), AUTOFILL_SERVICE_CRASH.pixelName to PixelParameter.removeAtb(), + + AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE.pixelName to PixelParameter.removeAtb(), ) } }