From 30a73e7e3b6f90d118005cd12afbfe95641d32fa Mon Sep 17 00:00:00 2001 From: Simranjit Kohli Date: Fri, 23 Sep 2022 07:52:56 -0700 Subject: [PATCH] [FillDialog] : Fix case to log no focus with Fill Dialog Currently, response expires when closing activity. However, we would want to maintain the reason that was set previously in such a case. BUG: 234185326 BUG: 248539712 Test: Manually tested with Sample Apk with Fill Dialog and then closing activity. Change-Id: Ia9b94775608f6c1255bf0f3cbbf5f71eb583683e --- .../server/autofill/PresentationStatsEventLogger.java | 8 ++++++++ .../java/com/android/server/autofill/Session.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java index b5fdaca838df5..511f699058b02 100644 --- a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java +++ b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java @@ -118,6 +118,14 @@ public final class PresentationStatsEventLogger { }); } + public void maybeSetNoPresentationEventReasonIfNoReasonExists(@NotShownReason int reason) { + mEventInternal.ifPresent(event -> { + if (event.mCountShown == 0 && event.mNoPresentationReason == NOT_SHOWN_REASON_UNKNOWN) { + event.mNoPresentationReason = reason; + } + }); + } + public void maybeSetAvailableCount(@Nullable List datasetList, AutofillId currentViewId) { mEventInternal.ifPresent(event -> { diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index 3d955b7718d0e..2149f2628e2b8 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -2922,7 +2922,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (sDebug) { Slog.d(TAG, "Set the response has expired."); } - mPresentationStatsEventLogger.maybeSetNoPresentationEventReason( + mPresentationStatsEventLogger.maybeSetNoPresentationEventReasonIfNoReasonExists( NOT_SHOWN_REASON_VIEW_CHANGED); mPresentationStatsEventLogger.logAndEndEvent(); return;