Merge "[Autofill PCC]: Add pick reason to datasets." into udc-dev am: b749e98b2b am: f6308988cb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23168098 Change-Id: I80dca7c3d7846baef8463e92e9b14e6377765671 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -123,47 +123,50 @@ public final class Dataset implements Parcelable {
|
||||
*/
|
||||
public static final int PICK_REASON_UNKNOWN = 0;
|
||||
/**
|
||||
* This dataset is picked because of autofill provider detection was chosen.
|
||||
* This dataset is picked because pcc wasn't enabled.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_AUTOFILL_PROVIDER_DETECTION = 1;
|
||||
public static final int PICK_REASON_NO_PCC = 1;
|
||||
/**
|
||||
* This dataset is picked because provider gave this dataset.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_PROVIDER_DETECTION_ONLY = 2;
|
||||
/**
|
||||
* This dataset is picked because provider detection was preferred. However, provider also made
|
||||
* this dataset available for PCC detected types, so they could've been picked up by PCC
|
||||
* detection. This however doesn't imply that this dataset would've been chosen for sure. For
|
||||
* eg, if PCC Detection was preferred, and PCC detected other field types, which wasn't
|
||||
* applicable to this dataset, it wouldn't have been shown.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC = 3;
|
||||
/**
|
||||
* This dataset is picked because of PCC detection was chosen.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_PCC_DETECTION = 2;
|
||||
public static final int PICK_REASON_PCC_DETECTION_ONLY = 4;
|
||||
/**
|
||||
* This dataset is picked because of Framework detection was chosen.
|
||||
* This dataset is picked because of PCC Detection was preferred. However, Provider also gave
|
||||
* this dataset, so if PCC wasn't enabled, this dataset would've been eligible anyway.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_FRAMEWORK_DETECTION = 3;
|
||||
/**
|
||||
* This dataset is picked because of Autofill Provider being a fallback.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_AUTOFILL_PROVIDER_FALLBACK = 4;
|
||||
/**
|
||||
* This dataset is picked because of PCC detection being a fallback.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_PCC_DETECTION_FALLBACK = 5;
|
||||
/**
|
||||
* This dataset is picked because of Framework detection being a fallback.
|
||||
* @hide
|
||||
*/
|
||||
public static final int PICK_REASON_FRAMEWORK_FALLBACK = 6;
|
||||
public static final int PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER = 5;
|
||||
|
||||
/**
|
||||
* Reason why the dataset was eligible for autofill.
|
||||
* @hide
|
||||
*/
|
||||
@IntDef(prefix = { "PICK_REASON_" }, value = {
|
||||
PICK_REASON_UNKNOWN,
|
||||
PICK_REASON_AUTOFILL_PROVIDER_DETECTION,
|
||||
PICK_REASON_PCC_DETECTION,
|
||||
PICK_REASON_FRAMEWORK_DETECTION,
|
||||
PICK_REASON_AUTOFILL_PROVIDER_FALLBACK,
|
||||
PICK_REASON_PCC_DETECTION_FALLBACK,
|
||||
PICK_REASON_FRAMEWORK_FALLBACK,
|
||||
PICK_REASON_NO_PCC,
|
||||
PICK_REASON_PROVIDER_DETECTION_ONLY,
|
||||
PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC,
|
||||
PICK_REASON_PCC_DETECTION_ONLY,
|
||||
PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER,
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@interface DatasetEligibleReason{}
|
||||
public @interface DatasetEligibleReason{}
|
||||
|
||||
private @DatasetEligibleReason int mEligibleReason;
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@ package com.android.server.autofill;
|
||||
import static android.Manifest.permission.PROVIDE_OWN_AUTOFILL_SUGGESTIONS;
|
||||
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
|
||||
import static android.service.autofill.AutofillService.EXTRA_FILL_RESPONSE;
|
||||
import static android.service.autofill.Dataset.PICK_REASON_NO_PCC;
|
||||
import static android.service.autofill.Dataset.PICK_REASON_PCC_DETECTION_ONLY;
|
||||
import static android.service.autofill.Dataset.PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER;
|
||||
import static android.service.autofill.Dataset.PICK_REASON_PROVIDER_DETECTION_ONLY;
|
||||
import static android.service.autofill.Dataset.PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC;
|
||||
import static android.service.autofill.Dataset.PICK_REASON_UNKNOWN;
|
||||
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_DIALOG;
|
||||
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_INLINE;
|
||||
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_MENU;
|
||||
@@ -124,6 +130,7 @@ import android.service.autofill.AutofillFieldClassificationService.Scores;
|
||||
import android.service.autofill.AutofillService;
|
||||
import android.service.autofill.CompositeUserData;
|
||||
import android.service.autofill.Dataset;
|
||||
import android.service.autofill.Dataset.DatasetEligibleReason;
|
||||
import android.service.autofill.FieldClassification;
|
||||
import android.service.autofill.FieldClassification.Match;
|
||||
import android.service.autofill.FieldClassificationUserData;
|
||||
@@ -1798,6 +1805,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
|
||||
private void computeDatasetsForProviderAndUpdateContainer(
|
||||
FillResponse response, DatasetComputationContainer container) {
|
||||
@DatasetEligibleReason int globalPickReason = PICK_REASON_UNKNOWN;
|
||||
boolean isPccEnabled = mService.isPccClassificationEnabled();
|
||||
if (isPccEnabled) {
|
||||
globalPickReason = PICK_REASON_PROVIDER_DETECTION_ONLY;
|
||||
} else {
|
||||
globalPickReason = PICK_REASON_NO_PCC;
|
||||
}
|
||||
List<Dataset> datasets = response.getDatasets();
|
||||
if (datasets == null) return;
|
||||
ArrayMap<AutofillId, Set<Dataset>> autofillIdToDatasetMap = new ArrayMap<>();
|
||||
@@ -1805,6 +1819,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
Set<AutofillId> eligibleAutofillIds = new ArraySet<>();
|
||||
for (Dataset dataset : response.getDatasets()) {
|
||||
if (dataset.getFieldIds() == null || dataset.getFieldIds().isEmpty()) continue;
|
||||
@DatasetEligibleReason int pickReason = globalPickReason;
|
||||
if (dataset.getAutofillDatatypes() != null
|
||||
&& !dataset.getAutofillDatatypes().isEmpty()) {
|
||||
// This dataset has information relevant for detection too, so we should filter
|
||||
@@ -1827,6 +1842,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
if (newSize == 0) continue;
|
||||
|
||||
if (conversionRequired) {
|
||||
pickReason = PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC;
|
||||
ArrayList<AutofillId> fieldIds = new ArrayList<>(newSize);
|
||||
ArrayList<AutofillValue> fieldValues = new ArrayList<>(newSize);
|
||||
ArrayList<RemoteViews> fieldPresentations = new ArrayList<>(newSize);
|
||||
@@ -1870,6 +1886,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
dataset.getAuthentication());
|
||||
}
|
||||
}
|
||||
dataset.setEligibleReasonReason(pickReason);
|
||||
eligibleDatasets.add(dataset);
|
||||
for (AutofillId id : dataset.getFieldIds()) {
|
||||
eligibleAutofillIds.add(id);
|
||||
@@ -1905,6 +1922,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
Set<AutofillId> eligibleAutofillIds = new ArraySet<>();
|
||||
|
||||
for (int i = 0; i < datasets.size(); i++) {
|
||||
|
||||
@DatasetEligibleReason int pickReason = PICK_REASON_PCC_DETECTION_ONLY;
|
||||
Dataset dataset = datasets.get(i);
|
||||
if (dataset.getAutofillDatatypes() == null
|
||||
|| dataset.getAutofillDatatypes().isEmpty()) continue;
|
||||
@@ -1919,7 +1938,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
Set<AutofillId> datasetAutofillIds = new ArraySet<>();
|
||||
|
||||
for (int j = 0; j < dataset.getAutofillDatatypes().size(); j++) {
|
||||
if (dataset.getAutofillDatatypes().get(j) == null) continue;
|
||||
if (dataset.getAutofillDatatypes().get(j) == null) {
|
||||
if (dataset.getFieldIds() != null && dataset.getFieldIds().get(j) != null) {
|
||||
pickReason = PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
String hint = dataset.getAutofillDatatypes().get(j);
|
||||
|
||||
if (hintsToAutofillIdMap.containsKey(hint)) {
|
||||
@@ -1966,6 +1990,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
||||
null,
|
||||
dataset.getId(),
|
||||
dataset.getAuthentication());
|
||||
dataset.setEligibleReasonReason(pickReason);
|
||||
eligibleDatasets.add(newDataset);
|
||||
Set<Dataset> newDatasets;
|
||||
for (AutofillId autofillId : datasetAutofillIds) {
|
||||
|
||||
Reference in New Issue
Block a user