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

Commit 98367aef authored by Feng Cao's avatar Feng Cao Committed by Android (Google) Code Review
Browse files

Merge "Make autofill requested by augmented autofill service non-manual" into rvc-dev

parents cd0281ea 08abd46f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -163,14 +163,18 @@ public abstract class AugmentedAutofillService extends Service {
    }

    /**
     * The child class of the service can call this method to initiate an Autofill flow.
     * The child class of the service can call this method to initiate a new Autofill flow. If all
     * conditions are met, it will make a request to the client app process to explicitly cancel
     * the current autofill session and create a new session. For example, an augmented autofill
     * service may notice some events which make it think a good time to provide updated
     * augmented autofill suggestions.
     *
     * <p> The request would be respected only if the previous augmented autofill request was
     * made for the same {@code activityComponent} and {@code autofillId}, and the field is
     * currently on focus.
     *
     * <p> The request would start a new autofill flow. It doesn't guarantee that the
     * {@link AutofillManager} will proceed with the request.
     * <p> The request would cancel the current session and start a new autofill flow.
     * It doesn't guarantee that the {@link AutofillManager} will proceed with the request.
     *
     * @param activityComponent the client component for which the autofill is requested for
     * @param autofillId        the client field id for which the autofill is requested for
@@ -179,8 +183,6 @@ public abstract class AugmentedAutofillService extends Service {
     */
    public final boolean requestAutofill(@NonNull ComponentName activityComponent,
            @NonNull AutofillId autofillId) {
        // TODO(b/149531989): revisit this. The request should start a new autofill session
        //  rather than reusing the existing session.
        final AutofillProxy proxy = mAutofillProxyForLastRequest;
        if (proxy == null || !proxy.mComponentName.equals(activityComponent)
                || !proxy.mFocusedId.equals(autofillId)) {
+21 −2
Original line number Diff line number Diff line
@@ -882,6 +882,25 @@ public final class AutofillManager {
        notifyViewEntered(view, FLAG_MANUAL_REQUEST);
    }

    /**
     * Explicitly cancels the current session and requests a new autofill context.
     *
     * <p>Normally, the autofill context is automatically started if necessary when
     * {@link #notifyViewEntered(View)} is called, but this method should be used in
     * cases where it must be explicitly started or restarted. Currently, this method should only
     * be called by
     * {@link android.service.autofill.augmented.AugmentedAutofillService#requestAutofill(
     * ComponentName, AutofillId)} to cancel the current session and trigger the autofill flow in
     * a new session, giving the autofill service or the augmented autofill service a chance to
     * send updated suggestions.
     *
     * @param view view requesting the new autofill context.
     */
    void requestAutofillFromNewSession(@NonNull View view) {
        cancel();
        notifyViewEntered(view);
    }

    /**
     * Explicitly requests a new autofill context for virtual views.
     *
@@ -1403,7 +1422,7 @@ public final class AutofillManager {
     * methods such as {@link android.app.Activity#finish()}.
     */
    public void cancel() {
        if (sVerbose) Log.v(TAG, "cancel() called by app");
        if (sVerbose) Log.v(TAG, "cancel() called by app or augmented autofill service");
        if (!hasAutofillFeature()) {
            return;
        }
@@ -3484,7 +3503,7 @@ public final class AutofillManager {
            if (sVerbose) {
                Log.v(TAG, "requestAutofill() by AugmentedAutofillService.");
            }
            afm.post(() -> afm.requestAutofill(view));
            afm.post(() -> afm.requestAutofillFromNewSession(view));
            return true;
        }