Added TYPE_DATASETS_SHOWN event to FillEventHistory

Fixes: 137225017
Test: atest android.autofillservice.cts.FillEventHistoryTest
Test: atest CtsAutoFillServiceTestCases
Change-Id: I5f858a01c98993148f71d616e73419a1914f5a1b
This commit is contained in:
Adam He
2019-07-10 13:22:15 -07:00
parent 4cd75cb8b9
commit 8a12f02b90
4 changed files with 26 additions and 2 deletions

View File

@@ -41046,6 +41046,7 @@ package android.service.autofill {
method public int getType();
field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
field public static final int TYPE_CONTEXT_COMMITTED = 4; // 0x4
field public static final int TYPE_DATASETS_SHOWN = 5; // 0x5
field public static final int TYPE_DATASET_AUTHENTICATION_SELECTED = 1; // 0x1
field public static final int TYPE_DATASET_SELECTED = 0; // 0x0
field public static final int TYPE_SAVE_SHOWN = 3; // 0x3

View File

@@ -224,13 +224,21 @@ public final class FillEventHistory implements Parcelable {
*/
public static final int TYPE_CONTEXT_COMMITTED = 4;
/**
* A dataset selector was shown.
*
* <p>This event is fired whenever the autofill UI was presented to the user.</p>
*/
public static final int TYPE_DATASETS_SHOWN = 5;
/** @hide */
@IntDef(prefix = { "TYPE_" }, value = {
TYPE_DATASET_SELECTED,
TYPE_DATASET_AUTHENTICATION_SELECTED,
TYPE_AUTHENTICATION_SELECTED,
TYPE_SAVE_SHOWN,
TYPE_CONTEXT_COMMITTED
TYPE_CONTEXT_COMMITTED,
TYPE_DATASETS_SHOWN
})
@Retention(RetentionPolicy.SOURCE)
@interface EventIds{}
@@ -473,7 +481,7 @@ public final class FillEventHistory implements Parcelable {
@Nullable ArrayList<ArrayList<String>> manuallyFilledDatasetIds,
@Nullable AutofillId[] detectedFieldIds,
@Nullable FieldClassification[] detectedFieldClassifications) {
mEventType = Preconditions.checkArgumentInRange(eventType, 0, TYPE_CONTEXT_COMMITTED,
mEventType = Preconditions.checkArgumentInRange(eventType, 0, TYPE_DATASETS_SHOWN,
"eventType");
mDatasetId = datasetId;
mClientState = clientState;

View File

@@ -768,6 +768,19 @@ final class AutofillManagerServiceImpl
}
}
/**
* Updates the last fill response when a dataset is shown.
*/
void logDatasetShown(int sessionId, @Nullable Bundle clientState) {
synchronized (mLock) {
if (isValidEventLocked("logDatasetShown", sessionId)) {
mEventHistory.addEvent(
new Event(Event.TYPE_DATASETS_SHOWN, null, clientState, null, null, null,
null, null, null, null, null));
}
}
}
/**
* Updates the last fill response when an autofill context is committed.
*/

View File

@@ -2497,6 +2497,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
mService.getServicePackageName(), mComponentName,
serviceLabel, serviceIcon, this, id, mCompatMode);
mService.logDatasetShown(id, mClientState);
synchronized (mLock) {
if (mUiShownTime == 0) {
// Log first time UI is shown.