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

Commit 627cc3c7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't log TYPE_DATASET_SELECTED on dataset authentication." into oc-mr1-dev

parents 415c7aad 63f7906c
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -22,8 +22,7 @@ import android.content.IntentSender;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
import android.view.autofill.AutofillId;
import android.widget.RemoteViews;
import android.view.autofill.AutofillManager;

import com.android.internal.util.Preconditions;

@@ -81,7 +80,7 @@ public final class FillEventHistory implements Parcelable {
    /**
     * Returns the client state set in the previous {@link FillResponse}.
     *
     * <p><b>NOTE: </b>the state is associated with the app that was autofilled in the previous
     * <p><b>Note: </b>the state is associated with the app that was autofilled in the previous
     * {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)}
     * , which is not necessary the same app being autofilled now.
     */
@@ -148,6 +147,14 @@ public final class FillEventHistory implements Parcelable {
    public static final class Event {
        /**
         * A dataset was selected. The dataset selected can be read from {@link #getDatasetId()}.
         *
         * <p><b>Note: </b>on Android {@link android.os.Build.VERSION_CODES#O}, this event was also
         * incorrectly reported after a
         * {@link Dataset.Builder#setAuthentication(IntentSender) dataset authentication} was
         * selected and the service returned a dataset in the
         * {@link AutofillManager#EXTRA_AUTHENTICATION_RESULT} of the activity launched from that
         * {@link IntentSender}. This behavior was fixed on Android
         * {@link android.os.Build.VERSION_CODES#O_MR1}.
         */
        public static final int TYPE_DATASET_SELECTED = 0;

@@ -158,8 +165,8 @@ public final class FillEventHistory implements Parcelable {
        public static final int TYPE_DATASET_AUTHENTICATION_SELECTED = 1;

        /**
         * A {@link FillResponse.Builder#setAuthentication(AutofillId[], IntentSender, RemoteViews)
         * fill response authentication} was selected.
         * A {@link FillResponse.Builder#setAuthentication(android.view.autofill.AutofillId[],
         * IntentSender, android.widget.RemoteViews) fill response authentication} was selected.
         */
        public static final int TYPE_AUTHENTICATION_SELECTED = 2;

+5 −5
Original line number Diff line number Diff line
@@ -533,9 +533,9 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill selection when an dataset authentication was selected.
     */
    void setDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId) {
    void logDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId) {
        synchronized (mLock) {
            if (isValidEventLocked("setDatasetAuthenticationSelected()", sessionId)) {
            if (isValidEventLocked("logDatasetAuthenticationSelected()", sessionId)) {
                mEventHistory.addEvent(
                        new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset));
            }
@@ -545,9 +545,9 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill selection when an save Ui is shown.
     */
    void setSaveShown(int sessionId) {
    void logSaveShown(int sessionId) {
        synchronized (mLock) {
            if (isValidEventLocked("setSaveShown()", sessionId)) {
            if (isValidEventLocked("logSaveShown()", sessionId)) {
                mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null));
            }
        }
@@ -556,7 +556,7 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill response when a dataset was selected.
     */
    void setDatasetSelected(@Nullable String selectedDataset, int sessionId) {
    void logDatasetSelected(@Nullable String selectedDataset, int sessionId) {
        synchronized (mLock) {
            if (isValidEventLocked("setDatasetSelected()", sessionId)) {
                mEventHistory.addEvent(new Event(Event.TYPE_DATASET_SELECTED, selectedDataset));
+8 −6
Original line number Diff line number Diff line
@@ -609,7 +609,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                return;
            }
        }
        mHandlerCaller.getHandler().post(() -> autoFill(requestId, datasetIndex, dataset));
        mHandlerCaller.getHandler().post(() -> autoFill(requestId, datasetIndex, dataset, true));
    }

    // AutoFillUiCallback
@@ -747,7 +747,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            if (datasetIdx != AutofillManager.AUTHENTICATION_ID_DATASET_ID_UNDEFINED) {
                final Dataset dataset = (Dataset) result;
                authenticatedResponse.getDatasets().set(datasetIdx, dataset);
                autoFill(requestId, datasetIdx, dataset);
                autoFill(requestId, datasetIdx, dataset, false);
            }
        } else {
            if (result != null) {
@@ -967,7 +967,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                }

                if (sDebug) Slog.d(TAG, "Good news, everyone! All checks passed, show save UI!");
                mService.setSaveShown(id);
                mService.logSaveShown(id);
                final IAutoFillManagerClient client = getClient();
                mPendingSaveUi = new PendingUi(mActivityToken, id, client);
                getUiForShowing().showSaveUi(mService.getServiceLabel(), saveInfo,
@@ -1536,7 +1536,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        return viewState;
    }

    void autoFill(int requestId, int datasetIndex, Dataset dataset) {
    void autoFill(int requestId, int datasetIndex, Dataset dataset, boolean generateEvent) {
        synchronized (mLock) {
            if (mDestroyed) {
                Slog.w(TAG, "Call to Session#autoFill() rejected - session: "
@@ -1545,14 +1545,16 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            }
            // Autofill it directly...
            if (dataset.getAuthentication() == null) {
                mService.setDatasetSelected(dataset.getId(), id);
                if (generateEvent) {
                    mService.logDatasetSelected(dataset.getId(), id);
                }

                autoFillApp(dataset);
                return;
            }

            // ...or handle authentication.
            mService.setDatasetAuthenticationSelected(dataset.getId(), id);
            mService.logDatasetAuthenticationSelected(dataset.getId(), id);
            setViewStatesLocked(null, dataset, ViewState.STATE_WAITING_DATASET_AUTH, false);
            final Intent fillInIntent = createAuthFillInIntentLocked(requestId, mClientState);