From fec1a4311e7cf8768f15eb0c230f25c61748ba90 Mon Sep 17 00:00:00 2001 From: Simranjit Kohli Date: Tue, 2 May 2023 00:04:40 -0700 Subject: [PATCH] PCC Authentication Fix authentication where the Provider may supply results by setting in hints. Similar to what we support for onFillResponse, providers can set response for types initially requested for PCC. Test: atest CtsAutoFillServiceTestCases BUG: 280329574 Change-Id: I3a25e9db2375174915dd1edf95b95ce9e7db84fe --- .../com/android/server/autofill/Session.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index d290c3611f78f..fb94af65513fb 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -1581,6 +1581,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState // TODO(b/266379948): Ideally wait for PCC request to finish for a while more // (say 100ms) before proceeding further on. + processResponseLockedForPcc(response, response.getClientState(), requestFlags); + } + + + @GuardedBy("mLock") + private void processResponseLockedForPcc(@NonNull FillResponse response, + @Nullable Bundle newClientState, int flags) { if (DBG) { Slog.d(TAG, "DBG: Initial response: " + response); } @@ -1588,12 +1595,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState response = getEffectiveFillResponse(response); if (isEmptyResponse(response)) { // Treat it as a null response. - processNullResponseLocked(requestId, requestFlags); + processNullResponseLocked( + response != null ? response.getRequestId() : 0, + flags); + return; } if (DBG) { Slog.d(TAG, "DBG: Processed response: " + response); } - processResponseLocked(response, null, requestFlags); + processResponseLocked(response, newClientState, flags); } } @@ -2490,7 +2500,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (sDebug) Slog.d(TAG, "Updating client state from auth dataset"); mClientState = newClientState; } - final Dataset dataset = (Dataset) result; + Dataset dataset = (Dataset) result; + FillResponse temp = new FillResponse.Builder().addDataset(dataset).build(); + temp = getEffectiveFillResponse(temp); + dataset = temp.getDatasets().get(0); final Dataset oldDataset = authenticatedResponse.getDatasets().get(datasetIdx); if (!isAuthResultDatasetEphemeral(oldDataset, data)) { authenticatedResponse.getDatasets().set(datasetIdx, dataset); @@ -4665,10 +4678,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState setViewStatesLocked(oldResponse, ViewState.STATE_INITIAL, true); // Move over the id newResponse.setRequestId(oldResponse.getRequestId()); - // Replace the old response - mResponses.put(newResponse.getRequestId(), newResponse); // Now process the new response - processResponseLocked(newResponse, newClientState, 0); + processResponseLockedForPcc(newResponse, newClientState, 0); } @GuardedBy("mLock")