diff options
3 files changed, 89 insertions, 20 deletions
diff --git a/services/autofill/java/com/android/server/autofill/FillResponseEventLogger.java b/services/autofill/java/com/android/server/autofill/FillResponseEventLogger.java index ab46a6e27d84..fc5fb1a4545c 100644 --- a/services/autofill/java/com/android/server/autofill/FillResponseEventLogger.java +++ b/services/autofill/java/com/android/server/autofill/FillResponseEventLogger.java @@ -16,6 +16,9 @@ package com.android.server.autofill; +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 com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED; import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_FAILURE; import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_RESULT_UNKNOWN; @@ -218,7 +221,16 @@ public final class FillResponseEventLogger { public void maybeSetAvailableCount(int val) { mEventInternal.ifPresent(event -> { - event.mAvailableCount = val; + // Don't reset if it's already populated. + // This is just a technical limitation of not having complicated logic. + // Autofill Provider may return some datasets which are applicable to data types. + // In such a case, we set available count to the number of datasets provided. + // However, it's possible that those data types aren't detected by PCC, so in effect, there + // are 0 datasets. In the codebase, we treat it as null response, which may call this again + // to set 0. But we don't want to overwrite this value. + if (event.mAvailableCount == 0) { + event.mAvailableCount = val; + } }); } @@ -336,6 +348,32 @@ public final class FillResponseEventLogger { }); } + /** + * Set available_pcc_count. + */ + public void maybeSetAvailableDatasetsPccCount(@Nullable List<Dataset> datasetList) { + mEventInternal.ifPresent(event -> { + int pccOnlyCount = 0; + int pccCount = 0; + if (datasetList != null) { + for (int i = 0; i < datasetList.size(); i++) { + Dataset dataset = datasetList.get(i); + if (dataset != null) { + if (dataset.getEligibleReason() == PICK_REASON_PCC_DETECTION_ONLY) { + pccOnlyCount++; + pccCount++; + } else if (dataset.getEligibleReason() + == PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER) { + pccCount++; + } + } + } + } + event.mAvailablePccOnlyCount = pccOnlyCount; + event.mAvailablePccCount = pccCount; + }); + } + /** * Log an AUTOFILL_FILL_RESPONSE_REPORTED event. diff --git a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java index be31ce47109d..b2f9a93b3038 100644 --- a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java +++ b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java @@ -16,6 +16,8 @@ package com.android.server.autofill; +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.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; @@ -228,36 +230,61 @@ public final class PresentationStatsEventLogger { public void maybeSetAvailableCount(@Nullable List<Dataset> datasetList, AutofillId currentViewId) { mEventInternal.ifPresent(event -> { - int availableCount = getDatasetCountForAutofillId(datasetList, currentViewId); - event.mAvailableCount = availableCount; - event.mIsDatasetAvailable = availableCount > 0; + CountContainer container = getDatasetCountForAutofillId(datasetList, currentViewId); + event.mAvailableCount = container.mAvailableCount; + event.mAvailablePccCount = container.mAvailablePccCount; + event.mAvailablePccOnlyCount = container.mAvailablePccOnlyCount; + event.mIsDatasetAvailable = container.mAvailableCount > 0; }); } public void maybeSetCountShown(@Nullable List<Dataset> datasetList, AutofillId currentViewId) { mEventInternal.ifPresent(event -> { - int countShown = getDatasetCountForAutofillId(datasetList, currentViewId); - event.mCountShown = countShown; - if (countShown > 0) { + CountContainer container = getDatasetCountForAutofillId(datasetList, currentViewId); + event.mCountShown = container.mAvailableCount; + if (container.mAvailableCount > 0) { event.mNoPresentationReason = NOT_SHOWN_REASON_ANY_SHOWN; } }); } - private static int getDatasetCountForAutofillId(@Nullable List<Dataset> datasetList, + private static CountContainer getDatasetCountForAutofillId(@Nullable List<Dataset> datasetList, AutofillId currentViewId) { - int availableCount = 0; + + CountContainer container = new CountContainer(); if (datasetList != null) { for (int i = 0; i < datasetList.size(); i++) { Dataset data = datasetList.get(i); if (data != null && data.getFieldIds() != null && data.getFieldIds().contains(currentViewId)) { - availableCount += 1; + container.mAvailableCount += 1; + if (data.getEligibleReason() == PICK_REASON_PCC_DETECTION_ONLY) { + container.mAvailablePccOnlyCount++; + container.mAvailablePccCount++; + } else if (data.getEligibleReason() + == PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER) { + container.mAvailablePccCount++; + } } } } - return availableCount; + return container; + } + + private static class CountContainer{ + int mAvailableCount = 0; + int mAvailablePccCount = 0; + int mAvailablePccOnlyCount = 0; + + CountContainer() {} + + CountContainer(int availableCount, int availablePccCount, + int availablePccOnlyCount) { + mAvailableCount = availableCount; + mAvailablePccCount = availablePccCount; + mAvailablePccOnlyCount = availablePccOnlyCount; + } } public void maybeSetCountFilteredUserTyping(int countFilteredUserTyping) { diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index fdbcceef764e..0a7bf9878c10 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -1561,9 +1561,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState Slog.d(TAG, message.toString()); } } - - if (((response.getDatasets() == null || response.getDatasets().isEmpty()) - && response.getAuthentication() == null) + List<Dataset> datasetList = response.getDatasets(); + if (((datasetList == null || datasetList.isEmpty()) && response.getAuthentication() == null) || autofillDisabled) { // Response is "empty" from a UI point of view, need to notify client. notifyUnavailableToClient( @@ -1585,6 +1584,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } } + mFillResponseEventLogger.maybeSetAvailableCount( + datasetList == null ? 0 : datasetList.size()); + // TODO(b/266379948): Ideally wait for PCC request to finish for a while more // (say 100ms) before proceeding further on. @@ -1735,6 +1737,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState } if (ids.isEmpty()) return saveInfo; AutofillId[] autofillIds = new AutofillId[ids.size()]; + mSaveEventLogger.maybeSetIsFrameworkCreatedSaveInfo(true); ids.toArray(autofillIds); return SaveInfo.copy(saveInfo, autofillIds); } @@ -4040,8 +4043,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mPresentationStatsEventLogger.maybeSetRequestId(response.getRequestId()); mPresentationStatsEventLogger.maybeSetAvailableCount( response.getDatasets(), mCurrentViewId); - mFillResponseEventLogger.maybeSetAvailableCount( - response.getDatasets(), mCurrentViewId); } if (isSameViewEntered) { @@ -4732,6 +4733,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState autofillableIds = null; } // Log the existing FillResponse event. + mFillResponseEventLogger.maybeSetAvailableCount(0); mFillResponseEventLogger.logAndEndEvent(); mService.resetLastResponse(); @@ -4960,10 +4962,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState mResponses.put(requestId, newResponse); mClientState = newClientState != null ? newClientState : newResponse.getClientState(); - mPresentationStatsEventLogger.maybeSetAvailableCount( - newResponse.getDatasets(), mCurrentViewId); - mFillResponseEventLogger.maybeSetAvailableCount( - newResponse.getDatasets(), mCurrentViewId); + List<Dataset> datasetList = newResponse.getDatasets(); + + mPresentationStatsEventLogger.maybeSetAvailableCount(datasetList, mCurrentViewId); + mFillResponseEventLogger.maybeSetAvailableDatasetsPccCount(datasetList); setViewStatesLocked(newResponse, ViewState.STATE_FILLABLE, false); updateFillDialogTriggerIdsLocked(); @@ -5088,6 +5090,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (generateEvent) { mService.logDatasetSelected(dataset.getId(), id, mClientState, uiType); mPresentationStatsEventLogger.maybeSetSelectedDatasetId(datasetIndex); + mPresentationStatsEventLogger.maybeSetSelectedDatasetPickReason( + dataset.getEligibleReason()); } if (mCurrentViewId != null) { mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); |