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

Commit b24c6401 authored by jiewenlei's avatar jiewenlei Committed by Automerger Merge Worker
Browse files

[DO NOT MERGE] Remove the Client Suggestions APIs. am: bcbec84f

parents b5d75473 bcbec84f
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -3632,18 +3632,12 @@ package android.view.autofill {
  }

  public final class AutofillManager {
    method public void clearAutofillRequestCallback();
    method @RequiresPermission(android.Manifest.permission.PROVIDE_OWN_AUTOFILL_SUGGESTIONS) public void setAutofillRequestCallback(@NonNull java.util.concurrent.Executor, @NonNull android.view.autofill.AutofillRequestCallback);
    field public static final String ANY_HINT = "any";
    field public static final int FLAG_SMART_SUGGESTION_OFF = 0; // 0x0
    field public static final int FLAG_SMART_SUGGESTION_SYSTEM = 1; // 0x1
    field public static final int MAX_TEMP_AUGMENTED_SERVICE_DURATION_MS = 120000; // 0x1d4c0
  }

  public interface AutofillRequestCallback {
    method public void onFillRequest(@Nullable android.view.inputmethod.InlineSuggestionsRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.FillCallback);
  }

}

package android.view.contentcapture {
@@ -3767,11 +3761,6 @@ package android.view.inputmethod {
    method @NonNull public static android.view.inputmethod.InlineSuggestionInfo newInlineSuggestionInfo(@NonNull android.widget.inline.InlinePresentationSpec, @NonNull String, @Nullable String[], @NonNull String, boolean);
  }

  public static final class InlineSuggestionsRequest.Builder {
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setClientSupported(boolean);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setServiceSupported(boolean);
  }

  public final class InlineSuggestionsResponse implements android.os.Parcelable {
    method @NonNull public static android.view.inputmethod.InlineSuggestionsResponse newInlineSuggestionsResponse(@NonNull java.util.List<android.view.inputmethod.InlineSuggestion>);
  }
+0 −2
Original line number Diff line number Diff line
@@ -97,8 +97,6 @@ public final class FillRequest implements Parcelable {
     */
    public static final @RequestFlags int FLAG_VIEW_NOT_FOCUSED = 0x10;

    // The flag value 0x20 has been defined in AutofillManager.

    /**
     * Indicates the request supports fill dialog presentation for the fields, the
     * system will send the request when the activity just started.
+0 −104
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.view.autofill;

import static android.Manifest.permission.PROVIDE_OWN_AUTOFILL_SUGGESTIONS;
import static android.service.autofill.FillRequest.FLAG_IME_SHOWING;
import static android.service.autofill.FillRequest.FLAG_MANUAL_REQUEST;
import static android.service.autofill.FillRequest.FLAG_PASSWORD_INPUT_TYPE;
@@ -30,7 +29,6 @@ import static android.view.autofill.Helper.sVerbose;
import static android.view.autofill.Helper.toList;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -52,21 +50,16 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Rect;
import android.metrics.LogMaker;
import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.IBinder;
import android.os.ICancellationSignal;
import android.os.Looper;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import android.service.autofill.AutofillService;
import android.service.autofill.FillCallback;
import android.service.autofill.FillEventHistory;
import android.service.autofill.IFillCallback;
import android.service.autofill.UserData;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -87,7 +80,6 @@ import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.accessibility.AccessibilityWindowInfo;
import android.view.inputmethod.InlineSuggestionsRequest;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.DatePicker;
@@ -187,12 +179,6 @@ import sun.misc.Cleaner;
 * shows an autofill save UI if the value of savable views have changed. If the user selects the
 * option to Save, the current value of the views is then sent to the autofill service.
 *
 * <p>There is another choice for the application to provide it's datasets to the Autofill framework
 * by setting an {@link AutofillRequestCallback} through
 * {@link #setAutofillRequestCallback(Executor, AutofillRequestCallback)}. The application can use
 * its callback instead of the default {@link AutofillService}. See
 * {@link AutofillRequestCallback} for more details.
 *
 * <h3 id="additional-notes">Additional notes</h3>
 *
 * <p>It is safe to call <code>AutofillManager</code> methods from any thread.
@@ -326,7 +312,6 @@ public final class AutofillManager {
    /** @hide */ public static final int FLAG_ADD_CLIENT_DEBUG = 0x2;
    /** @hide */ public static final int FLAG_ADD_CLIENT_VERBOSE = 0x4;
    /** @hide */ public static final int FLAG_ADD_CLIENT_ENABLED_FOR_AUGMENTED_AUTOFILL_ONLY = 0x8;
    /** @hide */ public static final int FLAG_ENABLED_CLIENT_SUGGESTIONS = 0x20;

    // NOTE: flag below is used by the session start receiver only, hence it can have values above
    /** @hide */ public static final int RECEIVER_FLAG_SESSION_FOR_AUGMENTED_AUTOFILL_ONLY = 0x1;
@@ -653,11 +638,6 @@ public final class AutofillManager {
    @GuardedBy("mLock")
    private boolean mEnabledForAugmentedAutofillOnly;

    @GuardedBy("mLock")
    @Nullable private AutofillRequestCallback mAutofillRequestCallback;
    @GuardedBy("mLock")
    @Nullable private Executor mRequestCallbackExecutor;

    /**
     * Indicates whether there is already a field to do a fill request after
     * the activity started.
@@ -2338,44 +2318,6 @@ public final class AutofillManager {
        return new AutofillId(parent.getAutofillViewId(), virtualId);
    }

    /**
     * Sets the client's suggestions callback for autofill.
     *
     * @see AutofillRequestCallback
     *
     * @param executor specifies the thread upon which the callbacks will be invoked.
     * @param callback which handles autofill request to provide client's suggestions.
     *
     * @hide
     */
    @TestApi
    @RequiresPermission(PROVIDE_OWN_AUTOFILL_SUGGESTIONS)
    public void setAutofillRequestCallback(@NonNull @CallbackExecutor Executor executor,
            @NonNull AutofillRequestCallback callback) {
        if (mContext.checkSelfPermission(PROVIDE_OWN_AUTOFILL_SUGGESTIONS)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Requires PROVIDE_OWN_AUTOFILL_SUGGESTIONS permission!");
        }

        synchronized (mLock) {
            mRequestCallbackExecutor = executor;
            mAutofillRequestCallback = callback;
        }
    }

    /**
     * clears the client's suggestions callback for autofill.
     *
     * @hide
     */
    @TestApi
    public void clearAutofillRequestCallback() {
        synchronized (mLock) {
            mRequestCallbackExecutor = null;
            mAutofillRequestCallback = null;
        }
    }

    @GuardedBy("mLock")
    private void startSessionLocked(@NonNull AutofillId id, @NonNull Rect bounds,
            @NonNull AutofillValue value, int flags) {
@@ -2436,13 +2378,6 @@ public final class AutofillManager {
                }
            }

            if (mAutofillRequestCallback != null) {
                if (sDebug) {
                    Log.d(TAG, "startSession with the client suggestions provider");
                }
                flags |= FLAG_ENABLED_CLIENT_SUGGESTIONS;
            }

            mService.startSession(client.autofillClientGetActivityToken(),
                    mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
                    mCallback != null, flags, clientActivity,
@@ -2796,28 +2731,6 @@ public final class AutofillManager {
        }
    }

    private void onFillRequest(InlineSuggestionsRequest request,
            CancellationSignal cancellationSignal, FillCallback callback) {
        final AutofillRequestCallback autofillRequestCallback;
        final Executor executor;
        synchronized (mLock) {
            autofillRequestCallback = mAutofillRequestCallback;
            executor = mRequestCallbackExecutor;
        }
        if (autofillRequestCallback != null && executor != null) {
            final long ident = Binder.clearCallingIdentity();
            try {
                executor.execute(() ->
                        autofillRequestCallback.onFillRequest(
                                request, cancellationSignal, callback));
            } finally {
                Binder.restoreCallingIdentity(ident);
            }
        } else {
            callback.onSuccess(null);
        }
    }

    /** @hide */
    public static final int SET_STATE_FLAG_ENABLED = 0x01;
    /** @hide */
@@ -4373,23 +4286,6 @@ public final class AutofillManager {
            }
        }

        @Override
        public void requestFillFromClient(int id, InlineSuggestionsRequest request,
                IFillCallback callback) {
            final AutofillManager afm = mAfm.get();
            if (afm != null) {
                ICancellationSignal transport = CancellationSignal.createTransport();
                try {
                    callback.onCancellable(transport);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Error requesting a cancellation", e);
                }

                afm.onFillRequest(request, CancellationSignal.fromTransport(transport),
                        new FillCallback(callback, id));
            }
        }

        @Override
        public void notifyFillDialogTriggerIds(List<AutofillId> ids) {
            final AutofillManager afm = mAfm.get();
+0 −76
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.autofill;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.os.CancellationSignal;
import android.service.autofill.FillCallback;
import android.view.inputmethod.InlineSuggestionsRequest;

/**
 * <p>This class is used to provide some input suggestions to the Autofill framework.
 *
 * <P>When the user is requested to input something, Autofill will try to query input suggestions
 * for the user choosing. If the application want to provide some internal input suggestions,
 * implements this callback and register via
 * {@link AutofillManager#setAutofillRequestCallback(java.util.concurrent.Executor,
 * AutofillRequestCallback)}. Autofill will callback the
 * {@link #onFillRequest(InlineSuggestionsRequest, CancellationSignal, FillCallback)} to request
 * input suggestions.
 *
 * <P>To make sure the callback to take effect, must register before the autofill session starts.
 * If the autofill session is started, calls {@link AutofillManager#cancel()} to finish current
 * session, and then the callback will be used at the next restarted session.
 *
 * <P>To create a {@link android.service.autofill.FillResponse}, application should fetch
 * {@link AutofillId}s from its view structure. Below is an example:
 * <pre class="prettyprint">
 * AutofillId usernameId = findViewById(R.id.username).getAutofillId();
 * AutofillId passwordId = findViewById(R.id.password).getAutofillId();
 * </pre>
 * To learn more about creating a {@link android.service.autofill.FillResponse}, read
 * <a href="/guide/topics/text/autofill-services#fill">Fill out client views</a>.
 *
 * <P>To fallback to the default {@link android.service.autofill.AutofillService}, just respond
 * a null of the {@link android.service.autofill.FillResponse}. And then Autofill will do a fill
 * request with the default {@link android.service.autofill.AutofillService}. Or clear the callback
 * from {@link AutofillManager} via {@link AutofillManager#clearAutofillRequestCallback()}. If the
 * client would like to keep no suggestions for the field, respond with an empty
 * {@link android.service.autofill.FillResponse} which has no dataset.
 *
 * <P>IMPORTANT: This should not be used for displaying anything other than input suggestions, or
 * the keyboard may choose to block your app from the inline strip.
 *
 * @hide
 */
@TestApi
public interface AutofillRequestCallback {
    /**
     * Called by the Android system to decide if a screen can be autofilled by the callback.
     *
     * @param inlineSuggestionsRequest the {@link InlineSuggestionsRequest request} to handle if
     *     currently inline suggestions are supported and can be displayed.
     * @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
     *     handling this fill request in order to save resources.
     * @param callback object used to notify the result of the request.
     */
    void onFillRequest(@Nullable InlineSuggestionsRequest inlineSuggestionsRequest,
            @NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback);
}
+0 −8
Original line number Diff line number Diff line
@@ -24,11 +24,9 @@ import android.content.Intent;
import android.content.IntentSender;
import android.graphics.Rect;
import android.os.IBinder;
import android.service.autofill.IFillCallback;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
import android.view.autofill.IAutofillWindowPresenter;
import android.view.inputmethod.InlineSuggestionsRequest;
import android.view.KeyEvent;

import com.android.internal.os.IResultReceiver;
@@ -143,12 +141,6 @@ oneway interface IAutoFillManagerClient {
    */
   void requestShowSoftInput(in AutofillId id);

    /**
     * Requests to determine if a screen can be autofilled by the client app.
     */
    void requestFillFromClient(int id, in InlineSuggestionsRequest request,
            in IFillCallback callback);

    /**
     * Notifies autofill ids that require to show the fill dialog.
     */
Loading