improvement: Better chance at suggesting to autofill the OTP fields
This commit is contained in:
parent
679c385ef2
commit
5d20685465
@ -208,7 +208,8 @@ class AutofillActivity : BaseActivity(), DIAware {
|
||||
it.hint == AutofillHint.PASSWORD ||
|
||||
it.hint == AutofillHint.PHONE_NUMBER ||
|
||||
it.hint == AutofillHint.EMAIL_ADDRESS ||
|
||||
it.hint == AutofillHint.USERNAME
|
||||
it.hint == AutofillHint.USERNAME ||
|
||||
it.hint == AutofillHint.APP_OTP
|
||||
} == true
|
||||
val cardSearch = args.autofillStructure2?.items?.any {
|
||||
it.hint == AutofillHint.CREDIT_CARD_NUMBER ||
|
||||
|
@ -21,6 +21,7 @@ import com.artemchep.keyguard.common.io.launchIn
|
||||
import com.artemchep.keyguard.common.io.toIO
|
||||
import com.artemchep.keyguard.common.model.AddCipherOpenedHistoryRequest
|
||||
import com.artemchep.keyguard.common.model.AddUriCipherRequest
|
||||
import com.artemchep.keyguard.common.model.AutofillHint
|
||||
import com.artemchep.keyguard.common.model.DSecret
|
||||
import com.artemchep.keyguard.common.model.MasterSession
|
||||
import com.artemchep.keyguard.common.model.TotpToken
|
||||
@ -95,7 +96,11 @@ class AutofillFakeAuthActivity : AppCompatActivity(), DIAware {
|
||||
if (result != null) {
|
||||
// We want to copy to OTP code when you autofill an
|
||||
// entry, so launch a totp service.
|
||||
launchCopyTotpService()
|
||||
val mayNeedToCopyTotp = args?.structure?.items
|
||||
?.none { it.hint == AutofillHint.APP_OTP } == true
|
||||
if (mayNeedToCopyTotp) {
|
||||
launchCopyTotpService()
|
||||
}
|
||||
launchEditService()
|
||||
launchHistoryService()
|
||||
|
||||
|
@ -76,6 +76,12 @@ class AutofillStructureParser {
|
||||
"密碼",
|
||||
)
|
||||
|
||||
private val autofillLabel2faTranslations = listOf(
|
||||
"totp",
|
||||
"otp",
|
||||
"2fa",
|
||||
)
|
||||
|
||||
private val autofillLabelEmailTranslations = listOf(
|
||||
"email",
|
||||
"e-mail",
|
||||
@ -758,6 +764,15 @@ class AutofillStructureParser {
|
||||
reason = "type",
|
||||
)
|
||||
|
||||
"totp",
|
||||
"twofa",
|
||||
"2fa",
|
||||
-> AutofillStructureItemBuilder(
|
||||
accuracy = AutofillStructureItem.Accuracy.HIGH,
|
||||
hint = AutofillHint.APP_OTP,
|
||||
reason = "type",
|
||||
)
|
||||
|
||||
// custom
|
||||
|
||||
"expdate" -> AutofillStructureItemBuilder(
|
||||
@ -789,7 +804,15 @@ class AutofillStructureParser {
|
||||
"password" in id -> AutofillStructureItemBuilder(
|
||||
accuracy = AutofillStructureItem.Accuracy.HIGH,
|
||||
hint = AutofillHint.PASSWORD,
|
||||
reason = "type",
|
||||
reason = "id",
|
||||
)
|
||||
|
||||
"totp" in id ||
|
||||
"twofa" in id ||
|
||||
"2fa" in id -> AutofillStructureItemBuilder(
|
||||
accuracy = AutofillStructureItem.Accuracy.HIGH,
|
||||
hint = AutofillHint.APP_OTP,
|
||||
reason = "id",
|
||||
)
|
||||
|
||||
else -> null
|
||||
@ -827,6 +850,13 @@ class AutofillStructureParser {
|
||||
reason = "label:$hint",
|
||||
)
|
||||
|
||||
autofillLabel2faTranslations.any { it in hint } ->
|
||||
AutofillStructureItemBuilder(
|
||||
accuracy = AutofillStructureItem.Accuracy.MEDIUM,
|
||||
hint = AutofillHint.APP_OTP,
|
||||
reason = "label:$hint",
|
||||
)
|
||||
|
||||
autofillLabelCreditCardNumberTranslations.any { it.matches(hint) } ->
|
||||
AutofillStructureItemBuilder(
|
||||
accuracy = AutofillStructureItem.Accuracy.MEDIUM,
|
||||
@ -909,6 +939,8 @@ class AutofillStructureParser {
|
||||
accuracy = AutofillStructureItem.Accuracy.LOWEST,
|
||||
hint = AutofillHint.USERNAME,
|
||||
)
|
||||
extractOfType(node.idType.orEmpty()).let(out::addAll)
|
||||
extractOfId(node.idEntry.orEmpty()).let(out::addAll)
|
||||
}
|
||||
|
||||
inputIsVariationType(
|
||||
|
@ -523,20 +523,20 @@ class KeyguardAutofillService : AutofillService(), DIAware {
|
||||
title = title,
|
||||
text = text,
|
||||
)
|
||||
val fields = run {
|
||||
val hints = struct.items
|
||||
.asSequence()
|
||||
.map { it.hint }
|
||||
.toSet()
|
||||
secret.gett(
|
||||
hints = hints,
|
||||
getTotpCode = getTotpCode,
|
||||
).bind()
|
||||
}
|
||||
|
||||
suspend fun createDatasetBuilder(): Dataset.Builder {
|
||||
val builder = Dataset.Builder(views)
|
||||
builder.setId(secret.id)
|
||||
val fields = run {
|
||||
val hints = struct.items
|
||||
.asSequence()
|
||||
.map { it.hint }
|
||||
.toSet()
|
||||
secret.gett(
|
||||
hints = hints,
|
||||
getTotpCode = getTotpCode,
|
||||
).bind()
|
||||
}
|
||||
struct.items.forEach { structItem ->
|
||||
val value = fields[structItem.hint]
|
||||
builder.trySetValue(
|
||||
|
@ -198,7 +198,8 @@ class GetSuggestionsImpl(
|
||||
AutofillHint.EMAIL_ADDRESS in target.hints ||
|
||||
AutofillHint.PHONE_NUMBER in target.hints ||
|
||||
AutofillHint.USERNAME in target.hints ||
|
||||
AutofillHint.PASSWORD in target.hints
|
||||
AutofillHint.PASSWORD in target.hints ||
|
||||
AutofillHint.APP_OTP in target.hints
|
||||
) {
|
||||
run {
|
||||
val equivalentDomains = equivalentDomainsHolder
|
||||
|
Loading…
x
Reference in New Issue
Block a user