| 1 | /* |
| 2 | * Copyright (C) 2021 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 com.android.internal.inputmethod; |
| 18 | |
| 19 | import android.annotation.NonNull; |
| 20 | import android.os.Parcel; |
| 21 | import android.os.Parcelable; |
| 22 | |
| 23 | /** |
| 24 | * A common IPC header used behind {@link RemoteInputConnectionImpl} and |
| 25 | * {@link android.inputmethodservice.RemoteInputConnection}. |
| 26 | */ |
| 27 | public final class InputConnectionCommandHeader implements Parcelable { |
| 28 | /** |
| 29 | * An identifier that is to be used when multiplexing multiple sessions into a single |
| 30 | * {@link com.android.internal.view.IInputContext}. |
| 31 | * |
| 32 | * <p>This ID is considered to belong to an implicit namespace defined for each |
| 33 | * {@link com.android.internal.view.IInputContext} instance. Uniqueness of the session ID |
| 34 | * across multiple instances of {@link com.android.internal.view.IInputContext} is not |
| 35 | * guaranteed unless explicitly noted in a higher layer.</p> |
| 36 | */ |
| 37 | public final int mSessionId; |
| 38 | |
| 39 | public InputConnectionCommandHeader(int sessionId) { |
| 40 | mSessionId = sessionId; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public int describeContents() { |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | @NonNull |
| 49 | public static final Parcelable.Creator<InputConnectionCommandHeader> CREATOR = |
| 50 | new Parcelable.Creator<InputConnectionCommandHeader>() { |
| 51 | @NonNull |
| 52 | public InputConnectionCommandHeader createFromParcel(Parcel in) { |
| 53 | final int sessionId = in.readInt(); |
| 54 | return new InputConnectionCommandHeader(sessionId); |
| 55 | } |
| 56 | |
| 57 | @NonNull |
| 58 | public InputConnectionCommandHeader[] newArray(int size) { |
| 59 | return new InputConnectionCommandHeader[size]; |
| 60 | } |
| 61 | }; |
| 62 | |
| 63 | @Override |
| 64 | public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 65 | dest.writeInt(mSessionId); |
| 66 | } |
| 67 | } |