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

Commit c12e0fa7 authored by Tim Yu's avatar Tim Yu
Browse files

Autofill Presentation Logging 4

Log when sending FillRequests resulted in TransactionTooLargeException.

This requires some refactoring.

Fixes: 301491465
Test: n/a logging only change
Change-Id: If5c46f1673ceee477880b0d8fd5290cf114d815b
parent 6f5572de
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_CANCELLED;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_FAILURE;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SESSION_DESTROYED;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_TRANSACTION_TOO_LARGE;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SUCCESS;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_TIMEOUT;
import static com.android.internal.util.FrameworkStatsLog.AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_UNKNOWN;
@@ -162,6 +163,8 @@ public final class FillResponseEventLogger {
      AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_CANCELLED;
  public static final int RESPONSE_STATUS_FAILURE =
      AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_FAILURE;
  public static final int RESPONSE_STATUS_TRANSACTION_TOO_LARGE =
      AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_TRANSACTION_TOO_LARGE;
  public static final int RESPONSE_STATUS_SESSION_DESTROYED =
      AUTOFILL_FILL_RESPONSE_REPORTED__RESPONSE_STATUS__RESPONSE_STATUS_SESSION_DESTROYED;
  public static final int RESPONSE_STATUS_SUCCESS =
+7 −7
Original line number Diff line number Diff line
@@ -82,9 +82,7 @@ final class RemoteFillService extends ServiceConnector.Impl<IAutoFillService> {
        void onFillRequestSuccess(int requestId, @Nullable FillResponse response,
                @NonNull String servicePackageName, int requestFlags);

        void onFillRequestFailure(int requestId, @Nullable CharSequence message);

        void onFillRequestTimeout(int requestId);
        void onFillRequestFailure(int requestId, Throwable t);

        void onSaveRequestSuccess(@NonNull String servicePackageName,
                @Nullable IntentSender intentSender);
@@ -345,11 +343,12 @@ final class RemoteFillService extends ServiceConnector.Impl<IAutoFillService> {
                Slog.e(TAG, "Error calling on fill request", err);
                if (err instanceof TimeoutException) {
                    dispatchCancellationSignal(cancellationSink.get());
                    mCallbacks.onFillRequestTimeout(request.getId());
                    mCallbacks.onFillRequestFailure(request.getId(), err);
                } else if (err instanceof CancellationException) {
                    // Cancellation is a part of the user flow - don't mark as failure
                    dispatchCancellationSignal(cancellationSink.get());
                } else {
                    mCallbacks.onFillRequestFailure(request.getId(), err.getMessage());
                    mCallbacks.onFillRequestFailure(request.getId(), err);
                }
            }
        }));
@@ -413,11 +412,12 @@ final class RemoteFillService extends ServiceConnector.Impl<IAutoFillService> {
                Slog.e(TAG, "Error calling on fill request", err);
                if (err instanceof TimeoutException) {
                    dispatchCancellationSignal(cancellationSink.get());
                    mCallbacks.onFillRequestTimeout(request.getId());
                    mCallbacks.onFillRequestFailure(request.getId(), err);
                } else if (err instanceof CancellationException) {
                    // Cancellation is a part of the user flow - don't mark as failure
                    dispatchCancellationSignal(cancellationSink.get());
                } else {
                    mCallbacks.onFillRequestFailure(request.getId(), err.getMessage());
                    mCallbacks.onFillRequestFailure(request.getId(), err);
                }
            }
        }));
+1 −6
Original line number Diff line number Diff line
@@ -75,12 +75,7 @@ final class SecondaryProviderHandler implements RemoteFillService.FillServiceCal
    }

    @Override
    public void onFillRequestFailure(int requestId, @Nullable CharSequence message) {

    }

    @Override
    public void onFillRequestTimeout(int requestId) {
    public void onFillRequestFailure(int requestId, Throwable t) {

    }

+12 −15
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ import static com.android.server.autofill.FillResponseEventLogger.RESPONSE_STATU
import static com.android.server.autofill.FillResponseEventLogger.RESPONSE_STATUS_SESSION_DESTROYED;
import static com.android.server.autofill.FillResponseEventLogger.RESPONSE_STATUS_SUCCESS;
import static com.android.server.autofill.FillResponseEventLogger.RESPONSE_STATUS_TIMEOUT;
import static com.android.server.autofill.FillResponseEventLogger.RESPONSE_STATUS_TRANSACTION_TOO_LARGE;
import static com.android.server.autofill.Helper.containsCharsInOrder;
import static com.android.server.autofill.Helper.createSanitizers;
import static com.android.server.autofill.Helper.getNumericValue;
@@ -137,6 +138,7 @@ import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.SystemClock;
import android.os.TransactionTooLargeException;
import android.service.assist.classification.FieldClassificationRequest;
import android.service.assist.classification.FieldClassificationResponse;
import android.service.autofill.AutofillFieldClassificationService.Scores;
@@ -211,6 +213,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -2346,20 +2349,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
    // FillServiceCallbacks
    @Override
    @SuppressWarnings("GuardedBy")
    public void onFillRequestFailure(int requestId, @Nullable CharSequence message) {
        onFillRequestFailureOrTimeout(requestId, false, message);
    }

    // FillServiceCallbacks
    @Override
    @SuppressWarnings("GuardedBy")
    public void onFillRequestTimeout(int requestId) {
        onFillRequestFailureOrTimeout(requestId, true, null);
    }

    @SuppressWarnings("GuardedBy")
    private void onFillRequestFailureOrTimeout(int requestId, boolean timedOut,
            @Nullable CharSequence message) {
    public void onFillRequestFailure(int requestId, Throwable t) {
        CharSequence message = t.getMessage();
        boolean timedOut = (t instanceof TimeoutException);
        boolean showMessage = !TextUtils.isEmpty(message);

        synchronized (mLock) {
@@ -2412,10 +2404,15 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                }
            }

            if (timedOut) {
            if (t instanceof TimeoutException) {
                mPresentationStatsEventLogger.maybeSetNoPresentationEventReason(
                        NOT_SHOWN_REASON_REQUEST_TIMEOUT);
                mFillResponseEventLogger.maybeSetResponseStatus(RESPONSE_STATUS_TIMEOUT);
            } else if (t instanceof TransactionTooLargeException) {
                mPresentationStatsEventLogger.maybeSetNoPresentationEventReason(
                        NOT_SHOWN_REASON_REQUEST_FAILED);
                mFillResponseEventLogger.maybeSetResponseStatus(
                        RESPONSE_STATUS_TRANSACTION_TOO_LARGE);
            } else {
                mPresentationStatsEventLogger.maybeSetNoPresentationEventReason(
                        NOT_SHOWN_REASON_REQUEST_FAILED);