mirror of
https://github.com/bitwarden/android.git
synced 2024-11-24 18:36:32 +03:00
All of the autofill processing happens in a job (#3545)
Some checks failed
Crowdin Push / Crowdin Push (push) Waiting to run
Scan / Check PR run (push) Failing after 0s
Scan / SAST scan (push) Has been skipped
Scan / Quality scan (push) Has been skipped
Test / Check PR run (push) Failing after 0s
Test / Test (push) Has been skipped
Some checks failed
Crowdin Push / Crowdin Push (push) Waiting to run
Scan / Check PR run (push) Failing after 0s
Scan / SAST scan (push) Has been skipped
Scan / Quality scan (push) Has been skipped
Test / Check PR run (push) Failing after 0s
Test / Test (push) Has been skipped
This commit is contained in:
parent
7d18310f30
commit
96324f01d7
2 changed files with 28 additions and 27 deletions
|
@ -55,11 +55,14 @@ class AutofillProcessorImpl(
|
|||
// Set the listener so that any long running work is cancelled when it is no longer needed.
|
||||
cancellationSignal.setOnCancelListener { job.cancel() }
|
||||
// Process the OS data and handle invoking the callback with the result.
|
||||
process(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
fillCallback = fillCallback,
|
||||
fillRequest = request,
|
||||
)
|
||||
job.cancel()
|
||||
job = scope.launch {
|
||||
process(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
fillCallback = fillCallback,
|
||||
fillRequest = request,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun processSaveRequest(
|
||||
|
@ -106,7 +109,7 @@ class AutofillProcessorImpl(
|
|||
/**
|
||||
* Process the [fillRequest] and invoke the [FillCallback] with the response.
|
||||
*/
|
||||
private fun process(
|
||||
private suspend fun process(
|
||||
autofillAppInfo: AutofillAppInfo,
|
||||
fillCallback: FillCallback,
|
||||
fillRequest: FillRequest,
|
||||
|
@ -118,28 +121,25 @@ class AutofillProcessorImpl(
|
|||
)
|
||||
when (autofillRequest) {
|
||||
is AutofillRequest.Fillable -> {
|
||||
job.cancel()
|
||||
job = scope.launch {
|
||||
// Fulfill the [autofillRequest].
|
||||
val filledData = filledDataBuilder.build(
|
||||
autofillRequest = autofillRequest,
|
||||
)
|
||||
val saveInfo = saveInfoBuilder.build(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
autofillPartition = autofillRequest.partition,
|
||||
fillRequest = fillRequest,
|
||||
packageName = autofillRequest.packageName,
|
||||
)
|
||||
// Fulfill the [autofillRequest].
|
||||
val filledData = filledDataBuilder.build(
|
||||
autofillRequest = autofillRequest,
|
||||
)
|
||||
val saveInfo = saveInfoBuilder.build(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
autofillPartition = autofillRequest.partition,
|
||||
fillRequest = fillRequest,
|
||||
packageName = autofillRequest.packageName,
|
||||
)
|
||||
|
||||
// Load the filledData and saveInfo into a FillResponse.
|
||||
val response = fillResponseBuilder.build(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
filledData = filledData,
|
||||
saveInfo = saveInfo,
|
||||
)
|
||||
// Load the filledData and saveInfo into a FillResponse.
|
||||
val response = fillResponseBuilder.build(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
filledData = filledData,
|
||||
saveInfo = saveInfo,
|
||||
)
|
||||
|
||||
fillCallback.onSuccess(response)
|
||||
}
|
||||
fillCallback.onSuccess(response)
|
||||
}
|
||||
|
||||
AutofillRequest.Unfillable -> {
|
||||
|
|
|
@ -107,6 +107,7 @@ class AutofillProcessorTest {
|
|||
fillCallback = fillCallback,
|
||||
request = fillRequest,
|
||||
)
|
||||
testDispatcher.scheduler.runCurrent()
|
||||
|
||||
// Verify
|
||||
verify(exactly = 1) {
|
||||
|
@ -445,9 +446,9 @@ class AutofillProcessorTest {
|
|||
verify(exactly = 1) {
|
||||
// These run as they are not part of the coroutine
|
||||
cancellationSignal.setOnCancelListener(any())
|
||||
parser.parse(autofillAppInfo = appInfo, fillRequest = fillRequest)
|
||||
}
|
||||
coVerify(exactly = 0) {
|
||||
parser.parse(autofillAppInfo = appInfo, fillRequest = fillRequest)
|
||||
filledDataBuilder.build(autofillRequest = autofillRequest)
|
||||
}
|
||||
verify(exactly = 0) {
|
||||
|
|
Loading…
Reference in a new issue