AF: Fix bug where Session#setViewStatesLocked doesn't clear response.

clearResponse=true doesn't clear the response if the `response` arg is non null.
The new behavior matches the corresponding logic for authenticated
responses above (lines 3197-3200).

This affects only 1 invoking method, replaceResponseLocked, which sets
the responses again soon after, so this change shouldn't affect any
behavior.

This change also fixes the javadoc for the method.

Bug: 152620157
Test: atest android.autofillservice.cts
Test: manual
Change-Id: I78262baa1c6c11ef7e4b3c12c2ecd3d9dd28bfd7
This commit is contained in:
Ahaan Ugale
2020-04-03 17:16:56 -07:00
parent 6f9b5cc365
commit 29350482e3

View File

@@ -3226,7 +3226,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
/**
* Sets the state of all views in the given dataset and response.
* Sets the state and response of all views in the given dataset.
*/
@GuardedBy("mLock")
private void setViewStatesLocked(@Nullable FillResponse response, @NonNull Dataset dataset,
@@ -3241,10 +3241,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (datasetId != null) {
viewState.setDatasetId(datasetId);
}
if (response != null) {
viewState.setResponse(response);
} else if (clearResponse) {
if (clearResponse) {
viewState.setResponse(null);
} else if (response != null) {
viewState.setResponse(response);
}
}
}