1 /*
2  * Copyright (C) 2008 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.view;
18 
19 import android.os.ResultReceiver;
20 import android.view.inputmethod.ImeTracker;
21 import android.view.inputmethod.InputMethodInfo;
22 import android.view.inputmethod.InputMethodSubtype;
23 import android.view.inputmethod.EditorInfo;
24 import android.window.ImeOnBackInvokedDispatcher;
25 
26 import com.android.internal.inputmethod.IImeTracker;
27 import com.android.internal.inputmethod.IInputMethodClient;
28 import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection;
29 import com.android.internal.inputmethod.IRemoteInputConnection;
30 import com.android.internal.inputmethod.InputBindResult;
31 
32 /**
33  * Public interface to the global input method manager, used by all client
34  * applications.
35  */
36 interface IInputMethodManager {
addClient(in IInputMethodClient client, in IRemoteInputConnection inputmethod, int untrustedDisplayId)37     void addClient(in IInputMethodClient client, in IRemoteInputConnection inputmethod,
38             int untrustedDisplayId);
39 
40     // TODO: Use ParceledListSlice instead
41     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
42             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getCurrentInputMethodInfoAsUser(int userId)43     InputMethodInfo getCurrentInputMethodInfoAsUser(int userId);
44 
45     // TODO: Use ParceledListSlice instead
46     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
47             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getInputMethodList(int userId, int directBootAwareness)48     List<InputMethodInfo> getInputMethodList(int userId, int directBootAwareness);
49 
50     // TODO: Use ParceledListSlice instead
51     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
52             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getEnabledInputMethodList(int userId)53     List<InputMethodInfo> getEnabledInputMethodList(int userId);
54 
55     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
56             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getEnabledInputMethodSubtypeList(in @ullable String imiId, boolean allowsImplicitlyEnabledSubtypes, int userId)57     List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in @nullable String imiId,
58             boolean allowsImplicitlyEnabledSubtypes, int userId);
59 
60     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
61             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getLastInputMethodSubtype(int userId)62     InputMethodSubtype getLastInputMethodSubtype(int userId);
63 
showSoftInput(in IInputMethodClient client, @nullable IBinder windowToken, in @nullable ImeTracker.Token statsToken, int flags, int lastClickToolType, in @nullable ResultReceiver resultReceiver, int reason)64     boolean showSoftInput(in IInputMethodClient client, @nullable IBinder windowToken,
65             in @nullable ImeTracker.Token statsToken, int flags, int lastClickToolType,
66             in @nullable ResultReceiver resultReceiver, int reason);
hideSoftInput(in IInputMethodClient client, @nullable IBinder windowToken, in @nullable ImeTracker.Token statsToken, int flags, in @nullable ResultReceiver resultReceiver, int reason)67     boolean hideSoftInput(in IInputMethodClient client, @nullable IBinder windowToken,
68             in @nullable ImeTracker.Token statsToken, int flags,
69             in @nullable ResultReceiver resultReceiver, int reason);
70     // If windowToken is null, this just does startInput().  Otherwise this reports that a window
71     // has gained focus, and if 'editorInfo' is non-null then also does startInput.
72     // @NonNull
73     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
74             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
startInputOrWindowGainedFocus( int startInputReason, in IInputMethodClient client, in @nullable IBinder windowToken, int startInputFlags, int softInputMode, int windowFlags, in @nullable EditorInfo editorInfo, in @nullable IRemoteInputConnection inputConnection, in @nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, int userId, in ImeOnBackInvokedDispatcher imeDispatcher)75     InputBindResult startInputOrWindowGainedFocus(
76             /* @StartInputReason */ int startInputReason,
77             in IInputMethodClient client, in @nullable IBinder windowToken,
78             /* @StartInputFlags */ int startInputFlags,
79             /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode,
80             /* @android.view.WindowManager.LayoutParams.Flags */ int windowFlags,
81             in @nullable EditorInfo editorInfo, in @nullable IRemoteInputConnection inputConnection,
82             in @nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection,
83             int unverifiedTargetSdkVersion, int userId,
84             in ImeOnBackInvokedDispatcher imeDispatcher);
85 
showInputMethodPickerFromClient(in IInputMethodClient client, int auxiliarySubtypeMode)86     void showInputMethodPickerFromClient(in IInputMethodClient client,
87             int auxiliarySubtypeMode);
88 
89     @EnforcePermission("WRITE_SECURE_SETTINGS")
90     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
91             + "android.Manifest.permission.WRITE_SECURE_SETTINGS)")
showInputMethodPickerFromSystem(int auxiliarySubtypeMode, int displayId)92     void showInputMethodPickerFromSystem(int auxiliarySubtypeMode, int displayId);
93 
94     @EnforcePermission("TEST_INPUT_METHOD")
95     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
96             + "android.Manifest.permission.TEST_INPUT_METHOD)")
isInputMethodPickerShownForTest()97     boolean isInputMethodPickerShownForTest();
98 
99     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
100             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getCurrentInputMethodSubtype(int userId)101     @nullable InputMethodSubtype getCurrentInputMethodSubtype(int userId);
102 
103     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
104             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes, int userId)105     void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes,
106             int userId);
107 
108     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
109             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
setExplicitlyEnabledInputMethodSubtypes(String imeId, in int[] subtypeHashCodes, int userId)110     void setExplicitlyEnabledInputMethodSubtypes(String imeId, in int[] subtypeHashCodes,
111             int userId);
112 
113     // This is kept due to @UnsupportedAppUsage.
114     // TODO(Bug 113914148): Consider removing this.
getInputMethodWindowVisibleHeight(in IInputMethodClient client)115     int getInputMethodWindowVisibleHeight(in IInputMethodClient client);
116 
reportVirtualDisplayGeometryAsync(in IInputMethodClient parentClient, int childDisplayId, in @nullable float[] matrixValues)117     oneway void reportVirtualDisplayGeometryAsync(in IInputMethodClient parentClient,
118             int childDisplayId, in @nullable float[] matrixValues);
119 
reportPerceptibleAsync(in IBinder windowToken, boolean perceptible)120     oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible);
121 
122     @EnforcePermission("INTERNAL_SYSTEM_WINDOW")
123     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
124             + "android.Manifest.permission.INTERNAL_SYSTEM_WINDOW)")
removeImeSurface()125     void removeImeSurface();
126 
127     /** Remove the IME surface. Requires passing the currently focused window. */
removeImeSurfaceFromWindowAsync(in IBinder windowToken)128     oneway void removeImeSurfaceFromWindowAsync(in IBinder windowToken);
129 
130     @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
startProtoDump(in byte[] protoDump, int source, String where)131     void startProtoDump(in byte[] protoDump, int source, String where);
132 
133     @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
isImeTraceEnabled()134     boolean isImeTraceEnabled();
135 
136     // Starts an ime trace.
137     @EnforcePermission("CONTROL_UI_TRACING")
138     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
139             + "android.Manifest.permission.CONTROL_UI_TRACING)")
startImeTrace()140     void startImeTrace();
141 
142     // Stops an ime trace.
143     @EnforcePermission("CONTROL_UI_TRACING")
144     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
145             + "android.Manifest.permission.CONTROL_UI_TRACING)")
stopImeTrace()146     void stopImeTrace();
147 
148     /** Start Stylus handwriting session **/
startStylusHandwriting(in IInputMethodClient client)149     void startStylusHandwriting(in IInputMethodClient client);
150 
151     /** Prepares delegation of starting stylus handwriting session to a different editor **/
prepareStylusHandwritingDelegation(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName)152     void prepareStylusHandwritingDelegation(in IInputMethodClient client,
153                 in int userId,
154                 in String delegatePackageName,
155                 in String delegatorPackageName);
156 
157     /** Accepts and starts a stylus handwriting session for the delegate view **/
acceptStylusHandwritingDelegation(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName)158     boolean acceptStylusHandwritingDelegation(in IInputMethodClient client,
159                 in int userId, in String delegatePackageName, in String delegatorPackageName);
160 
161     /** Returns {@code true} if currently selected IME supports Stylus handwriting. */
162     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
163             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
isStylusHandwritingAvailableAsUser(int userId)164     boolean isStylusHandwritingAvailableAsUser(int userId);
165 
166     /** add virtual stylus id for test Stylus handwriting session **/
167     @EnforcePermission("TEST_INPUT_METHOD")
168     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
169             + "android.Manifest.permission.TEST_INPUT_METHOD)")
addVirtualStylusIdForTestSession(in IInputMethodClient client)170     void addVirtualStylusIdForTestSession(in IInputMethodClient client);
171 
172     /** Set a stylus idle-timeout after which handwriting {@code InkWindow} will be removed. */
173     @EnforcePermission("TEST_INPUT_METHOD")
174     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
175             + "android.Manifest.permission.TEST_INPUT_METHOD)")
setStylusWindowIdleTimeoutForTest(in IInputMethodClient client, long timeout)176     void setStylusWindowIdleTimeoutForTest(in IInputMethodClient client, long timeout);
177 
178     /**
179      * Returns the singleton instance for the Ime Tracker Service.
180      * {@hide}
181      */
getImeTrackerService()182     IImeTracker getImeTrackerService();
183 }
184