File: InlineSuggestion.java

package info (click to toggle)
android-platform-frameworks-base 1%3A14~beta1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 326,092 kB
  • sloc: java: 2,032,373; xml: 343,016; cpp: 304,181; python: 3,683; ansic: 2,090; sh: 1,871; makefile: 117; sed: 19
file content (704 lines) | stat: -rw-r--r-- 28,731 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.inputmethod;

import android.annotation.BinderThread;
import android.annotation.CallbackExecutor;
import android.annotation.MainThread;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.util.Size;
import android.util.Slog;
import android.view.SurfaceControlViewHost;
import android.view.View;
import android.view.ViewGroup;
import android.widget.inline.InlineContentView;

import com.android.internal.util.DataClass;
import com.android.internal.util.Parcelling;
import com.android.internal.view.inline.IInlineContentCallback;
import com.android.internal.view.inline.IInlineContentProvider;
import com.android.internal.view.inline.InlineTooltipUi;

import java.lang.ref.WeakReference;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/**
 * This class represents an inline suggestion which is made by one app and can be embedded into the
 * UI of another. Suggestions may contain sensitive information not known to the host app which
 * needs to be protected from spoofing. To address that the suggestion view inflated on demand for
 * embedding is created in such a way that the hosting app cannot introspect its content and cannot
 * interact with it.
 */
@DataClass(genEqualsHashCode = true, genToString = true, genHiddenConstDefs = true,
        genHiddenConstructor = true)
public final class InlineSuggestion implements Parcelable {

    private static final String TAG = "InlineSuggestion";

    @NonNull
    private final InlineSuggestionInfo mInfo;

    /**
     * @hide
     */
    @Nullable
    private final IInlineContentProvider mContentProvider;

    /**
     * Used to keep a strong reference to the callback so it doesn't get garbage collected.
     *
     * @hide
     */
    @DataClass.ParcelWith(InlineContentCallbackImplParceling.class)
    @Nullable
    private InlineContentCallbackImpl mInlineContentCallback;

    /**
     * Used to show up the inline suggestion tooltip.
     *
     * @hide
     */
    @Nullable
    @DataClass.ParcelWith(InlineTooltipUiParceling.class)
    private InlineTooltipUi mInlineTooltipUi;

    /**
     * Creates a new {@link InlineSuggestion}, for testing purpose.
     *
     * @hide
     */
    @TestApi
    @NonNull
    public static InlineSuggestion newInlineSuggestion(@NonNull InlineSuggestionInfo info) {
        return new InlineSuggestion(info, null, /* inlineContentCallback */ null,
                /* inlineTooltipUi */ null);
    }

    /**
     * Creates a new {@link InlineSuggestion}.
     *
     * @hide
     */
    public InlineSuggestion(@NonNull InlineSuggestionInfo info,
            @Nullable IInlineContentProvider contentProvider) {
        this(info, contentProvider, /* inlineContentCallback */ null, /* inlineTooltipUi */ null);
    }

    /**
     * Inflates a view with the content of this suggestion at a specific size.
     *
     * <p> Each dimension of the size must satisfy one of the following conditions:
     *
     * <ol>
     *     <li>between {@link android.widget.inline.InlinePresentationSpec#getMinSize()} and
     * {@link android.widget.inline.InlinePresentationSpec#getMaxSize()} of the presentation spec
     * from {@code mInfo}
     *     <li>{@link ViewGroup.LayoutParams#WRAP_CONTENT}
     * </ol>
     *
     * If the size is set to {@link
     * ViewGroup.LayoutParams#WRAP_CONTENT}, then the size of the inflated view will be just large
     * enough to fit the content, while still conforming to the min / max size specified by the
     * {@link android.widget.inline.InlinePresentationSpec}.
     *
     * <p> The caller can attach an {@link android.view.View.OnClickListener} and/or an
     * {@link android.view.View.OnLongClickListener} to the view in the {@code callback} to receive
     * click and long click events on the view.
     *
     * @param context  Context in which to inflate the view.
     * @param size     The size at which to inflate the suggestion. For each dimension, it maybe an
     *                 exact value or {@link ViewGroup.LayoutParams#WRAP_CONTENT}.
     * @param callback Callback for receiving the inflated view, where the {@link
     *                 ViewGroup.LayoutParams} of the view is set as the actual size of the
     *                 underlying remote view.
     * @throws IllegalArgumentException If an invalid argument is passed.
     * @throws IllegalStateException    If this method is already called.
     */
    public void inflate(@NonNull Context context, @NonNull Size size,
            @NonNull @CallbackExecutor Executor callbackExecutor,
            @NonNull Consumer<InlineContentView> callback) {
        final Size minSize = mInfo.getInlinePresentationSpec().getMinSize();
        final Size maxSize = mInfo.getInlinePresentationSpec().getMaxSize();
        if (!isValid(size.getWidth(), minSize.getWidth(), maxSize.getWidth())
                || !isValid(size.getHeight(), minSize.getHeight(), maxSize.getHeight())) {
            throw new IllegalArgumentException(
                    "size is neither between min:" + minSize + " and max:" + maxSize
                            + ", nor wrap_content");
        }

        InlineSuggestion toolTip = mInfo.getTooltip();
        if (toolTip != null) {
            if (mInlineTooltipUi == null) {
                mInlineTooltipUi = new InlineTooltipUi(context);
            }
        } else {
            mInlineTooltipUi = null;
        }

        mInlineContentCallback = getInlineContentCallback(context, callbackExecutor, callback,
                mInlineTooltipUi);
        if (mContentProvider == null) {
            callbackExecutor.execute(() -> callback.accept(/* view */ null));
            mInlineTooltipUi = null;
            return;
        }
        try {
            mContentProvider.provideContent(size.getWidth(), size.getHeight(),
                    new InlineContentCallbackWrapper(mInlineContentCallback));
        } catch (RemoteException e) {
            Slog.w(TAG, "Error creating suggestion content surface: " + e);
            callbackExecutor.execute(() -> callback.accept(/* view */ null));
        }
        if (toolTip == null) return;

        final Size tooltipSize = new Size(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        mInfo.getTooltip().inflate(context, tooltipSize, callbackExecutor, view -> {
            Handler.getMain().post(() -> mInlineTooltipUi.setTooltipView(view));
        });
    }

    /**
     * Returns true if the {@code actual} length is within [min, max] or is {@link
     * ViewGroup.LayoutParams#WRAP_CONTENT}.
     */
    private static boolean isValid(int actual, int min, int max) {
        if (actual == ViewGroup.LayoutParams.WRAP_CONTENT) {
            return true;
        }
        return actual >= min && actual <= max;
    }

    private synchronized InlineContentCallbackImpl getInlineContentCallback(Context context,
            Executor callbackExecutor, Consumer<InlineContentView> callback,
            InlineTooltipUi inlineTooltipUi) {
        if (mInlineContentCallback != null) {
            throw new IllegalStateException("Already called #inflate()");
        }
        return new InlineContentCallbackImpl(context, mContentProvider, callbackExecutor,
                callback, inlineTooltipUi);
    }

    /**
     * A wrapper class around the {@link InlineContentCallbackImpl} to ensure it's not strongly
     * reference by the remote system server process.
     */
    private static final class InlineContentCallbackWrapper extends IInlineContentCallback.Stub {

        private final WeakReference<InlineContentCallbackImpl> mCallbackImpl;

        InlineContentCallbackWrapper(InlineContentCallbackImpl callbackImpl) {
            mCallbackImpl = new WeakReference<>(callbackImpl);
        }

        @Override
        @BinderThread
        public void onContent(SurfaceControlViewHost.SurfacePackage content, int width,
                int height) {
            final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
            if (callbackImpl != null) {
                callbackImpl.onContent(content, width, height);
            }
        }

        @Override
        @BinderThread
        public void onClick() {
            final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
            if (callbackImpl != null) {
                callbackImpl.onClick();
            }
        }

        @Override
        @BinderThread
        public void onLongClick() {
            final InlineContentCallbackImpl callbackImpl = mCallbackImpl.get();
            if (callbackImpl != null) {
                callbackImpl.onLongClick();
            }
        }
    }

    /**
     * Handles the communication between the inline suggestion view in current (IME) process and
     * the remote view provided from the system server.
     *
     * <p>This class is thread safe, because all the outside calls are piped into a single
     * handler thread to be processed.
     */
    private static final class InlineContentCallbackImpl {

        @NonNull
        private final Handler mMainHandler = new Handler(Looper.getMainLooper());

        @NonNull
        private final Context mContext;
        @Nullable
        private final IInlineContentProvider mInlineContentProvider;
        @NonNull
        private final Executor mCallbackExecutor;

        /**
         * Callback from the client (IME) that will receive the inflated suggestion view. It'll
         * only be called once when the view SurfacePackage is first sent back to the client. Any
         * updates to the view due to attach to window and detach from window events will be
         * handled under the hood, transparent from the client.
         */
        @NonNull
        private final Consumer<InlineContentView> mCallback;

        /**
         * Indicates whether the first content has been received or not.
         */
        private boolean mFirstContentReceived = false;

        /**
         * The client (IME) side view which internally wraps a remote view. It'll be set when
         * {@link #onContent(SurfaceControlViewHost.SurfacePackage, int, int)} is called, which
         * should only happen once in the lifecycle of this inline suggestion instance.
         */
        @Nullable
        private InlineContentView mView;

        /**
         * The SurfacePackage pointing to the remote view. It's cached here to be sent to the next
         * available consumer.
         */
        @Nullable
        private SurfaceControlViewHost.SurfacePackage mSurfacePackage;

        /**
         * The callback (from the {@link InlineContentView}) which consumes the surface package.
         * It's cached here to be called when the SurfacePackage is returned from the remote
         * view owning process.
         */
        @Nullable
        private Consumer<SurfaceControlViewHost.SurfacePackage> mSurfacePackageConsumer;

        @Nullable
        private InlineTooltipUi mInlineTooltipUi;

        InlineContentCallbackImpl(@NonNull Context context,
                @Nullable IInlineContentProvider inlineContentProvider,
                @NonNull @CallbackExecutor Executor callbackExecutor,
                @NonNull Consumer<InlineContentView> callback,
                @Nullable InlineTooltipUi inlineTooltipUi) {
            mContext = context;
            mInlineContentProvider = inlineContentProvider;
            mCallbackExecutor = callbackExecutor;
            mCallback = callback;
            mInlineTooltipUi = inlineTooltipUi;
        }

        @BinderThread
        public void onContent(SurfaceControlViewHost.SurfacePackage content, int width,
                int height) {
            mMainHandler.post(() -> handleOnContent(content, width, height));
        }

        @MainThread
        private void handleOnContent(SurfaceControlViewHost.SurfacePackage content, int width,
                int height) {
            if (!mFirstContentReceived) {
                handleOnFirstContentReceived(content, width, height);
                mFirstContentReceived = true;
            } else {
                handleOnSurfacePackage(content);
            }
        }

        /**
         * Called when the view content is returned for the first time.
         */
        @MainThread
        private void handleOnFirstContentReceived(SurfaceControlViewHost.SurfacePackage content,
                int width, int height) {
            mSurfacePackage = content;
            if (mSurfacePackage == null) {
                mCallbackExecutor.execute(() -> mCallback.accept(/* view */null));
            } else {
                mView = new InlineContentView(mContext);
                if (mInlineTooltipUi != null) {
                    mView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
                        @Override
                        public void onLayoutChange(View v, int left, int top, int right,
                                int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                            if (mInlineTooltipUi != null) {
                                mInlineTooltipUi.update(mView);
                            }
                        }
                    });
                }
                mView.setLayoutParams(new ViewGroup.LayoutParams(width, height));
                mView.setChildSurfacePackageUpdater(getSurfacePackageUpdater());
                mCallbackExecutor.execute(() -> mCallback.accept(mView));
            }
        }

        /**
         * Called when any subsequent SurfacePackage is returned from the remote view owning
         * process.
         */
        @MainThread
        private void handleOnSurfacePackage(SurfaceControlViewHost.SurfacePackage surfacePackage) {
            if (surfacePackage == null) {
                return;
            }
            if (mSurfacePackage != null || mSurfacePackageConsumer == null) {
                // The surface package is not consumed, release it immediately.
                surfacePackage.release();
                try {
                    mInlineContentProvider.onSurfacePackageReleased();
                } catch (RemoteException e) {
                    Slog.w(TAG, "Error calling onSurfacePackageReleased(): " + e);
                }
                return;
            }
            mSurfacePackage = surfacePackage;
            if (mSurfacePackage == null) {
                return;
            }
            if (mSurfacePackageConsumer != null) {
                mSurfacePackageConsumer.accept(mSurfacePackage);
                mSurfacePackageConsumer = null;
            }
        }

        @MainThread
        private void handleOnSurfacePackageReleased() {
            if (mSurfacePackage != null) {
                try {
                    mInlineContentProvider.onSurfacePackageReleased();
                } catch (RemoteException e) {
                    Slog.w(TAG, "Error calling onSurfacePackageReleased(): " + e);
                }
                mSurfacePackage = null;
            }
            // Clear the pending surface package consumer, if any. This can happen if the IME
            // attaches the view to window and then quickly detaches it from the window, before
            // the surface package requested upon attaching to window was returned.
            mSurfacePackageConsumer = null;
        }

        @MainThread
        private void handleGetSurfacePackage(
                Consumer<SurfaceControlViewHost.SurfacePackage> consumer) {
            if (mSurfacePackage != null) {
                consumer.accept(mSurfacePackage);
            } else {
                mSurfacePackageConsumer = consumer;
                try {
                    mInlineContentProvider.requestSurfacePackage();
                } catch (RemoteException e) {
                    Slog.w(TAG, "Error calling getSurfacePackage(): " + e);
                    consumer.accept(null);
                    mSurfacePackageConsumer = null;
                }
            }
        }

        private InlineContentView.SurfacePackageUpdater getSurfacePackageUpdater() {
            return new InlineContentView.SurfacePackageUpdater() {
                @Override
                public void onSurfacePackageReleased() {
                    mMainHandler.post(
                            () -> InlineContentCallbackImpl.this.handleOnSurfacePackageReleased());
                }

                @Override
                public void getSurfacePackage(
                        Consumer<SurfaceControlViewHost.SurfacePackage> consumer) {
                    mMainHandler.post(
                            () -> InlineContentCallbackImpl.this.handleGetSurfacePackage(consumer));
                }
            };
        }

        @BinderThread
        public void onClick() {
            mMainHandler.post(() -> {
                if (mView != null && mView.hasOnClickListeners()) {
                    mView.callOnClick();
                }
            });
        }

        @BinderThread
        public void onLongClick() {
            mMainHandler.post(() -> {
                if (mView != null && mView.hasOnLongClickListeners()) {
                    mView.performLongClick();
                }
            });
        }
    }

    /**
     * This class used to provide parcelling logic for InlineContentCallbackImpl. It's intended to
     * make this parcelling a no-op, since it can't be parceled and we don't need to parcel it.
     */
    private static class InlineContentCallbackImplParceling implements
            Parcelling<InlineContentCallbackImpl> {
        @Override
        public void parcel(InlineContentCallbackImpl item, Parcel dest, int parcelFlags) {
        }

        @Override
        public InlineContentCallbackImpl unparcel(Parcel source) {
            return null;
        }
    }

    /**
     * This class used to provide parcelling logic for InlineContentCallbackImpl. It's intended to
     * make this parcelling a no-op, since it can't be parceled and we don't need to parcel it.
     */
    private static class InlineTooltipUiParceling implements
            Parcelling<InlineTooltipUi> {
        @Override
        public void parcel(InlineTooltipUi item, Parcel dest, int parcelFlags) {
        }

        @Override
        public InlineTooltipUi unparcel(Parcel source) {
            return null;
        }
    }



    // Code below generated by codegen v1.0.22.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/inputmethod/InlineSuggestion.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
    //@formatter:off


    /**
     * Creates a new InlineSuggestion.
     *
     * @param inlineContentCallback
     *   Used to keep a strong reference to the callback so it doesn't get garbage collected.
     * @param inlineTooltipUi
     *   Used to show up the inline suggestion tooltip.
     * @hide
     */
    @DataClass.Generated.Member
    public InlineSuggestion(
            @NonNull InlineSuggestionInfo info,
            @Nullable IInlineContentProvider contentProvider,
            @Nullable InlineContentCallbackImpl inlineContentCallback,
            @Nullable InlineTooltipUi inlineTooltipUi) {
        this.mInfo = info;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mInfo);
        this.mContentProvider = contentProvider;
        this.mInlineContentCallback = inlineContentCallback;
        this.mInlineTooltipUi = inlineTooltipUi;

        // onConstructed(); // You can define this method to get a callback
    }

    @DataClass.Generated.Member
    public @NonNull InlineSuggestionInfo getInfo() {
        return mInfo;
    }

    /**
     * @hide
     */
    @DataClass.Generated.Member
    public @Nullable IInlineContentProvider getContentProvider() {
        return mContentProvider;
    }

    /**
     * Used to keep a strong reference to the callback so it doesn't get garbage collected.
     *
     * @hide
     */
    @DataClass.Generated.Member
    public @Nullable InlineContentCallbackImpl getInlineContentCallback() {
        return mInlineContentCallback;
    }

    /**
     * Used to show up the inline suggestion tooltip.
     *
     * @hide
     */
    @DataClass.Generated.Member
    public @Nullable InlineTooltipUi getInlineTooltipUi() {
        return mInlineTooltipUi;
    }

    @Override
    @DataClass.Generated.Member
    public String toString() {
        // You can override field toString logic by defining methods like:
        // String fieldNameToString() { ... }

        return "InlineSuggestion { " +
                "info = " + mInfo + ", " +
                "contentProvider = " + mContentProvider + ", " +
                "inlineContentCallback = " + mInlineContentCallback + ", " +
                "inlineTooltipUi = " + mInlineTooltipUi +
        " }";
    }

    @Override
    @DataClass.Generated.Member
    public boolean equals(@Nullable Object o) {
        // You can override field equality logic by defining either of the methods like:
        // boolean fieldNameEquals(InlineSuggestion other) { ... }
        // boolean fieldNameEquals(FieldType otherValue) { ... }

        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        @SuppressWarnings("unchecked")
        InlineSuggestion that = (InlineSuggestion) o;
        //noinspection PointlessBooleanExpression
        return true
                && java.util.Objects.equals(mInfo, that.mInfo)
                && java.util.Objects.equals(mContentProvider, that.mContentProvider)
                && java.util.Objects.equals(mInlineContentCallback, that.mInlineContentCallback)
                && java.util.Objects.equals(mInlineTooltipUi, that.mInlineTooltipUi);
    }

    @Override
    @DataClass.Generated.Member
    public int hashCode() {
        // You can override field hashCode logic by defining methods like:
        // int fieldNameHashCode() { ... }

        int _hash = 1;
        _hash = 31 * _hash + java.util.Objects.hashCode(mInfo);
        _hash = 31 * _hash + java.util.Objects.hashCode(mContentProvider);
        _hash = 31 * _hash + java.util.Objects.hashCode(mInlineContentCallback);
        _hash = 31 * _hash + java.util.Objects.hashCode(mInlineTooltipUi);
        return _hash;
    }

    @DataClass.Generated.Member
    static Parcelling<InlineContentCallbackImpl> sParcellingForInlineContentCallback =
            Parcelling.Cache.get(
                    InlineContentCallbackImplParceling.class);
    static {
        if (sParcellingForInlineContentCallback == null) {
            sParcellingForInlineContentCallback = Parcelling.Cache.put(
                    new InlineContentCallbackImplParceling());
        }
    }

    @DataClass.Generated.Member
    static Parcelling<InlineTooltipUi> sParcellingForInlineTooltipUi =
            Parcelling.Cache.get(
                    InlineTooltipUiParceling.class);
    static {
        if (sParcellingForInlineTooltipUi == null) {
            sParcellingForInlineTooltipUi = Parcelling.Cache.put(
                    new InlineTooltipUiParceling());
        }
    }

    @Override
    @DataClass.Generated.Member
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        // You can override field parcelling by defining methods like:
        // void parcelFieldName(Parcel dest, int flags) { ... }

        byte flg = 0;
        if (mContentProvider != null) flg |= 0x2;
        if (mInlineContentCallback != null) flg |= 0x4;
        if (mInlineTooltipUi != null) flg |= 0x8;
        dest.writeByte(flg);
        dest.writeTypedObject(mInfo, flags);
        if (mContentProvider != null) dest.writeStrongInterface(mContentProvider);
        sParcellingForInlineContentCallback.parcel(mInlineContentCallback, dest, flags);
        sParcellingForInlineTooltipUi.parcel(mInlineTooltipUi, dest, flags);
    }

    @Override
    @DataClass.Generated.Member
    public int describeContents() { return 0; }

    /** @hide */
    @SuppressWarnings({"unchecked", "RedundantCast"})
    @DataClass.Generated.Member
    /* package-private */ InlineSuggestion(@NonNull Parcel in) {
        // You can override field unparcelling by defining methods like:
        // static FieldType unparcelFieldName(Parcel in) { ... }

        byte flg = in.readByte();
        InlineSuggestionInfo info = (InlineSuggestionInfo) in.readTypedObject(InlineSuggestionInfo.CREATOR);
        IInlineContentProvider contentProvider = (flg & 0x2) == 0 ? null : IInlineContentProvider.Stub.asInterface(in.readStrongBinder());
        InlineContentCallbackImpl inlineContentCallback = sParcellingForInlineContentCallback.unparcel(in);
        InlineTooltipUi inlineTooltipUi = sParcellingForInlineTooltipUi.unparcel(in);

        this.mInfo = info;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mInfo);
        this.mContentProvider = contentProvider;
        this.mInlineContentCallback = inlineContentCallback;
        this.mInlineTooltipUi = inlineTooltipUi;

        // onConstructed(); // You can define this method to get a callback
    }

    @DataClass.Generated.Member
    public static final @NonNull Parcelable.Creator<InlineSuggestion> CREATOR
            = new Parcelable.Creator<InlineSuggestion>() {
        @Override
        public InlineSuggestion[] newArray(int size) {
            return new InlineSuggestion[size];
        }

        @Override
        public InlineSuggestion createFromParcel(@NonNull Parcel in) {
            return new InlineSuggestion(in);
        }
    };

    @DataClass.Generated(
            time = 1615562097666L,
            codegenVersion = "1.0.22",
            sourceFile = "frameworks/base/core/java/android/view/inputmethod/InlineSuggestion.java",
            inputSignatures = "private static final  java.lang.String TAG\nprivate final @android.annotation.NonNull android.view.inputmethod.InlineSuggestionInfo mInfo\nprivate final @android.annotation.Nullable com.android.internal.view.inline.IInlineContentProvider mContentProvider\nprivate @com.android.internal.util.DataClass.ParcelWith(android.view.inputmethod.InlineSuggestion.InlineContentCallbackImplParceling.class) @android.annotation.Nullable android.view.inputmethod.InlineSuggestion.InlineContentCallbackImpl mInlineContentCallback\nprivate @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(android.view.inputmethod.InlineSuggestion.InlineTooltipUiParceling.class) com.android.internal.view.inline.InlineTooltipUi mInlineTooltipUi\npublic static @android.annotation.TestApi @android.annotation.NonNull android.view.inputmethod.InlineSuggestion newInlineSuggestion(android.view.inputmethod.InlineSuggestionInfo)\npublic  void inflate(android.content.Context,android.util.Size,java.util.concurrent.Executor,java.util.function.Consumer<android.widget.inline.InlineContentView>)\nprivate static  boolean isValid(int,int,int)\nprivate synchronized  android.view.inputmethod.InlineSuggestion.InlineContentCallbackImpl getInlineContentCallback(android.content.Context,java.util.concurrent.Executor,java.util.function.Consumer<android.widget.inline.InlineContentView>,com.android.internal.view.inline.InlineTooltipUi)\nclass InlineSuggestion extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genToString=true, genHiddenConstDefs=true, genHiddenConstructor=true)")
    @Deprecated
    private void __metadata() {}


    //@formatter:on
    // End of generated code

}