Initial IME inline suggestions APIs
Test: manual verification with other local changes
Bug: 137800469
Change-Id: Ia0ead9d7208512920a3277559cef0bb92bea35f5
diff --git a/api/current.txt b/api/current.txt
index 28e9081..3cc7487 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -53452,6 +53452,23 @@
}
+package android.view.inline {
+
+ public final class InlinePresentationSpec implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public android.util.Size getMaxSize();
+ method @NonNull public android.util.Size getMinSize();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.view.inline.InlinePresentationSpec> CREATOR;
+ }
+
+ 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();
+ }
+
+}
+
package android.view.inputmethod {
public class BaseInputConnection implements android.view.inputmethod.InputConnection {
@@ -53615,6 +53632,48 @@
field public int token;
}
+ public final class InlineSuggestion implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public android.view.inputmethod.InlineSuggestionInfo getInfo();
+ method public void inflate(@NonNull android.content.Context, @NonNull android.util.Size, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.view.View>);
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.InlineSuggestion> CREATOR;
+ }
+
+ public final class InlineSuggestionInfo implements android.os.Parcelable {
+ method public int describeContents();
+ method @Nullable public String[] getAutofillHints();
+ method @NonNull public android.view.inline.InlinePresentationSpec getPresentationSpec();
+ method @NonNull public String getSource();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.InlineSuggestionInfo> CREATOR;
+ field public static final String SOURCE_AUTOFILL = "android:autofill";
+ field public static final String SOURCE_PLATFORM = "android:platform";
+ }
+
+ public final class InlineSuggestionsRequest implements android.os.Parcelable {
+ method public int describeContents();
+ method public int getMaxSuggestionCount();
+ method @NonNull public java.util.List<android.view.inline.InlinePresentationSpec> getPresentationSpecs();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.InlineSuggestionsRequest> CREATOR;
+ field public static final int SUGGESTION_COUNT_UNLIMITED = 2147483647; // 0x7fffffff
+ }
+
+ public static final class InlineSuggestionsRequest.Builder {
+ ctor public InlineSuggestionsRequest.Builder(@NonNull java.util.List<android.view.inline.InlinePresentationSpec>);
+ method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder addPresentationSpecs(@NonNull android.view.inline.InlinePresentationSpec);
+ method @NonNull public android.view.inputmethod.InlineSuggestionsRequest build();
+ method @NonNull public android.view.inputmethod.InlineSuggestionsRequest.Builder setMaxSuggestionCount(int);
+ }
+
+ public final class InlineSuggestionsResponse implements android.os.Parcelable {
+ method public int describeContents();
+ method @NonNull public java.util.List<android.view.inputmethod.InlineSuggestion> getInlineSuggestions();
+ method public void writeToParcel(@NonNull android.os.Parcel, int);
+ field @NonNull public static final android.os.Parcelable.Creator<android.view.inputmethod.InlineSuggestionsResponse> CREATOR;
+ }
+
public final class InputBinding implements android.os.Parcelable {
ctor public InputBinding(android.view.inputmethod.InputConnection, android.os.IBinder, int, int);
ctor public InputBinding(android.view.inputmethod.InputConnection, android.view.inputmethod.InputBinding);
diff --git a/core/java/android/view/inline/InlineContentView.java b/core/java/android/view/inline/InlineContentView.java
new file mode 100644
index 0000000..4bc2176
--- /dev/null
+++ b/core/java/android/view/inline/InlineContentView.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2019 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.inline;
+
+import android.annotation.NonNull;
+import android.content.Context;
+import android.graphics.PixelFormat;
+import android.view.SurfaceControl;
+import android.view.SurfaceHolder;
+import android.view.SurfaceView;
+
+/**
+ * This class represents a view that can hold an opaque content that may be from a different source.
+ *
+ * @hide
+ */
+public class InlineContentView extends SurfaceView {
+ public InlineContentView(@NonNull Context context,
+ @NonNull SurfaceControl surfaceControl) {
+ super(context);
+ setZOrderOnTop(true);
+ getHolder().addCallback(new SurfaceHolder.Callback() {
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ holder.setFormat(PixelFormat.TRANSPARENT);
+ new SurfaceControl.Transaction()
+ .reparent(surfaceControl, getSurfaceControl())
+ .setVisibility(surfaceControl, /* visible */ true)
+ .apply();
+ }
+
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ // TODO(b/137800469): implement this.
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ // TODO(b/137800469): implement this.
+ }
+ });
+ }
+}
diff --git a/core/java/android/view/inline/InlinePresentationSpec.aidl b/core/java/android/view/inline/InlinePresentationSpec.aidl
new file mode 100644
index 0000000..efa46c8
--- /dev/null
+++ b/core/java/android/view/inline/InlinePresentationSpec.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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.inline;
+
+parcelable InlinePresentationSpec;
diff --git a/core/java/android/view/inline/InlinePresentationSpec.java b/core/java/android/view/inline/InlinePresentationSpec.java
new file mode 100644
index 0000000..1eddef5
--- /dev/null
+++ b/core/java/android/view/inline/InlinePresentationSpec.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2019 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.inline;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcelable;
+import android.util.Size;
+
+import com.android.internal.util.DataClass;
+
+/**
+ * This class represents the presentation specification by which an inline suggestion
+ * should abide when constructing its UI. Since suggestions are inlined in a
+ * host application while provided by another source, they need to be consistent
+ * with the host's look at feel to allow building smooth and integrated UIs.
+ */
+@DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
+public final class InlinePresentationSpec implements Parcelable {
+ /** The minimal size of the suggestion. */
+ @NonNull
+ private final Size mMinSize;
+ /** The maximal size of the suggestion. */
+ @NonNull
+ private final Size mMaxSize;
+
+ // TODO(b/137800469): add more attributes, such as text appearance info.
+
+ /** @hide */
+ @DataClass.Suppress({"setMaxSize", "setMinSize"})
+ abstract static class BaseBuilder {
+ }
+
+
+
+ // 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/android/view/inline/InlinePresentationSpec.java
+ //
+ // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
+ // Settings > Editor > Code Style > Formatter Control
+ //@formatter:off
+
+
+ @DataClass.Generated.Member
+ /* package-private */ InlinePresentationSpec(
+ @NonNull Size minSize,
+ @NonNull Size maxSize) {
+ this.mMinSize = minSize;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mMinSize);
+ this.mMaxSize = maxSize;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mMaxSize);
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ /**
+ * The minimal size of the suggestion.
+ */
+ @DataClass.Generated.Member
+ public @NonNull Size getMinSize() {
+ return mMinSize;
+ }
+
+ /**
+ * The maximal size of the suggestion.
+ */
+ @DataClass.Generated.Member
+ public @NonNull Size getMaxSize() {
+ return mMaxSize;
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public String toString() {
+ // You can override field toString logic by defining methods like:
+ // String fieldNameToString() { ... }
+
+ return "InlinePresentationSpec { " +
+ "minSize = " + mMinSize + ", " +
+ "maxSize = " + mMaxSize +
+ " }";
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public boolean equals(@Nullable Object o) {
+ // You can override field equality logic by defining either of the methods like:
+ // boolean fieldNameEquals(InlinePresentationSpec other) { ... }
+ // boolean fieldNameEquals(FieldType otherValue) { ... }
+
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ @SuppressWarnings("unchecked")
+ InlinePresentationSpec that = (InlinePresentationSpec) o;
+ //noinspection PointlessBooleanExpression
+ return true
+ && java.util.Objects.equals(mMinSize, that.mMinSize)
+ && java.util.Objects.equals(mMaxSize, that.mMaxSize);
+ }
+
+ @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(mMinSize);
+ _hash = 31 * _hash + java.util.Objects.hashCode(mMaxSize);
+ 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.writeSize(mMinSize);
+ dest.writeSize(mMaxSize);
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public int describeContents() { return 0; }
+
+ /** @hide */
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ @DataClass.Generated.Member
+ /* package-private */ InlinePresentationSpec(@NonNull android.os.Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ Size minSize = (Size) in.readSize();
+ Size maxSize = (Size) in.readSize();
+
+ this.mMinSize = minSize;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mMinSize);
+ this.mMaxSize = maxSize;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mMaxSize);
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public static final @NonNull Parcelable.Creator<InlinePresentationSpec> CREATOR
+ = new Parcelable.Creator<InlinePresentationSpec>() {
+ @Override
+ public InlinePresentationSpec[] newArray(int size) {
+ return new InlinePresentationSpec[size];
+ }
+
+ @Override
+ public InlinePresentationSpec createFromParcel(@NonNull android.os.Parcel in) {
+ return new InlinePresentationSpec(in);
+ }
+ };
+
+ /**
+ * A builder for {@link InlinePresentationSpec}
+ */
+ @SuppressWarnings("WeakerAccess")
+ @DataClass.Generated.Member
+ public static final class Builder extends BaseBuilder {
+
+ private @NonNull Size mMinSize;
+ private @NonNull Size mMaxSize;
+
+ private long mBuilderFieldsSet = 0L;
+
+ /**
+ * Creates a new Builder.
+ *
+ * @param minSize
+ * The minimal size of the suggestion.
+ * @param maxSize
+ * The maximal size of the suggestion.
+ */
+ public Builder(
+ @NonNull Size minSize,
+ @NonNull Size maxSize) {
+ mMinSize = minSize;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mMinSize);
+ mMaxSize = maxSize;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mMaxSize);
+ }
+
+ /** Builds the instance. This builder should not be touched after calling this! */
+ public @NonNull InlinePresentationSpec build() {
+ checkNotUsed();
+ mBuilderFieldsSet |= 0x4; // Mark builder used
+
+ InlinePresentationSpec o = new InlinePresentationSpec(
+ mMinSize,
+ mMaxSize);
+ return o;
+ }
+
+ private void checkNotUsed() {
+ if ((mBuilderFieldsSet & 0x4) != 0) {
+ throw new IllegalStateException(
+ "This Builder should not be reused. Use a new Builder instance instead");
+ }
+ }
+ }
+
+ @DataClass.Generated(
+ time = 1574406062532L,
+ 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\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() {}
+
+
+ //@formatter:on
+ // End of generated code
+
+}
diff --git a/core/java/android/view/inputmethod/InlineSuggestion.aidl b/core/java/android/view/inputmethod/InlineSuggestion.aidl
new file mode 100644
index 0000000..208d964
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestion.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+parcelable InlineSuggestion;
diff --git a/core/java/android/view/inputmethod/InlineSuggestion.java b/core/java/android/view/inputmethod/InlineSuggestion.java
new file mode 100644
index 0000000..25e34d3
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestion.java
@@ -0,0 +1,285 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+import android.annotation.CallbackExecutor;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Parcelable;
+import android.os.RemoteException;
+import android.util.Size;
+import android.util.Slog;
+import android.view.SurfaceControl;
+import android.view.View;
+import android.view.inline.InlineContentView;
+import android.view.inline.InlinePresentationSpec;
+
+import com.android.internal.util.DataClass;
+import com.android.internal.view.inline.IInlineContentCallback;
+import com.android.internal.view.inline.IInlineContentProvider;
+
+import java.lang.ref.WeakReference;
+import java.util.concurrent.Executor;
+import java.util.function.Consumer;
+
+/**
+ * This class represents an inline suggestion which is made by one app
+ * and can be embedded into the UI of another. Suggestions may contain
+ * sensitive information not known to the host app which needs to be
+ * protected from spoofing. To address that the suggestion view inflated
+ * on demand for embedding is created in such a way that the hosting app
+ * cannot introspect its content and cannot interact with it.
+ */
+@DataClass(
+ genEqualsHashCode = true,
+ genToString = true,
+ genHiddenConstDefs = true,
+ genHiddenConstructor = true)
+@DataClass.Suppress({"getContentProvider"})
+public final class InlineSuggestion implements Parcelable {
+
+ private static final String TAG = "InlineSuggestion";
+
+ private final @NonNull InlineSuggestionInfo mInfo;
+
+ private final @Nullable IInlineContentProvider mContentProvider;
+
+ /**
+ * Inflates a view with the content of this suggestion at a specific size.
+ * The size must be between the {@link InlinePresentationSpec#getMinSize() min size}
+ * and the {@link InlinePresentationSpec#getMaxSize() max size} of the presentation
+ * spec returned by {@link InlineSuggestionInfo#getPresentationSpec()}. If an invalid
+ * argument is passed an exception is thrown.
+ *
+ * @param context Context in which to inflate the view.
+ * @param size The size at which to inflate the suggestion.
+ * @param callback Callback for receiving the inflated view.
+ */
+ public void inflate(@NonNull Context context, @NonNull Size size,
+ @NonNull @CallbackExecutor Executor callbackExecutor,
+ @NonNull Consumer<View> callback) {
+ final Size minSize = mInfo.getPresentationSpec().getMinSize();
+ final Size maxSize = mInfo.getPresentationSpec().getMaxSize();
+ if (size.getHeight() < minSize.getHeight() || size.getHeight() > maxSize.getHeight()
+ || size.getWidth() < minSize.getWidth() || size.getWidth() > maxSize.getWidth()) {
+ throw new IllegalArgumentException("size not between min:"
+ + minSize + " and max:" + maxSize);
+ }
+ AsyncTask.THREAD_POOL_EXECUTOR.execute(() -> {
+ if (mContentProvider == null) {
+ callback.accept(/* view */ null);
+ return;
+ }
+ // TODO(b/137800469): keep a strong reference to the contentCallback so it doesn't
+ // get GC'd. Also add a isInflated() method and make sure the view can only be
+ // inflated once.
+ try {
+ InlineContentCallbackImpl contentCallback = new InlineContentCallbackImpl(context,
+ callbackExecutor, callback);
+ mContentProvider.provideContent(size.getWidth(), size.getHeight(),
+ new InlineContentCallbackWrapper(contentCallback));
+ } catch (RemoteException e) {
+ Slog.w(TAG, "Error creating suggestion content surface: " + e);
+ callback.accept(/* view */ null);
+ }
+ });
+ }
+
+ private static final class InlineContentCallbackWrapper extends IInlineContentCallback.Stub {
+
+ private final WeakReference<InlineContentCallbackImpl> mCallbackImpl;
+
+ InlineContentCallbackWrapper(InlineContentCallbackImpl callbackImpl) {
+ mCallbackImpl = new WeakReference<>(callbackImpl);
+ }
+
+ @Override
+ public void onContent(SurfaceControl content) {
+ final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
+ if (callbackImpl != null) {
+ callbackImpl.onContent(content);
+ }
+ }
+ }
+
+ private static final class InlineContentCallbackImpl {
+
+ private final @NonNull Context mContext;
+ private final @NonNull Executor mCallbackExecutor;
+ private final @NonNull Consumer<View> mCallback;
+
+ InlineContentCallbackImpl(@NonNull Context context,
+ @NonNull @CallbackExecutor Executor callbackExecutor,
+ @NonNull Consumer<View> callback) {
+ mContext = context;
+ mCallbackExecutor = callbackExecutor;
+ mCallback = callback;
+ }
+
+ public void onContent(SurfaceControl content) {
+ if (content == null) {
+ mCallbackExecutor.execute(() -> mCallback.accept(/* view */null));
+ } else {
+ mCallbackExecutor.execute(
+ () -> mCallback.accept(new InlineContentView(mContext, content)));
+ }
+ }
+ }
+
+
+
+ // 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/android/view/inputmethod/InlineSuggestion.java
+ //
+ // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
+ // Settings > Editor > Code Style > Formatter Control
+ //@formatter:off
+
+
+ /**
+ * Creates a new InlineSuggestion.
+ *
+ * @hide
+ */
+ @DataClass.Generated.Member
+ public InlineSuggestion(
+ @NonNull InlineSuggestionInfo info,
+ @Nullable IInlineContentProvider contentProvider) {
+ this.mInfo = info;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mInfo);
+ this.mContentProvider = contentProvider;
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public @NonNull InlineSuggestionInfo getInfo() {
+ return mInfo;
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public String toString() {
+ // You can override field toString logic by defining methods like:
+ // String fieldNameToString() { ... }
+
+ return "InlineSuggestion { " +
+ "info = " + mInfo + ", " +
+ "contentProvider = " + mContentProvider +
+ " }";
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public boolean equals(@Nullable Object o) {
+ // You can override field equality logic by defining either of the methods like:
+ // boolean fieldNameEquals(InlineSuggestion other) { ... }
+ // boolean fieldNameEquals(FieldType otherValue) { ... }
+
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ @SuppressWarnings("unchecked")
+ InlineSuggestion that = (InlineSuggestion) o;
+ //noinspection PointlessBooleanExpression
+ return true
+ && java.util.Objects.equals(mInfo, that.mInfo)
+ && java.util.Objects.equals(mContentProvider, that.mContentProvider);
+ }
+
+ @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(mInfo);
+ _hash = 31 * _hash + java.util.Objects.hashCode(mContentProvider);
+ 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) { ... }
+
+ byte flg = 0;
+ if (mContentProvider != null) flg |= 0x2;
+ dest.writeByte(flg);
+ dest.writeTypedObject(mInfo, flags);
+ if (mContentProvider != null) dest.writeStrongInterface(mContentProvider);
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public int describeContents() { return 0; }
+
+ /** @hide */
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ @DataClass.Generated.Member
+ /* package-private */ InlineSuggestion(@NonNull android.os.Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ byte flg = in.readByte();
+ InlineSuggestionInfo info = (InlineSuggestionInfo) in.readTypedObject(InlineSuggestionInfo.CREATOR);
+ IInlineContentProvider contentProvider = (flg & 0x2) == 0 ? null : IInlineContentProvider.Stub.asInterface(in.readStrongBinder());
+
+ this.mInfo = info;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mInfo);
+ this.mContentProvider = contentProvider;
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public static final @NonNull Parcelable.Creator<InlineSuggestion> CREATOR
+ = new Parcelable.Creator<InlineSuggestion>() {
+ @Override
+ public InlineSuggestion[] newArray(int size) {
+ return new InlineSuggestion[size];
+ }
+
+ @Override
+ public InlineSuggestion createFromParcel(@NonNull android.os.Parcel in) {
+ return new InlineSuggestion(in);
+ }
+ };
+
+ @DataClass.Generated(
+ time = 1574446220398L,
+ codegenVersion = "1.0.14",
+ sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestion.java",
+ inputSignatures = "private static final java.lang.String TAG\nprivate final @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo mInfo\nprivate final @android.annotation.Nullable com.android.internal.view.inline.IInlineContentProvider mContentProvider\npublic void inflate(android.content.Context,android.util.Size,java.util.concurrent.Executor,java.util.function.Consumer<android.view.View>)\nclass InlineSuggestion extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
+ @Deprecated
+ private void __metadata() {}
+
+
+ //@formatter:on
+ // End of generated code
+
+}
diff --git a/core/java/android/view/inputmethod/InlineSuggestionInfo.aidl b/core/java/android/view/inputmethod/InlineSuggestionInfo.aidl
new file mode 100644
index 0000000..168bd0b
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestionInfo.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+parcelable InlineSuggestionInfo;
diff --git a/core/java/android/view/inputmethod/InlineSuggestionInfo.java b/core/java/android/view/inputmethod/InlineSuggestionInfo.java
new file mode 100644
index 0000000..07fce31
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestionInfo.java
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcelable;
+import android.view.inline.InlinePresentationSpec;
+
+import com.android.internal.util.DataClass;
+
+/**
+ * This class represents the description of an inline suggestion. It contains information to help
+ * the IME to decide where and when to show the suggestions. See {@link InlineSuggestion} for more
+ * information.
+ */
+@DataClass(
+ genEqualsHashCode = true,
+ genToString = true,
+ genHiddenConstDefs = true,
+ genHiddenConstructor = true)
+public final class InlineSuggestionInfo implements Parcelable {
+
+ /**
+ * Suggestion source: the suggestion is made by the user selected autofill service.
+ */
+ public static final @Source String SOURCE_AUTOFILL = "android:autofill";
+ /**
+ * Suggestion source: the suggestion is made by the platform.
+ */
+ public static final @Source String SOURCE_PLATFORM = "android:platform";
+
+ /** The presentation spec to which the inflated suggestion view abides. */
+ private final @NonNull InlinePresentationSpec mPresentationSpec;
+
+ /** The source from which the suggestion is provided. */
+ private final @NonNull @Source String mSource;
+
+ /** Hints for the type of data being suggested. */
+ private final @Nullable String[] mAutofillHints;
+
+
+
+
+ // 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/android/view/inputmethod/InlineSuggestionInfo.java
+ //
+ // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
+ // Settings > Editor > Code Style > Formatter Control
+ //@formatter:off
+
+
+ /** @hide */
+ @android.annotation.StringDef(prefix = "SOURCE_", value = {
+ SOURCE_AUTOFILL,
+ SOURCE_PLATFORM
+ })
+ @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE)
+ @DataClass.Generated.Member
+ public @interface Source {}
+
+ /**
+ * Creates a new InlineSuggestionInfo.
+ *
+ * @param presentationSpec
+ * The presentation spec to which the inflated suggestion view abides.
+ * @param source
+ * The source from which the suggestion is provided.
+ * @param autofillHints
+ * Hints for the type of data being suggested.
+ * @hide
+ */
+ @DataClass.Generated.Member
+ public InlineSuggestionInfo(
+ @NonNull InlinePresentationSpec presentationSpec,
+ @NonNull @Source String source,
+ @Nullable String[] autofillHints) {
+ this.mPresentationSpec = presentationSpec;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mPresentationSpec);
+ this.mSource = source;
+
+ if (!(java.util.Objects.equals(mSource, SOURCE_AUTOFILL))
+ && !(java.util.Objects.equals(mSource, SOURCE_PLATFORM))) {
+ throw new java.lang.IllegalArgumentException(
+ "source was " + mSource + " but must be one of: "
+ + "SOURCE_AUTOFILL(" + SOURCE_AUTOFILL + "), "
+ + "SOURCE_PLATFORM(" + SOURCE_PLATFORM + ")");
+ }
+
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mSource);
+ this.mAutofillHints = autofillHints;
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ /**
+ * The presentation spec to which the inflated suggestion view abides.
+ */
+ @DataClass.Generated.Member
+ public @NonNull InlinePresentationSpec getPresentationSpec() {
+ return mPresentationSpec;
+ }
+
+ /**
+ * The source from which the suggestion is provided.
+ */
+ @DataClass.Generated.Member
+ public @NonNull @Source String getSource() {
+ return mSource;
+ }
+
+ /**
+ * Hints for the type of data being suggested.
+ */
+ @DataClass.Generated.Member
+ public @Nullable String[] getAutofillHints() {
+ return mAutofillHints;
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public String toString() {
+ // You can override field toString logic by defining methods like:
+ // String fieldNameToString() { ... }
+
+ return "InlineSuggestionInfo { " +
+ "presentationSpec = " + mPresentationSpec + ", " +
+ "source = " + mSource + ", " +
+ "autofillHints = " + java.util.Arrays.toString(mAutofillHints) +
+ " }";
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public boolean equals(@Nullable Object o) {
+ // You can override field equality logic by defining either of the methods like:
+ // boolean fieldNameEquals(InlineSuggestionInfo other) { ... }
+ // boolean fieldNameEquals(FieldType otherValue) { ... }
+
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ @SuppressWarnings("unchecked")
+ InlineSuggestionInfo that = (InlineSuggestionInfo) o;
+ //noinspection PointlessBooleanExpression
+ return true
+ && java.util.Objects.equals(mPresentationSpec, that.mPresentationSpec)
+ && java.util.Objects.equals(mSource, that.mSource)
+ && java.util.Arrays.equals(mAutofillHints, that.mAutofillHints);
+ }
+
+ @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(mPresentationSpec);
+ _hash = 31 * _hash + java.util.Objects.hashCode(mSource);
+ _hash = 31 * _hash + java.util.Arrays.hashCode(mAutofillHints);
+ 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) { ... }
+
+ byte flg = 0;
+ if (mAutofillHints != null) flg |= 0x4;
+ dest.writeByte(flg);
+ dest.writeTypedObject(mPresentationSpec, flags);
+ dest.writeString(mSource);
+ if (mAutofillHints != null) dest.writeStringArray(mAutofillHints);
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public int describeContents() { return 0; }
+
+ /** @hide */
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ @DataClass.Generated.Member
+ /* package-private */ InlineSuggestionInfo(@NonNull android.os.Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ byte flg = in.readByte();
+ InlinePresentationSpec presentationSpec = (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR);
+ String source = in.readString();
+ String[] autofillHints = (flg & 0x4) == 0 ? null : in.createStringArray();
+
+ this.mPresentationSpec = presentationSpec;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mPresentationSpec);
+ this.mSource = source;
+
+ if (!(java.util.Objects.equals(mSource, SOURCE_AUTOFILL))
+ && !(java.util.Objects.equals(mSource, SOURCE_PLATFORM))) {
+ throw new java.lang.IllegalArgumentException(
+ "source was " + mSource + " but must be one of: "
+ + "SOURCE_AUTOFILL(" + SOURCE_AUTOFILL + "), "
+ + "SOURCE_PLATFORM(" + SOURCE_PLATFORM + ")");
+ }
+
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mSource);
+ this.mAutofillHints = autofillHints;
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public static final @NonNull Parcelable.Creator<InlineSuggestionInfo> CREATOR
+ = new Parcelable.Creator<InlineSuggestionInfo>() {
+ @Override
+ public InlineSuggestionInfo[] newArray(int size) {
+ return new InlineSuggestionInfo[size];
+ }
+
+ @Override
+ public InlineSuggestionInfo createFromParcel(@NonNull android.os.Parcel in) {
+ return new InlineSuggestionInfo(in);
+ }
+ };
+
+ @DataClass.Generated(
+ time = 1574406074120L,
+ codegenVersion = "1.0.14",
+ sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionInfo.java",
+ inputSignatures = "public static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_AUTOFILL\npublic static final @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String SOURCE_PLATFORM\nprivate final @android.annotation.NonNull android.view.inline.InlinePresentationSpec mPresentationSpec\nprivate final @android.annotation.NonNull @android.view.inputmethod.InlineSuggestionInfo.Source java.lang.String mSource\nprivate final @android.annotation.Nullable java.lang.String[] mAutofillHints\nclass InlineSuggestionInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
+ @Deprecated
+ private void __metadata() {}
+
+
+ //@formatter:on
+ // End of generated code
+
+}
diff --git a/core/java/android/view/inputmethod/InlineSuggestionsRequest.aidl b/core/java/android/view/inputmethod/InlineSuggestionsRequest.aidl
new file mode 100644
index 0000000..5a8abd2
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestionsRequest.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+parcelable InlineSuggestionsRequest;
diff --git a/core/java/android/view/inputmethod/InlineSuggestionsRequest.java b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
new file mode 100644
index 0000000..dd609ee
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+import android.annotation.NonNull;
+import android.os.Parcelable;
+import android.view.inline.InlinePresentationSpec;
+
+import com.android.internal.util.DataClass;
+import com.android.internal.util.Preconditions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class represents an inline suggestion request made by one app to get suggestions from the
+ * other source. See {@link InlineSuggestion} for more information.
+ */
+@DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
+public final class InlineSuggestionsRequest implements Parcelable {
+
+ /** Constant used to indicate not putting a cap on the number of suggestions to return. */
+ public static final int SUGGESTION_COUNT_UNLIMITED = Integer.MAX_VALUE;
+
+ private final int mMaxSuggestionCount;
+ private final @NonNull List<InlinePresentationSpec> mPresentationSpecs;
+
+ private void onConstructed() {
+ Preconditions.checkState(mMaxSuggestionCount >= mPresentationSpecs.size());
+ }
+
+ private static int defaultMaxSuggestionCount() {
+ return SUGGESTION_COUNT_UNLIMITED;
+ }
+
+ /** @hide */
+ abstract static class BaseBuilder {
+ abstract Builder setPresentationSpecs(@NonNull List<InlinePresentationSpec> value);
+ }
+
+
+
+ // 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/android/view/inputmethod/InlineSuggestionsRequest.java
+ //
+ // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
+ // Settings > Editor > Code Style > Formatter Control
+ //@formatter:off
+
+
+ @DataClass.Generated.Member
+ /* package-private */ InlineSuggestionsRequest(
+ int maxSuggestionCount,
+ @NonNull List<InlinePresentationSpec> presentationSpecs) {
+ this.mMaxSuggestionCount = maxSuggestionCount;
+ this.mPresentationSpecs = presentationSpecs;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mPresentationSpecs);
+
+ onConstructed();
+ }
+
+ @DataClass.Generated.Member
+ public int getMaxSuggestionCount() {
+ return mMaxSuggestionCount;
+ }
+
+ @DataClass.Generated.Member
+ public @NonNull List<InlinePresentationSpec> getPresentationSpecs() {
+ return mPresentationSpecs;
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public String toString() {
+ // You can override field toString logic by defining methods like:
+ // String fieldNameToString() { ... }
+
+ return "InlineSuggestionsRequest { " +
+ "maxSuggestionCount = " + mMaxSuggestionCount + ", " +
+ "presentationSpecs = " + mPresentationSpecs +
+ " }";
+ }
+
+ @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(InlineSuggestionsRequest other) { ... }
+ // boolean fieldNameEquals(FieldType otherValue) { ... }
+
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ @SuppressWarnings("unchecked")
+ InlineSuggestionsRequest that = (InlineSuggestionsRequest) o;
+ //noinspection PointlessBooleanExpression
+ return true
+ && mMaxSuggestionCount == that.mMaxSuggestionCount
+ && java.util.Objects.equals(mPresentationSpecs, that.mPresentationSpecs);
+ }
+
+ @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 + mMaxSuggestionCount;
+ _hash = 31 * _hash + java.util.Objects.hashCode(mPresentationSpecs);
+ 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.writeInt(mMaxSuggestionCount);
+ dest.writeParcelableList(mPresentationSpecs, flags);
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public int describeContents() { return 0; }
+
+ /** @hide */
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ @DataClass.Generated.Member
+ /* package-private */ InlineSuggestionsRequest(@NonNull android.os.Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ int maxSuggestionCount = in.readInt();
+ List<InlinePresentationSpec> presentationSpecs = new ArrayList<>();
+ in.readParcelableList(presentationSpecs, InlinePresentationSpec.class.getClassLoader());
+
+ this.mMaxSuggestionCount = maxSuggestionCount;
+ this.mPresentationSpecs = presentationSpecs;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mPresentationSpecs);
+
+ onConstructed();
+ }
+
+ @DataClass.Generated.Member
+ public static final @NonNull Parcelable.Creator<InlineSuggestionsRequest> CREATOR
+ = new Parcelable.Creator<InlineSuggestionsRequest>() {
+ @Override
+ public InlineSuggestionsRequest[] newArray(int size) {
+ return new InlineSuggestionsRequest[size];
+ }
+
+ @Override
+ public InlineSuggestionsRequest createFromParcel(@NonNull android.os.Parcel in) {
+ return new InlineSuggestionsRequest(in);
+ }
+ };
+
+ /**
+ * A builder for {@link InlineSuggestionsRequest}
+ */
+ @SuppressWarnings("WeakerAccess")
+ @DataClass.Generated.Member
+ public static final class Builder extends BaseBuilder {
+
+ private int mMaxSuggestionCount;
+ private @NonNull List<InlinePresentationSpec> mPresentationSpecs;
+
+ private long mBuilderFieldsSet = 0L;
+
+ public Builder(
+ @NonNull List<InlinePresentationSpec> presentationSpecs) {
+ mPresentationSpecs = presentationSpecs;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mPresentationSpecs);
+ }
+
+ @DataClass.Generated.Member
+ public @NonNull Builder setMaxSuggestionCount(int value) {
+ checkNotUsed();
+ mBuilderFieldsSet |= 0x1;
+ mMaxSuggestionCount = value;
+ return this;
+ }
+
+ @DataClass.Generated.Member
+ @Override
+ @NonNull Builder setPresentationSpecs(@NonNull List<InlinePresentationSpec> value) {
+ checkNotUsed();
+ mBuilderFieldsSet |= 0x2;
+ mPresentationSpecs = value;
+ return this;
+ }
+
+ /** @see #setPresentationSpecs */
+ @DataClass.Generated.Member
+ public @NonNull Builder addPresentationSpecs(@NonNull InlinePresentationSpec value) {
+ // You can refine this method's name by providing item's singular name, e.g.:
+ // @DataClass.PluralOf("item")) mItems = ...
+
+ if (mPresentationSpecs == null) setPresentationSpecs(new ArrayList<>());
+ mPresentationSpecs.add(value);
+ return this;
+ }
+
+ /** Builds the instance. This builder should not be touched after calling this! */
+ public @NonNull InlineSuggestionsRequest build() {
+ checkNotUsed();
+ mBuilderFieldsSet |= 0x4; // Mark builder used
+
+ if ((mBuilderFieldsSet & 0x1) == 0) {
+ mMaxSuggestionCount = defaultMaxSuggestionCount();
+ }
+ InlineSuggestionsRequest o = new InlineSuggestionsRequest(
+ mMaxSuggestionCount,
+ mPresentationSpecs);
+ return o;
+ }
+
+ private void checkNotUsed() {
+ if ((mBuilderFieldsSet & 0x4) != 0) {
+ throw new IllegalStateException(
+ "This Builder should not be reused. Use a new Builder instance instead");
+ }
+ }
+ }
+
+ @DataClass.Generated(
+ time = 1574406255024L,
+ codegenVersion = "1.0.14",
+ 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.view.inline.InlinePresentationSpec> mPresentationSpecs\nprivate void onConstructed()\nprivate static int defaultMaxSuggestionCount()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract android.view.inputmethod.InlineSuggestionsRequest.Builder setPresentationSpecs(java.util.List<android.view.inline.InlinePresentationSpec>)\nclass BaseBuilder extends java.lang.Object implements []")
+ @Deprecated
+ private void __metadata() {}
+
+
+ //@formatter:on
+ // End of generated code
+
+}
diff --git a/core/java/android/view/inputmethod/InlineSuggestionsResponse.aidl b/core/java/android/view/inputmethod/InlineSuggestionsResponse.aidl
new file mode 100644
index 0000000..9343fe9
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestionsResponse.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+parcelable InlineSuggestionsResponse;
diff --git a/core/java/android/view/inputmethod/InlineSuggestionsResponse.java b/core/java/android/view/inputmethod/InlineSuggestionsResponse.java
new file mode 100644
index 0000000..924a5ee
--- /dev/null
+++ b/core/java/android/view/inputmethod/InlineSuggestionsResponse.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2019 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.inputmethod;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcelable;
+
+import com.android.internal.util.DataClass;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class represents an inline suggestion response. See {@link InlineSuggestion} for more
+ * information.
+ */
+@DataClass(genEqualsHashCode = true, genToString = true, genHiddenConstructor = true)
+public final class InlineSuggestionsResponse implements Parcelable {
+ private final @NonNull List<InlineSuggestion> mInlineSuggestions;
+
+
+
+ // 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/android/view/inputmethod/InlineSuggestionsResponse.java
+ //
+ // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
+ // Settings > Editor > Code Style > Formatter Control
+ //@formatter:off
+
+
+ /**
+ * Creates a new InlineSuggestionsResponse.
+ *
+ * @hide
+ */
+ @DataClass.Generated.Member
+ public InlineSuggestionsResponse(
+ @NonNull List<InlineSuggestion> inlineSuggestions) {
+ this.mInlineSuggestions = inlineSuggestions;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mInlineSuggestions);
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public @NonNull List<InlineSuggestion> getInlineSuggestions() {
+ return mInlineSuggestions;
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public String toString() {
+ // You can override field toString logic by defining methods like:
+ // String fieldNameToString() { ... }
+
+ return "InlineSuggestionsResponse { " +
+ "inlineSuggestions = " + mInlineSuggestions +
+ " }";
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public boolean equals(@Nullable Object o) {
+ // You can override field equality logic by defining either of the methods like:
+ // boolean fieldNameEquals(InlineSuggestionsResponse other) { ... }
+ // boolean fieldNameEquals(FieldType otherValue) { ... }
+
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ @SuppressWarnings("unchecked")
+ InlineSuggestionsResponse that = (InlineSuggestionsResponse) o;
+ //noinspection PointlessBooleanExpression
+ return true
+ && java.util.Objects.equals(mInlineSuggestions, that.mInlineSuggestions);
+ }
+
+ @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(mInlineSuggestions);
+ 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.writeParcelableList(mInlineSuggestions, flags);
+ }
+
+ @Override
+ @DataClass.Generated.Member
+ public int describeContents() { return 0; }
+
+ /** @hide */
+ @SuppressWarnings({"unchecked", "RedundantCast"})
+ @DataClass.Generated.Member
+ /* package-private */ InlineSuggestionsResponse(@NonNull android.os.Parcel in) {
+ // You can override field unparcelling by defining methods like:
+ // static FieldType unparcelFieldName(Parcel in) { ... }
+
+ List<InlineSuggestion> inlineSuggestions = new ArrayList<>();
+ in.readParcelableList(inlineSuggestions, InlineSuggestion.class.getClassLoader());
+
+ this.mInlineSuggestions = inlineSuggestions;
+ com.android.internal.util.AnnotationValidations.validate(
+ NonNull.class, null, mInlineSuggestions);
+
+ // onConstructed(); // You can define this method to get a callback
+ }
+
+ @DataClass.Generated.Member
+ public static final @NonNull Parcelable.Creator<InlineSuggestionsResponse> CREATOR
+ = new Parcelable.Creator<InlineSuggestionsResponse>() {
+ @Override
+ public InlineSuggestionsResponse[] newArray(int size) {
+ return new InlineSuggestionsResponse[size];
+ }
+
+ @Override
+ public InlineSuggestionsResponse createFromParcel(@NonNull android.os.Parcel in) {
+ return new InlineSuggestionsResponse(in);
+ }
+ };
+
+ @DataClass.Generated(
+ time = 1574406147911L,
+ codegenVersion = "1.0.14",
+ sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsResponse.java",
+ inputSignatures = "private final @android.annotation.NonNull java.util.List<android.view.inputmethod.InlineSuggestion> mInlineSuggestions\nclass InlineSuggestionsResponse extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstructor=true)")
+ @Deprecated
+ private void __metadata() {}
+
+
+ //@formatter:on
+ // End of generated code
+
+}
diff --git a/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl b/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl
new file mode 100644
index 0000000..6b54910
--- /dev/null
+++ b/core/java/com/android/internal/view/IInlineSuggestionsRequestCallback.aidl
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 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.view.inputmethod.InlineSuggestionsRequest;
+
+import com.android.internal.view.IInlineSuggestionsResponseCallback;
+
+/**
+ * Binder interface for the IME service to send an inline suggestion request to the system.
+ * {@hide}
+ */
+oneway interface IInlineSuggestionsRequestCallback {
+ void onInlineSuggestionsUnsupported();
+ void onInlineSuggestionsRequest(in InlineSuggestionsRequest request,
+ in IInlineSuggestionsResponseCallback callback);
+}
diff --git a/core/java/com/android/internal/view/IInlineSuggestionsResponseCallback.aidl b/core/java/com/android/internal/view/IInlineSuggestionsResponseCallback.aidl
new file mode 100644
index 0000000..0f93b8e
--- /dev/null
+++ b/core/java/com/android/internal/view/IInlineSuggestionsResponseCallback.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 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.view.inputmethod.InlineSuggestionsResponse;
+
+/**
+ * Binder interface for the IME service to receive an inline suggestion response from the system.
+ * {@hide}
+ */
+oneway interface IInlineSuggestionsResponseCallback {
+ void onInlineSuggestionsResponse(in InlineSuggestionsResponse response);
+}
diff --git a/core/java/com/android/internal/view/inline/IInlineContentCallback.aidl b/core/java/com/android/internal/view/inline/IInlineContentCallback.aidl
new file mode 100644
index 0000000..8cc49ca
--- /dev/null
+++ b/core/java/com/android/internal/view/inline/IInlineContentCallback.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 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.inline;
+
+import android.view.SurfaceControl;
+
+/**
+ * Binder interface to send the inline content from one process to the other.
+ * {@hide}
+ */
+oneway interface IInlineContentCallback {
+ void onContent(in SurfaceControl content);
+}
diff --git a/core/java/com/android/internal/view/inline/IInlineContentProvider.aidl b/core/java/com/android/internal/view/inline/IInlineContentProvider.aidl
new file mode 100644
index 0000000..08a349c
--- /dev/null
+++ b/core/java/com/android/internal/view/inline/IInlineContentProvider.aidl
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2019 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.inline;
+
+import com.android.internal.view.inline.IInlineContentCallback;
+
+/**
+ * Binder interface for a process to request the inline content from the other process.
+ * {@hide}
+ */
+oneway interface IInlineContentProvider {
+ void provideContent(int width, int height, in IInlineContentCallback callback);
+}