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