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

Commit 3f38c264 authored by jiewenlei's avatar jiewenlei Committed by Jiewen Lei
Browse files

Rmove the client suggestions APIs and related codes.

Test: atest CtsAutoFillServiceTestCases
Bug: 301307224
Bug: 296484290
Bug: 288109790
Change-Id: I900b3584e743a70fe42aaf8a3b886c0f6f344375
parent eb7e841e
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -54652,7 +54652,6 @@ package android.view.autofill {
  public final class AutofillManager {
    method public void cancel();
    method public void clearAutofillRequestCallback();
    method public void commit();
    method public void disableAutofillServices();
    method @Nullable public android.content.ComponentName getAutofillServiceComponentName();
@@ -54679,7 +54678,6 @@ package android.view.autofill {
    method public void registerCallback(@Nullable android.view.autofill.AutofillManager.AutofillCallback);
    method public void requestAutofill(@NonNull android.view.View);
    method public void requestAutofill(@NonNull android.view.View, int, @NonNull android.graphics.Rect);
    method @RequiresPermission(android.Manifest.permission.PROVIDE_OWN_AUTOFILL_SUGGESTIONS) public void setAutofillRequestCallback(@NonNull java.util.concurrent.Executor, @NonNull android.view.autofill.AutofillRequestCallback);
    method public void setUserData(@Nullable android.service.autofill.UserData);
    method public boolean showAutofillDialog(@NonNull android.view.View);
    method public boolean showAutofillDialog(@NonNull android.view.View, int);
@@ -54700,10 +54698,6 @@ package android.view.autofill {
    field public static final int EVENT_INPUT_UNAVAILABLE = 3; // 0x3
  }
  public interface AutofillRequestCallback {
    method public void onFillRequest(@Nullable android.view.inputmethod.InlineSuggestionsRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.FillCallback);
  }
  public final class AutofillValue implements android.os.Parcelable {
    method public int describeContents();
    method public static android.view.autofill.AutofillValue forDate(long);
@@ -55155,12 +55149,10 @@ package android.view.inputmethod {
    ctor public InlineSuggestionsRequest.Builder(@NonNull java.util.List<android.widget.inline.InlinePresentationSpec>);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder addInlinePresentationSpecs(@NonNull android.widget.inline.InlinePresentationSpec);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest build();
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setClientSupported(boolean);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setExtras(@NonNull android.os.Bundle);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(@NonNull java.util.List<android.widget.inline.InlinePresentationSpec>);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setInlineTooltipPresentationSpec(@NonNull android.widget.inline.InlinePresentationSpec);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setMaxSuggestionCount(int);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setServiceSupported(boolean);
    method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setSupportedLocales(@NonNull android.os.LocaleList);
  }
+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 −99
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;
@@ -31,12 +30,10 @@ 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;
import android.annotation.RequiresFeature;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.annotation.SystemService;
import android.annotation.TestApi;
@@ -53,19 +50,15 @@ 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.Flags;
import android.service.autofill.IFillCallback;
@@ -89,7 +82,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;
@@ -119,7 +111,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;

import sun.misc.Cleaner;
@@ -189,12 +180,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.
@@ -334,7 +319,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;
@@ -676,11 +660,6 @@ public final class AutofillManager {
    @GuardedBy("mLock")
    private boolean mEnabledForAugmentedAutofillOnly;

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

    private boolean mScreenHasCredmanField;

    /**
@@ -2434,38 +2413,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.
     */
    @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.
     */
    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) {
@@ -2526,13 +2473,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,
@@ -2890,28 +2830,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 */
@@ -4494,23 +4412,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 −72
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.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.
 */
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;
@@ -148,12 +146,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