• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view.inputmethod;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.app.ActivityThread;
22 import android.app.compat.CompatChanges;
23 import android.compat.annotation.ChangeId;
24 import android.compat.annotation.EnabledSince;
25 import android.os.Build;
26 import android.os.Bundle;
27 import android.os.IBinder;
28 import android.os.LocaleList;
29 import android.os.Parcel;
30 import android.os.Parcelable;
31 import android.view.Display;
32 import android.widget.inline.InlinePresentationSpec;
33 
34 import com.android.internal.util.DataClass;
35 import com.android.internal.util.Preconditions;
36 import com.android.internal.widget.InlinePresentationStyleUtils;
37 
38 import java.util.ArrayList;
39 import java.util.List;
40 
41 /**
42  * This class represents an inline suggestion request made by one app to get suggestions from the
43  * other source. See {@link InlineSuggestion} for more information.
44  */
45 @DataClass(genEqualsHashCode = true, genToString = true, genBuilder = true)
46 public final class InlineSuggestionsRequest implements Parcelable {
47 
48     /** Constant used to indicate not putting a cap on the number of suggestions to return. */
49     public static final int SUGGESTION_COUNT_UNLIMITED = Integer.MAX_VALUE;
50 
51     /**
52      * Max number of suggestions expected from the response. It must be a positive value.
53      * Defaults to {@code SUGGESTION_COUNT_UNLIMITED} if not set.
54      *
55      * <p>In practice, it is recommended that the max suggestion count does not exceed <b>5</b>
56      * for performance reasons.</p>
57      */
58     private final int mMaxSuggestionCount;
59 
60     /**
61      * The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
62      * count is larger than the number of specs in the list, then the last spec is used for the
63      * remainder of the suggestions. The list should not be empty.
64      */
65     private final @NonNull List<InlinePresentationSpec> mInlinePresentationSpecs;
66 
67     /**
68      * The package name of the app that requests for the inline suggestions and will host the
69      * embedded suggestion views. The app does not have to set the value for the field because
70      * it'll be set by the system for safety reasons.
71      */
72     private @NonNull String mHostPackageName;
73 
74     /**
75      * The IME provided locales for the request. If non-empty, the inline suggestions should
76      * return languages from the supported locales. If not provided, it'll default to be empty if
77      * target SDK is S or above, and default to system locale otherwise.
78      *
79      * <p>Note for Autofill Providers: It is <b>recommended</b> for the returned inline suggestions
80      * to have one locale to guarantee consistent UI rendering.</p>
81      */
82     private @NonNull LocaleList mSupportedLocales;
83 
84     /**
85      * The extras state propagated from the IME to pass extra data.
86      *
87      * <p>Note: There should be no remote objects in the bundle, all included remote objects will
88      * be removed from the bundle before transmission.</p>
89      */
90     private @NonNull Bundle mExtras;
91 
92     /**
93      * The host input token of the IME that made the request. This will be set by the system for
94      * safety reasons.
95      *
96      * @hide
97      */
98     private @Nullable IBinder mHostInputToken;
99 
100     /**
101      * The host display id of the IME that made the request. This will be set by the system for
102      * safety reasons.
103      *
104      * @hide
105      */
106     private int mHostDisplayId;
107 
108     /**
109      * Specifies the UI specification for the inline suggestion tooltip in the response.
110      */
111     private @Nullable InlinePresentationSpec mInlineTooltipPresentationSpec;
112 
113     /**
114      * @hide
115      * @see {@link #mHostInputToken}.
116      */
setHostInputToken(IBinder hostInputToken)117     public void setHostInputToken(IBinder hostInputToken) {
118         mHostInputToken = hostInputToken;
119     }
120 
extrasEquals(@onNull Bundle extras)121     private boolean extrasEquals(@NonNull Bundle extras) {
122         return InlinePresentationStyleUtils.bundleEquals(mExtras, extras);
123     }
124 
125     // TODO(b/149609075): remove once IBinder parcelling is natively supported
parcelHostInputToken(@onNull Parcel parcel, int flags)126     private void parcelHostInputToken(@NonNull Parcel parcel, int flags) {
127         parcel.writeStrongBinder(mHostInputToken);
128     }
129 
130     // TODO(b/149609075): remove once IBinder parcelling is natively supported
unparcelHostInputToken(Parcel parcel)131     private @Nullable IBinder unparcelHostInputToken(Parcel parcel) {
132         return parcel.readStrongBinder();
133     }
134 
135     /**
136      * @hide
137      * @see {@link #mHostDisplayId}.
138      */
setHostDisplayId(int hostDisplayId)139     public void setHostDisplayId(int hostDisplayId) {
140         mHostDisplayId = hostDisplayId;
141     }
142 
onConstructed()143     private void onConstructed() {
144         Preconditions.checkState(!mInlinePresentationSpecs.isEmpty());
145         Preconditions.checkState(mMaxSuggestionCount >= mInlinePresentationSpecs.size());
146     }
147 
148     /**
149      * Removes the remote objects from the bundles within the {@Code mExtras} and the
150      * {@code mInlinePresentationSpecs}.
151      *
152      * @hide
153      */
filterContentTypes()154     public void filterContentTypes() {
155         InlinePresentationStyleUtils.filterContentTypes(mExtras);
156         for (int i = 0; i < mInlinePresentationSpecs.size(); i++) {
157             mInlinePresentationSpecs.get(i).filterContentTypes();
158         }
159 
160         if (mInlineTooltipPresentationSpec != null) {
161             mInlineTooltipPresentationSpec.filterContentTypes();
162         }
163     }
164 
defaultMaxSuggestionCount()165     private static int defaultMaxSuggestionCount() {
166         return SUGGESTION_COUNT_UNLIMITED;
167     }
168 
defaultHostPackageName()169     private static String defaultHostPackageName() {
170         return ActivityThread.currentPackageName();
171     }
172 
defaultInlineTooltipPresentationSpec()173     private static InlinePresentationSpec defaultInlineTooltipPresentationSpec() {
174         return null;
175     }
176 
177     /**
178      * The {@link InlineSuggestionsRequest#getSupportedLocales()} now returns empty locale list when
179      * it's not set, instead of the default system locale.
180      */
181     @ChangeId
182     @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
183     private static final long IME_AUTOFILL_DEFAULT_SUPPORTED_LOCALES_IS_EMPTY = 169273070L;
184 
defaultSupportedLocales()185     private static LocaleList defaultSupportedLocales() {
186         if (CompatChanges.isChangeEnabled(IME_AUTOFILL_DEFAULT_SUPPORTED_LOCALES_IS_EMPTY)) {
187             return LocaleList.getEmptyLocaleList();
188         }
189         return LocaleList.getDefault();
190     }
191 
192     @Nullable
defaultHostInputToken()193     private static IBinder defaultHostInputToken() {
194         return null;
195     }
196 
197     @Nullable
defaultHostDisplayId()198     private static int defaultHostDisplayId() {
199         return Display.INVALID_DISPLAY;
200     }
201 
202     @NonNull
defaultExtras()203     private static Bundle defaultExtras() {
204         return Bundle.EMPTY;
205     }
206 
207     /** @hide */
208     abstract static class BaseBuilder {
setInlinePresentationSpecs( @onNull List<android.widget.inline.InlinePresentationSpec> specs)209         abstract Builder setInlinePresentationSpecs(
210                 @NonNull List<android.widget.inline.InlinePresentationSpec> specs);
211 
setHostPackageName(@ullable String value)212         abstract Builder setHostPackageName(@Nullable String value);
213 
setHostInputToken(IBinder hostInputToken)214         abstract Builder setHostInputToken(IBinder hostInputToken);
215 
setHostDisplayId(int value)216         abstract Builder setHostDisplayId(int value);
217     }
218 
219     // Code below generated by codegen v1.0.23.
220     //
221     // DO NOT MODIFY!
222     // CHECKSTYLE:OFF Generated code
223     //
224     // To regenerate run:
225     // $ codegen $ANDROID_BUILD_TOP/./frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
226     //
227     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
228     //   Settings > Editor > Code Style > Formatter Control
229     //@formatter:off
230 
231 
232     @DataClass.Generated.Member
InlineSuggestionsRequest( int maxSuggestionCount, @NonNull List<InlinePresentationSpec> inlinePresentationSpecs, @NonNull String hostPackageName, @NonNull LocaleList supportedLocales, @NonNull Bundle extras, @Nullable IBinder hostInputToken, int hostDisplayId, @Nullable InlinePresentationSpec inlineTooltipPresentationSpec)233     /* package-private */ InlineSuggestionsRequest(
234             int maxSuggestionCount,
235             @NonNull List<InlinePresentationSpec> inlinePresentationSpecs,
236             @NonNull String hostPackageName,
237             @NonNull LocaleList supportedLocales,
238             @NonNull Bundle extras,
239             @Nullable IBinder hostInputToken,
240             int hostDisplayId,
241             @Nullable InlinePresentationSpec inlineTooltipPresentationSpec) {
242         this.mMaxSuggestionCount = maxSuggestionCount;
243         this.mInlinePresentationSpecs = inlinePresentationSpecs;
244         com.android.internal.util.AnnotationValidations.validate(
245                 NonNull.class, null, mInlinePresentationSpecs);
246         this.mHostPackageName = hostPackageName;
247         com.android.internal.util.AnnotationValidations.validate(
248                 NonNull.class, null, mHostPackageName);
249         this.mSupportedLocales = supportedLocales;
250         com.android.internal.util.AnnotationValidations.validate(
251                 NonNull.class, null, mSupportedLocales);
252         this.mExtras = extras;
253         com.android.internal.util.AnnotationValidations.validate(
254                 NonNull.class, null, mExtras);
255         this.mHostInputToken = hostInputToken;
256         this.mHostDisplayId = hostDisplayId;
257         this.mInlineTooltipPresentationSpec = inlineTooltipPresentationSpec;
258 
259         onConstructed();
260     }
261 
262     /**
263      * Max number of suggestions expected from the response. It must be a positive value.
264      * Defaults to {@code SUGGESTION_COUNT_UNLIMITED} if not set.
265      *
266      * <p>In practice, it is recommended that the max suggestion count does not exceed <b>5</b>
267      * for performance reasons.</p>
268      */
269     @DataClass.Generated.Member
getMaxSuggestionCount()270     public int getMaxSuggestionCount() {
271         return mMaxSuggestionCount;
272     }
273 
274     /**
275      * The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
276      * count is larger than the number of specs in the list, then the last spec is used for the
277      * remainder of the suggestions. The list should not be empty.
278      */
279     @DataClass.Generated.Member
getInlinePresentationSpecs()280     public @NonNull List<InlinePresentationSpec> getInlinePresentationSpecs() {
281         return mInlinePresentationSpecs;
282     }
283 
284     /**
285      * The package name of the app that requests for the inline suggestions and will host the
286      * embedded suggestion views. The app does not have to set the value for the field because
287      * it'll be set by the system for safety reasons.
288      */
289     @DataClass.Generated.Member
getHostPackageName()290     public @NonNull String getHostPackageName() {
291         return mHostPackageName;
292     }
293 
294     /**
295      * The IME provided locales for the request. If non-empty, the inline suggestions should
296      * return languages from the supported locales. If not provided, it'll default to be empty if
297      * target SDK is S or above, and default to system locale otherwise.
298      *
299      * <p>Note for Autofill Providers: It is <b>recommended</b> for the returned inline suggestions
300      * to have one locale to guarantee consistent UI rendering.</p>
301      */
302     @DataClass.Generated.Member
getSupportedLocales()303     public @NonNull LocaleList getSupportedLocales() {
304         return mSupportedLocales;
305     }
306 
307     /**
308      * The extras state propagated from the IME to pass extra data.
309      *
310      * <p>Note: There should be no remote objects in the bundle, all included remote objects will
311      * be removed from the bundle before transmission.</p>
312      */
313     @DataClass.Generated.Member
getExtras()314     public @NonNull Bundle getExtras() {
315         return mExtras;
316     }
317 
318     /**
319      * The host input token of the IME that made the request. This will be set by the system for
320      * safety reasons.
321      *
322      * @hide
323      */
324     @DataClass.Generated.Member
getHostInputToken()325     public @Nullable IBinder getHostInputToken() {
326         return mHostInputToken;
327     }
328 
329     /**
330      * The host display id of the IME that made the request. This will be set by the system for
331      * safety reasons.
332      *
333      * @hide
334      */
335     @DataClass.Generated.Member
getHostDisplayId()336     public int getHostDisplayId() {
337         return mHostDisplayId;
338     }
339 
340     /**
341      * Specifies the UI specification for the inline suggestion tooltip in the response.
342      */
343     @DataClass.Generated.Member
getInlineTooltipPresentationSpec()344     public @Nullable InlinePresentationSpec getInlineTooltipPresentationSpec() {
345         return mInlineTooltipPresentationSpec;
346     }
347 
348     @Override
349     @DataClass.Generated.Member
toString()350     public String toString() {
351         // You can override field toString logic by defining methods like:
352         // String fieldNameToString() { ... }
353 
354         return "InlineSuggestionsRequest { " +
355                 "maxSuggestionCount = " + mMaxSuggestionCount + ", " +
356                 "inlinePresentationSpecs = " + mInlinePresentationSpecs + ", " +
357                 "hostPackageName = " + mHostPackageName + ", " +
358                 "supportedLocales = " + mSupportedLocales + ", " +
359                 "extras = " + mExtras + ", " +
360                 "hostInputToken = " + mHostInputToken + ", " +
361                 "hostDisplayId = " + mHostDisplayId + ", " +
362                 "inlineTooltipPresentationSpec = " + mInlineTooltipPresentationSpec +
363         " }";
364     }
365 
366     @Override
367     @DataClass.Generated.Member
equals(@ullable Object o)368     public boolean equals(@Nullable Object o) {
369         // You can override field equality logic by defining either of the methods like:
370         // boolean fieldNameEquals(InlineSuggestionsRequest other) { ... }
371         // boolean fieldNameEquals(FieldType otherValue) { ... }
372 
373         if (this == o) return true;
374         if (o == null || getClass() != o.getClass()) return false;
375         @SuppressWarnings("unchecked")
376         InlineSuggestionsRequest that = (InlineSuggestionsRequest) o;
377         //noinspection PointlessBooleanExpression
378         return true
379                 && mMaxSuggestionCount == that.mMaxSuggestionCount
380                 && java.util.Objects.equals(mInlinePresentationSpecs, that.mInlinePresentationSpecs)
381                 && java.util.Objects.equals(mHostPackageName, that.mHostPackageName)
382                 && java.util.Objects.equals(mSupportedLocales, that.mSupportedLocales)
383                 && extrasEquals(that.mExtras)
384                 && java.util.Objects.equals(mHostInputToken, that.mHostInputToken)
385                 && mHostDisplayId == that.mHostDisplayId
386                 && java.util.Objects.equals(mInlineTooltipPresentationSpec, that.mInlineTooltipPresentationSpec);
387     }
388 
389     @Override
390     @DataClass.Generated.Member
hashCode()391     public int hashCode() {
392         // You can override field hashCode logic by defining methods like:
393         // int fieldNameHashCode() { ... }
394 
395         int _hash = 1;
396         _hash = 31 * _hash + mMaxSuggestionCount;
397         _hash = 31 * _hash + java.util.Objects.hashCode(mInlinePresentationSpecs);
398         _hash = 31 * _hash + java.util.Objects.hashCode(mHostPackageName);
399         _hash = 31 * _hash + java.util.Objects.hashCode(mSupportedLocales);
400         _hash = 31 * _hash + java.util.Objects.hashCode(mExtras);
401         _hash = 31 * _hash + java.util.Objects.hashCode(mHostInputToken);
402         _hash = 31 * _hash + mHostDisplayId;
403         _hash = 31 * _hash + java.util.Objects.hashCode(mInlineTooltipPresentationSpec);
404         return _hash;
405     }
406 
407     @Override
408     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)409     public void writeToParcel(@NonNull Parcel dest, int flags) {
410         // You can override field parcelling by defining methods like:
411         // void parcelFieldName(Parcel dest, int flags) { ... }
412 
413         int flg = 0;
414         if (mHostInputToken != null) flg |= 0x20;
415         if (mInlineTooltipPresentationSpec != null) flg |= 0x80;
416         dest.writeInt(flg);
417         dest.writeInt(mMaxSuggestionCount);
418         dest.writeParcelableList(mInlinePresentationSpecs, flags);
419         dest.writeString(mHostPackageName);
420         dest.writeTypedObject(mSupportedLocales, flags);
421         dest.writeBundle(mExtras);
422         parcelHostInputToken(dest, flags);
423         dest.writeInt(mHostDisplayId);
424         if (mInlineTooltipPresentationSpec != null) dest.writeTypedObject(mInlineTooltipPresentationSpec, flags);
425     }
426 
427     @Override
428     @DataClass.Generated.Member
describeContents()429     public int describeContents() { return 0; }
430 
431     /** @hide */
432     @SuppressWarnings({"unchecked", "RedundantCast"})
433     @DataClass.Generated.Member
InlineSuggestionsRequest(@onNull Parcel in)434     /* package-private */ InlineSuggestionsRequest(@NonNull Parcel in) {
435         // You can override field unparcelling by defining methods like:
436         // static FieldType unparcelFieldName(Parcel in) { ... }
437 
438         int flg = in.readInt();
439         int maxSuggestionCount = in.readInt();
440         List<InlinePresentationSpec> inlinePresentationSpecs = new ArrayList<>();
441         in.readParcelableList(inlinePresentationSpecs, InlinePresentationSpec.class.getClassLoader());
442         String hostPackageName = in.readString();
443         LocaleList supportedLocales = (LocaleList) in.readTypedObject(LocaleList.CREATOR);
444         Bundle extras = in.readBundle();
445         IBinder hostInputToken = unparcelHostInputToken(in);
446         int hostDisplayId = in.readInt();
447         InlinePresentationSpec inlineTooltipPresentationSpec = (flg & 0x80) == 0 ? null : (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR);
448 
449         this.mMaxSuggestionCount = maxSuggestionCount;
450         this.mInlinePresentationSpecs = inlinePresentationSpecs;
451         com.android.internal.util.AnnotationValidations.validate(
452                 NonNull.class, null, mInlinePresentationSpecs);
453         this.mHostPackageName = hostPackageName;
454         com.android.internal.util.AnnotationValidations.validate(
455                 NonNull.class, null, mHostPackageName);
456         this.mSupportedLocales = supportedLocales;
457         com.android.internal.util.AnnotationValidations.validate(
458                 NonNull.class, null, mSupportedLocales);
459         this.mExtras = extras;
460         com.android.internal.util.AnnotationValidations.validate(
461                 NonNull.class, null, mExtras);
462         this.mHostInputToken = hostInputToken;
463         this.mHostDisplayId = hostDisplayId;
464         this.mInlineTooltipPresentationSpec = inlineTooltipPresentationSpec;
465 
466         onConstructed();
467     }
468 
469     @DataClass.Generated.Member
470     public static final @NonNull Parcelable.Creator<InlineSuggestionsRequest> CREATOR
471             = new Parcelable.Creator<InlineSuggestionsRequest>() {
472         @Override
473         public InlineSuggestionsRequest[] newArray(int size) {
474             return new InlineSuggestionsRequest[size];
475         }
476 
477         @Override
478         public InlineSuggestionsRequest createFromParcel(@NonNull Parcel in) {
479             return new InlineSuggestionsRequest(in);
480         }
481     };
482 
483     /**
484      * A builder for {@link InlineSuggestionsRequest}
485      */
486     @SuppressWarnings("WeakerAccess")
487     @DataClass.Generated.Member
488     public static final class Builder extends BaseBuilder {
489 
490         private int mMaxSuggestionCount;
491         private @NonNull List<InlinePresentationSpec> mInlinePresentationSpecs;
492         private @NonNull String mHostPackageName;
493         private @NonNull LocaleList mSupportedLocales;
494         private @NonNull Bundle mExtras;
495         private @Nullable IBinder mHostInputToken;
496         private int mHostDisplayId;
497         private @Nullable InlinePresentationSpec mInlineTooltipPresentationSpec;
498 
499         private long mBuilderFieldsSet = 0L;
500 
501         /**
502          * Creates a new Builder.
503          *
504          * @param inlinePresentationSpecs
505          *   The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
506          *   count is larger than the number of specs in the list, then the last spec is used for the
507          *   remainder of the suggestions. The list should not be empty.
508          */
Builder( @onNull List<InlinePresentationSpec> inlinePresentationSpecs)509         public Builder(
510                 @NonNull List<InlinePresentationSpec> inlinePresentationSpecs) {
511             mInlinePresentationSpecs = inlinePresentationSpecs;
512             com.android.internal.util.AnnotationValidations.validate(
513                     NonNull.class, null, mInlinePresentationSpecs);
514         }
515 
516         /**
517          * Max number of suggestions expected from the response. It must be a positive value.
518          * Defaults to {@code SUGGESTION_COUNT_UNLIMITED} if not set.
519          *
520          * <p>In practice, it is recommended that the max suggestion count does not exceed <b>5</b>
521          * for performance reasons.</p>
522          */
523         @DataClass.Generated.Member
setMaxSuggestionCount(int value)524         public @NonNull Builder setMaxSuggestionCount(int value) {
525             checkNotUsed();
526             mBuilderFieldsSet |= 0x1;
527             mMaxSuggestionCount = value;
528             return this;
529         }
530 
531         /**
532          * The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
533          * count is larger than the number of specs in the list, then the last spec is used for the
534          * remainder of the suggestions. The list should not be empty.
535          */
536         @DataClass.Generated.Member
setInlinePresentationSpecs(@onNull List<InlinePresentationSpec> value)537         public @NonNull Builder setInlinePresentationSpecs(@NonNull List<InlinePresentationSpec> value) {
538             checkNotUsed();
539             mBuilderFieldsSet |= 0x2;
540             mInlinePresentationSpecs = value;
541             return this;
542         }
543 
544         /** @see #setInlinePresentationSpecs */
545         @DataClass.Generated.Member
addInlinePresentationSpecs(@onNull InlinePresentationSpec value)546         public @NonNull Builder addInlinePresentationSpecs(@NonNull InlinePresentationSpec value) {
547             // You can refine this method's name by providing item's singular name, e.g.:
548             // @DataClass.PluralOf("item")) mItems = ...
549 
550             if (mInlinePresentationSpecs == null) setInlinePresentationSpecs(new ArrayList<>());
551             mInlinePresentationSpecs.add(value);
552             return this;
553         }
554 
555         /**
556          * The package name of the app that requests for the inline suggestions and will host the
557          * embedded suggestion views. The app does not have to set the value for the field because
558          * it'll be set by the system for safety reasons.
559          */
560         @DataClass.Generated.Member
561         @Override
setHostPackageName(@onNull String value)562         @NonNull Builder setHostPackageName(@NonNull String value) {
563             checkNotUsed();
564             mBuilderFieldsSet |= 0x4;
565             mHostPackageName = value;
566             return this;
567         }
568 
569         /**
570          * The IME provided locales for the request. If non-empty, the inline suggestions should
571          * return languages from the supported locales. If not provided, it'll default to be empty if
572          * target SDK is S or above, and default to system locale otherwise.
573          *
574          * <p>Note for Autofill Providers: It is <b>recommended</b> for the returned inline suggestions
575          * to have one locale to guarantee consistent UI rendering.</p>
576          */
577         @DataClass.Generated.Member
setSupportedLocales(@onNull LocaleList value)578         public @NonNull Builder setSupportedLocales(@NonNull LocaleList value) {
579             checkNotUsed();
580             mBuilderFieldsSet |= 0x8;
581             mSupportedLocales = value;
582             return this;
583         }
584 
585         /**
586          * The extras state propagated from the IME to pass extra data.
587          *
588          * <p>Note: There should be no remote objects in the bundle, all included remote objects will
589          * be removed from the bundle before transmission.</p>
590          */
591         @DataClass.Generated.Member
setExtras(@onNull Bundle value)592         public @NonNull Builder setExtras(@NonNull Bundle value) {
593             checkNotUsed();
594             mBuilderFieldsSet |= 0x10;
595             mExtras = value;
596             return this;
597         }
598 
599         /**
600          * The host input token of the IME that made the request. This will be set by the system for
601          * safety reasons.
602          *
603          * @hide
604          */
605         @DataClass.Generated.Member
606         @Override
setHostInputToken(@onNull IBinder value)607         @NonNull Builder setHostInputToken(@NonNull IBinder value) {
608             checkNotUsed();
609             mBuilderFieldsSet |= 0x20;
610             mHostInputToken = value;
611             return this;
612         }
613 
614         /**
615          * The host display id of the IME that made the request. This will be set by the system for
616          * safety reasons.
617          *
618          * @hide
619          */
620         @DataClass.Generated.Member
621         @Override
setHostDisplayId(int value)622         @NonNull Builder setHostDisplayId(int value) {
623             checkNotUsed();
624             mBuilderFieldsSet |= 0x40;
625             mHostDisplayId = value;
626             return this;
627         }
628 
629         /**
630          * Specifies the UI specification for the inline suggestion tooltip in the response.
631          */
632         @DataClass.Generated.Member
setInlineTooltipPresentationSpec(@onNull InlinePresentationSpec value)633         public @NonNull Builder setInlineTooltipPresentationSpec(@NonNull InlinePresentationSpec value) {
634             checkNotUsed();
635             mBuilderFieldsSet |= 0x80;
636             mInlineTooltipPresentationSpec = value;
637             return this;
638         }
639 
640         /** Builds the instance. This builder should not be touched after calling this! */
build()641         public @NonNull InlineSuggestionsRequest build() {
642             checkNotUsed();
643             mBuilderFieldsSet |= 0x100; // Mark builder used
644 
645             if ((mBuilderFieldsSet & 0x1) == 0) {
646                 mMaxSuggestionCount = defaultMaxSuggestionCount();
647             }
648             if ((mBuilderFieldsSet & 0x4) == 0) {
649                 mHostPackageName = defaultHostPackageName();
650             }
651             if ((mBuilderFieldsSet & 0x8) == 0) {
652                 mSupportedLocales = defaultSupportedLocales();
653             }
654             if ((mBuilderFieldsSet & 0x10) == 0) {
655                 mExtras = defaultExtras();
656             }
657             if ((mBuilderFieldsSet & 0x20) == 0) {
658                 mHostInputToken = defaultHostInputToken();
659             }
660             if ((mBuilderFieldsSet & 0x40) == 0) {
661                 mHostDisplayId = defaultHostDisplayId();
662             }
663             if ((mBuilderFieldsSet & 0x80) == 0) {
664                 mInlineTooltipPresentationSpec = defaultInlineTooltipPresentationSpec();
665             }
666             InlineSuggestionsRequest o = new InlineSuggestionsRequest(
667                     mMaxSuggestionCount,
668                     mInlinePresentationSpecs,
669                     mHostPackageName,
670                     mSupportedLocales,
671                     mExtras,
672                     mHostInputToken,
673                     mHostDisplayId,
674                     mInlineTooltipPresentationSpec);
675             return o;
676         }
677 
checkNotUsed()678         private void checkNotUsed() {
679             if ((mBuilderFieldsSet & 0x100) != 0) {
680                 throw new IllegalStateException(
681                         "This Builder should not be reused. Use a new Builder instance instead");
682             }
683         }
684     }
685 
686     @DataClass.Generated(
687             time = 1696889841006L,
688             codegenVersion = "1.0.23",
689             sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java",
690             inputSignatures = "public static final  int SUGGESTION_COUNT_UNLIMITED\nprivate final  int mMaxSuggestionCount\nprivate final @android.annotation.NonNull java.util.List<android.widget.inline.InlinePresentationSpec> mInlinePresentationSpecs\nprivate @android.annotation.NonNull java.lang.String mHostPackageName\nprivate @android.annotation.NonNull android.os.LocaleList mSupportedLocales\nprivate @android.annotation.NonNull android.os.Bundle mExtras\nprivate @android.annotation.Nullable android.os.IBinder mHostInputToken\nprivate  int mHostDisplayId\nprivate @android.annotation.Nullable android.widget.inline.InlinePresentationSpec mInlineTooltipPresentationSpec\nprivate static final @android.compat.annotation.ChangeId @android.compat.annotation.EnabledSince long IME_AUTOFILL_DEFAULT_SUPPORTED_LOCALES_IS_EMPTY\npublic  void setHostInputToken(android.os.IBinder)\nprivate  boolean extrasEquals(android.os.Bundle)\nprivate  void parcelHostInputToken(android.os.Parcel,int)\nprivate @android.annotation.Nullable android.os.IBinder unparcelHostInputToken(android.os.Parcel)\npublic  void setHostDisplayId(int)\nprivate  void onConstructed()\npublic  void filterContentTypes()\nprivate static  int defaultMaxSuggestionCount()\nprivate static  java.lang.String defaultHostPackageName()\nprivate static  android.widget.inline.InlinePresentationSpec defaultInlineTooltipPresentationSpec()\nprivate static  android.os.LocaleList defaultSupportedLocales()\nprivate static @android.annotation.Nullable android.os.IBinder defaultHostInputToken()\nprivate static @android.annotation.Nullable int defaultHostDisplayId()\nprivate static @android.annotation.NonNull android.os.Bundle defaultExtras()\nclass InlineSuggestionsRequest extends java.lang.Object implements [android.os.Parcelable]\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genBuilder=true)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setInlinePresentationSpecs(java.util.List<android.widget.inline.InlinePresentationSpec>)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setHostPackageName(java.lang.String)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setHostInputToken(android.os.IBinder)\nabstract  android.view.inputmethod.InlineSuggestionsRequest.Builder setHostDisplayId(int)\nclass BaseBuilder extends java.lang.Object implements []")
691     @Deprecated
__metadata()692     private void __metadata() {}
693 
694 
695     //@formatter:on
696     // End of generated code
697 
698 }
699