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

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

Merge "Few improvements on Augmented Autofill."

parents 9da2ff0f bf93cdcb
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4992,6 +4992,7 @@ package android.service.intelligence {
  }

  public final class FillRequest {
    method public android.view.autofill.AutofillValue getFocusedAutofillValue();
    method public android.view.autofill.AutofillId getFocusedId();
    method public android.service.intelligence.PresentationParams getPresentationParams();
    method public android.service.intelligence.InteractionSessionId getSessionId();
+7 −1
Original line number Diff line number Diff line
@@ -15,8 +15,10 @@
 */
package android.service.intelligence;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.service.intelligence.SmartSuggestionsService.AutofillProxy;

/**
 * Callback used to indicate at {@link FillRequest} has been fulfilled.
@@ -25,8 +27,11 @@ import android.annotation.SystemApi;
 */
@SystemApi
public final class FillCallback {
    private final AutofillProxy mProxy;

    FillCallback() {}
    FillCallback(@NonNull AutofillProxy proxy) {
        mProxy = proxy;
    }

    /**
     * Sets the response associated with the request.
@@ -35,6 +40,7 @@ public final class FillCallback {
     * could not provide autofill for the request.
     */
    public void onSuccess(@Nullable FillResponse response) {
        mProxy.report(AutofillProxy.REPORT_EVENT_ON_SUCCESS);
        final FillWindow fillWindow = response.getFillWindow();
        if (fillWindow != null) {
            fillWindow.show();
+9 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.service.intelligence.SmartSuggestionsService.AutofillProxy;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;

/**
 * Represents a request to augment-fill an activity.
@@ -51,6 +52,14 @@ public final class FillRequest {
        return mProxy.focusedId;
    }

    /**
     * Gets the current value of the field that triggered the request.
     */
    @NonNull
    public AutofillValue getFocusedAutofillValue() {
        return mProxy.focusedValue;
    }

    /**
     * Gets the Smart Suggestions object used to embed the autofill UI.
     *
+32 −6
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.annotation.SystemApi;
import android.app.Dialog;
import android.graphics.Rect;
import android.service.intelligence.PresentationParams.Area;
import android.service.intelligence.SmartSuggestionsService.AutofillProxy;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
@@ -33,6 +34,8 @@ import android.view.WindowManager;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.Preconditions;

import dalvik.system.CloseGuard;

import java.io.PrintWriter;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -73,6 +76,7 @@ public final class FillWindow {
    @interface Flags{}

    private final Object mLock = new Object();
    private final CloseGuard mCloseGuard = CloseGuard.get();

    @GuardedBy("mLock")
    private Dialog mDialog;
@@ -80,6 +84,8 @@ public final class FillWindow {
    @GuardedBy("mLock")
    private boolean mDestroyed;

    private AutofillProxy mProxy;

    /**
     * Updates the content of the window.
     *
@@ -123,6 +129,8 @@ public final class FillWindow {
        synchronized (mLock) {
            checkNotDestroyedLocked();

            mProxy = area.proxy;

            // TODO(b/111330312): once we have the SurfaceControl approach, we should update the
            // window instead of destroying. In fact, it might be better to allocate a full window
            // initially, which is transparent (and let touches get through) everywhere but in the
@@ -133,6 +141,7 @@ public final class FillWindow {
            // etc.

            mDialog = new Dialog(rootView.getContext());
            mCloseGuard.open("destroy");
            final Window window = mDialog.getWindow();
            window.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);

@@ -156,7 +165,7 @@ public final class FillWindow {
                Log.d(TAG, "Created FillWindow: params= " + smartSuggestion + " view=" + rootView);
            }

            area.proxy.setFillWindow(this);
            mProxy.setFillWindow(this);
            return true;
        }
    }
@@ -173,6 +182,9 @@ public final class FillWindow {
            }

            mDialog.show();
            if (mProxy != null) {
                mProxy.report(AutofillProxy.REPORT_EVENT_UI_SHOWN);
            }
        }
    }

@@ -182,15 +194,29 @@ public final class FillWindow {
     * <p>Once destroyed, this window cannot be used anymore
     */
    public void destroy() {
        if (DEBUG) Log.d(TAG, "destroy(): mDestroyed = " + mDestroyed);
        if (DEBUG) Log.d(TAG, "destroy(): mDestroyed=" + mDestroyed + " mDialog=" + mDialog);

        synchronized (this) {
            if (mDestroyed) return;
            if (mDestroyed || mDialog == null) return;

            if (mDialog != null) {
            mDialog.dismiss();
            mDialog = null;
            if (mProxy != null) {
                mProxy.report(AutofillProxy.REPORT_EVENT_UI_DESTROYED);
            }
            mCloseGuard.close();
        }
    }

    @Override
    protected void finalize() throws Throwable {
        try {
            if (mCloseGuard != null) {
                mCloseGuard.warnIfOpen();
            }
            destroy();
        } finally {
            super.finalize();
        }
    }

+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.service.intelligence.InteractionContext;
import android.service.intelligence.SnapshotData;

import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
import android.view.intelligence.ContentCaptureEvent;

import java.util.List;
@@ -45,7 +46,8 @@ oneway interface IIntelligenceService {
                            in SnapshotData snapshotData);

    void onAutofillRequest(in InteractionSessionId sessionId, in IBinder autofillManagerClient,
                           int autofilSessionId, in AutofillId focusedId);
                           int autofilSessionId, in AutofillId focusedId,
                           in AutofillValue focusedValue, long requestTime);

    void onDestroyAutofillWindowsRequest(in InteractionSessionId sessionId);
}
Loading