Fix webDomain with Autofill compatibility mode #551

This commit is contained in:
J-Jamet
2020-10-05 19:29:19 +02:00
parent 9947a23343
commit a775e29aef
2 changed files with 12 additions and 6 deletions

View File

@@ -48,8 +48,7 @@ class KeeAutofillService : AutofillService() {
override fun onFillRequest(request: FillRequest,
cancellationSignal: CancellationSignal,
callback: FillCallback) {
val fillContexts = request.fillContexts
val latestStructure = fillContexts[fillContexts.size - 1].structure
val latestStructure = request.fillContexts.last().structure
cancellationSignal.setOnCancelListener { Log.w(TAG, "Cancel autofill.") }

View File

@@ -74,7 +74,9 @@ internal class StructureParser(private val structure: AssistStructure) {
Log.d(TAG, "Autofill domain: $webDomain")
}
}
val domainNotEmpty = result?.domain?.isNotEmpty() == true
var returnValue = false
// Only parse visible nodes
if (node.visibility == View.VISIBLE) {
if (node.autofillId != null
@@ -83,19 +85,24 @@ internal class StructureParser(private val structure: AssistStructure) {
val hints = node.autofillHints
if (hints != null && hints.isNotEmpty()) {
if (parseNodeByAutofillHint(node))
return true
returnValue = true
} else if (parseNodeByHtmlAttributes(node))
return true
returnValue = true
else if (parseNodeByAndroidInput(node))
return true
returnValue = true
}
// Optimized return but only if domain not empty
if (domainNotEmpty && returnValue)
return true
// Recursive method to process each node
for (i in 0 until node.childCount) {
if (parseViewNode(node.getChildAt(i)))
returnValue = true
if (domainNotEmpty && returnValue)
return true
}
}
return false
return returnValue
}
private fun parseNodeByAutofillHint(node: AssistStructure.ViewNode): Boolean {