• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.CursorAnchorInfo;
21 import android.view.inputmethod.ImeTracker;
22 import android.view.inputmethod.InputMethodInfo;
23 import android.view.inputmethod.InputMethodSubtype;
24 import android.view.inputmethod.EditorInfo;
25 import android.window.ImeOnBackInvokedDispatcher;
26 
27 import com.android.internal.inputmethod.IBooleanListener;
28 import com.android.internal.inputmethod.IConnectionlessHandwritingCallback;
29 import com.android.internal.inputmethod.IImeTracker;
30 import com.android.internal.inputmethod.IInputMethodClient;
31 import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection;
32 import com.android.internal.inputmethod.IRemoteInputConnection;
33 import com.android.internal.inputmethod.InputBindResult;
34 import com.android.internal.inputmethod.InputMethodInfoSafeList;
35 
36 /**
37  * Public interface to the global input method manager, used by all client applications.
38  *
39  * When adding new methods, make sure the associated user can be inferred from the arguments.
40  * Consider passing the associated userId when not already passing a display id or a window token.
41  */
42 interface IInputMethodManager {
addClient(in IInputMethodClient client, in IRemoteInputConnection inputmethod, int untrustedDisplayId)43     void addClient(in IInputMethodClient client, in IRemoteInputConnection inputmethod,
44             int untrustedDisplayId);
45 
46     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
47             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getCurrentInputMethodInfoAsUser(int userId)48     InputMethodInfo getCurrentInputMethodInfoAsUser(int userId);
49 
50     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
51             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getInputMethodList(int userId, int directBootAwareness)52     InputMethodInfoSafeList getInputMethodList(int userId, int directBootAwareness);
53 
54     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
55             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getEnabledInputMethodList(int userId)56     InputMethodInfoSafeList getEnabledInputMethodList(int userId);
57 
58     // TODO(b/339761278): Remove after getInputMethodList() is fully deployed.
59     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
60             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getInputMethodListLegacy(int userId, int directBootAwareness)61     List<InputMethodInfo> getInputMethodListLegacy(int userId, int directBootAwareness);
62 
63     // TODO(b/339761278): Remove after getEnabledInputMethodList() is fully deployed.
64     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
65             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getEnabledInputMethodListLegacy(int userId)66     List<InputMethodInfo> getEnabledInputMethodListLegacy(int userId);
67 
68     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
69             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getEnabledInputMethodSubtypeList(in @ullable String imiId, boolean allowsImplicitlyEnabledSubtypes, int userId)70     List<InputMethodSubtype> getEnabledInputMethodSubtypeList(in @nullable String imiId,
71             boolean allowsImplicitlyEnabledSubtypes, int userId);
72 
73     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
74             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getLastInputMethodSubtype(int userId)75     InputMethodSubtype getLastInputMethodSubtype(int userId);
76 
showSoftInput(in IInputMethodClient client, @nullable IBinder windowToken, in ImeTracker.Token statsToken, int flags, int lastClickToolType, in @nullable ResultReceiver resultReceiver, int reason, boolean async)77     boolean showSoftInput(in IInputMethodClient client, @nullable IBinder windowToken,
78             in ImeTracker.Token statsToken, int flags, int lastClickToolType,
79             in @nullable ResultReceiver resultReceiver, int reason, boolean async);
hideSoftInput(in IInputMethodClient client, @nullable IBinder windowToken, in ImeTracker.Token statsToken, int flags, in @nullable ResultReceiver resultReceiver, int reason, boolean async)80     boolean hideSoftInput(in IInputMethodClient client, @nullable IBinder windowToken,
81             in ImeTracker.Token statsToken, int flags,
82             in @nullable ResultReceiver resultReceiver, int reason, boolean async);
83 
84     /**
85      * A test API for CTS to request hiding the current soft input window, with the request origin
86      * on the server side.
87      */
88     @EnforcePermission("TEST_INPUT_METHOD")
89     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
90             + "android.Manifest.permission.TEST_INPUT_METHOD)")
hideSoftInputFromServerForTest()91     void hideSoftInputFromServerForTest();
92 
93     // TODO(b/293640003): Remove method once Flags.useZeroJankProxy() is enabled.
94     // If windowToken is null, this just does startInput().  Otherwise this reports that a window
95     // has gained focus, and if 'editorInfo' is non-null then also does startInput.
96     // @NonNull
97     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
98             + "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, boolean imeRequestedVisible)99     InputBindResult startInputOrWindowGainedFocus(
100             /* @StartInputReason */ int startInputReason,
101             in IInputMethodClient client, in @nullable IBinder windowToken,
102             /* @StartInputFlags */ int startInputFlags,
103             /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode,
104             /* @android.view.WindowManager.LayoutParams.Flags */ int windowFlags,
105             in @nullable EditorInfo editorInfo, in @nullable IRemoteInputConnection inputConnection,
106             in @nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection,
107             int unverifiedTargetSdkVersion, int userId,
108             in ImeOnBackInvokedDispatcher imeDispatcher, boolean imeRequestedVisible);
109 
110     // If windowToken is null, this just does startInput().  Otherwise this reports that a window
111     // has gained focus, and if 'editorInfo' is non-null then also does startInput.
112     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
113             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
startInputOrWindowGainedFocusAsync( 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, boolean imeRequestedVisible, int startInputSeq, boolean useAsyncShowHideMethod)114     void startInputOrWindowGainedFocusAsync(
115             /* @StartInputReason */ int startInputReason,
116             in IInputMethodClient client, in @nullable IBinder windowToken,
117             /* @StartInputFlags */ int startInputFlags,
118             /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode,
119             /* @android.view.WindowManager.LayoutParams.Flags */ int windowFlags,
120             in @nullable EditorInfo editorInfo, in @nullable IRemoteInputConnection inputConnection,
121             in @nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection,
122             int unverifiedTargetSdkVersion, int userId,
123             in ImeOnBackInvokedDispatcher imeDispatcher, boolean imeRequestedVisible,
124             int startInputSeq, boolean useAsyncShowHideMethod);
125 
showInputMethodPickerFromClient(in IInputMethodClient client, int auxiliarySubtypeMode)126     void showInputMethodPickerFromClient(in IInputMethodClient client,
127             int auxiliarySubtypeMode);
128 
129     @EnforcePermission(allOf = {"WRITE_SECURE_SETTINGS", "INTERACT_ACROSS_USERS_FULL"})
130     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf = {android.Manifest."
131     + "permission.WRITE_SECURE_SETTINGS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})")
showInputMethodPickerFromSystem(int auxiliarySubtypeMode, int displayId)132     void showInputMethodPickerFromSystem(int auxiliarySubtypeMode, int displayId);
133 
134     @EnforcePermission("TEST_INPUT_METHOD")
135     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
136             + "android.Manifest.permission.TEST_INPUT_METHOD)")
isInputMethodPickerShownForTest()137     boolean isInputMethodPickerShownForTest();
138 
139     /**
140      * Called when the IME switch button was clicked from the system. Depending on the number of
141      * enabled IME subtypes, this will either switch to the next IME/subtype, or show the input
142      * method picker dialog.
143      *
144      * @param displayId The ID of the display where the input method picker dialog should be shown.
145      * @param userId    The ID of the user that triggered the click.
146      */
147     @EnforcePermission(allOf = {"WRITE_SECURE_SETTINGS" ,"INTERACT_ACROSS_USERS_FULL"})
148     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf = {android.Manifest."
149     + "permission.WRITE_SECURE_SETTINGS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})")
onImeSwitchButtonClickFromSystem(int displayId)150     oneway void onImeSwitchButtonClickFromSystem(int displayId);
151 
152     /**
153      * A test API for CTS to check whether the IME Switcher button should be shown when the IME
154      * is shown.
155      */
156     @EnforcePermission("TEST_INPUT_METHOD")
157     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
158             + "android.Manifest.permission.TEST_INPUT_METHOD)")
shouldShowImeSwitcherButtonForTest()159     boolean shouldShowImeSwitcherButtonForTest();
160 
161     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
162             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
getCurrentInputMethodSubtype(int userId)163     @nullable InputMethodSubtype getCurrentInputMethodSubtype(int userId);
164 
165     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
166             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes, int userId)167     void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes,
168             int userId);
169 
170     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
171             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
setExplicitlyEnabledInputMethodSubtypes(String imeId, in int[] subtypeHashCodes, int userId)172     void setExplicitlyEnabledInputMethodSubtypes(String imeId, in int[] subtypeHashCodes,
173             int userId);
174 
175     // This is kept due to @UnsupportedAppUsage.
176     // TODO(Bug 113914148): Consider removing this.
getInputMethodWindowVisibleHeight(in IInputMethodClient client)177     int getInputMethodWindowVisibleHeight(in IInputMethodClient client);
178 
reportPerceptibleAsync(in IBinder windowToken, boolean perceptible)179     oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible);
180 
181     @EnforcePermission(allOf = {"INTERNAL_SYSTEM_WINDOW", "INTERACT_ACROSS_USERS_FULL"})
182     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf = {android.Manifest."
183     + "permission.INTERNAL_SYSTEM_WINDOW, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL})")
removeImeSurface(int displayId)184     void removeImeSurface(int displayId);
185 
186     /** Remove the IME surface. Requires passing the currently focused window. */
removeImeSurfaceFromWindowAsync(in IBinder windowToken)187     oneway void removeImeSurfaceFromWindowAsync(in IBinder windowToken);
188 
189     @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
startProtoDump(in byte[] protoDump, int source, String where)190     void startProtoDump(in byte[] protoDump, int source, String where);
191 
192     @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
isImeTraceEnabled()193     boolean isImeTraceEnabled();
194 
195     // Starts an ime trace.
196     @EnforcePermission("CONTROL_UI_TRACING")
197     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
198             + "android.Manifest.permission.CONTROL_UI_TRACING)")
startImeTrace()199     void startImeTrace();
200 
201     // Stops an ime trace.
202     @EnforcePermission("CONTROL_UI_TRACING")
203     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
204             + "android.Manifest.permission.CONTROL_UI_TRACING)")
stopImeTrace()205     void stopImeTrace();
206 
207     /** Start Stylus handwriting session **/
startStylusHandwriting(in IInputMethodClient client)208     void startStylusHandwriting(in IInputMethodClient client);
startConnectionlessStylusHandwriting(in IInputMethodClient client, int userId, in CursorAnchorInfo cursorAnchorInfo, in String delegatePackageName, in String delegatorPackageName, in IConnectionlessHandwritingCallback callback)209     oneway void startConnectionlessStylusHandwriting(in IInputMethodClient client, int userId,
210             in CursorAnchorInfo cursorAnchorInfo, in String delegatePackageName,
211             in String delegatorPackageName, in IConnectionlessHandwritingCallback callback);
212 
213     /** Prepares delegation of starting stylus handwriting session to a different editor **/
prepareStylusHandwritingDelegation(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName)214     void prepareStylusHandwritingDelegation(in IInputMethodClient client,
215                 in int userId,
216                 in String delegatePackageName,
217                 in String delegatorPackageName);
218 
219     /** Accepts and starts a stylus handwriting session for the delegate view **/
acceptStylusHandwritingDelegation(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName, int flags)220     boolean acceptStylusHandwritingDelegation(in IInputMethodClient client, in int userId,
221             in String delegatePackageName, in String delegatorPackageName, int flags);
222 
223     /** Accepts and starts a stylus handwriting session for the delegate view and provides result
224      *  async **/
acceptStylusHandwritingDelegationAsync(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName, int flags, in IBooleanListener callback)225     oneway void acceptStylusHandwritingDelegationAsync(in IInputMethodClient client, in int userId,
226             in String delegatePackageName, in String delegatorPackageName, int flags,
227                 in IBooleanListener callback);
228 
229     /** Returns {@code true} if currently selected IME supports Stylus handwriting. */
230     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
231             + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)")
isStylusHandwritingAvailableAsUser(int userId, boolean connectionless)232     boolean isStylusHandwritingAvailableAsUser(int userId, boolean connectionless);
233 
234     /** add virtual stylus id for test Stylus handwriting session **/
235     @EnforcePermission("TEST_INPUT_METHOD")
236     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
237             + "android.Manifest.permission.TEST_INPUT_METHOD)")
addVirtualStylusIdForTestSession(in IInputMethodClient client)238     void addVirtualStylusIdForTestSession(in IInputMethodClient client);
239 
240     /** Set a stylus idle-timeout after which handwriting {@code InkWindow} will be removed. */
241     @EnforcePermission("TEST_INPUT_METHOD")
242     @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = "
243             + "android.Manifest.permission.TEST_INPUT_METHOD)")
setStylusWindowIdleTimeoutForTest(in IInputMethodClient client, long timeout)244     void setStylusWindowIdleTimeoutForTest(in IInputMethodClient client, long timeout);
245 
246     /**
247      * Returns the singleton instance for the Ime Tracker Service.
248      * {@hide}
249      */
getImeTrackerService()250     IImeTracker getImeTrackerService();
251 }
252