fix: Remove Lock in Autofill

This commit is contained in:
J-Jamet
2023-09-04 20:45:32 +02:00
parent 6d633c9986
commit 544f7003f6

View File

@@ -45,7 +45,6 @@ import com.kunzisoft.keepass.settings.AutofillSettingsActivity
import com.kunzisoft.keepass.settings.PreferencesUtil import com.kunzisoft.keepass.settings.PreferencesUtil
import com.kunzisoft.keepass.utils.WebDomain import com.kunzisoft.keepass.utils.WebDomain
import org.joda.time.DateTime import org.joda.time.DateTime
import java.util.concurrent.atomic.AtomicBoolean
@RequiresApi(api = Build.VERSION_CODES.O) @RequiresApi(api = Build.VERSION_CODES.O)
@@ -57,7 +56,6 @@ class KeeAutofillService : AutofillService() {
private var webDomainBlocklist: Set<String>? = null private var webDomainBlocklist: Set<String>? = null
private var askToSaveData: Boolean = false private var askToSaveData: Boolean = false
private var autofillInlineSuggestionsEnabled: Boolean = false private var autofillInlineSuggestionsEnabled: Boolean = false
private var mLock = AtomicBoolean()
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
@@ -96,35 +94,31 @@ class KeeAutofillService : AutofillService() {
Log.d(TAG, "Autofill requested in native mode") Log.d(TAG, "Autofill requested in native mode")
} }
// Lock // Check user's settings for authenticating Responses and Datasets.
if (!mLock.get()) { val latestStructure = request.fillContexts.last().structure
mLock.set(true) StructureParser(latestStructure).parse()?.let { parseResult ->
// Check user's settings for authenticating Responses and Datasets.
val latestStructure = request.fillContexts.last().structure
StructureParser(latestStructure).parse()?.let { parseResult ->
// Build search info only if applicationId or webDomain are not blocked // Build search info only if applicationId or webDomain are not blocked
if (autofillAllowedFor(parseResult.applicationId, applicationIdBlocklist) if (autofillAllowedFor(parseResult.applicationId, applicationIdBlocklist)
&& autofillAllowedFor(parseResult.webDomain, webDomainBlocklist)) { && autofillAllowedFor(parseResult.webDomain, webDomainBlocklist)) {
val searchInfo = SearchInfo().apply { val searchInfo = SearchInfo().apply {
applicationId = parseResult.applicationId applicationId = parseResult.applicationId
webDomain = parseResult.webDomain webDomain = parseResult.webDomain
webScheme = parseResult.webScheme webScheme = parseResult.webScheme
} }
WebDomain.getConcreteWebDomain(this, searchInfo.webDomain) { webDomainWithoutSubDomain -> WebDomain.getConcreteWebDomain(this, searchInfo.webDomain) { webDomainWithoutSubDomain ->
searchInfo.webDomain = webDomainWithoutSubDomain searchInfo.webDomain = webDomainWithoutSubDomain
val inlineSuggestionsRequest = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R val inlineSuggestionsRequest = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
&& autofillInlineSuggestionsEnabled) { && autofillInlineSuggestionsEnabled) {
CompatInlineSuggestionsRequest(request) CompatInlineSuggestionsRequest(request)
} else { } else {
null null
}
launchSelection(mDatabase,
searchInfo,
parseResult,
inlineSuggestionsRequest,
callback)
} }
launchSelection(mDatabase,
searchInfo,
parseResult,
inlineSuggestionsRequest,
callback)
} }
} }
} }
@@ -376,7 +370,6 @@ class KeeAutofillService : AutofillService() {
} }
override fun onDisconnected() { override fun onDisconnected() {
mLock.set(false)
Log.d(TAG, "onDisconnected") Log.d(TAG, "onDisconnected")
} }