Debian Codegraph @

core/java/android/view/inputmethod/IAccessibilityInputMethodSessionInvoker.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2022 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.AnyThread;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.os.RemoteException;
23 import android.util.Log;
24
25 import com.android.internal.inputmethod.IAccessibilityInputMethodSession;
26 import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection;
27
28 final class IAccessibilityInputMethodSessionInvoker {
29 private static final String TAG = "IAccessibilityInputMethodSessionInvoker";
30
31 /**
32 * The actual instance of the method to make calls on it.
33 */
34 @NonNull
35 private final IAccessibilityInputMethodSession mSession;
36
37 private IAccessibilityInputMethodSessionInvoker(
38 @NonNull IAccessibilityInputMethodSession session) {
39 mSession = session;
40 }
41
42 /**
43 * Create a {@link IAccessibilityInputMethodSessionInvoker} instance if applicable.
44 *
45 * @param session {@link IAccessibilityInputMethodSession} object to be wrapped.
46 * @return an instance of {@link IAccessibilityInputMethodSessionInvoker} if
47 * {@code inputMethodSession} is not {@code null}. {@code null} otherwise.
48 */
49 @Nullable
50 public static IAccessibilityInputMethodSessionInvoker createOrNull(
51 @NonNull IAccessibilityInputMethodSession session) {
52 return session == null ? null : new IAccessibilityInputMethodSessionInvoker(session);
53 }
54
55 @AnyThread
56 void finishInput() {
57 try {
58 mSession.finishInput();
59 } catch (RemoteException e) {
60 Log.w(TAG, "A11yIME died", e);
61 }
62 }
63
64 @AnyThread
65 void updateSelection(int oldSelStart, int oldSelEnd, int selStart, int selEnd,
66 int candidatesStart, int candidatesEnd) {
67 try {
68 mSession.updateSelection(
69 oldSelStart, oldSelEnd, selStart, selEnd, candidatesStart, candidatesEnd);
70 } catch (RemoteException e) {
71 Log.w(TAG, "A11yIME died", e);
72 }
73 }
74
75 @AnyThread
76 void invalidateInput(EditorInfo editorInfo, IRemoteAccessibilityInputConnection connection,
77 int sessionId) {
78 try {
79 mSession.invalidateInput(editorInfo, connection, sessionId);
80 } catch (RemoteException e) {
81 Log.w(TAG, "A11yIME died", e);
82 }
83 }
84 }