summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Simranjit Kohli <simranjit@google.com> 2023-09-23 00:29:47 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-09-23 00:29:47 +0000
commitc4bb8c387855c897be02999064d45c90184a5bbd (patch)
tree263941ed0f2dcfffbea94d2cf2b3b43190f1978e
parent23c425f3ba1752b6cff5cbbc5071346ada2bc8dc (diff)
parent54fa4ab46cbbb2acc5b892db5b2a6dbefc0a54c5 (diff)
Merge changes from topic "additional-autofill-pcc-logging" into udc-qpr-dev am: 328d684368 am: 54fa4ab46c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24829888 Change-Id: Ica527f2a2e426901e3f0cecdb300e624f9bf3964 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--services/autofill/java/com/android/server/autofill/FieldClassificationEventLogger.java120
-rw-r--r--services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java33
-rw-r--r--services/autofill/java/com/android/server/autofill/RemoteFieldClassificationService.java52
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java54
4 files changed, 239 insertions, 20 deletions
diff --git a/services/autofill/java/com/android/server/autofill/FieldClassificationEventLogger.java b/services/autofill/java/com/android/server/autofill/FieldClassificationEventLogger.java
index ffb4632164a3..db2e18a0fd57 100644
--- a/services/autofill/java/com/android/server/autofill/FieldClassificationEventLogger.java
+++ b/services/autofill/java/com/android/server/autofill/FieldClassificationEventLogger.java
@@ -17,12 +17,19 @@
package com.android.server.autofill;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED;
+import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_CANCELLED;
+import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_FAIL;
+import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_SUCCESS;
+import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_UNKNOWN;
import static com.android.server.autofill.Helper.sVerbose;
+import android.annotation.IntDef;
import android.util.Slog;
import com.android.internal.util.FrameworkStatsLog;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.Optional;
/**
@@ -36,6 +43,29 @@ public final class FieldClassificationEventLogger {
mEventInternal = Optional.empty();
}
+ public static final int STATUS_SUCCESS =
+ AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_SUCCESS;
+ public static final int STATUS_UNKNOWN =
+ AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_UNKNOWN;
+ public static final int STATUS_FAIL =
+ AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_FAIL;
+ public static final int STATUS_CANCELLED =
+ AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED__STATUS__STATUS_CANCELLED;
+
+ /**
+ * Status of the FieldClassification IPC request. These are wrappers around
+ * {@link com.android.os.AtomsProto.AutofillFieldClassificationEventReported.FieldClassificationRequestStatus}.
+ */
+ @IntDef(prefix = {"STATUS"}, value = {
+ STATUS_UNKNOWN,
+ STATUS_SUCCESS,
+ STATUS_FAIL,
+ STATUS_CANCELLED
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface FieldClassificationStatus {
+ }
+
/**
* A factory constructor to create FieldClassificationEventLogger.
*/
@@ -56,7 +86,7 @@ public final class FieldClassificationEventLogger {
}
/**
- * Set latency as long as mEventInternal presents.
+ * Set latency_millis as long as mEventInternal presents.
*/
public void maybeSetLatencyMillis(long timestamp) {
mEventInternal.ifPresent(event -> {
@@ -65,6 +95,69 @@ public final class FieldClassificationEventLogger {
}
/**
+ * Set count_classifications as long as mEventInternal presents.
+ */
+ public void maybeSetCountClassifications(int countClassifications) {
+ mEventInternal.ifPresent(event -> {
+ event.mCountClassifications = countClassifications;
+ });
+ }
+
+ /**
+ * Set session_id as long as mEventInternal presents.
+ */
+ public void maybeSetSessionId(int sessionId) {
+ mEventInternal.ifPresent(event -> {
+ event.mSessionId = sessionId;
+ });
+ }
+
+ /**
+ * Set request_id as long as mEventInternal presents.
+ */
+ public void maybeSetRequestId(int requestId) {
+ mEventInternal.ifPresent(event -> {
+ event.mRequestId = requestId;
+ });
+ }
+
+ /**
+ * Set next_fill_request_id as long as mEventInternal presents.
+ */
+ public void maybeSetNextFillRequestId(int nextFillRequestId) {
+ mEventInternal.ifPresent(event -> {
+ event.mNextFillRequestId = nextFillRequestId;
+ });
+ }
+
+ /**
+ * Set app_package_uid as long as mEventInternal presents.
+ */
+ public void maybeSetAppPackageUid(int uid) {
+ mEventInternal.ifPresent(event -> {
+ event.mAppPackageUid = uid;
+ });
+ }
+
+ /**
+ * Set status as long as mEventInternal presents.
+ */
+ public void maybeSetRequestStatus(@FieldClassificationStatus int status) {
+ mEventInternal.ifPresent(event -> {
+ event.mStatus = status;
+ });
+ }
+
+ /**
+ * Set is_session_gc as long as mEventInternal presents.
+ */
+ public void maybeSetSessionGc(boolean isSessionGc) {
+ mEventInternal.ifPresent(event -> {
+ event.mIsSessionGc = isSessionGc;
+ });
+ }
+
+ /**
* Log an AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED event.
*/
public void logAndEndEvent() {
@@ -77,16 +170,37 @@ public final class FieldClassificationEventLogger {
if (sVerbose) {
Slog.v(TAG, "Log AutofillFieldClassificationEventReported:"
+ " mLatencyClassificationRequestMillis="
- + event.mLatencyClassificationRequestMillis);
+ + event.mLatencyClassificationRequestMillis
+ + " mCountClassifications=" + event.mCountClassifications
+ + " mSessionId=" + event.mSessionId
+ + " mRequestId=" + event.mRequestId
+ + " mNextFillRequestId=" + event.mNextFillRequestId
+ + " mAppPackageUid=" + event.mAppPackageUid
+ + " mStatus=" + event.mStatus
+ + " mIsSessionGc=" + event.mIsSessionGc);
}
FrameworkStatsLog.write(
AUTOFILL_FIELD_CLASSIFICATION_EVENT_REPORTED,
- event.mLatencyClassificationRequestMillis);
+ event.mLatencyClassificationRequestMillis,
+ event.mCountClassifications,
+ event.mSessionId,
+ event.mRequestId,
+ event.mNextFillRequestId,
+ event.mAppPackageUid,
+ event.mStatus,
+ event.mIsSessionGc);
mEventInternal = Optional.empty();
}
private static final class FieldClassificationEventInternal {
long mLatencyClassificationRequestMillis = -1;
+ int mCountClassifications = -1;
+ int mSessionId = -1;
+ int mRequestId = -1;
+ int mNextFillRequestId = -1;
+ int mAppPackageUid = -1;
+ int mStatus;
+ boolean mIsSessionGc;
FieldClassificationEventInternal() {
}
diff --git a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java
index 11b45db29d5d..6b0fdb5f7fe0 100644
--- a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java
+++ b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java
@@ -211,15 +211,25 @@ public final class PresentationStatsEventLogger {
public static final int DETECTION_PREFER_PCC =
AUTOFILL_FILL_RESPONSE_REPORTED__DETECTION_PREFERENCE__DETECTION_PREFER_PCC;
private final int mSessionId;
+
+ /**
+ * For app_package_uid.
+ */
+ private final int mCallingAppUid;
private Optional<PresentationStatsEventInternal> mEventInternal;
- private PresentationStatsEventLogger(int sessionId) {
+ private PresentationStatsEventLogger(int sessionId, int callingAppUid) {
mSessionId = sessionId;
+ mCallingAppUid = callingAppUid;
mEventInternal = Optional.empty();
}
- public static PresentationStatsEventLogger forSessionId(int sessionId) {
- return new PresentationStatsEventLogger(sessionId);
+ /**
+ * Create PresentationStatsEventLogger, populated with sessionId and the callingAppUid
+ */
+ public static PresentationStatsEventLogger createPresentationLog(
+ int sessionId, int callingAppUid) {
+ return new PresentationStatsEventLogger(sessionId, callingAppUid);
}
public void startNewEvent() {
@@ -508,6 +518,14 @@ public final class PresentationStatsEventLogger {
return PICK_REASON_UNKNOWN;
}
+ /**
+ * Set field_classification_request_id as long as mEventInternal presents.
+ */
+ public void maybeSetFieldClassificationRequestId(int requestId) {
+ mEventInternal.ifPresent(event -> {
+ event.mFieldClassificationRequestId = requestId;
+ });
+ }
public void logAndEndEvent() {
if (!mEventInternal.isPresent()) {
@@ -547,7 +565,9 @@ public final class PresentationStatsEventLogger {
+ " mAvailablePccCount=" + event.mAvailablePccCount
+ " mAvailablePccOnlyCount=" + event.mAvailablePccOnlyCount
+ " mSelectedDatasetPickedReason=" + event.mSelectedDatasetPickedReason
- + " mDetectionPreference=" + event.mDetectionPreference);
+ + " mDetectionPreference=" + event.mDetectionPreference
+ + " mFieldClassificationRequestId=" + event.mFieldClassificationRequestId
+ + " mAppPackageUid=" + mCallingAppUid);
}
// TODO(b/234185326): Distinguish empty responses from other no presentation reasons.
@@ -584,7 +604,9 @@ public final class PresentationStatsEventLogger {
event.mAvailablePccCount,
event.mAvailablePccOnlyCount,
event.mSelectedDatasetPickedReason,
- event.mDetectionPreference);
+ event.mDetectionPreference,
+ event.mFieldClassificationRequestId,
+ mCallingAppUid);
mEventInternal = Optional.empty();
}
@@ -617,6 +639,7 @@ public final class PresentationStatsEventLogger {
int mAvailablePccOnlyCount = -1;
@DatasetPickedReason int mSelectedDatasetPickedReason = PICK_REASON_UNKNOWN;
@DetectionPreference int mDetectionPreference = DETECTION_PREFER_UNKNOWN;
+ int mFieldClassificationRequestId = -1;
PresentationStatsEventInternal() {}
}
diff --git a/services/autofill/java/com/android/server/autofill/RemoteFieldClassificationService.java b/services/autofill/java/com/android/server/autofill/RemoteFieldClassificationService.java
index bcca0069eb34..50fabfdaef83 100644
--- a/services/autofill/java/com/android/server/autofill/RemoteFieldClassificationService.java
+++ b/services/autofill/java/com/android/server/autofill/RemoteFieldClassificationService.java
@@ -69,6 +69,9 @@ final class RemoteFieldClassificationService
void onClassificationRequestFailure(int requestId, @Nullable CharSequence message);
void onClassificationRequestTimeout(int requestId);
void onServiceDied(@NonNull RemoteFieldClassificationService service);
+ void logFieldClassificationEvent(
+ long startTime, @NonNull FieldClassificationResponse response,
+ @FieldClassificationEventLogger.FieldClassificationStatus int status);
}
RemoteFieldClassificationService(Context context, ComponentName serviceName,
@@ -149,15 +152,24 @@ final class RemoteFieldClassificationService
new IFieldClassificationCallback.Stub() {
@Override
public void onCancellable(ICancellationSignal cancellation) {
- logLatency(startTime);
if (sDebug) {
Log.d(TAG, "onCancellable");
}
+ FieldClassificationServiceCallbacks
+ fieldClassificationServiceCallbacks =
+ Helper.weakDeref(
+ fieldClassificationServiceCallbacksWeakRef,
+ TAG, "onCancellable "
+ );
+ logFieldClassificationEvent(
+ startTime,
+ fieldClassificationServiceCallbacks,
+ FieldClassificationEventLogger.STATUS_CANCELLED,
+ null);
}
@Override
public void onSuccess(FieldClassificationResponse response) {
- logLatency(startTime);
if (sDebug) {
if (Build.IS_DEBUGGABLE) {
Slog.d(TAG, "onSuccess Response: " + response);
@@ -179,6 +191,11 @@ final class RemoteFieldClassificationService
fieldClassificationServiceCallbacksWeakRef,
TAG, "onSuccess "
);
+ logFieldClassificationEvent(
+ startTime,
+ fieldClassificationServiceCallbacks,
+ FieldClassificationEventLogger.STATUS_SUCCESS,
+ response);
if (fieldClassificationServiceCallbacks == null) {
return;
}
@@ -188,7 +205,6 @@ final class RemoteFieldClassificationService
@Override
public void onFailure() {
- logLatency(startTime);
if (sDebug) {
Slog.d(TAG, "onFailure");
}
@@ -198,6 +214,11 @@ final class RemoteFieldClassificationService
fieldClassificationServiceCallbacksWeakRef,
TAG, "onFailure "
);
+ logFieldClassificationEvent(
+ startTime,
+ fieldClassificationServiceCallbacks,
+ FieldClassificationEventLogger.STATUS_FAIL,
+ null);
if (fieldClassificationServiceCallbacks == null) {
return;
}
@@ -215,11 +236,24 @@ final class RemoteFieldClassificationService
}));
}
- private void logLatency(long startTime) {
- final FieldClassificationEventLogger logger = FieldClassificationEventLogger.createLogger();
- logger.startNewLogForRequest();
- logger.maybeSetLatencyMillis(
- SystemClock.elapsedRealtime() - startTime);
- logger.logAndEndEvent();
+ private void logFieldClassificationEvent(
+ long startTime,
+ @Nullable FieldClassificationServiceCallbacks fieldClassificationServiceCallbacks,
+ @FieldClassificationEventLogger.FieldClassificationStatus int status,
+ FieldClassificationResponse response) {
+ if (fieldClassificationServiceCallbacks == null) {
+ final FieldClassificationEventLogger logger =
+ FieldClassificationEventLogger.createLogger();
+ logger.startNewLogForRequest();
+ logger.maybeSetLatencyMillis(
+ SystemClock.elapsedRealtime() - startTime);
+ logger.maybeSetSessionGc(true);
+ logger.maybeSetRequestStatus(status);
+ logger.logAndEndEvent();
+ } else {
+ fieldClassificationServiceCallbacks.logFieldClassificationEvent(
+ startTime, response, status);
+ }
+
}
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 1ae912544cc8..4e5b0589446a 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -229,6 +229,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
private static final String PCC_HINTS_DELIMITER = ",";
public static final String EXTRA_KEY_DETECTIONS = "detections";
+ private static final int DEFAULT__FILL_REQUEST_ID_SNAPSHOT = -2;
+ private static final int DEFAULT__FIELD_CLASSIFICATION_REQUEST_ID_SNAPSHOT = -2;
final Object mLock;
@@ -412,6 +414,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
@GuardedBy("mLock")
private long mUiShownTime;
+ /**
+ * Tracks the value of the fill request id at the time of issuing request for field
+ * classification.
+ */
+ @GuardedBy("mLock")
+ private int mFillRequestIdSnapshot = DEFAULT__FILL_REQUEST_ID_SNAPSHOT;
+
+ /**
+ * Tracks the value of the field classification id at the time of issuing request for fill
+ * request.
+ */
+ @GuardedBy("mLock")
+ private int mFieldClassificationIdSnapshot = DEFAULT__FIELD_CLASSIFICATION_REQUEST_ID_SNAPSHOT;
+
@GuardedBy("mLock")
private final LocalLog mUiLatencyHistory;
@@ -673,6 +689,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (mPendingFillRequest == null) {
return;
}
+ mFieldClassificationIdSnapshot = sIdCounterForPcc.get();
if (mWaitForInlineRequest) {
if (mPendingInlineSuggestionsRequest == null) {
@@ -1239,6 +1256,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
+ ", flags=" + flags);
}
mPresentationStatsEventLogger.maybeSetRequestId(requestId);
+ mPresentationStatsEventLogger.maybeSetFieldClassificationRequestId(
+ mFieldClassificationIdSnapshot);
mFillRequestEventLogger.maybeSetRequestId(requestId);
mFillRequestEventLogger.maybeSetAutofillServiceUid(getAutofillServiceUid());
if (mSessionFlags.mInlineSupportedByService) {
@@ -1327,6 +1346,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
@GuardedBy("mLock")
private void requestAssistStructureForPccLocked(int flags) {
if (!mClassificationState.shouldTriggerRequest()) return;
+ mFillRequestIdSnapshot = sIdCounter.get();
mClassificationState.updatePendingRequest();
// Get request id
int requestId;
@@ -1411,7 +1431,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
mStartTime = SystemClock.elapsedRealtime();
mLatencyBaseTime = mStartTime;
mRequestCount = 0;
- mPresentationStatsEventLogger = PresentationStatsEventLogger.forSessionId(sessionId);
+ mPresentationStatsEventLogger = PresentationStatsEventLogger.createPresentationLog(
+ sessionId, uid);
mFillRequestEventLogger = FillRequestEventLogger.forSessionId(sessionId);
mFillResponseEventLogger = FillResponseEventLogger.forSessionId(sessionId);
mSessionCommittedEventLogger = SessionCommittedEventLogger.forSessionId(sessionId);
@@ -4301,6 +4322,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (viewState.getResponse() != null) {
FillResponse response = viewState.getResponse();
mPresentationStatsEventLogger.maybeSetRequestId(response.getRequestId());
+ mPresentationStatsEventLogger.maybeSetFieldClassificationRequestId(
+ mFieldClassificationIdSnapshot);
mPresentationStatsEventLogger.maybeSetAvailableCount(
response.getDatasets(), mCurrentViewId);
}
@@ -4478,6 +4501,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
public void onFillReady(@NonNull FillResponse response, @NonNull AutofillId filledId,
@Nullable AutofillValue value, int flags) {
synchronized (mLock) {
+ mPresentationStatsEventLogger.maybeSetFieldClassificationRequestId(
+ mFieldClassificationIdSnapshot);
if (mDestroyed) {
Slog.w(TAG, "Call to Session#onFillReady() rejected - session: "
+ id + " destroyed");
@@ -5389,6 +5414,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
List<Dataset> datasetList = newResponse.getDatasets();
+ mPresentationStatsEventLogger.maybeSetFieldClassificationRequestId(sIdCounterForPcc.get());
mPresentationStatsEventLogger.maybeSetAvailableCount(datasetList, mCurrentViewId);
mFillResponseEventLogger.maybeSetDatasetsCountAfterPotentialPccFiltering(datasetList);
@@ -6451,7 +6477,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return serviceInfo == null ? Process.INVALID_UID : serviceInfo.applicationInfo.uid;
}
- // FieldClassificationServiceCallbacks
+ // FieldClassificationServiceCallbacks start
public void onClassificationRequestSuccess(@Nullable FieldClassificationResponse response) {
mClassificationState.updateResponseReceived(response);
}
@@ -6472,6 +6498,28 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// forceRemoveFromServiceLocked();
}
}
- // DetectionServiceCallbacks end
+
+ @Override
+ public void logFieldClassificationEvent(
+ long startTime, FieldClassificationResponse response,
+ @FieldClassificationEventLogger.FieldClassificationStatus int status) {
+ final FieldClassificationEventLogger logger = FieldClassificationEventLogger.createLogger();
+ logger.startNewLogForRequest();
+ logger.maybeSetLatencyMillis(
+ SystemClock.elapsedRealtime() - startTime);
+ logger.maybeSetAppPackageUid(uid);
+ logger.maybeSetNextFillRequestId(mFillRequestIdSnapshot + 1);
+ logger.maybeSetRequestId(sIdCounterForPcc.get());
+ logger.maybeSetSessionId(id);
+ int count = -1;
+ if (response != null) {
+ count = response.getClassifications().size();
+ }
+ logger.maybeSetRequestStatus(status);
+ logger.maybeSetCountClassifications(count);
+ logger.logAndEndEvent();
+ mFillRequestIdSnapshot = DEFAULT__FILL_REQUEST_ID_SNAPSHOT;
+ }
+ // FieldClassificationServiceCallbacks end
}