Merge changes from topic "revert-13738532-client_suggestions_fillrequest-sc-dev-EQZRQWLQUO" into sc-dev

* changes:
  [DO NOT MERGE] Remove the Client Suggestions APIs
  [DO NOT MERGE] Remove Client suggestions implementations
This commit is contained in:
TreeHugger Robot
2021-05-20 01:23:24 +00:00
committed by Android (Google) Code Review
8 changed files with 49 additions and 732 deletions

View File

@@ -51431,7 +51431,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();
@@ -51457,7 +51456,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 public void setAutofillRequestCallback(@NonNull java.util.concurrent.Executor, @NonNull android.view.autofill.AutofillRequestCallback);
method public void setUserData(@Nullable android.service.autofill.UserData);
method public void unregisterCallback(@Nullable android.view.autofill.AutofillManager.AutofillCallback);
field public static final String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
@@ -51476,10 +51474,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);
@@ -51850,12 +51844,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);
}

View File

@@ -96,8 +96,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.
/** @hide */
public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;

View File

@@ -25,7 +25,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;
@@ -46,21 +45,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;
@@ -80,7 +74,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.EditText;
import android.widget.TextView;
@@ -106,7 +99,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Executor;
import sun.misc.Cleaner;
@@ -175,12 +167,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.
@@ -306,7 +292,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;
@@ -607,11 +592,6 @@ public final class AutofillManager {
@GuardedBy("mLock")
private boolean mEnabledForAugmentedAutofillOnly;
@GuardedBy("mLock")
@Nullable private AutofillRequestCallback mAutofillRequestCallback;
@GuardedBy("mLock")
@Nullable private Executor mRequestCallbackExecutor;
/** @hide */
public interface AutofillClient {
/**
@@ -1856,32 +1836,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.
*/
public void setAutofillRequestCallback(@NonNull @CallbackExecutor Executor executor,
@NonNull AutofillRequestCallback callback) {
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) {
@@ -1942,13 +1896,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,
@@ -2298,28 +2245,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 */
@@ -3699,23 +3624,6 @@ public final class AutofillManager {
afm.post(() -> afm.requestShowSoftInput(id));
}
}
@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));
}
}
}
private static final class AugmentedAutofillManagerClient

View File

@@ -1,72 +0,0 @@
/*
* 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);
}

View File

@@ -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;
@@ -142,10 +140,4 @@ oneway interface IAutoFillManagerClient {
* Requests to show the soft input method if the focus is on the given id.
*/
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);
}

View File

@@ -110,22 +110,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
*/
private @Nullable InlinePresentationSpec mInlineTooltipPresentationSpec;
/**
* Whether the IME supports inline suggestions from the default Autofill service that
* provides the input view.
*
* Note: The default value is {@code true}.
*/
private boolean mServiceSupported;
/**
* Whether the IME supports inline suggestions from the application that provides the
* input view.
*
* Note: The default value is {@code true}.
*/
private boolean mClientSupported;
/**
* @hide
* @see {@link #mHostInputToken}.
@@ -220,14 +204,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
return Bundle.EMPTY;
}
private static boolean defaultServiceSupported() {
return true;
}
private static boolean defaultClientSupported() {
return true;
}
/** @hide */
abstract static class BaseBuilder {
abstract Builder setInlinePresentationSpecs(
@@ -240,25 +216,15 @@ public final class InlineSuggestionsRequest implements Parcelable {
abstract Builder setHostDisplayId(int value);
}
/** @hide */
public boolean isServiceSupported() {
return mServiceSupported;
}
/** @hide */
public boolean isClientSupported() {
return mClientSupported;
}
// Code below generated by codegen v1.0.22.
// Code below generated by codegen v1.0.23.
//
// DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code
//
// To regenerate run:
// $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
// $ codegen $ANDROID_BUILD_TOP/./frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
//
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
// Settings > Editor > Code Style > Formatter Control
@@ -274,9 +240,7 @@ public final class InlineSuggestionsRequest implements Parcelable {
@NonNull Bundle extras,
@Nullable IBinder hostInputToken,
int hostDisplayId,
@Nullable InlinePresentationSpec inlineTooltipPresentationSpec,
boolean serviceSupported,
boolean clientSupported) {
@Nullable InlinePresentationSpec inlineTooltipPresentationSpec) {
this.mMaxSuggestionCount = maxSuggestionCount;
this.mInlinePresentationSpecs = inlinePresentationSpecs;
com.android.internal.util.AnnotationValidations.validate(
@@ -293,8 +257,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
this.mHostInputToken = hostInputToken;
this.mHostDisplayId = hostDisplayId;
this.mInlineTooltipPresentationSpec = inlineTooltipPresentationSpec;
this.mServiceSupported = serviceSupported;
this.mClientSupported = clientSupported;
onConstructed();
}
@@ -378,9 +340,7 @@ public final class InlineSuggestionsRequest implements Parcelable {
}
/**
* The {@link InlinePresentationSpec} for the inline suggestion tooltip in the response.
*
* @see android.service.autofill.InlinePresentation#createTooltipPresentation(Slice, InlinePresentationSpec)
* Specifies the UI specification for the inline suggestion tooltip in the response.
*/
@DataClass.Generated.Member
public @Nullable InlinePresentationSpec getInlineTooltipPresentationSpec() {
@@ -401,9 +361,7 @@ public final class InlineSuggestionsRequest implements Parcelable {
"extras = " + mExtras + ", " +
"hostInputToken = " + mHostInputToken + ", " +
"hostDisplayId = " + mHostDisplayId + ", " +
"inlineTooltipPresentationSpec = " + mInlineTooltipPresentationSpec + ", " +
"serviceSupported = " + mServiceSupported + ", " +
"clientSupported = " + mClientSupported +
"inlineTooltipPresentationSpec = " + mInlineTooltipPresentationSpec +
" }";
}
@@ -427,9 +385,7 @@ public final class InlineSuggestionsRequest implements Parcelable {
&& extrasEquals(that.mExtras)
&& java.util.Objects.equals(mHostInputToken, that.mHostInputToken)
&& mHostDisplayId == that.mHostDisplayId
&& java.util.Objects.equals(mInlineTooltipPresentationSpec, that.mInlineTooltipPresentationSpec)
&& mServiceSupported == that.mServiceSupported
&& mClientSupported == that.mClientSupported;
&& java.util.Objects.equals(mInlineTooltipPresentationSpec, that.mInlineTooltipPresentationSpec);
}
@Override
@@ -447,8 +403,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
_hash = 31 * _hash + java.util.Objects.hashCode(mHostInputToken);
_hash = 31 * _hash + mHostDisplayId;
_hash = 31 * _hash + java.util.Objects.hashCode(mInlineTooltipPresentationSpec);
_hash = 31 * _hash + Boolean.hashCode(mServiceSupported);
_hash = 31 * _hash + Boolean.hashCode(mClientSupported);
return _hash;
}
@@ -459,8 +413,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
// void parcelFieldName(Parcel dest, int flags) { ... }
int flg = 0;
if (mServiceSupported) flg |= 0x100;
if (mClientSupported) flg |= 0x200;
if (mHostInputToken != null) flg |= 0x20;
if (mInlineTooltipPresentationSpec != null) flg |= 0x80;
dest.writeInt(flg);
@@ -486,8 +438,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
// static FieldType unparcelFieldName(Parcel in) { ... }
int flg = in.readInt();
boolean serviceSupported = (flg & 0x100) != 0;
boolean clientSupported = (flg & 0x200) != 0;
int maxSuggestionCount = in.readInt();
List<InlinePresentationSpec> inlinePresentationSpecs = new ArrayList<>();
in.readParcelableList(inlinePresentationSpecs, InlinePresentationSpec.class.getClassLoader());
@@ -514,8 +464,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
this.mHostInputToken = hostInputToken;
this.mHostDisplayId = hostDisplayId;
this.mInlineTooltipPresentationSpec = inlineTooltipPresentationSpec;
this.mServiceSupported = serviceSupported;
this.mClientSupported = clientSupported;
onConstructed();
}
@@ -549,8 +497,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
private @Nullable IBinder mHostInputToken;
private int mHostDisplayId;
private @Nullable InlinePresentationSpec mInlineTooltipPresentationSpec;
private boolean mServiceSupported;
private boolean mClientSupported;
private long mBuilderFieldsSet = 0L;
@@ -683,9 +629,7 @@ public final class InlineSuggestionsRequest implements Parcelable {
}
/**
* The {@link InlinePresentationSpec} for the inline suggestion tooltip in the response.
*
* @see android.service.autofill.InlinePresentation#createTooltipPresentation(Slice, InlinePresentationSpec)s
* Specifies the UI specification for the inline suggestion tooltip in the response.
*/
@DataClass.Generated.Member
public @NonNull Builder setInlineTooltipPresentationSpec(@NonNull InlinePresentationSpec value) {
@@ -695,38 +639,10 @@ public final class InlineSuggestionsRequest implements Parcelable {
return this;
}
/**
* Whether the IME supports inline suggestions from the default Autofill service that
* provides the input view.
*
* Note: The default value is {@code true}.
*/
@DataClass.Generated.Member
public @NonNull Builder setServiceSupported(boolean value) {
checkNotUsed();
mBuilderFieldsSet |= 0x100;
mServiceSupported = value;
return this;
}
/**
* Whether the IME supports inline suggestions from the application that provides the
* input view.
*
* Note: The default value is {@code true}.
*/
@DataClass.Generated.Member
public @NonNull Builder setClientSupported(boolean value) {
checkNotUsed();
mBuilderFieldsSet |= 0x200;
mClientSupported = value;
return this;
}
/** Builds the instance. This builder should not be touched after calling this! */
public @NonNull InlineSuggestionsRequest build() {
checkNotUsed();
mBuilderFieldsSet |= 0x400; // Mark builder used
mBuilderFieldsSet |= 0x100; // Mark builder used
if ((mBuilderFieldsSet & 0x1) == 0) {
mMaxSuggestionCount = defaultMaxSuggestionCount();
@@ -749,12 +665,6 @@ public final class InlineSuggestionsRequest implements Parcelable {
if ((mBuilderFieldsSet & 0x80) == 0) {
mInlineTooltipPresentationSpec = defaultInlineTooltipPresentationSpec();
}
if ((mBuilderFieldsSet & 0x100) == 0) {
mServiceSupported = defaultServiceSupported();
}
if ((mBuilderFieldsSet & 0x200) == 0) {
mClientSupported = defaultClientSupported();
}
InlineSuggestionsRequest o = new InlineSuggestionsRequest(
mMaxSuggestionCount,
mInlinePresentationSpecs,
@@ -763,14 +673,12 @@ public final class InlineSuggestionsRequest implements Parcelable {
mExtras,
mHostInputToken,
mHostDisplayId,
mInlineTooltipPresentationSpec,
mServiceSupported,
mClientSupported);
mInlineTooltipPresentationSpec);
return o;
}
private void checkNotUsed() {
if ((mBuilderFieldsSet & 0x400) != 0) {
if ((mBuilderFieldsSet & 0x100) != 0) {
throw new IllegalStateException(
"This Builder should not be reused. Use a new Builder instance instead");
}
@@ -778,10 +686,10 @@ public final class InlineSuggestionsRequest implements Parcelable {
}
@DataClass.Generated(
time = 1615798784918L,
codegenVersion = "1.0.22",
time = 1621415989607L,
codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java",
inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.widget.inline.InlinePresentationSpec> mInlinePresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.NonNull android.os.Bundle mExtras\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate int mHostDisplayId\nprivate @android.annotation.Nullable android.widget.inline.InlinePresentationSpec mInlineTooltipPresentationSpec\nprivate boolean mServiceSupported\nprivate boolean mClientSupported\nprivate static final @android.compat.annotation.ChangeId @android.compat.annotation.EnabledSince long IME_AUTOFILL_DEFAULT_SUPPORTED_LOCALES_IS_EMPTY\npublic void setHostInputToken(android.os.IBinder)\nprivate boolean extrasEquals(android.os.Bundle)\nprivate void parcelHostInputToken(android.os.Parcel,int)\nprivate @android.annotation.Nullable android.os.IBinder unparcelHostInputToken(android.os.Parcel)\npublic void setHostDisplayId(int)\nprivate void onConstructed()\npublic void filterContentTypes()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.widget.inline.InlinePresentationSpec defaultInlineTooltipPresentationSpec()\nprivate static android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable int defaultHostDisplayId()\nprivate static @android.annotation.NonNull android.os.Bundle defaultExtras()\nprivate static boolean defaultServiceSupported()\nprivate static boolean defaultClientSupported()\npublic boolean isServiceSupported()\npublic boolean isClientSupported()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []")
inputSignatures = "public static final int SUGGESTION_COUNT_UNLIMITED\nprivate final int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.widget.inline.InlinePresentationSpec> mInlinePresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.NonNull android.os.Bundle mExtras\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate int mHostDisplayId\nprivate @android.annotation.Nullable android.widget.inline.InlinePresentationSpec mInlineTooltipPresentationSpec\nprivate static final @android.compat.annotation.ChangeId @android.compat.annotation.EnabledSince long IME_AUTOFILL_DEFAULT_SUPPORTED_LOCALES_IS_EMPTY\npublic void setHostInputToken(android.os.IBinder)\nprivate boolean extrasEquals(android.os.Bundle)\nprivate void parcelHostInputToken(android.os.Parcel,int)\nprivate @android.annotation.Nullable android.os.IBinder unparcelHostInputToken(android.os.Parcel)\npublic void setHostDisplayId(int)\nprivate void onConstructed()\npublic void filterContentTypes()\nprivate static int defaultMaxSuggestionCount()\nprivate static java.lang.String defaultHostPackageName()\nprivate static android.widget.inline.InlinePresentationSpec defaultInlineTooltipPresentationSpec()\nprivate static android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable int defaultHostDisplayId()\nprivate static @android.annotation.NonNull android.os.Bundle defaultExtras()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []")
@Deprecated
private void __metadata() {}

View File

@@ -1,293 +0,0 @@
/*
* Copyright (C) 2021 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 com.android.server.autofill;
import static android.service.autofill.FillRequest.INVALID_REQUEST_ID;
import static com.android.server.autofill.Helper.sVerbose;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.ICancellationSignal;
import android.os.RemoteException;
import android.service.autofill.Dataset;
import android.service.autofill.FillResponse;
import android.service.autofill.IFillCallback;
import android.service.autofill.SaveInfo;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Slog;
import android.view.autofill.AutofillId;
import android.view.autofill.IAutoFillManagerClient;
import android.view.inputmethod.InlineSuggestionsRequest;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.infra.AndroidFuture;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
/**
* Maintains a client suggestions session with the
* {@link android.view.autofill.AutofillRequestCallback} through the {@link IAutoFillManagerClient}.
*
*/
final class ClientSuggestionsSession {
private static final String TAG = "ClientSuggestionsSession";
private static final long TIMEOUT_REMOTE_REQUEST_MILLIS = 15 * DateUtils.SECOND_IN_MILLIS;
private final int mSessionId;
private final IAutoFillManagerClient mClient;
private final Handler mHandler;
private final ComponentName mComponentName;
private final RemoteFillService.FillServiceCallbacks mCallbacks;
private final Object mLock = new Object();
@GuardedBy("mLock")
private AndroidFuture<FillResponse> mPendingFillRequest;
@GuardedBy("mLock")
private int mPendingFillRequestId = INVALID_REQUEST_ID;
ClientSuggestionsSession(int sessionId, IAutoFillManagerClient client, Handler handler,
ComponentName componentName, RemoteFillService.FillServiceCallbacks callbacks) {
mSessionId = sessionId;
mClient = client;
mHandler = handler;
mComponentName = componentName;
mCallbacks = callbacks;
}
void onFillRequest(int requestId, InlineSuggestionsRequest inlineRequest, int flags) {
final AtomicReference<ICancellationSignal> cancellationSink = new AtomicReference<>();
final AtomicReference<AndroidFuture<FillResponse>> futureRef = new AtomicReference<>();
final AndroidFuture<FillResponse> fillRequest = new AndroidFuture<>();
mHandler.post(() -> {
if (sVerbose) {
Slog.v(TAG, "calling onFillRequest() for id=" + requestId);
}
try {
mClient.requestFillFromClient(requestId, inlineRequest,
new FillCallbackImpl(fillRequest, futureRef, cancellationSink));
} catch (RemoteException e) {
fillRequest.completeExceptionally(e);
}
});
fillRequest.orTimeout(TIMEOUT_REMOTE_REQUEST_MILLIS, TimeUnit.MILLISECONDS);
futureRef.set(fillRequest);
synchronized (mLock) {
mPendingFillRequest = fillRequest;
mPendingFillRequestId = requestId;
}
fillRequest.whenComplete((res, err) -> mHandler.post(() -> {
synchronized (mLock) {
mPendingFillRequest = null;
mPendingFillRequestId = INVALID_REQUEST_ID;
}
if (err == null) {
processAutofillId(res);
mCallbacks.onFillRequestSuccess(requestId, res,
mComponentName.getPackageName(), flags);
} else {
Slog.e(TAG, "Error calling on client fill request", err);
if (err instanceof TimeoutException) {
dispatchCancellationSignal(cancellationSink.get());
mCallbacks.onFillRequestTimeout(requestId);
} else if (err instanceof CancellationException) {
dispatchCancellationSignal(cancellationSink.get());
} else {
mCallbacks.onFillRequestFailure(requestId, err.getMessage());
}
}
}));
}
/**
* Gets the application info for the component.
*/
@Nullable
static ApplicationInfo getAppInfo(ComponentName comp, @UserIdInt int userId) {
try {
ApplicationInfo si = AppGlobals.getPackageManager().getApplicationInfo(
comp.getPackageName(),
PackageManager.GET_META_DATA,
userId);
if (si != null) {
return si;
}
} catch (RemoteException e) {
}
return null;
}
/**
* Gets the user-visible name of the application.
*/
@Nullable
@GuardedBy("mLock")
static CharSequence getAppLabelLocked(Context context, ApplicationInfo appInfo) {
return appInfo == null ? null : appInfo.loadSafeLabel(
context.getPackageManager(), 0 /* do not ellipsize */,
TextUtils.SAFE_STRING_FLAG_FIRST_LINE | TextUtils.SAFE_STRING_FLAG_TRIM);
}
/**
* Gets the user-visible icon of the application.
*/
@Nullable
@GuardedBy("mLock")
static Drawable getAppIconLocked(Context context, ApplicationInfo appInfo) {
return appInfo == null ? null : appInfo.loadIcon(context.getPackageManager());
}
int cancelCurrentRequest() {
synchronized (mLock) {
return mPendingFillRequest != null && mPendingFillRequest.cancel(false)
? mPendingFillRequestId
: INVALID_REQUEST_ID;
}
}
/**
* The {@link AutofillId} which the client gets from its view is not contain the session id,
* but Autofill framework is using the {@link AutofillId} with a session id. So before using
* those ids in the Autofill framework, applies the current session id.
*
* @param res which response need to apply for a session id
*/
private void processAutofillId(FillResponse res) {
if (res == null) {
return;
}
final List<Dataset> datasets = res.getDatasets();
if (datasets != null && !datasets.isEmpty()) {
for (int i = 0; i < datasets.size(); i++) {
final Dataset dataset = datasets.get(i);
if (dataset != null) {
applySessionId(dataset.getFieldIds());
}
}
}
final SaveInfo saveInfo = res.getSaveInfo();
if (saveInfo != null) {
applySessionId(saveInfo.getOptionalIds());
applySessionId(saveInfo.getRequiredIds());
applySessionId(saveInfo.getSanitizerValues());
applySessionId(saveInfo.getTriggerId());
}
}
private void applySessionId(List<AutofillId> ids) {
if (ids == null || ids.isEmpty()) {
return;
}
for (int i = 0; i < ids.size(); i++) {
applySessionId(ids.get(i));
}
}
private void applySessionId(AutofillId[][] ids) {
if (ids == null) {
return;
}
for (int i = 0; i < ids.length; i++) {
applySessionId(ids[i]);
}
}
private void applySessionId(AutofillId[] ids) {
if (ids == null) {
return;
}
for (int i = 0; i < ids.length; i++) {
applySessionId(ids[i]);
}
}
private void applySessionId(AutofillId id) {
if (id == null) {
return;
}
id.setSessionId(mSessionId);
}
private void dispatchCancellationSignal(@Nullable ICancellationSignal signal) {
if (signal == null) {
return;
}
try {
signal.cancel();
} catch (RemoteException e) {
Slog.e(TAG, "Error requesting a cancellation", e);
}
}
private class FillCallbackImpl extends IFillCallback.Stub {
final AndroidFuture<FillResponse> mFillRequest;
final AtomicReference<AndroidFuture<FillResponse>> mFutureRef;
final AtomicReference<ICancellationSignal> mCancellationSink;
FillCallbackImpl(AndroidFuture<FillResponse> fillRequest,
AtomicReference<AndroidFuture<FillResponse>> futureRef,
AtomicReference<ICancellationSignal> cancellationSink) {
mFillRequest = fillRequest;
mFutureRef = futureRef;
mCancellationSink = cancellationSink;
}
@Override
public void onCancellable(ICancellationSignal cancellation) {
AndroidFuture<FillResponse> future = mFutureRef.get();
if (future != null && future.isCancelled()) {
dispatchCancellationSignal(cancellation);
} else {
mCancellationSink.set(cancellation);
}
}
@Override
public void onSuccess(FillResponse response) {
mFillRequest.complete(response);
}
@Override
public void onFailure(int requestId, CharSequence message) {
String errorMessage = message == null ? "" : String.valueOf(message);
mFillRequest.completeExceptionally(
new RuntimeException(errorMessage));
}
}
}

View File

@@ -26,7 +26,6 @@ import static android.view.autofill.AutofillManager.ACTION_START_SESSION;
import static android.view.autofill.AutofillManager.ACTION_VALUE_CHANGED;
import static android.view.autofill.AutofillManager.ACTION_VIEW_ENTERED;
import static android.view.autofill.AutofillManager.ACTION_VIEW_EXITED;
import static android.view.autofill.AutofillManager.FLAG_ENABLED_CLIENT_SUGGESTIONS;
import static android.view.autofill.AutofillManager.FLAG_SMART_SUGGESTION_SYSTEM;
import static android.view.autofill.AutofillManager.getSmartSuggestionModeToString;
@@ -54,7 +53,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@@ -348,9 +346,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
*/
private final AssistDataReceiverImpl mAssistReceiver = new AssistDataReceiverImpl();
@Nullable
private ClientSuggestionsSession mClientSuggestionsSession;
void onSwitchInputMethodLocked() {
// One caveat is that for the case where the focus is on a field for which regular autofill
// returns null, and augmented autofill is triggered, and then the user switches the input
@@ -421,10 +416,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
/** Whether the current {@link FillResponse} is expired. */
@GuardedBy("mLock")
private boolean mExpiredResponse;
/** Whether the client is using {@link android.view.autofill.AutofillRequestCallback}. */
@GuardedBy("mLock")
private boolean mClientSuggestionsEnabled;
}
/**
@@ -450,19 +441,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return;
}
mPendingInlineSuggestionsRequest = inlineSuggestionsRequest;
maybeRequestFillFromServiceLocked();
maybeRequestFillLocked();
viewState.resetState(ViewState.STATE_PENDING_CREATE_INLINE_REQUEST);
}
} : null;
}
void newAutofillRequestLocked(@Nullable InlineSuggestionsRequest inlineRequest) {
mPendingFillRequest = null;
mWaitForInlineRequest = inlineRequest != null;
mPendingInlineSuggestionsRequest = inlineRequest;
}
void maybeRequestFillFromServiceLocked() {
void maybeRequestFillLocked() {
if (mPendingFillRequest == null) {
return;
}
@@ -472,12 +457,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return;
}
if (mPendingInlineSuggestionsRequest.isServiceSupported()) {
mPendingFillRequest = new FillRequest(mPendingFillRequest.getId(),
mPendingFillRequest.getFillContexts(),
mPendingFillRequest.getClientState(),
mPendingFillRequest.getFlags(), mPendingInlineSuggestionsRequest);
}
mPendingFillRequest = new FillRequest(mPendingFillRequest.getId(),
mPendingFillRequest.getFillContexts(), mPendingFillRequest.getClientState(),
mPendingFillRequest.getFlags(), mPendingInlineSuggestionsRequest);
}
mRemoteFillService.onFillRequest(mPendingFillRequest);
@@ -584,7 +566,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
/*inlineSuggestionsRequest=*/null);
mPendingFillRequest = request;
maybeRequestFillFromServiceLocked();
maybeRequestFillLocked();
}
if (mActivityToken != null) {
@@ -746,39 +728,30 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
/**
* Cancels the last request sent to the {@link #mRemoteFillService} or the
* {@link #mClientSuggestionsSession}.
* Cancels the last request sent to the {@link #mRemoteFillService}.
*/
@GuardedBy("mLock")
private void cancelCurrentRequestLocked() {
if (mRemoteFillService == null && mClientSuggestionsSession == null) {
wtf(null, "cancelCurrentRequestLocked() called without a remote service or a "
+ "client suggestions session. mForAugmentedAutofillOnly: %s",
mSessionFlags.mAugmentedAutofillOnly);
if (mRemoteFillService == null) {
wtf(null, "cancelCurrentRequestLocked() called without a remote service. "
+ "mForAugmentedAutofillOnly: %s", mSessionFlags.mAugmentedAutofillOnly);
return;
}
final int canceledRequest = mRemoteFillService.cancelCurrentRequest();
if (mRemoteFillService != null) {
final int canceledRequest = mRemoteFillService.cancelCurrentRequest();
// Remove the FillContext as there will never be a response for the service
if (canceledRequest != INVALID_REQUEST_ID && mContexts != null) {
final int numContexts = mContexts.size();
// Remove the FillContext as there will never be a response for the service
if (canceledRequest != INVALID_REQUEST_ID && mContexts != null) {
final int numContexts = mContexts.size();
// It is most likely the last context, hence search backwards
for (int i = numContexts - 1; i >= 0; i--) {
if (mContexts.get(i).getRequestId() == canceledRequest) {
if (sDebug) Slog.d(TAG, "cancelCurrentRequest(): id = " + canceledRequest);
mContexts.remove(i);
break;
}
// It is most likely the last context, hence search backwards
for (int i = numContexts - 1; i >= 0; i--) {
if (mContexts.get(i).getRequestId() == canceledRequest) {
if (sDebug) Slog.d(TAG, "cancelCurrentRequest(): id = " + canceledRequest);
mContexts.remove(i);
break;
}
}
}
if (mClientSuggestionsSession != null) {
mClientSuggestionsSession.cancelCurrentRequest();
}
}
private boolean isViewFocusedLocked(int flags) {
@@ -843,30 +816,17 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// structure is taken. This causes only one fill request per burst of focus changes.
cancelCurrentRequestLocked();
// Only ask IME to create inline suggestions request when
// 1. Autofill provider supports it or client enabled client suggestions.
// 2. The render service is available.
// 3. The view is focused. (The view may not be focused if the autofill is triggered
// manually.)
// Only ask IME to create inline suggestions request if Autofill provider supports it and
// the render service is available except the autofill is triggered manually and the view
// is also not focused.
final RemoteInlineSuggestionRenderService remoteRenderService =
mService.getRemoteInlineSuggestionRenderServiceLocked();
if ((mSessionFlags.mInlineSupportedByService || mSessionFlags.mClientSuggestionsEnabled)
if (mSessionFlags.mInlineSupportedByService
&& remoteRenderService != null
&& isViewFocusedLocked(flags)) {
Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestConsumer;
if (mSessionFlags.mClientSuggestionsEnabled) {
final int finalRequestId = requestId;
inlineSuggestionsRequestConsumer = (inlineSuggestionsRequest) -> {
// Using client suggestions
synchronized (mLock) {
onClientFillRequestLocked(finalRequestId, inlineSuggestionsRequest);
}
viewState.resetState(ViewState.STATE_PENDING_CREATE_INLINE_REQUEST);
};
} else {
inlineSuggestionsRequestConsumer = mAssistReceiver.newAutofillRequestLocked(
viewState, /* isInlineRequest= */ true);
}
Consumer<InlineSuggestionsRequest> inlineSuggestionsRequestConsumer =
mAssistReceiver.newAutofillRequestLocked(viewState,
/* isInlineRequest= */ true);
if (inlineSuggestionsRequestConsumer != null) {
final AutofillId focusedId = mCurrentViewId;
final int requestIdCopy = requestId;
@@ -882,24 +842,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
);
viewState.setState(ViewState.STATE_PENDING_CREATE_INLINE_REQUEST);
}
} else if (mSessionFlags.mClientSuggestionsEnabled) {
// Request client suggestions for the dropdown mode
onClientFillRequestLocked(requestId, null);
} else {
mAssistReceiver.newAutofillRequestLocked(viewState, /* isInlineRequest= */ false);
}
if (mSessionFlags.mClientSuggestionsEnabled) {
// Using client suggestions, unnecessary request AssistStructure
return;
}
// Now request the assist structure data.
requestAssistStructureLocked(requestId, flags);
}
@GuardedBy("mLock")
private void requestAssistStructureLocked(int requestId, int flags) {
try {
final Bundle receiverExtras = new Bundle();
receiverExtras.putInt(EXTRA_REQUEST_ID, requestId);
@@ -948,13 +895,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
mComponentName = componentName;
mCompatMode = compatMode;
mSessionState = STATE_ACTIVE;
synchronized (mLock) {
mSessionFlags = new SessionFlags();
mSessionFlags.mAugmentedAutofillOnly = forAugmentedAutofillOnly;
mSessionFlags.mInlineSupportedByService = mService.isInlineSuggestionsEnabledLocked();
mSessionFlags.mClientSuggestionsEnabled =
(mFlags & FLAG_ENABLED_CLIENT_SUGGESTIONS) != 0;
setClientLocked(client);
}
@@ -1066,13 +1010,12 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
if (requestLog != null) {
requestLog.addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_DATASETS, -1);
}
processNullResponseOrFallbackLocked(requestId, requestFlags);
processNullResponseLocked(requestId, requestFlags);
return;
}
fieldClassificationIds = response.getFieldClassificationIds();
if (!mSessionFlags.mClientSuggestionsEnabled && fieldClassificationIds != null
&& !mService.isFieldClassificationEnabledLocked()) {
if (fieldClassificationIds != null && !mService.isFieldClassificationEnabledLocked()) {
Slog.w(TAG, "Ignoring " + response + " because field detection is disabled");
processNullResponseLocked(requestId, requestFlags);
return;
@@ -1151,26 +1094,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
}
@GuardedBy("mLock")
private void processNullResponseOrFallbackLocked(int requestId, int flags) {
if (!mSessionFlags.mClientSuggestionsEnabled) {
processNullResponseLocked(requestId, flags);
return;
}
// fallback to the default platform password manager
mSessionFlags.mClientSuggestionsEnabled = false;
final InlineSuggestionsRequest inlineRequest =
(mLastInlineSuggestionsRequest != null
&& mLastInlineSuggestionsRequest.first == requestId)
? mLastInlineSuggestionsRequest.second : null;
mAssistReceiver.newAutofillRequestLocked(inlineRequest);
requestAssistStructureLocked(requestId,
flags & ~FLAG_ENABLED_CLIENT_SUGGESTIONS);
return;
}
// FillServiceCallbacks
@Override
public void onFillRequestFailure(int requestId, @Nullable CharSequence message) {
@@ -3109,22 +3032,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
filterText = value.getTextValue().toString();
}
final CharSequence targetLabel;
final Drawable targetIcon;
final CharSequence serviceLabel;
final Drawable serviceIcon;
synchronized (mLock) {
if (mSessionFlags.mClientSuggestionsEnabled) {
final ApplicationInfo appInfo = ClientSuggestionsSession.getAppInfo(mComponentName,
mService.getUserId());
targetLabel = ClientSuggestionsSession.getAppLabelLocked(
mService.getMaster().getContext(), appInfo);
targetIcon = ClientSuggestionsSession.getAppIconLocked(
mService.getMaster().getContext(), appInfo);
} else {
targetLabel = mService.getServiceLabelLocked();
targetIcon = mService.getServiceIconLocked();
}
serviceLabel = mService.getServiceLabelLocked();
serviceIcon = mService.getServiceIconLocked();
}
if (targetLabel == null || targetIcon == null) {
if (serviceLabel == null || serviceIcon == null) {
wtf(null, "onFillReady(): no service label or icon");
return;
}
@@ -3144,7 +3058,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
getUiForShowing().showFillUi(filledId, response, filterText,
mService.getServicePackageName(), mComponentName,
targetLabel, targetIcon, this, id, mCompatMode);
serviceLabel, serviceIcon, this, id, mCompatMode);
mService.logDatasetShown(id, mClientState);
@@ -3191,17 +3105,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
return false;
}
final InlineSuggestionsRequest request = inlineSuggestionsRequest.get();
if (mSessionFlags.mClientSuggestionsEnabled && !request.isClientSupported()
|| !mSessionFlags.mClientSuggestionsEnabled && !request.isServiceSupported()) {
if (sDebug) {
Slog.d(TAG, "Inline suggestions not supported for "
+ (mSessionFlags.mClientSuggestionsEnabled ? "client" : "service")
+ ". Falling back to dropdown.");
}
return false;
}
final RemoteInlineSuggestionRenderService remoteRenderService =
mService.getRemoteInlineSuggestionRenderServiceLocked();
if (remoteRenderService == null) {
@@ -3210,7 +3113,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
final InlineFillUi.InlineFillUiInfo inlineFillUiInfo =
new InlineFillUi.InlineFillUiInfo(request, focusedId,
new InlineFillUi.InlineFillUiInfo(inlineSuggestionsRequest.get(), focusedId,
filterText, remoteRenderService, userId, id);
InlineFillUi inlineFillUi = InlineFillUi.forAutofill(inlineFillUiInfo, response,
new InlineFillUi.InlineSuggestionUiCallback() {
@@ -3812,25 +3715,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
}
@GuardedBy("mLock")
private void onClientFillRequestLocked(int requestId,
InlineSuggestionsRequest inlineSuggestionsRequest) {
if (mClientSuggestionsSession == null) {
mClientSuggestionsSession = new ClientSuggestionsSession(id, mClient, mHandler,
mComponentName, this);
}
if (mContexts == null) {
mContexts = new ArrayList<>(1);
}
if (inlineSuggestionsRequest != null && !inlineSuggestionsRequest.isClientSupported()) {
inlineSuggestionsRequest = null;
}
mClientSuggestionsSession.onFillRequest(requestId, inlineSuggestionsRequest, mFlags);
}
/**
* The result of checking whether to show the save dialog, when session can be saved.
*