Skip to content

Commit 4232b91

Browse files
committed
Add pixel where auth indicates a hardware missing error
1 parent 39c82d2 commit 4232b91

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/deviceauth/AuthLauncher.kt

+20
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ import androidx.biometric.BiometricPrompt
2424
import androidx.core.content.ContextCompat
2525
import androidx.fragment.app.Fragment
2626
import androidx.fragment.app.FragmentActivity
27+
import com.duckduckgo.app.statistics.pixels.Pixel
28+
import com.duckduckgo.app.statistics.pixels.Pixel.PixelType
2729
import com.duckduckgo.appbuildconfig.api.AppBuildConfig
2830
import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult
2931
import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult.Error
3032
import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult.Success
3133
import com.duckduckgo.autofill.impl.deviceauth.DeviceAuthenticator.AuthResult.UserCancelled
34+
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE
3235
import com.duckduckgo.di.scopes.AppScope
3336
import com.squareup.anvil.annotations.ContributesBinding
3437
import javax.inject.Inject
@@ -55,6 +58,7 @@ class RealAuthLauncher @Inject constructor(
5558
private val context: Context,
5659
private val appBuildConfig: AppBuildConfig,
5760
private val autofillAuthorizationGracePeriod: AutofillAuthorizationGracePeriod,
61+
private val pixel: Pixel,
5862
) : AuthLauncher {
5963

6064
override fun launch(
@@ -101,6 +105,7 @@ class RealAuthLauncher @Inject constructor(
101105
onResult(UserCancelled)
102106
} else {
103107
onResult(Error(String.format("(%d) %s", errorCode, errString)))
108+
sendErrorPixel(errorCode)
104109
}
105110
}
106111

@@ -115,6 +120,21 @@ class RealAuthLauncher @Inject constructor(
115120
super.onAuthenticationFailed()
116121
Timber.v("onAuthenticationFailed")
117122
}
123+
124+
private fun sendErrorPixel(errorCode: Int) {
125+
when (errorCode) {
126+
BiometricPrompt.ERROR_HW_NOT_PRESENT -> {
127+
val params = mapOf(
128+
"manufacturer" to appBuildConfig.manufacturer,
129+
"model" to appBuildConfig.model,
130+
)
131+
pixel.fire(AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE, parameters = params, type = PixelType.Unique())
132+
}
133+
else -> {
134+
// no-op
135+
}
136+
}
137+
}
118138
}
119139

120140
private fun getPromptInfo(titleText: Int, featureAuthText: Int): BiometricPrompt.PromptInfo {

autofill/autofill-impl/src/main/java/com/duckduckgo/autofill/impl/pixel/AutofillPixelNames.kt

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package com.duckduckgo.autofill.impl.pixel
1919
import com.duckduckgo.app.statistics.pixels.Pixel
2020
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DECLINE_PROMPT_TO_DISABLE_AUTOFILL_SNACKBAR_OPEN_SETTINGS
2121
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DECLINE_PROMPT_TO_DISABLE_AUTOFILL_SNACKBAR_SHOWN
22+
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE
2223
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_ENGAGEMENT_ACTIVE_USER
2324
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_ENGAGEMENT_ENABLED_USER
2425
import com.duckduckgo.autofill.impl.pixel.AutofillPixelNames.AUTOFILL_ENGAGEMENT_ONBOARDED_USER
@@ -145,6 +146,7 @@ enum class AutofillPixelNames(override val pixelName: String) : Pixel.PixelName
145146
"m_autofill_device_capability_secure_storage_unavailable_and_device_auth_disabled",
146147
),
147148
AUTOFILL_DEVICE_CAPABILITY_UNKNOWN_ERROR("m_autofill_device_capability_unknown"),
149+
AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE("autofill_device_auth_error_hardware_unavailable"),
148150

149151
AUTOFILL_SURVEY_AVAILABLE_PROMPT_DISPLAYED("m_autofill_management_screen_visit_survey_available"),
150152

@@ -256,6 +258,8 @@ object AutofillPixelsRequiringDataCleaning : PixelParamRemovalPlugin {
256258
AUTOFILL_SERVICE_PASSWORDS_SEARCH.pixelName to PixelParameter.removeAtb(),
257259
AUTOFILL_SERVICE_PASSWORDS_SEARCH_INPUT.pixelName to PixelParameter.removeAtb(),
258260
AUTOFILL_SERVICE_CRASH.pixelName to PixelParameter.removeAtb(),
261+
262+
AUTOFILL_DEVICE_AUTH_ERROR_HARDWARE_UNAVAILABLE.pixelName to PixelParameter.removeAtb(),
259263
)
260264
}
261265
}

0 commit comments

Comments
 (0)