[Autofill PCC Detection] Provide detection info during save.

Provide detection info during save, so that the provider can trigger
save properly in the case of misdeteciton. Otherwise, provider may
save it for wrong fields, or may decide not to save at all.

Test: atest CtsAutoFillServiceTestCases.
Some tests were failing, but they were failing irrespective of this
change.
Bug: 277538115

Change-Id: I8a78e1c483339cb3ba8086224942108a77a93c55
This commit is contained in:
Simranjit Kohli
2023-05-22 11:21:31 -07:00
parent ec8f827230
commit 2373682ff3

View File

@@ -224,6 +224,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
private static final String EXTRA_REQUEST_ID = "android.service.autofill.extra.REQUEST_ID";
private static final String PCC_HINTS_DELIMITER = ",";
public static final String EXTRA_KEY_DETECTIONS = "detections";
final Object mLock;
@@ -3646,6 +3647,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
final ArrayList<FillContext> contexts = mergePreviousSessionLocked( /* forSave= */ true);
FieldClassificationResponse fieldClassificationResponse =
mClassificationState.mLastFieldClassificationResponse;
if (mService.isPccClassificationEnabled()
&& fieldClassificationResponse != null
&& !fieldClassificationResponse.getClassifications().isEmpty()) {
if (mClientState == null) {
mClientState = new Bundle();
}
mClientState.putParcelableArrayList(EXTRA_KEY_DETECTIONS, new ArrayList<>(
fieldClassificationResponse.getClassifications()));
}
final SaveRequest saveRequest =
new SaveRequest(contexts, mClientState, mSelectedDatasetIds);
mRemoteFillService.onSaveRequest(saveRequest);