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 
220 
221     // Code below generated by codegen v1.0.23.
222     //
223     // DO NOT MODIFY!
224     // CHECKSTYLE:OFF Generated code
225     //
226     // To regenerate run:
227     // $ codegen $ANDROID_BUILD_TOP/./frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java
228     //
229     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
230     //   Settings > Editor > Code Style > Formatter Control
231     //@formatter:off
232 
233 
234     @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)235     /* package-private */ InlineSuggestionsRequest(
236             int maxSuggestionCount,
237             @NonNull List<InlinePresentationSpec> inlinePresentationSpecs,
238             @NonNull String hostPackageName,
239             @NonNull LocaleList supportedLocales,
240             @NonNull Bundle extras,
241             @Nullable IBinder hostInputToken,
242             int hostDisplayId,
243             @Nullable InlinePresentationSpec inlineTooltipPresentationSpec) {
244         this.mMaxSuggestionCount = maxSuggestionCount;
245         this.mInlinePresentationSpecs = inlinePresentationSpecs;
246         com.android.internal.util.AnnotationValidations.validate(
247                 NonNull.class, null, mInlinePresentationSpecs);
248         this.mHostPackageName = hostPackageName;
249         com.android.internal.util.AnnotationValidations.validate(
250                 NonNull.class, null, mHostPackageName);
251         this.mSupportedLocales = supportedLocales;
252         com.android.internal.util.AnnotationValidations.validate(
253                 NonNull.class, null, mSupportedLocales);
254         this.mExtras = extras;
255         com.android.internal.util.AnnotationValidations.validate(
256                 NonNull.class, null, mExtras);
257         this.mHostInputToken = hostInputToken;
258         this.mHostDisplayId = hostDisplayId;
259         this.mInlineTooltipPresentationSpec = inlineTooltipPresentationSpec;
260 
261         onConstructed();
262     }
263 
264     /**
265      * Max number of suggestions expected from the response. It must be a positive value.
266      * Defaults to {@code SUGGESTION_COUNT_UNLIMITED} if not set.
267      *
268      * <p>In practice, it is recommended that the max suggestion count does not exceed <b>5</b>
269      * for performance reasons.</p>
270      */
271     @DataClass.Generated.Member
getMaxSuggestionCount()272     public int getMaxSuggestionCount() {
273         return mMaxSuggestionCount;
274     }
275 
276     /**
277      * The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
278      * count is larger than the number of specs in the list, then the last spec is used for the
279      * remainder of the suggestions. The list should not be empty.
280      */
281     @DataClass.Generated.Member
getInlinePresentationSpecs()282     public @NonNull List<InlinePresentationSpec> getInlinePresentationSpecs() {
283         return mInlinePresentationSpecs;
284     }
285 
286     /**
287      * The package name of the app that requests for the inline suggestions and will host the
288      * embedded suggestion views. The app does not have to set the value for the field because
289      * it'll be set by the system for safety reasons.
290      */
291     @DataClass.Generated.Member
getHostPackageName()292     public @NonNull String getHostPackageName() {
293         return mHostPackageName;
294     }
295 
296     /**
297      * The IME provided locales for the request. If non-empty, the inline suggestions should
298      * return languages from the supported locales. If not provided, it'll default to be empty if
299      * target SDK is S or above, and default to system locale otherwise.
300      *
301      * <p>Note for Autofill Providers: It is <b>recommended</b> for the returned inline suggestions
302      * to have one locale to guarantee consistent UI rendering.</p>
303      */
304     @DataClass.Generated.Member
getSupportedLocales()305     public @NonNull LocaleList getSupportedLocales() {
306         return mSupportedLocales;
307     }
308 
309     /**
310      * The extras state propagated from the IME to pass extra data.
311      *
312      * <p>Note: There should be no remote objects in the bundle, all included remote objects will
313      * be removed from the bundle before transmission.</p>
314      */
315     @DataClass.Generated.Member
getExtras()316     public @NonNull Bundle getExtras() {
317         return mExtras;
318     }
319 
320     /**
321      * The host input token of the IME that made the request. This will be set by the system for
322      * safety reasons.
323      *
324      * @hide
325      */
326     @DataClass.Generated.Member
getHostInputToken()327     public @Nullable IBinder getHostInputToken() {
328         return mHostInputToken;
329     }
330 
331     /**
332      * The host display id of the IME that made the request. This will be set by the system for
333      * safety reasons.
334      *
335      * @hide
336      */
337     @DataClass.Generated.Member
getHostDisplayId()338     public int getHostDisplayId() {
339         return mHostDisplayId;
340     }
341 
342     /**
343      * Specifies the UI specification for the inline suggestion tooltip in the response.
344      */
345     @DataClass.Generated.Member
getInlineTooltipPresentationSpec()346     public @Nullable InlinePresentationSpec getInlineTooltipPresentationSpec() {
347         return mInlineTooltipPresentationSpec;
348     }
349 
350     @Override
351     @DataClass.Generated.Member
toString()352     public String toString() {
353         // You can override field toString logic by defining methods like:
354         // String fieldNameToString() { ... }
355 
356         return "InlineSuggestionsRequest { " +
357                 "maxSuggestionCount = " + mMaxSuggestionCount + ", " +
358                 "inlinePresentationSpecs = " + mInlinePresentationSpecs + ", " +
359                 "hostPackageName = " + mHostPackageName + ", " +
360                 "supportedLocales = " + mSupportedLocales + ", " +
361                 "extras = " + mExtras + ", " +
362                 "hostInputToken = " + mHostInputToken + ", " +
363                 "hostDisplayId = " + mHostDisplayId + ", " +
364                 "inlineTooltipPresentationSpec = " + mInlineTooltipPresentationSpec +
365         " }";
366     }
367 
368     @Override
369     @DataClass.Generated.Member
equals(@ullable Object o)370     public boolean equals(@Nullable Object o) {
371         // You can override field equality logic by defining either of the methods like:
372         // boolean fieldNameEquals(InlineSuggestionsRequest other) { ... }
373         // boolean fieldNameEquals(FieldType otherValue) { ... }
374 
375         if (this == o) return true;
376         if (o == null || getClass() != o.getClass()) return false;
377         @SuppressWarnings("unchecked")
378         InlineSuggestionsRequest that = (InlineSuggestionsRequest) o;
379         //noinspection PointlessBooleanExpression
380         return true
381                 && mMaxSuggestionCount == that.mMaxSuggestionCount
382                 && java.util.Objects.equals(mInlinePresentationSpecs, that.mInlinePresentationSpecs)
383                 && java.util.Objects.equals(mHostPackageName, that.mHostPackageName)
384                 && java.util.Objects.equals(mSupportedLocales, that.mSupportedLocales)
385                 && extrasEquals(that.mExtras)
386                 && java.util.Objects.equals(mHostInputToken, that.mHostInputToken)
387                 && mHostDisplayId == that.mHostDisplayId
388                 && java.util.Objects.equals(mInlineTooltipPresentationSpec, that.mInlineTooltipPresentationSpec);
389     }
390 
391     @Override
392     @DataClass.Generated.Member
hashCode()393     public int hashCode() {
394         // You can override field hashCode logic by defining methods like:
395         // int fieldNameHashCode() { ... }
396 
397         int _hash = 1;
398         _hash = 31 * _hash + mMaxSuggestionCount;
399         _hash = 31 * _hash + java.util.Objects.hashCode(mInlinePresentationSpecs);
400         _hash = 31 * _hash + java.util.Objects.hashCode(mHostPackageName);
401         _hash = 31 * _hash + java.util.Objects.hashCode(mSupportedLocales);
402         _hash = 31 * _hash + java.util.Objects.hashCode(mExtras);
403         _hash = 31 * _hash + java.util.Objects.hashCode(mHostInputToken);
404         _hash = 31 * _hash + mHostDisplayId;
405         _hash = 31 * _hash + java.util.Objects.hashCode(mInlineTooltipPresentationSpec);
406         return _hash;
407     }
408 
409     @Override
410     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)411     public void writeToParcel(@NonNull Parcel dest, int flags) {
412         // You can override field parcelling by defining methods like:
413         // void parcelFieldName(Parcel dest, int flags) { ... }
414 
415         int flg = 0;
416         if (mHostInputToken != null) flg |= 0x20;
417         if (mInlineTooltipPresentationSpec != null) flg |= 0x80;
418         dest.writeInt(flg);
419         dest.writeInt(mMaxSuggestionCount);
420         dest.writeParcelableList(mInlinePresentationSpecs, flags);
421         dest.writeString(mHostPackageName);
422         dest.writeTypedObject(mSupportedLocales, flags);
423         dest.writeBundle(mExtras);
424         parcelHostInputToken(dest, flags);
425         dest.writeInt(mHostDisplayId);
426         if (mInlineTooltipPresentationSpec != null) dest.writeTypedObject(mInlineTooltipPresentationSpec, flags);
427     }
428 
429     @Override
430     @DataClass.Generated.Member
describeContents()431     public int describeContents() { return 0; }
432 
433     /** @hide */
434     @SuppressWarnings({"unchecked", "RedundantCast"})
435     @DataClass.Generated.Member
InlineSuggestionsRequest(@onNull Parcel in)436     /* package-private */ InlineSuggestionsRequest(@NonNull Parcel in) {
437         // You can override field unparcelling by defining methods like:
438         // static FieldType unparcelFieldName(Parcel in) { ... }
439 
440         int flg = in.readInt();
441         int maxSuggestionCount = in.readInt();
442         List<InlinePresentationSpec> inlinePresentationSpecs = new ArrayList<>();
443         in.readParcelableList(inlinePresentationSpecs, InlinePresentationSpec.class.getClassLoader());
444         String hostPackageName = in.readString();
445         LocaleList supportedLocales = (LocaleList) in.readTypedObject(LocaleList.CREATOR);
446         Bundle extras = in.readBundle();
447         IBinder hostInputToken = unparcelHostInputToken(in);
448         int hostDisplayId = in.readInt();
449         InlinePresentationSpec inlineTooltipPresentationSpec = (flg & 0x80) == 0 ? null : (InlinePresentationSpec) in.readTypedObject(InlinePresentationSpec.CREATOR);
450 
451         this.mMaxSuggestionCount = maxSuggestionCount;
452         this.mInlinePresentationSpecs = inlinePresentationSpecs;
453         com.android.internal.util.AnnotationValidations.validate(
454                 NonNull.class, null, mInlinePresentationSpecs);
455         this.mHostPackageName = hostPackageName;
456         com.android.internal.util.AnnotationValidations.validate(
457                 NonNull.class, null, mHostPackageName);
458         this.mSupportedLocales = supportedLocales;
459         com.android.internal.util.AnnotationValidations.validate(
460                 NonNull.class, null, mSupportedLocales);
461         this.mExtras = extras;
462         com.android.internal.util.AnnotationValidations.validate(
463                 NonNull.class, null, mExtras);
464         this.mHostInputToken = hostInputToken;
465         this.mHostDisplayId = hostDisplayId;
466         this.mInlineTooltipPresentationSpec = inlineTooltipPresentationSpec;
467 
468         onConstructed();
469     }
470 
471     @DataClass.Generated.Member
472     public static final @NonNull Parcelable.Creator<InlineSuggestionsRequest> CREATOR
473             = new Parcelable.Creator<InlineSuggestionsRequest>() {
474         @Override
475         public InlineSuggestionsRequest[] newArray(int size) {
476             return new InlineSuggestionsRequest[size];
477         }
478 
479         @Override
480         public InlineSuggestionsRequest createFromParcel(@NonNull Parcel in) {
481             return new InlineSuggestionsRequest(in);
482         }
483     };
484 
485     /**
486      * A builder for {@link InlineSuggestionsRequest}
487      */
488     @SuppressWarnings("WeakerAccess")
489     @DataClass.Generated.Member
490     public static final class Builder extends BaseBuilder {
491 
492         private int mMaxSuggestionCount;
493         private @NonNull List<InlinePresentationSpec> mInlinePresentationSpecs;
494         private @NonNull String mHostPackageName;
495         private @NonNull LocaleList mSupportedLocales;
496         private @NonNull Bundle mExtras;
497         private @Nullable IBinder mHostInputToken;
498         private int mHostDisplayId;
499         private @Nullable InlinePresentationSpec mInlineTooltipPresentationSpec;
500 
501         private long mBuilderFieldsSet = 0L;
502 
503         /**
504          * Creates a new Builder.
505          *
506          * @param inlinePresentationSpecs
507          *   The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
508          *   count is larger than the number of specs in the list, then the last spec is used for the
509          *   remainder of the suggestions. The list should not be empty.
510          */
Builder( @onNull List<InlinePresentationSpec> inlinePresentationSpecs)511         public Builder(
512                 @NonNull List<InlinePresentationSpec> inlinePresentationSpecs) {
513             mInlinePresentationSpecs = inlinePresentationSpecs;
514             com.android.internal.util.AnnotationValidations.validate(
515                     NonNull.class, null, mInlinePresentationSpecs);
516         }
517 
518         /**
519          * Max number of suggestions expected from the response. It must be a positive value.
520          * Defaults to {@code SUGGESTION_COUNT_UNLIMITED} if not set.
521          *
522          * <p>In practice, it is recommended that the max suggestion count does not exceed <b>5</b>
523          * for performance reasons.</p>
524          */
525         @DataClass.Generated.Member
setMaxSuggestionCount(int value)526         public @NonNull Builder setMaxSuggestionCount(int value) {
527             checkNotUsed();
528             mBuilderFieldsSet |= 0x1;
529             mMaxSuggestionCount = value;
530             return this;
531         }
532 
533         /**
534          * The {@link InlinePresentationSpec} for each suggestion in the response. If the max suggestion
535          * count is larger than the number of specs in the list, then the last spec is used for the
536          * remainder of the suggestions. The list should not be empty.
537          */
538         @DataClass.Generated.Member
setInlinePresentationSpecs(@onNull List<InlinePresentationSpec> value)539         public @NonNull Builder setInlinePresentationSpecs(@NonNull List<InlinePresentationSpec> value) {
540             checkNotUsed();
541             mBuilderFieldsSet |= 0x2;
542             mInlinePresentationSpecs = value;
543             return this;
544         }
545 
546         /** @see #setInlinePresentationSpecs */
547         @DataClass.Generated.Member
addInlinePresentationSpecs(@onNull InlinePresentationSpec value)548         public @NonNull Builder addInlinePresentationSpecs(@NonNull InlinePresentationSpec value) {
549             // You can refine this method's name by providing item's singular name, e.g.:
550             // @DataClass.PluralOf("item")) mItems = ...
551 
552             if (mInlinePresentationSpecs == null) setInlinePresentationSpecs(new ArrayList<>());
553             mInlinePresentationSpecs.add(value);
554             return this;
555         }
556 
557         /**
558          * The package name of the app that requests for the inline suggestions and will host the
559          * embedded suggestion views. The app does not have to set the value for the field because
560          * it'll be set by the system for safety reasons.
561          */
562         @DataClass.Generated.Member
563         @Override
setHostPackageName(@onNull String value)564         @NonNull Builder setHostPackageName(@NonNull String value) {
565             checkNotUsed();
566             mBuilderFieldsSet |= 0x4;
567             mHostPackageName = value;
568             return this;
569         }
570 
571         /**
572          * The IME provided locales for the request. If non-empty, the inline suggestions should
573          * return languages from the supported locales. If not provided, it'll default to be empty if
574          * target SDK is S or above, and default to system locale otherwise.
575          *
576          * <p>Note for Autofill Providers: It is <b>recommended</b> for the returned inline suggestions
577          * to have one locale to guarantee consistent UI rendering.</p>
578          */
579         @DataClass.Generated.Member
setSupportedLocales(@onNull LocaleList value)580         public @NonNull Builder setSupportedLocales(@NonNull LocaleList value) {
581             checkNotUsed();
582             mBuilderFieldsSet |= 0x8;
583             mSupportedLocales = value;
584             return this;
585         }
586 
587         /**
588          * The extras state propagated from the IME to pass extra data.
589          *
590          * <p>Note: There should be no remote objects in the bundle, all included remote objects will
591          * be removed from the bundle before transmission.</p>
592          */
593         @DataClass.Generated.Member
setExtras(@onNull Bundle value)594         public @NonNull Builder setExtras(@NonNull Bundle value) {
595             checkNotUsed();
596             mBuilderFieldsSet |= 0x10;
597             mExtras = value;
598             return this;
599         }
600 
601         /**
602          * The host input token of the IME that made the request. This will be set by the system for
603          * safety reasons.
604          *
605          * @hide
606          */
607         @DataClass.Generated.Member
608         @Override
setHostInputToken(@onNull IBinder value)609         @NonNull Builder setHostInputToken(@NonNull IBinder value) {
610             checkNotUsed();
611             mBuilderFieldsSet |= 0x20;
612             mHostInputToken = value;
613             return this;
614         }
615 
616         /**
617          * The host display id of the IME that made the request. This will be set by the system for
618          * safety reasons.
619          *
620          * @hide
621          */
622         @DataClass.Generated.Member
623         @Override
setHostDisplayId(int value)624         @NonNull Builder setHostDisplayId(int value) {
625             checkNotUsed();
626             mBuilderFieldsSet |= 0x40;
627             mHostDisplayId = value;
628             return this;
629         }
630 
631         /**
632          * Specifies the UI specification for the inline suggestion tooltip in the response.
633          */
634         @DataClass.Generated.Member
setInlineTooltipPresentationSpec(@onNull InlinePresentationSpec value)635         public @NonNull Builder setInlineTooltipPresentationSpec(@NonNull InlinePresentationSpec value) {
636             checkNotUsed();
637             mBuilderFieldsSet |= 0x80;
638             mInlineTooltipPresentationSpec = value;
639             return this;
640         }
641 
642         /** Builds the instance. This builder should not be touched after calling this! */
build()643         public @NonNull InlineSuggestionsRequest build() {
644             checkNotUsed();
645             mBuilderFieldsSet |= 0x100; // Mark builder used
646 
647             if ((mBuilderFieldsSet & 0x1) == 0) {
648                 mMaxSuggestionCount = defaultMaxSuggestionCount();
649             }
650             if ((mBuilderFieldsSet & 0x4) == 0) {
651                 mHostPackageName = defaultHostPackageName();
652             }
653             if ((mBuilderFieldsSet & 0x8) == 0) {
654                 mSupportedLocales = defaultSupportedLocales();
655             }
656             if ((mBuilderFieldsSet & 0x10) == 0) {
657                 mExtras = defaultExtras();
658             }
659             if ((mBuilderFieldsSet & 0x20) == 0) {
660                 mHostInputToken = defaultHostInputToken();
661             }
662             if ((mBuilderFieldsSet & 0x40) == 0) {
663                 mHostDisplayId = defaultHostDisplayId();
664             }
665             if ((mBuilderFieldsSet & 0x80) == 0) {
666                 mInlineTooltipPresentationSpec = defaultInlineTooltipPresentationSpec();
667             }
668             InlineSuggestionsRequest o = new InlineSuggestionsRequest(
669                     mMaxSuggestionCount,
670                     mInlinePresentationSpecs,
671                     mHostPackageName,
672                     mSupportedLocales,
673                     mExtras,
674                     mHostInputToken,
675                     mHostDisplayId,
676                     mInlineTooltipPresentationSpec);
677             return o;
678         }
679 
checkNotUsed()680         private void checkNotUsed() {
681             if ((mBuilderFieldsSet & 0x100) != 0) {
682                 throw new IllegalStateException(
683                         "This Builder should not be reused. Use a new Builder instance instead");
684             }
685         }
686     }
687 
688     @DataClass.Generated(
689             time = 1621415989607L,
690             codegenVersion = "1.0.23",
691             sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestionsRequest.java",
692             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 []")
693     @Deprecated
__metadata()694     private void __metadata() {}
695 
696 
697     //@formatter:on
698     // End of generated code
699 
700 }
701