mirror of
https://github.com/bitwarden/android.git
synced 2024-11-28 06:04:16 +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,12 +55,15 @@ 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.
|
||||
job.cancel()
|
||||
job = scope.launch {
|
||||
process(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
fillCallback = fillCallback,
|
||||
fillRequest = request,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun processSaveRequest(
|
||||
autofillAppInfo: AutofillAppInfo,
|
||||
|
@ -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,8 +121,6 @@ class AutofillProcessorImpl(
|
|||
)
|
||||
when (autofillRequest) {
|
||||
is AutofillRequest.Fillable -> {
|
||||
job.cancel()
|
||||
job = scope.launch {
|
||||
// Fulfill the [autofillRequest].
|
||||
val filledData = filledDataBuilder.build(
|
||||
autofillRequest = autofillRequest,
|
||||
|
@ -140,7 +141,6 @@ class AutofillProcessorImpl(
|
|||
|
||||
fillCallback.onSuccess(response)
|
||||
}
|
||||
}
|
||||
|
||||
AutofillRequest.Unfillable -> {
|
||||
// If we are unable to fulfill the request, we should invoke the callback
|
||||
|
|
|
@ -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