Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 28132167 authored by Simranjit Kohli's avatar Simranjit Kohli Committed by Android (Google) Code Review
Browse files

Merge "More logging for views filling" into main

parents c9cb114c 76ea19d9
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -1978,6 +1978,13 @@ public final class AutofillManager {

                    if (Objects.equals(mLastAutofilledData.get(id), value)) {
                        view.setAutofilled(true, hideHighlight);
                        try {
                            mService.setViewAutofilled(mSessionId, id, mContext.getUserId());
                        } catch (RemoteException e) {
                            // The failure could be a consequence of something going wrong on the
                            // server side. Do nothing here since it's just logging, but it's
                            // possible follow-up actions may fail.
                        }
                    } else {
                        view.setAutofilled(false, false);
                        mLastAutofilledData.remove(id);
@@ -2978,6 +2985,13 @@ public final class AutofillManager {
                mLastAutofilledData.put(view.getAutofillId(), targetValue);
            }
            view.setAutofilled(true, hideHighlight);
            try {
                mService.setViewAutofilled(mSessionId, view.getAutofillId(), mContext.getUserId());
            } catch (RemoteException e) {
                // The failure could be a consequence of something going wrong on the server side.
                // Do nothing here since it's just logging, but it's possible follow-up actions may
                // fail.
            }
        }
    }

+1 −0
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ oneway interface IAutoFillManager {
    void updateSession(int sessionId, in AutofillId id, in Rect bounds,
        in AutofillValue value, int action, int flags, int userId);
    void setAutofillFailure(int sessionId, in List<AutofillId> ids, int userId);
    void setViewAutofilled(int sessionId, in AutofillId id, int userId);
    void finishSession(int sessionId, int userId, int commitReason);
    void cancelSession(int sessionId, int userId);
    void setAuthenticationResult(in Bundle data, int sessionId, int authenticationId, int userId);
+13 −0
Original line number Diff line number Diff line
@@ -1997,6 +1997,19 @@ public final class AutofillManagerService
            }
        }

        @Override
        public void setViewAutofilled(int sessionId, @NonNull AutofillId id, int userId) {
            synchronized (mLock) {
                final AutofillManagerServiceImpl service =
                        peekServiceForUserWithLocalBinderIdentityLocked(userId);
                if (service != null) {
                    service.setViewAutofilled(sessionId, getCallingUid(), id);
                } else if (sVerbose) {
                    Slog.v(TAG, "setAutofillFailure(): no service for " + userId);
                }
            }
        }

        @Override
        public void finishSession(int sessionId, int userId,
                @AutofillCommitReason int commitReason) {
+16 −0
Original line number Diff line number Diff line
@@ -466,6 +466,7 @@ final class AutofillManagerServiceImpl
    @GuardedBy("mLock")
    void setAutofillFailureLocked(int sessionId, int uid, @NonNull List<AutofillId> ids) {
        if (!isEnabledLocked()) {
            Slog.wtf(TAG, "Service not enabled");
            return;
        }
        final Session session = mSessions.get(sessionId);
@@ -476,9 +477,24 @@ final class AutofillManagerServiceImpl
        session.setAutofillFailureLocked(ids);
    }

    @GuardedBy("mLock")
    void setViewAutofilled(int sessionId, int uid, @NonNull AutofillId id) {
        if (!isEnabledLocked()) {
            Slog.wtf(TAG, "Service not enabled");
            return;
        }
        final Session session = mSessions.get(sessionId);
        if (session == null || uid != session.uid) {
            Slog.v(TAG, "setViewAutofilled(): no session for " + sessionId + "(" + uid + ")");
            return;
        }
        session.setViewAutofilled(id);
    }

    @GuardedBy("mLock")
    void finishSessionLocked(int sessionId, int uid, @AutofillCommitReason int commitReason) {
        if (!isEnabledLocked()) {
            Slog.wtf(TAG, "Service not enabled");
            return;
        }

+39 −4
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import android.content.pm.PackageManager;
import android.provider.Settings;
import android.service.autofill.Dataset;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.Slog;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillManager;
@@ -548,9 +549,10 @@ public final class PresentationStatsEventLogger {
    /**
     * Set views_fillable_total_count as long as mEventInternal presents.
     */
    public void maybeSetViewFillableCounts(int totalFillableCount) {
    public void maybeSetViewFillablesAndCount(List<AutofillId> autofillIds) {
        mEventInternal.ifPresent(event -> {
            event.mViewFillableTotalCount = totalFillableCount;
            event.mAutofillIdsAttemptedAutofill = new ArraySet<>(autofillIds);
            event.mViewFillableTotalCount = event.mAutofillIdsAttemptedAutofill.size();
        });
    }

@@ -575,6 +577,29 @@ public final class PresentationStatsEventLogger {
            event.mFocusedId = id;
        });
    }
    /**
     * Set views_filled_failure_count using failure count as long as mEventInternal
     * presents.
     */
    public void maybeAddSuccessId(AutofillId autofillId) {
        mEventInternal.ifPresent(event -> {
            ArraySet<AutofillId> autofillIds = event.mAutofillIdsAttemptedAutofill;
            if (autofillIds == null) {
                Slog.w(TAG, "Attempted autofill ids is null, but received autofillId:" + autofillId
                        + " successfully filled");
                event.mViewFilledButUnexpectedCount++;
            } else if (autofillIds.contains(autofillId)) {
                if (sVerbose) {
                    Slog.v(TAG, "Logging autofill for id:" + autofillId);
                    event.mViewFillSuccessCount++;
                }
            } else {
                Slog.w(TAG, "Successfully filled autofillId:" + autofillId
                        + " not found in list of attempted autofill ids: " + autofillIds);
                event.mViewFilledButUnexpectedCount++;
            }
        });
    }

    public void logAndEndEvent() {
        if (!mEventInternal.isPresent()) {
@@ -621,7 +646,9 @@ public final class PresentationStatsEventLogger {
                    + " mWebviewRequestedCredential=" + event.mWebviewRequestedCredential
                    + " mViewFillableTotalCount=" + event.mViewFillableTotalCount
                    + " mViewFillFailureCount=" + event.mViewFillFailureCount
                    + " mFocusedId=" + event.mFocusedId);
                    + " mFocusedId=" + event.mFocusedId
                    + " mViewFillSuccessCount=" + event.mViewFillSuccessCount
                    + " mViewFilledButUnexpectedCount=" + event.mViewFilledButUnexpectedCount);
        }

        // TODO(b/234185326): Distinguish empty responses from other no presentation reasons.
@@ -665,7 +692,9 @@ public final class PresentationStatsEventLogger {
                event.mWebviewRequestedCredential,
                event.mViewFillableTotalCount,
                event.mViewFillFailureCount,
                event.mFocusedId);
                event.mFocusedId,
                event.mViewFillSuccessCount,
                event.mViewFilledButUnexpectedCount);
        mEventInternal = Optional.empty();
    }

@@ -705,6 +734,12 @@ public final class PresentationStatsEventLogger {
        int mViewFillFailureCount = -1;
        int mFocusedId = -1;

        // Default value for success count is set to 0 explicitly. Setting it to -1 for
        // uninitialized doesn't help much, as this would be non-zero only if callback is received.
        int mViewFillSuccessCount = 0;
        int mViewFilledButUnexpectedCount = 0;

        ArraySet<AutofillId> mAutofillIdsAttemptedAutofill;
        PresentationStatsEventInternal() {}
    }

Loading