• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.server.inputmethod;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.IBinder;
22 import android.util.SparseArray;
23 import android.view.inputmethod.InputBinding;
24 
25 import com.android.internal.annotations.GuardedBy;
26 import com.android.internal.inputmethod.IRemoteInputConnection;
27 
28 final class ClientState {
29 
30     @NonNull
31     final IInputMethodClientInvoker mClient;
32     @NonNull
33     final IRemoteInputConnection mFallbackInputConnection;
34     final int mUid;
35     final int mPid;
36     final int mSelfReportedDisplayId;
37     @NonNull
38     final InputBinding mBinding;
39     @NonNull
40     final IBinder.DeathRecipient mClientDeathRecipient;
41 
42     @GuardedBy("ImfLock.class")
43     boolean mSessionRequested;
44 
45     @GuardedBy("ImfLock.class")
46     boolean mSessionRequestedForAccessibility;
47 
48     @GuardedBy("ImfLock.class")
49     @Nullable
50     InputMethodManagerService.SessionState mCurSession;
51 
52     @GuardedBy("ImfLock.class")
53     @NonNull
54     final SparseArray<InputMethodManagerService.AccessibilitySessionState> mAccessibilitySessions =
55             new SparseArray<>();
56 
ClientState(@onNull IInputMethodClientInvoker client, @NonNull IRemoteInputConnection fallbackInputConnection, int uid, int pid, int selfReportedDisplayId, @NonNull IBinder.DeathRecipient clientDeathRecipient)57     ClientState(@NonNull IInputMethodClientInvoker client,
58             @NonNull IRemoteInputConnection fallbackInputConnection, int uid, int pid,
59             int selfReportedDisplayId, @NonNull IBinder.DeathRecipient clientDeathRecipient) {
60         mClient = client;
61         mFallbackInputConnection = fallbackInputConnection;
62         mUid = uid;
63         mPid = pid;
64         mSelfReportedDisplayId = selfReportedDisplayId;
65         mBinding = new InputBinding(null /* conn */, fallbackInputConnection.asBinder(), mUid,
66                 mPid);
67         mClientDeathRecipient = clientDeathRecipient;
68     }
69 
70     @Override
toString()71     public String toString() {
72         return "ClientState{" + Integer.toHexString(System.identityHashCode(this))
73                 + " mUid=" + mUid + " mPid=" + mPid
74                 + " mSelfReportedDisplayId=" + mSelfReportedDisplayId + "}";
75     }
76 }
77