Merge "[Autofill PCC]: Add pick reason to datasets." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b749e98b2b
@@ -123,47 +123,50 @@ public final class Dataset implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public static final int PICK_REASON_UNKNOWN = 0;
|
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
|
* @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.
|
* This dataset is picked because of PCC detection was chosen.
|
||||||
* @hide
|
* @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
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final int PICK_REASON_FRAMEWORK_DETECTION = 3;
|
public static final int PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER = 5;
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reason why the dataset was eligible for autofill.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
@IntDef(prefix = { "PICK_REASON_" }, value = {
|
@IntDef(prefix = { "PICK_REASON_" }, value = {
|
||||||
PICK_REASON_UNKNOWN,
|
PICK_REASON_UNKNOWN,
|
||||||
PICK_REASON_AUTOFILL_PROVIDER_DETECTION,
|
PICK_REASON_NO_PCC,
|
||||||
PICK_REASON_PCC_DETECTION,
|
PICK_REASON_PROVIDER_DETECTION_ONLY,
|
||||||
PICK_REASON_FRAMEWORK_DETECTION,
|
PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC,
|
||||||
PICK_REASON_AUTOFILL_PROVIDER_FALLBACK,
|
PICK_REASON_PCC_DETECTION_ONLY,
|
||||||
PICK_REASON_PCC_DETECTION_FALLBACK,
|
PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER,
|
||||||
PICK_REASON_FRAMEWORK_FALLBACK,
|
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@interface DatasetEligibleReason{}
|
public @interface DatasetEligibleReason{}
|
||||||
|
|
||||||
private @DatasetEligibleReason int mEligibleReason;
|
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.Manifest.permission.PROVIDE_OWN_AUTOFILL_SUGGESTIONS;
|
||||||
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
|
import static android.service.autofill.AutofillFieldClassificationService.EXTRA_SCORES;
|
||||||
import static android.service.autofill.AutofillService.EXTRA_FILL_RESPONSE;
|
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_DIALOG;
|
||||||
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_INLINE;
|
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_INLINE;
|
||||||
import static android.service.autofill.FillEventHistory.Event.UI_TYPE_MENU;
|
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.AutofillService;
|
||||||
import android.service.autofill.CompositeUserData;
|
import android.service.autofill.CompositeUserData;
|
||||||
import android.service.autofill.Dataset;
|
import android.service.autofill.Dataset;
|
||||||
|
import android.service.autofill.Dataset.DatasetEligibleReason;
|
||||||
import android.service.autofill.FieldClassification;
|
import android.service.autofill.FieldClassification;
|
||||||
import android.service.autofill.FieldClassification.Match;
|
import android.service.autofill.FieldClassification.Match;
|
||||||
import android.service.autofill.FieldClassificationUserData;
|
import android.service.autofill.FieldClassificationUserData;
|
||||||
@@ -1798,6 +1805,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
|
|
||||||
private void computeDatasetsForProviderAndUpdateContainer(
|
private void computeDatasetsForProviderAndUpdateContainer(
|
||||||
FillResponse response, DatasetComputationContainer container) {
|
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();
|
List<Dataset> datasets = response.getDatasets();
|
||||||
if (datasets == null) return;
|
if (datasets == null) return;
|
||||||
ArrayMap<AutofillId, Set<Dataset>> autofillIdToDatasetMap = new ArrayMap<>();
|
ArrayMap<AutofillId, Set<Dataset>> autofillIdToDatasetMap = new ArrayMap<>();
|
||||||
@@ -1805,6 +1819,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
Set<AutofillId> eligibleAutofillIds = new ArraySet<>();
|
Set<AutofillId> eligibleAutofillIds = new ArraySet<>();
|
||||||
for (Dataset dataset : response.getDatasets()) {
|
for (Dataset dataset : response.getDatasets()) {
|
||||||
if (dataset.getFieldIds() == null || dataset.getFieldIds().isEmpty()) continue;
|
if (dataset.getFieldIds() == null || dataset.getFieldIds().isEmpty()) continue;
|
||||||
|
@DatasetEligibleReason int pickReason = globalPickReason;
|
||||||
if (dataset.getAutofillDatatypes() != null
|
if (dataset.getAutofillDatatypes() != null
|
||||||
&& !dataset.getAutofillDatatypes().isEmpty()) {
|
&& !dataset.getAutofillDatatypes().isEmpty()) {
|
||||||
// This dataset has information relevant for detection too, so we should filter
|
// 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 (newSize == 0) continue;
|
||||||
|
|
||||||
if (conversionRequired) {
|
if (conversionRequired) {
|
||||||
|
pickReason = PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC;
|
||||||
ArrayList<AutofillId> fieldIds = new ArrayList<>(newSize);
|
ArrayList<AutofillId> fieldIds = new ArrayList<>(newSize);
|
||||||
ArrayList<AutofillValue> fieldValues = new ArrayList<>(newSize);
|
ArrayList<AutofillValue> fieldValues = new ArrayList<>(newSize);
|
||||||
ArrayList<RemoteViews> fieldPresentations = new ArrayList<>(newSize);
|
ArrayList<RemoteViews> fieldPresentations = new ArrayList<>(newSize);
|
||||||
@@ -1870,6 +1886,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
dataset.getAuthentication());
|
dataset.getAuthentication());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dataset.setEligibleReasonReason(pickReason);
|
||||||
eligibleDatasets.add(dataset);
|
eligibleDatasets.add(dataset);
|
||||||
for (AutofillId id : dataset.getFieldIds()) {
|
for (AutofillId id : dataset.getFieldIds()) {
|
||||||
eligibleAutofillIds.add(id);
|
eligibleAutofillIds.add(id);
|
||||||
@@ -1905,6 +1922,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
Set<AutofillId> eligibleAutofillIds = new ArraySet<>();
|
Set<AutofillId> eligibleAutofillIds = new ArraySet<>();
|
||||||
|
|
||||||
for (int i = 0; i < datasets.size(); i++) {
|
for (int i = 0; i < datasets.size(); i++) {
|
||||||
|
|
||||||
|
@DatasetEligibleReason int pickReason = PICK_REASON_PCC_DETECTION_ONLY;
|
||||||
Dataset dataset = datasets.get(i);
|
Dataset dataset = datasets.get(i);
|
||||||
if (dataset.getAutofillDatatypes() == null
|
if (dataset.getAutofillDatatypes() == null
|
||||||
|| dataset.getAutofillDatatypes().isEmpty()) continue;
|
|| dataset.getAutofillDatatypes().isEmpty()) continue;
|
||||||
@@ -1919,7 +1938,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
Set<AutofillId> datasetAutofillIds = new ArraySet<>();
|
Set<AutofillId> datasetAutofillIds = new ArraySet<>();
|
||||||
|
|
||||||
for (int j = 0; j < dataset.getAutofillDatatypes().size(); j++) {
|
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);
|
String hint = dataset.getAutofillDatatypes().get(j);
|
||||||
|
|
||||||
if (hintsToAutofillIdMap.containsKey(hint)) {
|
if (hintsToAutofillIdMap.containsKey(hint)) {
|
||||||
@@ -1966,6 +1990,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
null,
|
null,
|
||||||
dataset.getId(),
|
dataset.getId(),
|
||||||
dataset.getAuthentication());
|
dataset.getAuthentication());
|
||||||
|
dataset.setEligibleReasonReason(pickReason);
|
||||||
eligibleDatasets.add(newDataset);
|
eligibleDatasets.add(newDataset);
|
||||||
Set<Dataset> newDatasets;
|
Set<Dataset> newDatasets;
|
||||||
for (AutofillId autofillId : datasetAutofillIds) {
|
for (AutofillId autofillId : datasetAutofillIds) {
|
||||||
|
|||||||
Reference in New Issue
Block a user