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

Commit 8fc813fe authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Automerger Merge Worker
Browse files

Merge "Do not replace the authenticated dataset for pinned inline suggestion"...

Merge "Do not replace the authenticated dataset for pinned inline suggestion" into rvc-dev am: 913b610e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12001033

Change-Id: I0a0b42281ddb7999be201abcc5338b30ea3fa755
parents 95954faf 913b610e
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -312,7 +312,12 @@ public final class Dataset implements Parcelable {
         * setting it to the {@link
         * android.view.autofill.AutofillManager#EXTRA_AUTHENTICATION_RESULT} extra. If you
         * provide a dataset in the result, it will replace the authenticated dataset and
         * will be immediately filled in. If you provide a response, it will replace the
         * will be immediately filled in. An exception to this behavior is if the original
         * dataset represents a pinned inline suggestion (i.e. any of the field in the dataset
         * has a pinned inline presentation, see {@link InlinePresentation#isPinned()}), then
         * the original dataset will not be replaced,
         * so that it can be triggered as a pending intent again.
         * If you provide a response, it will replace the
         * current response and the UI will be refreshed. For example, if you provided
         * credit card information without the CVV for the data set in the {@link FillResponse
         * response} then the returned data set should contain the CVV entry.
+16 −4
Original line number Diff line number Diff line
@@ -50,7 +50,11 @@ public final class InlinePresentation implements Parcelable {

    /**
     * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
     * host.
     * host. However, it's eventually up to the host whether the UI is pinned or not.
     *
     * <p> Also a {@link Dataset} with a pinned inline presentation will not be replaced by the
     * new data set returned from authentication intent. See
     * {@link Dataset.Builder#setAuthentication(android.content.IntentSender)} for more information.
     */
    private final boolean mPinned;

@@ -90,7 +94,11 @@ public final class InlinePresentation implements Parcelable {
     *   Specifies the UI specification for the inline suggestion.
     * @param pinned
     *   Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
     *   host.
     *   host. However, it's eventually up to the host whether the UI is pinned or not.
     *
     *   <p> Also a {@link Dataset} with a pinned inline presentation will not be replaced by the
     *   new data set returned from authentication intent. See
     *   {@link Dataset.Builder#setAuthentication(android.content.IntentSender)} for more information.
     */
    @DataClass.Generated.Member
    public InlinePresentation(
@@ -126,7 +134,11 @@ public final class InlinePresentation implements Parcelable {

    /**
     * Indicates whether the UI should be pinned, hence non-scrollable and non-filterable, in the
     * host.
     * host. However, it's eventually up to the host whether the UI is pinned or not.
     *
     * <p> Also a {@link Dataset} with a pinned inline presentation will not be replaced by the
     * new data set returned from authentication intent. See
     * {@link Dataset.Builder#setAuthentication(android.content.IntentSender)} for more information.
     */
    @DataClass.Generated.Member
    public boolean isPinned() {
@@ -232,7 +244,7 @@ public final class InlinePresentation implements Parcelable {
    };

    @DataClass.Generated(
            time = 1586992400667L,
            time = 1593131904745L,
            codegenVersion = "1.0.15",
            sourceFile = "frameworks/base/core/java/android/service/autofill/InlinePresentation.java",
            inputSignatures = "private final @android.annotation.NonNull android.app.slice.Slice mSlice\nprivate final @android.annotation.NonNull android.widget.inline.InlinePresentationSpec mInlinePresentationSpec\nprivate final  boolean mPinned\npublic @android.annotation.NonNull @android.annotation.Size(min=0L) java.lang.String[] getAutofillHints()\nclass InlinePresentation extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)")
+26 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import android.service.autofill.FieldClassificationUserData;
import android.service.autofill.FillContext;
import android.service.autofill.FillRequest;
import android.service.autofill.FillResponse;
import android.service.autofill.InlinePresentation;
import android.service.autofill.InternalSanitizer;
import android.service.autofill.InternalValidator;
import android.service.autofill.SaveInfo;
@@ -1437,7 +1438,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    mClientState = newClientState;
                }
                final Dataset dataset = (Dataset) result;
                final Dataset oldDataset = authenticatedResponse.getDatasets().get(datasetIdx);
                if (!isPinnedDataset(oldDataset)) {
                    authenticatedResponse.getDatasets().set(datasetIdx, dataset);
                }
                autoFill(requestId, datasetIdx, dataset, false);
            } else {
                Slog.w(TAG, "invalid index (" + datasetIdx + ") for authentication id "
@@ -1455,6 +1459,27 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        }
    }

    /**
     * A dataset can potentially have multiple fields, and it's possible that some of the fields'
     * has inline presentation and some don't. It's also possible that some of the fields'
     * inline presentation is pinned and some isn't. So the concept of whether a dataset is
     * pinned or not is ill-defined. Here we say a dataset is pinned if any of the field has a
     * pinned inline presentation in the dataset. It's not ideal but hopefully it is sufficient
     * for most of the cases.
     */
    private static boolean isPinnedDataset(@Nullable Dataset dataset) {
        if (dataset != null && dataset.getFieldIds() != null) {
            final int numOfFields = dataset.getFieldIds().size();
            for (int i = 0; i < numOfFields; i++) {
                final InlinePresentation inlinePresentation = dataset.getFieldInlinePresentation(i);
                if (inlinePresentation != null && inlinePresentation.isPinned()) {
                    return true;
                }
            }
        }
        return false;
    }

    @GuardedBy("mLock")
    void setAuthenticationResultForAugmentedAutofillLocked(Bundle data, int authId) {
        final Dataset dataset = (data == null) ? null :