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

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

Merge "[Autofill] Log for virtual views fill" into main

parents a0f45f66 87f2c420
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -60,6 +60,11 @@ public final class AutofillId implements Parcelable {
        this(FLAG_IS_VIRTUAL_INT, hostId, virtualChildId, NO_SESSION);
    }

    /** @hide */
    public AutofillId(@NonNull AutofillId hostId, int virtualChildId, int sessionId) {
        this(FLAG_IS_VIRTUAL_INT | FLAG_HAS_SESSION, hostId.mViewId, virtualChildId, sessionId);
    }

    /** @hide */
    @TestApi
    public AutofillId(@NonNull AutofillId hostId, long virtualChildId, int sessionId) {
@@ -236,9 +241,9 @@ public final class AutofillId implements Parcelable {
    public String toString() {
        final StringBuilder builder = new StringBuilder().append(mViewId);
        if (isVirtualInt()) {
            builder.append(':').append(mVirtualIntId);
            builder.append(":i").append(mVirtualIntId);
        } else if (isVirtualLong()) {
            builder.append(':').append(mVirtualLongId);
            builder.append(":l").append(mVirtualLongId);
        }

        if (hasSession()) {
+32 −6
Original line number Diff line number Diff line
@@ -193,6 +193,7 @@ import sun.misc.Cleaner;
@RequiresFeature(PackageManager.FEATURE_AUTOFILL)
public final class AutofillManager {

    private static final boolean DBG = false;
    private static final String TAG = "AutofillManager";

    /**
@@ -2027,7 +2028,31 @@ public final class AutofillManager {
        if (!hasAutofillFeature()) {
            return;
        }
        if (DBG) {
            Log.v(TAG, "notifyValueChanged() called with virtualId:" + virtualId + " value:"
                    + value);
        }
        synchronized (mLock) {
            if (mLastAutofilledData != null) {
                AutofillId id = new AutofillId(view.getAutofillId(), virtualId, mSessionId);
                if (mLastAutofilledData.containsKey(id)) {
                    if (Objects.equals(mLastAutofilledData.get(id), value)) {
                        // Indicates that the view was autofilled
                        if (sDebug) {
                            Log.v(TAG, "notifyValueChanged() virtual view autofilled successfully:"
                                    + virtualId + " value:" + value);
                        }
                        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.
                            Log.w(TAG, "RemoteException caught but ignored " + e);
                        }
                    }
                }
            }
            if (!mEnabled || !isActiveLocked()) {
                if (sVerbose) {
                    Log.v(TAG, "notifyValueChanged(" + view.getAutofillId() + ":" + virtualId
@@ -3114,6 +3139,10 @@ public final class AutofillManager {

            ArrayList<AutofillId> failedIds = new ArrayList<>();

            if (mLastAutofilledData == null) {
                mLastAutofilledData = new ParcelableMap(itemCount);
            }

            for (int i = 0; i < itemCount; i++) {
                final AutofillId id = ids.get(i);
                final AutofillValue value = values.get(i);
@@ -3126,6 +3155,9 @@ public final class AutofillManager {
                    failedIds.add(id);
                    continue;
                }
                // Mark the view as to be autofilled with 'value'
                mLastAutofilledData.put(id, value);

                if (id.isVirtualInt()) {
                    if (virtualValues == null) {
                        // Most likely there will be just one view with virtual children.
@@ -3139,12 +3171,6 @@ public final class AutofillManager {
                    }
                    valuesByParent.put(id.getVirtualChildIntId(), value);
                } else {
                    // Mark the view as to be autofilled with 'value'
                    if (mLastAutofilledData == null) {
                        mLastAutofilledData = new ParcelableMap(itemCount - i);
                    }
                    mLastAutofilledData.put(id, value);

                    view.autofill(value);

                    // Set as autofilled if the values match now, e.g. when the value was updated
+9 −1
Original line number Diff line number Diff line
@@ -675,7 +675,14 @@ public final class PresentationStatsEventLogger {
            } else if (autofillIds.contains(autofillId)) {
                if (sVerbose) {
                    Slog.v(TAG, "Logging autofill for id:" + autofillId);
                }
                event.mViewFillSuccessCount++;
                autofillIds.remove(autofillId);
                event.mAlreadyFilledAutofillIds.add(autofillId);
            } else if (event.mAlreadyFilledAutofillIds.contains(autofillId)) {
                if (sVerbose) {
                    Slog.v(TAG, "Successfully filled autofillId:" + autofillId
                            + " already processed ");
                }
            } else {
                Slog.w(TAG, "Successfully filled autofillId:" + autofillId
@@ -850,6 +857,7 @@ public final class PresentationStatsEventLogger {
        int mViewFilledButUnexpectedCount = 0;

        ArraySet<AutofillId> mAutofillIdsAttemptedAutofill;
        ArraySet<AutofillId> mAlreadyFilledAutofillIds = new ArraySet<>();
        PresentationStatsEventInternal() {}
    }