fix: search parameters

This commit is contained in:
J-Jamet
2025-08-20 10:11:55 +02:00
parent d0c0c4a4d6
commit e3083c7773
3 changed files with 46 additions and 57 deletions

View File

@@ -84,6 +84,29 @@ class PasskeyProviderService : CredentialProviderService() {
super.onDestroy() super.onDestroy()
} }
private fun buildPasskeySearchInfo(relyingParty: String): SearchInfo {
return SearchInfo().apply {
webDomain = relyingParty
searchParameters.apply {
allowEmptyQuery = false
searchInTitles = false
searchInUsernames = false
searchInPasswords = false
searchInUrls = true
searchInNotes = false
searchInOTP = false
searchParameters.searchInRelyingParty = true
searchInOther = false
searchInUUIDs = false
searchInTags = false
searchInCurrentGroup = false
searchInSearchableGroup = true
searchInRecycleBin = false
searchInTemplates = false
}
}
}
override fun onBeginGetCredentialRequest( override fun onBeginGetCredentialRequest(
request: BeginGetCredentialRequest, request: BeginGetCredentialRequest,
cancellationSignal: CancellationSignal, cancellationSignal: CancellationSignal,
@@ -119,9 +142,7 @@ class PasskeyProviderService : CredentialProviderService() {
val passkeyEntries: MutableList<CredentialEntry> = mutableListOf() val passkeyEntries: MutableList<CredentialEntry> = mutableListOf()
val relyingPartyId = PublicKeyCredentialRequestOptions(option.requestJson).rpId val relyingPartyId = PublicKeyCredentialRequestOptions(option.requestJson).rpId
val searchInfo = SearchInfo().apply { val searchInfo = buildPasskeySearchInfo(relyingPartyId)
relyingParty = relyingPartyId
}
Log.d(TAG, "Build passkey search for relying party $relyingPartyId") Log.d(TAG, "Build passkey search for relying party $relyingPartyId")
SearchHelper.checkAutoSearchInfo( SearchHelper.checkAutoSearchInfo(
context = this, context = this,
@@ -255,9 +276,7 @@ class PasskeyProviderService : CredentialProviderService() {
requestJson = request.requestJson, requestJson = request.requestJson,
clientDataHash = request.clientDataHash clientDataHash = request.clientDataHash
).relyingPartyEntity.id ).relyingPartyEntity.id
val searchInfo = SearchInfo().apply { val searchInfo = buildPasskeySearchInfo(relyingPartyId)
relyingParty = relyingPartyId
}
Log.d(TAG, "Build passkey search for relying party $relyingPartyId") Log.d(TAG, "Build passkey search for relying party $relyingPartyId")
SearchHelper.checkAutoSearchInfo( SearchHelper.checkAutoSearchInfo(
context = this, context = this,

View File

@@ -891,7 +891,7 @@ open class Database {
): Group? { ): Group? {
return mSearchHelper.createVirtualGroupWithSearchResult( return mSearchHelper.createVirtualGroupWithSearchResult(
database = this, database = this,
searchParameters = searchInfo.buildSearchParameters(), searchParameters = searchInfo.searchParameters,
fromGroup = null, fromGroup = null,
max = max max = max
) )

View File

@@ -35,9 +35,10 @@ class SearchInfo : ObjectNameResource, Parcelable {
get() { get() {
return if (webDomain == null) null else field return if (webDomain == null) null else field
} }
var relyingParty: String? = null
var otpString: String? = null var otpString: String? = null
var searchParameters: SearchParameters = buildSearchParameters()
constructor() constructor()
constructor(toCopy: SearchInfo?) { constructor(toCopy: SearchInfo?) {
@@ -46,7 +47,6 @@ class SearchInfo : ObjectNameResource, Parcelable {
applicationId = toCopy?.applicationId applicationId = toCopy?.applicationId
webDomain = toCopy?.webDomain webDomain = toCopy?.webDomain
webScheme = toCopy?.webScheme webScheme = toCopy?.webScheme
relyingParty = toCopy?.relyingParty
otpString = toCopy?.otpString otpString = toCopy?.otpString
} }
@@ -60,8 +60,6 @@ class SearchInfo : ObjectNameResource, Parcelable {
webDomain = if (readDomain.isNullOrEmpty()) null else readDomain webDomain = if (readDomain.isNullOrEmpty()) null else readDomain
val readScheme = parcel.readString() val readScheme = parcel.readString()
webScheme = if (readScheme.isNullOrEmpty()) null else readScheme webScheme = if (readScheme.isNullOrEmpty()) null else readScheme
val readRelyingParty = parcel.readString()
relyingParty = if (readRelyingParty.isNullOrEmpty()) null else readRelyingParty
val readOtp = parcel.readString() val readOtp = parcel.readString()
otpString = if (readOtp.isNullOrEmpty()) null else readOtp otpString = if (readOtp.isNullOrEmpty()) null else readOtp
} }
@@ -76,7 +74,6 @@ class SearchInfo : ObjectNameResource, Parcelable {
parcel.writeString(applicationId ?: "") parcel.writeString(applicationId ?: "")
parcel.writeString(webDomain ?: "") parcel.writeString(webDomain ?: "")
parcel.writeString(webScheme ?: "") parcel.writeString(webScheme ?: "")
parcel.writeString(relyingParty ?: "")
parcel.writeString(otpString ?: "") parcel.writeString(otpString ?: "")
} }
@@ -94,7 +91,6 @@ class SearchInfo : ObjectNameResource, Parcelable {
&& applicationId == null && applicationId == null
&& webDomain == null && webDomain == null
&& webScheme == null && webScheme == null
&& relyingParty == null
&& otpString == null && otpString == null
} }
@@ -102,48 +98,24 @@ class SearchInfo : ObjectNameResource, Parcelable {
return toString() == webDomain && webDomain != null return toString() == webDomain && webDomain != null
} }
private fun isAPasskeySearch(): Boolean { private fun buildSearchParameters(): SearchParameters {
return toString() == relyingParty && relyingParty != null
}
fun buildSearchParameters(): SearchParameters {
return SearchParameters().apply { return SearchParameters().apply {
if (isAPasskeySearch()) { searchQuery = toString()
searchQuery = relyingParty!! allowEmptyQuery = false
allowEmptyQuery = false searchInTitles = true
searchInTitles = false searchInUsernames = false
searchInUsernames = false searchInPasswords = false
searchInPasswords = false searchInUrls = true
searchInUrls = false searchByDomain = isASearchByDomain()
searchByDomain = false searchInNotes = true
searchInNotes = false searchInOTP = false
searchInOTP = false searchInOther = true
searchInOther = false searchInUUIDs = false
searchInUUIDs = false searchInTags = false
searchInTags = false searchInCurrentGroup = false
searchInRelyingParty = true searchInSearchableGroup = true
searchInCurrentGroup = false searchInRecycleBin = false
searchInSearchableGroup = false searchInTemplates = false
searchInRecycleBin = false
searchInTemplates = false
} else {
searchQuery = toString()
allowEmptyQuery = false
searchInTitles = true
searchInUsernames = false
searchInPasswords = false
searchInUrls = true
searchByDomain = isASearchByDomain()
searchInNotes = true
searchInOTP = false
searchInOther = true
searchInUUIDs = false
searchInTags = false
searchInCurrentGroup = false
searchInSearchableGroup = true
searchInRecycleBin = false
searchInTemplates = false
}
} }
} }
@@ -156,7 +128,6 @@ class SearchInfo : ObjectNameResource, Parcelable {
if (applicationId != other.applicationId) return false if (applicationId != other.applicationId) return false
if (webDomain != other.webDomain) return false if (webDomain != other.webDomain) return false
if (webScheme != other.webScheme) return false if (webScheme != other.webScheme) return false
if (relyingParty != other.relyingParty) return false
if (otpString != other.otpString) return false if (otpString != other.otpString) return false
return true return true
@@ -168,13 +139,12 @@ class SearchInfo : ObjectNameResource, Parcelable {
result = 31 * result + (applicationId?.hashCode() ?: 0) result = 31 * result + (applicationId?.hashCode() ?: 0)
result = 31 * result + (webDomain?.hashCode() ?: 0) result = 31 * result + (webDomain?.hashCode() ?: 0)
result = 31 * result + (webScheme?.hashCode() ?: 0) result = 31 * result + (webScheme?.hashCode() ?: 0)
result = 31 * result + (relyingParty?.hashCode() ?: 0)
result = 31 * result + (otpString?.hashCode() ?: 0) result = 31 * result + (otpString?.hashCode() ?: 0)
return result return result
} }
override fun toString(): String { override fun toString(): String {
return otpString ?: webDomain ?: applicationId ?: relyingParty ?: tag ?: "" return otpString ?: webDomain ?: applicationId ?: tag ?: ""
} }
companion object { companion object {