diff --git a/api/current.txt b/api/current.txt index 24478f4d06d2b..5d8ea4ddb3be1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -23166,7 +23166,7 @@ package android.inputmethodservice { method public void onConfigureWindow(android.view.Window, boolean, boolean); method public android.view.View onCreateCandidatesView(); method public android.view.View onCreateExtractTextView(); - method @Nullable public android.view.inputmethod.InlineSuggestionsRequest onCreateInlineSuggestionsRequest(); + method @Nullable public android.view.inputmethod.InlineSuggestionsRequest onCreateInlineSuggestionsRequest(@NonNull android.os.Bundle); method public android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodImpl onCreateInputMethodInterface(); method public android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodSessionImpl onCreateInputMethodSessionInterface(); method public android.view.View onCreateInputView(); @@ -56486,7 +56486,7 @@ package android.view.inline { method public int describeContents(); method @NonNull public android.util.Size getMaxSize(); method @NonNull public android.util.Size getMinSize(); - method @Nullable public String getStyle(); + method @Nullable public android.os.Bundle getStyle(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator CREATOR; } @@ -56494,7 +56494,7 @@ package android.view.inline { public static final class InlinePresentationSpec.Builder { ctor public InlinePresentationSpec.Builder(@NonNull android.util.Size, @NonNull android.util.Size); method @NonNull public android.view.inline.InlinePresentationSpec build(); - method @NonNull public android.view.inline.InlinePresentationSpec.Builder setStyle(@Nullable String); + method @NonNull public android.view.inline.InlinePresentationSpec.Builder setStyle(@Nullable android.os.Bundle); } } diff --git a/api/system-current.txt b/api/system-current.txt index 5b6bd21acede2..314af957a4353 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -10187,6 +10187,7 @@ package android.service.autofill { public abstract class InlineSuggestionRenderService extends android.app.Service { ctor public InlineSuggestionRenderService(); method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); + method @Nullable public android.os.Bundle onGetInlineSuggestionsRendererInfo(); method @Nullable public android.view.View onRenderSuggestion(@NonNull android.service.autofill.InlinePresentation, int, int); field public static final String SERVICE_INTERFACE = "android.service.autofill.InlineSuggestionRenderService"; } diff --git a/api/test-current.txt b/api/test-current.txt index 79d29f6e906fa..d367dc90a37ec 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3145,6 +3145,7 @@ package android.service.autofill { public abstract class InlineSuggestionRenderService extends android.app.Service { ctor public InlineSuggestionRenderService(); method @Nullable public final android.os.IBinder onBind(@NonNull android.content.Intent); + method @Nullable public android.os.Bundle onGetInlineSuggestionsRendererInfo(); method @Nullable public android.view.View onRenderSuggestion(@NonNull android.service.autofill.InlinePresentation, int, int); field public static final String SERVICE_INTERFACE = "android.service.autofill.InlineSuggestionRenderService"; } diff --git a/core/java/android/inputmethodservice/IInputMethodWrapper.java b/core/java/android/inputmethodservice/IInputMethodWrapper.java index 2a441de067c6d..f0b1eaa9f2574 100644 --- a/core/java/android/inputmethodservice/IInputMethodWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodWrapper.java @@ -19,7 +19,6 @@ package android.inputmethodservice; import android.annotation.BinderThread; import android.annotation.MainThread; import android.compat.annotation.UnsupportedAppUsage; -import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.os.Binder; @@ -29,7 +28,6 @@ import android.os.RemoteException; import android.os.ResultReceiver; import android.util.Log; import android.view.InputChannel; -import android.view.autofill.AutofillId; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputBinding; import android.view.inputmethod.InputConnection; @@ -46,6 +44,7 @@ import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethod; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; import com.android.internal.view.InputConnectionWrapper; import java.io.FileDescriptor; @@ -233,8 +232,9 @@ class IInputMethodWrapper extends IInputMethod.Stub return; case DO_CREATE_INLINE_SUGGESTIONS_REQUEST: args = (SomeArgs) msg.obj; - inputMethod.onCreateInlineSuggestionsRequest((ComponentName) args.arg1, - (AutofillId) args.arg2, (IInlineSuggestionsRequestCallback) args.arg3); + inputMethod.onCreateInlineSuggestionsRequest( + (InlineSuggestionsRequestInfo) args.arg1, + (IInlineSuggestionsRequestCallback) args.arg2); return; } @@ -279,11 +279,10 @@ class IInputMethodWrapper extends IInputMethod.Stub @BinderThread @Override - public void onCreateInlineSuggestionsRequest(ComponentName componentName, AutofillId autofillId, + public void onCreateInlineSuggestionsRequest(InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb) { mCaller.executeOrSendMessage( - mCaller.obtainMessageOOO(DO_CREATE_INLINE_SUGGESTIONS_REQUEST, componentName, - autofillId, cb)); + mCaller.obtainMessageOO(DO_CREATE_INLINE_SUGGESTIONS_REQUEST, requestInfo, cb)); } @BinderThread diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index b1aa67e9f7ed0..20a4ab35defec 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -34,7 +34,6 @@ import android.annotation.Nullable; import android.app.ActivityManager; import android.app.Dialog; import android.compat.annotation.UnsupportedAppUsage; -import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; @@ -74,7 +73,6 @@ import android.view.Window; import android.view.WindowInsets; import android.view.WindowManager; import android.view.animation.AnimationUtils; -import android.view.autofill.AutofillId; import android.view.inputmethod.CompletionInfo; import android.view.inputmethod.CursorAnchorInfo; import android.view.inputmethod.EditorInfo; @@ -99,6 +97,7 @@ import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.inputmethod.InputMethodPrivilegedOperations; import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import com.android.internal.view.IInlineSuggestionsRequestCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -526,12 +525,13 @@ public class InputMethodService extends AbstractInputMethodService { */ @MainThread @Override - public void onCreateInlineSuggestionsRequest(ComponentName componentName, - AutofillId autofillId, IInlineSuggestionsRequestCallback cb) { + public void onCreateInlineSuggestionsRequest( + @NonNull InlineSuggestionsRequestInfo requestInfo, + @NonNull IInlineSuggestionsRequestCallback cb) { if (DEBUG) { Log.d(TAG, "InputMethodService received onCreateInlineSuggestionsRequest()"); } - handleOnCreateInlineSuggestionsRequest(componentName, cb); + handleOnCreateInlineSuggestionsRequest(requestInfo, cb); } /** @@ -742,11 +742,14 @@ public class InputMethodService extends AbstractInputMethodService { // TODO(b/137800469): Add detailed docs explaining the inline suggestions process. /** - * Returns an {@link InlineSuggestionsRequest} to be sent to Autofill. + * This method should be implemented by subclass which supports displaying autofill inline + * suggestion. * - *

Should be implemented by subclasses.

+ * @param uiExtras the extras that contain the UI renderer related information + * @return an {@link InlineSuggestionsRequest} to be sent to Autofill. */ - public @Nullable InlineSuggestionsRequest onCreateInlineSuggestionsRequest() { + @Nullable + public InlineSuggestionsRequest onCreateInlineSuggestionsRequest(@NonNull Bundle uiExtras) { return null; } @@ -764,7 +767,8 @@ public class InputMethodService extends AbstractInputMethodService { } @MainThread - private void handleOnCreateInlineSuggestionsRequest(@NonNull ComponentName componentName, + private void handleOnCreateInlineSuggestionsRequest( + @NonNull InlineSuggestionsRequestInfo requestInfo, @NonNull IInlineSuggestionsRequestCallback callback) { if (!mInputStarted) { try { @@ -779,8 +783,9 @@ public class InputMethodService extends AbstractInputMethodService { if (mInlineSuggestionSession != null) { mInlineSuggestionSession.invalidateSession(); } - mInlineSuggestionSession = new InlineSuggestionSession(componentName, callback, - this::getEditorInfoPackageName, this::onCreateInlineSuggestionsRequest, + mInlineSuggestionSession = new InlineSuggestionSession(requestInfo.getComponentName(), + callback, this::getEditorInfoPackageName, + () -> onCreateInlineSuggestionsRequest(requestInfo.getUiExtras()), this::getHostInputToken, this::onInlineSuggestionsResponse); } diff --git a/core/java/android/service/autofill/InlineSuggestionRenderService.java b/core/java/android/service/autofill/InlineSuggestionRenderService.java index 4aafb6302ab42..29069e7035f9c 100644 --- a/core/java/android/service/autofill/InlineSuggestionRenderService.java +++ b/core/java/android/service/autofill/InlineSuggestionRenderService.java @@ -25,6 +25,7 @@ import android.app.Service; import android.app.slice.Slice; import android.content.Intent; import android.graphics.PixelFormat; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; @@ -117,6 +118,14 @@ public abstract class InlineSuggestionRenderService extends Service { return null; } + /** + * Returns the metadata about the renderer. Returns {@code null} if no metadata is provided. + */ + @Nullable + public Bundle onGetInlineSuggestionsRendererInfo() { + return null; + } + /** * Renders the slice into a view. */ diff --git a/core/java/android/view/inline/InlinePresentationSpec.java b/core/java/android/view/inline/InlinePresentationSpec.java index 8bda339bea169..3cc04b8c5b861 100644 --- a/core/java/android/view/inline/InlinePresentationSpec.java +++ b/core/java/android/view/inline/InlinePresentationSpec.java @@ -18,6 +18,7 @@ package android.view.inline; import android.annotation.NonNull; import android.annotation.Nullable; +import android.os.Bundle; import android.os.Parcelable; import android.util.Size; @@ -40,15 +41,13 @@ public final class InlinePresentationSpec implements Parcelable { private final Size mMaxSize; /** - * The fully qualified resource name of the UI style resource identifier, defaults to {@code - * null}. - * - *

The value can be obtained by calling {@code Resources#getResourceName(int)}. + * The extras encoding the UI style information. Defaults to {@code null} in which case the + * default system UI style will be used. */ @Nullable - private final String mStyle; + private final Bundle mStyle; - private static String defaultStyle() { + private static Bundle defaultStyle() { return null; } @@ -76,7 +75,7 @@ public final class InlinePresentationSpec implements Parcelable { /* package-private */ InlinePresentationSpec( @NonNull Size minSize, @NonNull Size maxSize, - @Nullable String style) { + @Nullable Bundle style) { this.mMinSize = minSize; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMinSize); @@ -105,13 +104,11 @@ public final class InlinePresentationSpec implements Parcelable { } /** - * The fully qualified resource name of the UI style resource identifier, defaults to {@code - * null}. - * - *

The value can be obtained by calling {@code Resources#getResourceName(int)}. + * The extras encoding the UI style information. Defaults to null in which case the default + * system UI style will be used. */ @DataClass.Generated.Member - public @Nullable String getStyle() { + public @Nullable Bundle getStyle() { return mStyle; } @@ -170,7 +167,7 @@ public final class InlinePresentationSpec implements Parcelable { dest.writeByte(flg); dest.writeSize(mMinSize); dest.writeSize(mMaxSize); - if (mStyle != null) dest.writeString(mStyle); + if (mStyle != null) dest.writeBundle(mStyle); } @Override @@ -187,7 +184,7 @@ public final class InlinePresentationSpec implements Parcelable { byte flg = in.readByte(); Size minSize = (Size) in.readSize(); Size maxSize = (Size) in.readSize(); - String style = (flg & 0x4) == 0 ? null : in.readString(); + Bundle style = (flg & 0x4) == 0 ? null : in.readBundle(); this.mMinSize = minSize; com.android.internal.util.AnnotationValidations.validate( @@ -223,7 +220,7 @@ public final class InlinePresentationSpec implements Parcelable { private @NonNull Size mMinSize; private @NonNull Size mMaxSize; - private @Nullable String mStyle; + private @Nullable Bundle mStyle; private long mBuilderFieldsSet = 0L; @@ -247,13 +244,11 @@ public final class InlinePresentationSpec implements Parcelable { } /** - * The fully qualified resource name of the UI style resource identifier, defaults to {@code - * null}. - * - *

The value can be obtained by calling {@code Resources#getResourceName(int)}. + * The extras encoding the UI style information. Defaults to null in which case the default + * system UI style will be used. */ @DataClass.Generated.Member - public @NonNull Builder setStyle(@Nullable String value) { + public @NonNull Builder setStyle(@Nullable Bundle value) { checkNotUsed(); mBuilderFieldsSet |= 0x4; mStyle = value; @@ -284,10 +279,10 @@ public final class InlinePresentationSpec implements Parcelable { } @DataClass.Generated( - time = 1581736227796L, + time = 1582078731418L, codegenVersion = "1.0.14", sourceFile = "frameworks/base/core/java/android/view/inline/InlinePresentationSpec.java", - inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.Nullable java.lang.String mStyle\nprivate static java.lang.String defaultStyle()\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []") + inputSignatures = "private final @android.annotation.NonNull android.util.Size mMinSize\nprivate final @android.annotation.NonNull android.util.Size mMaxSize\nprivate final @android.annotation.Nullable android.os.Bundle mStyle\nprivate static android.os.Bundle defaultStyle()\nclass InlinePresentationSpec extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nclass BaseBuilder extends java.lang.Object implements []") @Deprecated private void __metadata() {} diff --git a/core/java/android/view/inputmethod/InputMethod.java b/core/java/android/view/inputmethod/InputMethod.java index 91e15c1949b62..71c9e33d0eeef 100644 --- a/core/java/android/view/inputmethod/InputMethod.java +++ b/core/java/android/view/inputmethod/InputMethod.java @@ -21,17 +21,16 @@ import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; -import android.content.ComponentName; import android.inputmethodservice.InputMethodService; import android.os.IBinder; import android.os.RemoteException; import android.os.ResultReceiver; import android.util.Log; import android.view.View; -import android.view.autofill.AutofillId; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.view.IInlineSuggestionsRequestCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; /** * The InputMethod interface represents an input method which can generate key @@ -114,14 +113,13 @@ public interface InputMethod { /** * Called to notify the IME that Autofill Frameworks requested an inline suggestions request. * - * @param componentName {@link ComponentName} of current app/activity. - * @param autofillId {@link AutofillId} of currently focused field. + * @param requestInfo information needed to create an {@link InlineSuggestionsRequest}. * @param cb {@link IInlineSuggestionsRequestCallback} used to pass back the request object. * * @hide */ - default void onCreateInlineSuggestionsRequest(ComponentName componentName, - AutofillId autofillId, IInlineSuggestionsRequestCallback cb) { + default void onCreateInlineSuggestionsRequest(InlineSuggestionsRequestInfo requestInfo, + IInlineSuggestionsRequestCallback cb) { try { cb.onInlineSuggestionsUnsupported(); } catch (RemoteException e) { diff --git a/core/java/com/android/internal/view/IInputMethod.aidl b/core/java/com/android/internal/view/IInputMethod.aidl index 475a3214096d7..fd4b5abe2b210 100644 --- a/core/java/com/android/internal/view/IInputMethod.aidl +++ b/core/java/com/android/internal/view/IInputMethod.aidl @@ -16,10 +16,8 @@ package com.android.internal.view; -import android.content.ComponentName; import android.os.IBinder; import android.os.ResultReceiver; -import android.view.autofill.AutofillId; import android.view.InputChannel; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputBinding; @@ -29,6 +27,7 @@ import com.android.internal.view.IInlineSuggestionsRequestCallback; import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; /** * Top-level interface to an input method component (implemented in a @@ -38,7 +37,7 @@ import com.android.internal.view.IInputSessionCallback; oneway interface IInputMethod { void initializeInternal(IBinder token, int displayId, IInputMethodPrivilegedOperations privOps); - void onCreateInlineSuggestionsRequest(in ComponentName componentName, in AutofillId autofillId, + void onCreateInlineSuggestionsRequest(in InlineSuggestionsRequestInfo requestInfo, in IInlineSuggestionsRequestCallback cb); void bindInput(in InputBinding binding); diff --git a/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.aidl b/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.aidl new file mode 100644 index 0000000000000..8125c0df219ba --- /dev/null +++ b/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.aidl @@ -0,0 +1,19 @@ +/* + * 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 com.android.internal.view; + +parcelable InlineSuggestionsRequestInfo; diff --git a/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.java b/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.java new file mode 100644 index 0000000000000..61484906269e1 --- /dev/null +++ b/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.java @@ -0,0 +1,229 @@ +/* + * 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 com.android.internal.view; + +import android.annotation.NonNull; +import android.content.ComponentName; +import android.os.Bundle; +import android.os.Parcelable; +import android.view.autofill.AutofillId; +import android.view.inputmethod.InlineSuggestionsRequest; + +import com.android.internal.util.DataClass; + +/** + * Wraps the information needed to create an {@link InlineSuggestionsRequest}. + * + * @hide + */ +@DataClass( + genToString = true, + genHiddenConstDefs = true, + genEqualsHashCode = true) +public final class InlineSuggestionsRequestInfo implements Parcelable { + /** + * The {@link ComponentName} of current app/activity + */ + private final @NonNull ComponentName mComponentName; + + /** + * The {@link AutofillId} of currently focused field. + */ + private final @NonNull AutofillId mAutofillId; + + /** + * The extras that contain the UI renderer related information + */ + private final @NonNull Bundle mUiExtras; + + + + // Code below generated by codegen v1.0.14. + // + // DO NOT MODIFY! + // CHECKSTYLE:OFF Generated code + // + // To regenerate run: + // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.java + // + // To exclude the generated code from IntelliJ auto-formatting enable (one-time): + // Settings > Editor > Code Style > Formatter Control + //@formatter:off + + + /** + * Creates a new InlineSuggestionsRequestInfo. + * + * @param componentName + * The {@link ComponentName} of current app/activity + * @param autofillId + * The {@link AutofillId} of currently focused field. + * @param uiExtras + * The extras that contain the ui renderer related information + */ + @DataClass.Generated.Member + public InlineSuggestionsRequestInfo( + @NonNull ComponentName componentName, + @NonNull AutofillId autofillId, + @NonNull Bundle uiExtras) { + this.mComponentName = componentName; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mComponentName); + this.mAutofillId = autofillId; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mAutofillId); + this.mUiExtras = uiExtras; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mUiExtras); + + // onConstructed(); // You can define this method to get a callback + } + + /** + * The {@link ComponentName} of current app/activity + */ + @DataClass.Generated.Member + public @NonNull ComponentName getComponentName() { + return mComponentName; + } + + /** + * The {@link AutofillId} of currently focused field. + */ + @DataClass.Generated.Member + public @NonNull AutofillId getAutofillId() { + return mAutofillId; + } + + /** + * The extras that contain the ui renderer related information + */ + @DataClass.Generated.Member + public @NonNull Bundle getUiExtras() { + return mUiExtras; + } + + @Override + @DataClass.Generated.Member + public String toString() { + // You can override field toString logic by defining methods like: + // String fieldNameToString() { ... } + + return "InlineSuggestionsRequestInfo { " + + "componentName = " + mComponentName + ", " + + "autofillId = " + mAutofillId + ", " + + "uiExtras = " + mUiExtras + + " }"; + } + + @Override + @DataClass.Generated.Member + public boolean equals(@android.annotation.Nullable Object o) { + // You can override field equality logic by defining either of the methods like: + // boolean fieldNameEquals(InlineSuggestionsRequestInfo other) { ... } + // boolean fieldNameEquals(FieldType otherValue) { ... } + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + @SuppressWarnings("unchecked") + InlineSuggestionsRequestInfo that = (InlineSuggestionsRequestInfo) o; + //noinspection PointlessBooleanExpression + return true + && java.util.Objects.equals(mComponentName, that.mComponentName) + && java.util.Objects.equals(mAutofillId, that.mAutofillId) + && java.util.Objects.equals(mUiExtras, that.mUiExtras); + } + + @Override + @DataClass.Generated.Member + public int hashCode() { + // You can override field hashCode logic by defining methods like: + // int fieldNameHashCode() { ... } + + int _hash = 1; + _hash = 31 * _hash + java.util.Objects.hashCode(mComponentName); + _hash = 31 * _hash + java.util.Objects.hashCode(mAutofillId); + _hash = 31 * _hash + java.util.Objects.hashCode(mUiExtras); + return _hash; + } + + @Override + @DataClass.Generated.Member + public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { + // You can override field parcelling by defining methods like: + // void parcelFieldName(Parcel dest, int flags) { ... } + + dest.writeTypedObject(mComponentName, flags); + dest.writeTypedObject(mAutofillId, flags); + dest.writeBundle(mUiExtras); + } + + @Override + @DataClass.Generated.Member + public int describeContents() { return 0; } + + /** @hide */ + @SuppressWarnings({"unchecked", "RedundantCast"}) + @DataClass.Generated.Member + /* package-private */ InlineSuggestionsRequestInfo(@NonNull android.os.Parcel in) { + // You can override field unparcelling by defining methods like: + // static FieldType unparcelFieldName(Parcel in) { ... } + + ComponentName componentName = (ComponentName) in.readTypedObject(ComponentName.CREATOR); + AutofillId autofillId = (AutofillId) in.readTypedObject(AutofillId.CREATOR); + Bundle uiExtras = in.readBundle(); + + this.mComponentName = componentName; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mComponentName); + this.mAutofillId = autofillId; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mAutofillId); + this.mUiExtras = uiExtras; + com.android.internal.util.AnnotationValidations.validate( + NonNull.class, null, mUiExtras); + + // onConstructed(); // You can define this method to get a callback + } + + @DataClass.Generated.Member + public static final @NonNull Parcelable.Creator CREATOR + = new Parcelable.Creator() { + @Override + public InlineSuggestionsRequestInfo[] newArray(int size) { + return new InlineSuggestionsRequestInfo[size]; + } + + @Override + public InlineSuggestionsRequestInfo createFromParcel(@NonNull android.os.Parcel in) { + return new InlineSuggestionsRequestInfo(in); + } + }; + + @DataClass.Generated( + time = 1582076613213L, + codegenVersion = "1.0.14", + sourceFile = "frameworks/base/core/java/com/android/internal/view/InlineSuggestionsRequestInfo.java", + inputSignatures = "private final @android.annotation.NonNull android.content.ComponentName mComponentName\nprivate final @android.annotation.NonNull android.view.autofill.AutofillId mAutofillId\nprivate final @android.annotation.NonNull android.os.Bundle mUiExtras\nclass InlineSuggestionsRequestInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)") + @Deprecated + private void __metadata() {} + + + //@formatter:on + // End of generated code + +} diff --git a/services/autofill/java/com/android/server/autofill/InlineSuggestionSession.java b/services/autofill/java/com/android/server/autofill/InlineSuggestionSession.java index 1fc48d235add5..6daa1064c89ed 100644 --- a/services/autofill/java/com/android/server/autofill/InlineSuggestionSession.java +++ b/services/autofill/java/com/android/server/autofill/InlineSuggestionSession.java @@ -21,6 +21,7 @@ import static com.android.server.autofill.Helper.sDebug; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.ComponentName; +import android.os.Bundle; import android.os.RemoteException; import android.util.Log; import android.view.autofill.AutofillId; @@ -29,6 +30,7 @@ import android.view.inputmethod.InlineSuggestionsRequest; import com.android.internal.annotations.GuardedBy; import com.android.internal.view.IInlineSuggestionsRequestCallback; import com.android.internal.view.IInlineSuggestionsResponseCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; import com.android.server.inputmethod.InputMethodManagerInternal; import java.util.concurrent.CancellationException; @@ -71,8 +73,10 @@ final class InlineSuggestionSession { synchronized (mLock) { cancelCurrentRequest(); mPendingImeResponse = new CompletableFuture<>(); + // TODO(b/146454892): pipe the uiExtras from the ExtServices. mInputMethodManagerInternal.onCreateInlineSuggestionsRequest( - mUserId, mComponentName, currentViewId, + mUserId, + new InlineSuggestionsRequestInfo(mComponentName, currentViewId, new Bundle()), new InlineSuggestionsRequestCallbackImpl(mPendingImeResponse)); } } diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java index 9f76e1ed113df..eac2d24c3dab2 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerInternal.java @@ -18,12 +18,11 @@ package com.android.server.inputmethod; import android.annotation.NonNull; import android.annotation.UserIdInt; -import android.content.ComponentName; -import android.view.autofill.AutofillId; import android.view.inputmethod.InlineSuggestionsRequest; import android.view.inputmethod.InputMethodInfo; import com.android.internal.view.IInlineSuggestionsRequestCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; import com.android.server.LocalServices; import java.util.Collections; @@ -74,13 +73,11 @@ public abstract class InputMethodManagerInternal { * Called by the Autofill Frameworks to request an {@link InlineSuggestionsRequest} from * the input method. * - * @param componentName {@link ComponentName} of current app/activity. - * @param autofillId {@link AutofillId} of currently focused field. + * @param requestInfo information needed to create an {@link InlineSuggestionsRequest}. * @param cb {@link IInlineSuggestionsRequestCallback} used to pass back the request object. */ public abstract void onCreateInlineSuggestionsRequest(@UserIdInt int userId, - ComponentName componentName, AutofillId autofillId, - IInlineSuggestionsRequestCallback cb); + InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb); /** * Force switch to the enabled input method by {@code imeId} for current user. If the input @@ -124,7 +121,7 @@ public abstract class InputMethodManagerInternal { @Override public void onCreateInlineSuggestionsRequest(int userId, - ComponentName componentName, AutofillId autofillId, + InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb) { } diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 47622f38f3f22..d7cb192fdd36e 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -109,7 +109,6 @@ import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams.SoftInputModeFlags; -import android.view.autofill.AutofillId; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InlineSuggestionsRequest; import android.view.inputmethod.InputBinding; @@ -150,6 +149,7 @@ import com.android.internal.view.IInputMethodClient; import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; +import com.android.internal.view.InlineSuggestionsRequestInfo; import com.android.internal.view.InputBindResult; import com.android.server.EventLogTags; import com.android.server.LocalServices; @@ -1812,16 +1812,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @GuardedBy("mMethodMap") private void onCreateInlineSuggestionsRequestLocked(@UserIdInt int userId, - ComponentName componentName, AutofillId autofillId, - IInlineSuggestionsRequestCallback callback) { + InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback) { final InputMethodInfo imi = mMethodMap.get(mCurMethodId); try { if (userId == mSettings.getCurrentUserId() && imi != null && imi.isInlineSuggestionsEnabled() && mCurMethod != null) { executeOrSendMessage(mCurMethod, - mCaller.obtainMessageOOOO(MSG_INLINE_SUGGESTIONS_REQUEST, mCurMethod, - componentName, autofillId, - new InlineSuggestionsRequestCallbackDecorator(callback, + mCaller.obtainMessageOOO(MSG_INLINE_SUGGESTIONS_REQUEST, mCurMethod, + requestInfo, new InlineSuggestionsRequestCallbackDecorator(callback, imi.getPackageName()))); } else { callback.onInlineSuggestionsUnsupported(); @@ -3972,13 +3970,13 @@ public class InputMethodManagerService extends IInputMethodManager.Stub // --------------------------------------------------------------- case MSG_INLINE_SUGGESTIONS_REQUEST: args = (SomeArgs) msg.obj; - final ComponentName componentName = (ComponentName) args.arg2; - final AutofillId autofillId = (AutofillId) args.arg3; + final InlineSuggestionsRequestInfo requestInfo = + (InlineSuggestionsRequestInfo) args.arg2; final IInlineSuggestionsRequestCallback callback = - (IInlineSuggestionsRequestCallback) args.arg4; + (IInlineSuggestionsRequestCallback) args.arg3; try { - ((IInputMethod) args.arg1).onCreateInlineSuggestionsRequest(componentName, - autofillId, callback); + ((IInputMethod) args.arg1).onCreateInlineSuggestionsRequest(requestInfo, + callback); } catch (RemoteException e) { Slog.w(TAG, "RemoteException calling onCreateInlineSuggestionsRequest(): " + e); } @@ -4549,10 +4547,10 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } private void onCreateInlineSuggestionsRequest(@UserIdInt int userId, - ComponentName componentName, AutofillId autofillId, + InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback callback) { synchronized (mMethodMap) { - onCreateInlineSuggestionsRequestLocked(userId, componentName, autofillId, callback); + onCreateInlineSuggestionsRequestLocked(userId, requestInfo, callback); } } @@ -4620,9 +4618,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } @Override - public void onCreateInlineSuggestionsRequest(int userId, ComponentName componentName, - AutofillId autofillId, IInlineSuggestionsRequestCallback cb) { - mService.onCreateInlineSuggestionsRequest(userId, componentName, autofillId, cb); + public void onCreateInlineSuggestionsRequest(int userId, + InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb) { + mService.onCreateInlineSuggestionsRequest(userId, requestInfo, cb); } @Override diff --git a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java index 54af69432ee0e..4904061ec1afc 100644 --- a/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/MultiClientInputMethodManagerService.java @@ -63,7 +63,6 @@ import android.util.Slog; import android.util.SparseArray; import android.view.InputChannel; import android.view.WindowManager.LayoutParams.SoftInputModeFlags; -import android.view.autofill.AutofillId; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnectionInspector.MissingMethodFlags; import android.view.inputmethod.InputMethodInfo; @@ -88,6 +87,7 @@ import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodClient; import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; +import com.android.internal.view.InlineSuggestionsRequestInfo; import com.android.internal.view.InputBindResult; import com.android.server.LocalServices; import com.android.server.SystemService; @@ -192,7 +192,7 @@ public final class MultiClientInputMethodManagerService { @Override public void onCreateInlineSuggestionsRequest(int userId, - ComponentName componentName, AutofillId autofillId, + InlineSuggestionsRequestInfo requestInfo, IInlineSuggestionsRequestCallback cb) { try { //TODO(b/137800469): support multi client IMEs.