BIT-2022: Autofill crash (#1126)

This commit is contained in:
Ramsey Smith
2024-03-12 11:18:16 -06:00
committed by Álison Fernandes
parent 3e680b9703
commit b3e4d3807c
4 changed files with 19 additions and 14 deletions

View File

@@ -31,7 +31,7 @@ class FilledDataBuilderImpl(
// Use getOrLastOrNull so if the list has run dry take the last spec.
autofillRequest
.inlinePresentationSpecs
.getOrLastOrNull(inlineSuggestionsAdded)
?.getOrLastOrNull(inlineSuggestionsAdded)
} else {
null
}
@@ -73,7 +73,7 @@ class FilledDataBuilderImpl(
// Use getOrLastOrNull so if the list has run dry take the last spec.
val vaultItemInlinePresentationSpec = autofillRequest
.inlinePresentationSpecs
.getOrLastOrNull(inlineSuggestionsAdded)
?.getOrLastOrNull(inlineSuggestionsAdded)
return FilledData(
filledPartitions = filledPartitions,

View File

@@ -13,7 +13,7 @@ sealed class AutofillRequest {
*/
data class Fillable(
val ignoreAutofillIds: List<AutofillId>,
val inlinePresentationSpecs: List<InlinePresentationSpec>,
val inlinePresentationSpecs: List<InlinePresentationSpec>?,
val maxInlineSuggestionsCount: Int,
val packageName: String?,
val partition: AutofillPartition,

View File

@@ -13,12 +13,13 @@ import com.x8bit.bitwarden.data.autofill.model.AutofillAppInfo
fun FillRequest?.getInlinePresentationSpecs(
autofillAppInfo: AutofillAppInfo,
isInlineAutofillEnabled: Boolean,
): List<InlinePresentationSpec> =
if (this != null &&
isInlineAutofillEnabled &&
autofillAppInfo.sdkInt >= Build.VERSION_CODES.R
) {
inlineSuggestionsRequest?.inlinePresentationSpecs ?: emptyList()
): List<InlinePresentationSpec>? =
if (autofillAppInfo.sdkInt < Build.VERSION_CODES.R) {
// When SDK version is bellow 30, InlinePresentationSpec is not available and null
// must be returned.
null
} else if (isInlineAutofillEnabled) {
this?.inlineSuggestionsRequest?.inlinePresentationSpecs.orEmpty()
} else {
emptyList()
}