summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Simranjit Kohli <simranjit@google.com> 2023-05-11 03:00:11 -0700
committer Simranjit Kohli <simranjit@google.com> 2023-05-12 14:03:32 -0700
commit8d548042221d13589c151548c68db40a7392ee59 (patch)
tree0756ba88a9e0aa6768fcdea8cdced23faff27a30
parent3090ffdceb35bc536dace715bf96699f3d97855e (diff)
[Autofill PCC]: Add pick reason to datasets.
Tag datasets with the reason that dataset was eligible for autofill purposes. Test: atest CtsAutoFillServiceTestCases Bug: 265037574 Change-Id: I3bee856ec5cb611c94558ff408ed331d6e85be0d
-rw-r--r--core/java/android/service/autofill/Dataset.java43
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java27
2 files changed, 49 insertions, 21 deletions
diff --git a/core/java/android/service/autofill/Dataset.java b/core/java/android/service/autofill/Dataset.java
index 5f7486addd69..d04ff8e361b3 100644
--- a/core/java/android/service/autofill/Dataset.java
+++ b/core/java/android/service/autofill/Dataset.java
@@ -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 of PCC detection was chosen.
+ * This dataset is picked because provider gave this dataset.
* @hide
*/
- public static final int PICK_REASON_PCC_DETECTION = 2;
+ public static final int PICK_REASON_PROVIDER_DETECTION_ONLY = 2;
/**
- * This dataset is picked because of Framework detection was chosen.
+ * 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_FRAMEWORK_DETECTION = 3;
+ public static final int PICK_REASON_PROVIDER_DETECTION_PREFERRED_WITH_PCC = 3;
/**
- * This dataset is picked because of Autofill Provider being a fallback.
+ * This dataset is picked because of PCC detection was chosen.
* @hide
*/
- public static final int PICK_REASON_AUTOFILL_PROVIDER_FALLBACK = 4;
+ public static final int PICK_REASON_PCC_DETECTION_ONLY = 4;
/**
- * This dataset is picked because of PCC detection being a fallback.
+ * 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_PCC_DETECTION_FALLBACK = 5;
+ public static final int PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER = 5;
+
/**
- * This dataset is picked because of Framework detection being a fallback.
+ * Reason why the dataset was eligible for autofill.
* @hide
*/
- public static final int PICK_REASON_FRAMEWORK_FALLBACK = 6;
-
@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;
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 192fdfe463a3..9de7e4dc5664 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -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) {