1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.autofill;
18 
19 import static android.service.autofill.Dataset.PICK_REASON_PCC_DETECTION_ONLY;
20 import static android.service.autofill.Dataset.PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER;
21 
22 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED;
23 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_FAILURE;
24 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_RESULT_UNKNOWN;
25 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_SUCCESS;
26 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_TYPE__AUTHENTICATION_TYPE_UNKNOWN;
27 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_TYPE__DATASET_AUTHENTICATION;
28 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_TYPE__FULL_AUTHENTICATION;
29 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_AUTOFILL_PROVIDER;
30 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_PCC;
31 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_UNKONWN;
32 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__DIALOG;
33 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__INLINE;
34 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__MENU;
35 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE;
36 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_CANCELLED;
37 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_FAILURE;
38 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SESSION_DESTROYED;
39 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SUCCESS;
40 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_TIMEOUT;
41 import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_UNKNOWN;
42 import static com.android.server.autofill.Helper.sVerbose;
43 
44 import android.annotation.IntDef;
45 import android.annotation.Nullable;
46 import android.os.SystemClock;
47 import android.service.autofill.Dataset;
48 import android.util.Slog;
49 import android.view.autofill.AutofillId;
50 
51 import com.android.internal.util.FrameworkStatsLog;
52 
53 import java.lang.annotation.Retention;
54 import java.lang.annotation.RetentionPolicy;
55 import java.util.List;
56 import java.util.Optional;
57 
58 /**
59  * Helper class to log Autofill FillResponse stats.
60  */
61 public final class FillResponseEventLogger {
62   private static final String TAG = "FillResponseEventLogger";
63 
64   private static final long UNINITIALIZED_TIMESTAMP = -1;
65   private long startResponseProcessingTimestamp = UNINITIALIZED_TIMESTAMP;
66 
67   /**
68    * Reasons why presentation was not shown. These are wrappers around
69    * {@link com.android.os.AtomsProto.AutofillFillRequestReported.RequestTriggerReason}.
70    */
71   @IntDef(prefix = {"DISPLAY_PRESENTATION_TYPE"}, value = {
72       DISPLAY_PRESENTATION_TYPE_UNKNOWN,
73       DISPLAY_PRESENTATION_TYPE_MENU,
74       DISPLAY_PRESENTATION_TYPE_INLINE,
75       DISPLAY_PRESENTATION_TYPE_DIALOG
76   })
77   @Retention(RetentionPolicy.SOURCE)
78   public @interface DisplayPresentationType {
79   }
80 
81   /**
82    * Reasons why presentation was not shown. These are wrappers around
83    * {@link com.android.os.AtomsProto.AutofillFillResponseReported.AuthenticationType}.
84    */
85   @IntDef(prefix = {"AUTHENTICATION_TYPE"}, value = {
86       AUTHENTICATION_TYPE_UNKNOWN,
87       AUTHENTICATION_TYPE_DATASET_AHTHENTICATION,
88       AUTHENTICATION_TYPE_FULL_AHTHENTICATION
89   })
90   @Retention(RetentionPolicy.SOURCE)
91   public @interface AuthenticationType {
92   }
93 
94   /**
95    * Reasons why presentation was not shown. These are wrappers around
96    * {@link com.android.os.AtomsProto.AutofillFillResponseReported.FillResponseStatus}.
97    */
98   @IntDef(prefix = {"RESPONSE_STATUS"}, value = {
99       RESPONSE_STATUS_UNKNOWN,
100       RESPONSE_STATUS_FAILURE,
101       RESPONSE_STATUS_SUCCESS,
102       RESPONSE_STATUS_CANCELLED,
103       RESPONSE_STATUS_TIMEOUT,
104       RESPONSE_STATUS_SESSION_DESTROYED
105   })
106   @Retention(RetentionPolicy.SOURCE)
107   public @interface ResponseStatus {
108   }
109 
110 
111   /**
112    * Reasons why presentation was not shown. These are wrappers around
113    * {@link com.android.os.AtomsProto.AutofillFillResponseReported.AuthenticationResult}.
114    */
115   @IntDef(prefix = {"AUTHENTICATION_RESULT"}, value = {
116       AUTHENTICATION_RESULT_UNKNOWN,
117       AUTHENTICATION_RESULT_SUCCESS,
118       AUTHENTICATION_RESULT_FAILURE
119   })
120   @Retention(RetentionPolicy.SOURCE)
121   public @interface AuthenticationResult {
122   }
123 
124 
125   /**
126    * Reasons why presentation was not shown. These are wrappers around
127    * {@link com.android.os.AtomsProto.AutofillFillResponseReported.DetectionPreference}.
128    */
129   @IntDef(prefix = {"DETECTION_PREFER"}, value = {
130       DETECTION_PREFER_UNKNOWN,
131       DETECTION_PREFER_AUTOFILL_PROVIDER,
132       DETECTION_PREFER_PCC
133   })
134   @Retention(RetentionPolicy.SOURCE)
135   public @interface DetectionPreference {
136   }
137 
138   public static final int DISPLAY_PRESENTATION_TYPE_UNKNOWN =
139       AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__UNKNOWN_AUTOFILL_DISPLAY_PRESENTATION_TYPE;
140   public static final int DISPLAY_PRESENTATION_TYPE_MENU =
141       AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__MENU;
142   public static final int DISPLAY_PRESENTATION_TYPE_INLINE =
143       AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__INLINE;
144   public static final int DISPLAY_PRESENTATION_TYPE_DIALOG =
145       AUTOFILL_FILL_RESPONSE_REPORTED__DISPLAY_PRESENTATION_TYPE__DIALOG;
146   public static final int AUTHENTICATION_TYPE_UNKNOWN =
147       AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_TYPE__AUTHENTICATION_TYPE_UNKNOWN;
148   public static final int AUTHENTICATION_TYPE_DATASET_AHTHENTICATION =
149       AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_TYPE__DATASET_AUTHENTICATION;
150   public static final int AUTHENTICATION_TYPE_FULL_AHTHENTICATION =
151       AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_TYPE__FULL_AUTHENTICATION;
152 
153   public static final int AUTHENTICATION_RESULT_UNKNOWN =
154       AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_RESULT_UNKNOWN;
155   public static final int AUTHENTICATION_RESULT_SUCCESS =
156       AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_SUCCESS;
157   public static final int AUTHENTICATION_RESULT_FAILURE =
158       AUTOFILL_FILL_RESPONSE_REPORTED__AUTHENTICATION_RESULT__AUTHENTICATION_FAILURE;
159   public static final int RESPONSE_STATUS_TIMEOUT =
160       AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_TIMEOUT;
161   public static final int RESPONSE_STATUS_CANCELLED =
162       AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_CANCELLED;
163   public static final int RESPONSE_STATUS_FAILURE =
164       AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_FAILURE;
165   public static final int RESPONSE_STATUS_SESSION_DESTROYED =
166       AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SESSION_DESTROYED;
167   public static final int RESPONSE_STATUS_SUCCESS =
168       AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SUCCESS;
169   public static final int RESPONSE_STATUS_UNKNOWN =
170       AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_UNKNOWN;
171 
172   // Values for AutofillFillResponseReported.detection_preference
173   public static final int DETECTION_PREFER_UNKNOWN =
174           AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_UNKONWN;
175   public static final int DETECTION_PREFER_AUTOFILL_PROVIDER =
176           AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_AUTOFILL_PROVIDER;
177   public static final int DETECTION_PREFER_PCC =
178           AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_PCC;
179 
180 
181   // Log a magic number when FillRequest failed or timeout to differentiate with FillRequest
182   // succeeded.
183   public static final int AVAILABLE_COUNT_WHEN_FILL_REQUEST_FAILED_OR_TIMEOUT = -1;
184 
185   // Log a magic number to indicate that the FillResponse contains a saveTriggerId.
186   public static final int HAVE_SAVE_TRIGGER_ID = 1;
187 
188   private final int mSessionId;
189   private Optional<FillResponseEventInternal> mEventInternal;
190 
FillResponseEventLogger(int sessionId)191   private FillResponseEventLogger(int sessionId) {
192     mSessionId = sessionId;
193     mEventInternal = Optional.empty();
194   }
195 
196   /**
197    * A factory constructor to create FillResponseEventLogger.
198    */
forSessionId(int sessionId)199   public static FillResponseEventLogger forSessionId(int sessionId) {
200     return new FillResponseEventLogger(sessionId);
201   }
202 
203   /**
204    * Reset mEventInternal before logging for a new response. It shall be called
205    * for each FillResponse.
206    */
startLogForNewResponse()207   public void startLogForNewResponse() {
208     if (!mEventInternal.isEmpty()) {
209       Slog.w(TAG, "FillResponseEventLogger is not empty before starting " +
210           "for a new request");
211     }
212     mEventInternal = Optional.of(new FillResponseEventInternal());
213   }
214 
215   /**
216    * Set request_id as long as mEventInternal presents.
217    */
maybeSetRequestId(int val)218   public void maybeSetRequestId(int val) {
219     mEventInternal.ifPresent(event -> event.mRequestId = val);
220   }
221 
222   /**
223    * Set app_package_uid as long as mEventInternal presents.
224    */
maybeSetAppPackageUid(int val)225   public void maybeSetAppPackageUid(int val) {
226     mEventInternal.ifPresent(event -> {
227       event.mAppPackageUid = val;
228     });
229   }
230 
231   /**
232    * Set display_presentation_type as long as mEventInternal presents.
233    */
maybeSetDisplayPresentationType(@isplayPresentationType int val)234   public void maybeSetDisplayPresentationType(@DisplayPresentationType int val) {
235     mEventInternal.ifPresent(event -> {
236       event.mDisplayPresentationType = val;
237     });
238   }
239 
240   /**
241    * Set available_count as long as mEventInternal presents.
242    * For cases of FillRequest failed and timeout, set to -1.
243    */
maybeSetAvailableCount(@ullable List<Dataset> datasetList, AutofillId currentViewId)244   public void maybeSetAvailableCount(@Nullable List<Dataset> datasetList,
245       AutofillId currentViewId) {
246     mEventInternal.ifPresent(event -> {
247       int availableCount = getDatasetCountForAutofillId(datasetList, currentViewId);
248       event.mAvailableCount = availableCount;
249     });
250   }
251 
maybeSetAvailableCount(int val)252   public void maybeSetAvailableCount(int val) {
253     mEventInternal.ifPresent(event -> {
254       event.mAvailableCount = val;
255     });
256   }
257 
maybeSetTotalDatasetsProvided(int val)258   public void maybeSetTotalDatasetsProvided(int val) {
259     mEventInternal.ifPresent(event -> {
260       // Don't reset if it's already populated.
261       // This is just a technical limitation of not having complicated logic.
262       // Autofill Provider may return some datasets which are applicable to data types.
263       // In such a case, we set available count to the number of datasets provided.
264       // However, it's possible that those data types aren't detected by PCC, so in effect, there
265       // are 0 datasets. In the codebase, we treat it as null response, which may call this again
266       // to set 0. But we don't want to overwrite already set value.
267       if (event.mTotalDatasetsProvided == -1) {
268         event.mTotalDatasetsProvided = val;
269       }
270     });
271   }
272 
getDatasetCountForAutofillId(@ullable List<Dataset> datasetList, AutofillId currentViewId)273   private static int getDatasetCountForAutofillId(@Nullable List<Dataset> datasetList,
274       AutofillId currentViewId) {
275     int availableCount = 0;
276     if (datasetList != null) {
277       for (int i = 0; i < datasetList.size(); i++) {
278         Dataset data = datasetList.get(i);
279         if (data != null && data.getFieldIds() != null
280             && data.getFieldIds().contains(currentViewId)) {
281           availableCount += 1;
282         }
283       }
284     }
285     return availableCount;
286   }
287 
288   /**
289    * Set save_ui_trigger_ids as long as mEventInternal presents.
290    */
maybeSetSaveUiTriggerIds(int val)291   public void maybeSetSaveUiTriggerIds(int val) {
292     mEventInternal.ifPresent(event -> {
293       event.mSaveUiTriggerIds = val;
294     });
295   }
296 
297   /**
298    * Set latency_fill_response_received_millis as long as mEventInternal presents.
299    */
maybeSetLatencyFillResponseReceivedMillis(int val)300   public void maybeSetLatencyFillResponseReceivedMillis(int val) {
301     mEventInternal.ifPresent(event -> {
302       event.mLatencyFillResponseReceivedMillis = val;
303     });
304   }
305 
306   /**
307    * Set authentication_type as long as mEventInternal presents.
308    */
maybeSetAuthenticationType(@uthenticationType int val)309   public void maybeSetAuthenticationType(@AuthenticationType int val) {
310     mEventInternal.ifPresent(event -> {
311       event.mAuthenticationType = val;
312     });
313   }
314 
315   /**
316    * Set authentication_result as long as mEventInternal presents.
317    */
maybeSetAuthenticationResult(@uthenticationResult int val)318   public void maybeSetAuthenticationResult(@AuthenticationResult int val) {
319     mEventInternal.ifPresent(event -> {
320       event.mAuthenticationResult = val;
321     });
322   }
323 
324   /**
325    * Set authentication_failure_reason as long as mEventInternal presents.
326    */
maybeSetAuthenticationFailureReason(int val)327   public void maybeSetAuthenticationFailureReason(int val) {
328     mEventInternal.ifPresent(event -> {
329       event.mAuthenticationFailureReason = val;
330     });
331   }
332 
333   /**
334    * Set latency_authentication_ui_display_millis as long as mEventInternal presents.
335    */
maybeSetLatencyAuthenticationUiDisplayMillis(int val)336   public void maybeSetLatencyAuthenticationUiDisplayMillis(int val) {
337     mEventInternal.ifPresent(event -> {
338       event.mLatencyAuthenticationUiDisplayMillis = val;
339     });
340   }
341 
342   /**
343    * Set latency_dataset_display_millis as long as mEventInternal presents.
344    */
maybeSetLatencyDatasetDisplayMillis(int val)345   public void maybeSetLatencyDatasetDisplayMillis(int val) {
346     mEventInternal.ifPresent(event -> {
347       event.mLatencyDatasetDisplayMillis = val;
348     });
349   }
350 
351   /**
352    * Set response_status as long as mEventInternal presents.
353    */
maybeSetResponseStatus(@esponseStatus int val)354   public void maybeSetResponseStatus(@ResponseStatus int val) {
355     mEventInternal.ifPresent(event -> {
356       event.mResponseStatus = val;
357     });
358   }
359 
startResponseProcessingTime()360   public void startResponseProcessingTime() {
361     startResponseProcessingTimestamp = SystemClock.elapsedRealtime();
362   }
363 
364   /**
365    * Set latency_response_processing_millis as long as mEventInternal presents.
366    */
maybeSetLatencyResponseProcessingMillis()367   public void maybeSetLatencyResponseProcessingMillis() {
368     mEventInternal.ifPresent(event -> {
369       if (startResponseProcessingTimestamp == UNINITIALIZED_TIMESTAMP && sVerbose) {
370         Slog.v(TAG, "uninitialized startResponseProcessingTimestamp");
371       }
372       event.mLatencyResponseProcessingMillis
373               = SystemClock.elapsedRealtime() - startResponseProcessingTimestamp;
374     });
375   }
376 
377   /**
378    * Set available_pcc_count.
379    */
maybeSetAvailablePccCount(int val)380   public void maybeSetAvailablePccCount(int val) {
381     mEventInternal.ifPresent(event -> {
382       event.mAvailablePccCount = val;
383     });
384   }
385 
386   /**
387    * Set available_pcc_only_count.
388    */
maybeSetAvailablePccOnlyCount(int val)389   public void maybeSetAvailablePccOnlyCount(int val) {
390     mEventInternal.ifPresent(event -> {
391       event.mAvailablePccOnlyCount = val;
392     });
393   }
394 
395   /**
396    * Set available_pcc_count.
397    */
maybeSetDatasetsCountAfterPotentialPccFiltering(@ullable List<Dataset> datasetList)398   public void maybeSetDatasetsCountAfterPotentialPccFiltering(@Nullable List<Dataset> datasetList) {
399     mEventInternal.ifPresent(event -> {
400       int pccOnlyCount = 0;
401       int pccCount = 0;
402       int totalCount = 0;
403       if (datasetList != null) {
404         totalCount = datasetList.size();
405         for (int i = 0; i < datasetList.size(); i++) {
406           Dataset dataset = datasetList.get(i);
407           if (dataset != null) {
408             if (dataset.getEligibleReason() == PICK_REASON_PCC_DETECTION_ONLY) {
409               pccOnlyCount++;
410               pccCount++;
411             } else if (dataset.getEligibleReason()
412                     == PICK_REASON_PCC_DETECTION_PREFERRED_WITH_PROVIDER) {
413               pccCount++;
414             }
415           }
416         }
417       }
418       event.mAvailablePccOnlyCount = pccOnlyCount;
419       event.mAvailablePccCount = pccCount;
420       event.mAvailableCount = totalCount;
421     });
422   }
423 
424   /**
425    * Set detection_pref
426    */
maybeSetDetectionPreference(@etectionPreference int detectionPreference)427   public void maybeSetDetectionPreference(@DetectionPreference int detectionPreference) {
428     mEventInternal.ifPresent(event -> {
429       event.mDetectionPref = detectionPreference;
430     });
431   }
432 
433   /**
434    * Log an AUTOFILL_FILL_RESPONSE_REPORTED event.
435    */
logAndEndEvent()436   public void logAndEndEvent() {
437     if (!mEventInternal.isPresent()) {
438       Slog.w(TAG, "Shouldn't be logging AutofillFillRequestReported again for same "
439           + "event");
440       return;
441     }
442     FillResponseEventInternal event = mEventInternal.get();
443     if (sVerbose) {
444       Slog.v(TAG, "Log AutofillFillResponseReported:"
445           + " requestId=" + event.mRequestId
446           + " sessionId=" + mSessionId
447           + " mAppPackageUid=" + event.mAppPackageUid
448           + " mDisplayPresentationType=" + event.mDisplayPresentationType
449           + " mAvailableCount=" + event.mAvailableCount
450           + " mSaveUiTriggerIds=" + event.mSaveUiTriggerIds
451           + " mLatencyFillResponseReceivedMillis=" + event.mLatencyFillResponseReceivedMillis
452           + " mAuthenticationType=" + event.mAuthenticationType
453           + " mAuthenticationResult=" + event.mAuthenticationResult
454           + " mAuthenticationFailureReason=" + event.mAuthenticationFailureReason
455           + " mLatencyAuthenticationUiDisplayMillis=" + event.mLatencyAuthenticationUiDisplayMillis
456           + " mLatencyDatasetDisplayMillis=" + event.mLatencyDatasetDisplayMillis
457           + " mResponseStatus=" + event.mResponseStatus
458           + " mLatencyResponseProcessingMillis=" + event.mLatencyResponseProcessingMillis
459           + " mAvailablePccCount=" + event.mAvailablePccCount
460           + " mAvailablePccOnlyCount=" + event.mAvailablePccOnlyCount
461           + " mTotalDatasetsProvided=" + event.mTotalDatasetsProvided
462           + " mDetectionPref=" + event.mDetectionPref);
463     }
464     FrameworkStatsLog.write(
465         AUTOFILL_FILL_RESPONSE_REPORTED,
466         event.mRequestId,
467         mSessionId,
468         event.mAppPackageUid,
469         event.mDisplayPresentationType,
470         event.mAvailableCount,
471         event.mSaveUiTriggerIds,
472         event.mLatencyFillResponseReceivedMillis,
473         event.mAuthenticationType,
474         event.mAuthenticationResult,
475         event.mAuthenticationFailureReason,
476         event.mLatencyAuthenticationUiDisplayMillis,
477         event.mLatencyDatasetDisplayMillis,
478         event.mResponseStatus,
479         event.mLatencyResponseProcessingMillis,
480         event.mAvailablePccCount,
481         event.mAvailablePccOnlyCount,
482         event.mTotalDatasetsProvided,
483         event.mDetectionPref);
484     mEventInternal = Optional.empty();
485   }
486 
487   private static final class FillResponseEventInternal {
488     int mRequestId = -1;
489     int mAppPackageUid = -1;
490     int mDisplayPresentationType = DISPLAY_PRESENTATION_TYPE_UNKNOWN;
491     int mAvailableCount = 0;
492     int mSaveUiTriggerIds = -1;
493     int mLatencyFillResponseReceivedMillis = (int) UNINITIALIZED_TIMESTAMP;
494     int mAuthenticationType = AUTHENTICATION_TYPE_UNKNOWN;
495     int mAuthenticationResult = AUTHENTICATION_RESULT_UNKNOWN;
496     int mAuthenticationFailureReason = -1;
497     int mLatencyAuthenticationUiDisplayMillis = (int) UNINITIALIZED_TIMESTAMP;
498     int mLatencyDatasetDisplayMillis = (int) UNINITIALIZED_TIMESTAMP;
499     int mResponseStatus = RESPONSE_STATUS_UNKNOWN;
500     long mLatencyResponseProcessingMillis = UNINITIALIZED_TIMESTAMP;
501     int mAvailablePccCount = -1;
502     int mAvailablePccOnlyCount = -1;
503     int mTotalDatasetsProvided = -1;
504     @DetectionPreference
505     int mDetectionPref = DETECTION_PREFER_UNKNOWN;
506 
FillResponseEventInternal()507     FillResponseEventInternal() {
508     }
509   }
510 }
511