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

Commit 3dac19b0 authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

Merge "Pass FillResponse bundle on subsequent onFillRequest() calls." into oc-dev

am: 84705f9f

Change-Id: I044ab29d793b8fa5a1ce7830e61205b8240f2fef
parents 7e3af23c 84705f9f
Loading
Loading
Loading
Loading
+12 −10
Original line number Diff line number Diff line
@@ -204,11 +204,12 @@ public abstract class AutofillService extends Service {
     * to notify the result of the request.
     *
     * @param structure {@link Activity}'s view structure.
     * @param data bundle containing data passed by the service on previous calls to fill.
     *     This bundle allows your service to keep state between fill and save requests
     *     as well as when filling different sections of the UI as the system will try to
     *     aggressively unbind from the service to conserve resources. See {@link
     *     FillResponse} Javadoc for examples of multiple-sections requests.
     * @param data bundle containing data passed by the service in a last call to
     *        {@link FillResponse.Builder#setExtras(Bundle)}, if any. This bundle allows your
     *        service to keep state between fill and save requests as well as when filling different
     *        sections of the UI as the system will try to aggressively unbind from the service to
     *        conserve resources.
     *        See {@link FillResponse} for examples of multiple-sections requests.
     * @param flags either {@code 0} or {@link AutofillManager#FLAG_MANUAL_REQUEST}.
     * @param cancellationSignal signal for observing cancellation requests. The system will use
     *     this to notify you that the fill result is no longer needed and you should stop
@@ -242,11 +243,12 @@ public abstract class AutofillService extends Service {
     * to notify the result of the request.
     *
     * @param structure {@link Activity}'s view structure.
     * @param data bundle containing data passed by the service on previous calls to fill.
     *     This bundle allows your service to keep state between fill and save requests
     *     as well as when filling different sections of the UI as the system will try to
     *     aggressively unbind from the service to conserve resources. See {@link
     *     FillResponse} Javadoc for examples of multiple-sections requests.
     * @param data bundle containing data passed by the service in a last call to
     *        {@link FillResponse.Builder#setExtras(Bundle)}, if any. This bundle allows your
     *        service to keep state between fill and save requests as well as when filling different
     *        sections of the UI as the system will try to aggressively unbind from the service to
     *        conserve resources.
     *        See {@link FillResponse} for examples of multiple-sections requests.
     * @param callback object used to notify the result of the request.
     */
    public abstract void onSaveRequest(@NonNull AssistStructure structure, @Nullable Bundle data,
+3 −0
Original line number Diff line number Diff line
@@ -297,6 +297,9 @@ public final class FillResponse implements Parcelable {
         * android.os.CancellationSignal, FillCallback)} and {@link AutofillService#onSaveRequest(
         * android.app.assist.AssistStructure, Bundle, SaveCallback)}.
         *
         * <p>If this method is called on multiple {@link FillResponse} objects for the same
         * activity, just the latest bundle is passed back to the service.
         *
         * @param extras The response extras.
         * @return This builder.
         */
+1 −1
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ final class AutofillManagerServiceImpl {
                // TODO(b/33197203): since service is fetching the data (to use for save later),
                // we should optimize what's sent (for example, remove layout containers,
                // color / font info, etc...)
                session.mStructure = structure;
                session.setStructureLocked(structure);
            }


+19 −13
Original line number Diff line number Diff line
@@ -133,13 +133,21 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
     * Assist structure sent by the app; it will be updated (sanitized, change values for save)
     * before sent to {@link AutofillService}.
     */
    @GuardedBy("mLock") AssistStructure mStructure;
    @GuardedBy("mLock")
    private AssistStructure mStructure;

    /**
     * Whether the client has an {@link android.view.autofill.AutofillManager.AutofillCallback}.
     */
    private boolean mHasCallback;

    /**
     * Extras sent by service on {@code onFillRequest()} calls; the first non-null extra is saved
     * and used on subsequent {@code onFillRequest()} and {@code onSaveRequest()} calls.
     */
    @GuardedBy("mLock")
    private Bundle mExtras;

    /**
     * Flags used to start the session.
     */
@@ -353,6 +361,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
        mHasCallback = hasIt;
    }

    public void setStructureLocked(AssistStructure structure) {
        mStructure = structure;
    }

    /**
     * Shows the save UI, when session can be saved.
     *
@@ -475,9 +487,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            Slog.d(TAG, "callSaveLocked(): mViewStates=" + mViewStates);
        }

        // TODO(b/33197203 , b/35707731): decide how to handle bundle in multiple partitions
        final Bundle extras = mResponses != null ? mResponses.get(0).getExtras() : null;

        for (Entry<AutofillId, ViewState> entry : mViewStates.entrySet()) {
            final AutofillValue value = entry.getValue().getCurrentValue();
            if (value == null) {
@@ -507,7 +516,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mStructure.dump();
        }

        mRemoteFillService.onSaveRequest(mStructure, extras);
        mRemoteFillService.onSaveRequest(mStructure, mExtras);
    }

    void updateLocked(AutofillId id, Rect virtualBounds, AutofillValue value, int flags) {
@@ -593,13 +602,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                new ViewState(this, id, value, this,ViewState.STATE_STARTED_PARTITION);
        mViewStates.put(id, newViewState);

        /*
         * TODO(b/33197203 , b/35707731): when start a new partition, it should
         *
         * - pass the first onFillRequest() bundle
         * - optional: perhaps add a new flag onFilLRequest() to indicate it's a new partition?
         */

        // Must update value of nodes so:
        // - proper node is focused
        // - autofillValue is sent back to service when it was previously autofilled
@@ -621,7 +623,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            overlay.focused = id.equals(viewState.id);
            node.setAutofillOverlay(overlay);
        }
        mRemoteFillService.onFillRequest(mStructure, null, 0);
        mRemoteFillService.onFillRequest(mStructure, mExtras, 0);

        return newViewState;
    }
@@ -671,6 +673,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            mResponses = new ArrayList<>(4);
        }
        mResponses.add(response);
        if (response != null) {
            mExtras = response.getExtras();
        }

        setViewStatesLocked(response, ViewState.STATE_FILLABLE);

@@ -812,6 +817,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            }
        }
        pw.print(prefix); pw.print("mHasCallback: "); pw.println(mHasCallback);
        pw.print(prefix); pw.print("mExtras: "); pw.println(Helper.bundleToString(mExtras));
        mRemoteFillService.dump(prefix, pw);
    }