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)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); hideSoftInput(in IInputMethodClient client, @nullable IBinder windowToken, in ImeTracker.Token statsToken, int flags, in @nullable ResultReceiver resultReceiver, int reason)80 boolean hideSoftInput(in IInputMethodClient client, @nullable IBinder windowToken, 81 in ImeTracker.Token statsToken, int flags, 82 in @nullable ResultReceiver resultReceiver, int reason); 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)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); 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, int startInputSeq)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, int startInputSeq); 124 showInputMethodPickerFromClient(in IInputMethodClient client, int auxiliarySubtypeMode)125 void showInputMethodPickerFromClient(in IInputMethodClient client, 126 int auxiliarySubtypeMode); 127 128 @EnforcePermission("WRITE_SECURE_SETTINGS") 129 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 130 + "android.Manifest.permission.WRITE_SECURE_SETTINGS)") showInputMethodPickerFromSystem(int auxiliarySubtypeMode, int displayId)131 void showInputMethodPickerFromSystem(int auxiliarySubtypeMode, int displayId); 132 133 @EnforcePermission("TEST_INPUT_METHOD") 134 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 135 + "android.Manifest.permission.TEST_INPUT_METHOD)") isInputMethodPickerShownForTest()136 boolean isInputMethodPickerShownForTest(); 137 138 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 139 + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)") getCurrentInputMethodSubtype(int userId)140 @nullable InputMethodSubtype getCurrentInputMethodSubtype(int userId); 141 142 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 143 + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)") setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes, int userId)144 void setAdditionalInputMethodSubtypes(String id, in InputMethodSubtype[] subtypes, 145 int userId); 146 147 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 148 + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)") setExplicitlyEnabledInputMethodSubtypes(String imeId, in int[] subtypeHashCodes, int userId)149 void setExplicitlyEnabledInputMethodSubtypes(String imeId, in int[] subtypeHashCodes, 150 int userId); 151 152 // This is kept due to @UnsupportedAppUsage. 153 // TODO(Bug 113914148): Consider removing this. getInputMethodWindowVisibleHeight(in IInputMethodClient client)154 int getInputMethodWindowVisibleHeight(in IInputMethodClient client); 155 reportPerceptibleAsync(in IBinder windowToken, boolean perceptible)156 oneway void reportPerceptibleAsync(in IBinder windowToken, boolean perceptible); 157 158 @EnforcePermission("INTERNAL_SYSTEM_WINDOW") 159 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 160 + "android.Manifest.permission.INTERNAL_SYSTEM_WINDOW)") removeImeSurface()161 void removeImeSurface(); 162 163 /** Remove the IME surface. Requires passing the currently focused window. */ removeImeSurfaceFromWindowAsync(in IBinder windowToken)164 oneway void removeImeSurfaceFromWindowAsync(in IBinder windowToken); 165 166 @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission") startProtoDump(in byte[] protoDump, int source, String where)167 void startProtoDump(in byte[] protoDump, int source, String where); 168 169 @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission") isImeTraceEnabled()170 boolean isImeTraceEnabled(); 171 172 // Starts an ime trace. 173 @EnforcePermission("CONTROL_UI_TRACING") 174 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 175 + "android.Manifest.permission.CONTROL_UI_TRACING)") startImeTrace()176 void startImeTrace(); 177 178 // Stops an ime trace. 179 @EnforcePermission("CONTROL_UI_TRACING") 180 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 181 + "android.Manifest.permission.CONTROL_UI_TRACING)") stopImeTrace()182 void stopImeTrace(); 183 184 /** Start Stylus handwriting session **/ startStylusHandwriting(in IInputMethodClient client)185 void startStylusHandwriting(in IInputMethodClient client); startConnectionlessStylusHandwriting(in IInputMethodClient client, int userId, in CursorAnchorInfo cursorAnchorInfo, in String delegatePackageName, in String delegatorPackageName, in IConnectionlessHandwritingCallback callback)186 oneway void startConnectionlessStylusHandwriting(in IInputMethodClient client, int userId, 187 in CursorAnchorInfo cursorAnchorInfo, in String delegatePackageName, 188 in String delegatorPackageName, in IConnectionlessHandwritingCallback callback); 189 190 /** Prepares delegation of starting stylus handwriting session to a different editor **/ prepareStylusHandwritingDelegation(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName)191 void prepareStylusHandwritingDelegation(in IInputMethodClient client, 192 in int userId, 193 in String delegatePackageName, 194 in String delegatorPackageName); 195 196 /** 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)197 boolean acceptStylusHandwritingDelegation(in IInputMethodClient client, in int userId, 198 in String delegatePackageName, in String delegatorPackageName, int flags); 199 200 /** Accepts and starts a stylus handwriting session for the delegate view and provides result 201 * async **/ acceptStylusHandwritingDelegationAsync(in IInputMethodClient client, in int userId, in String delegatePackageName, in String delegatorPackageName, int flags, in IBooleanListener callback)202 oneway void acceptStylusHandwritingDelegationAsync(in IInputMethodClient client, in int userId, 203 in String delegatePackageName, in String delegatorPackageName, int flags, 204 in IBooleanListener callback); 205 206 /** Returns {@code true} if currently selected IME supports Stylus handwriting. */ 207 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 208 + "android.Manifest.permission.INTERACT_ACROSS_USERS_FULL, conditional = true)") isStylusHandwritingAvailableAsUser(int userId, boolean connectionless)209 boolean isStylusHandwritingAvailableAsUser(int userId, boolean connectionless); 210 211 /** add virtual stylus id for test Stylus handwriting session **/ 212 @EnforcePermission("TEST_INPUT_METHOD") 213 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 214 + "android.Manifest.permission.TEST_INPUT_METHOD)") addVirtualStylusIdForTestSession(in IInputMethodClient client)215 void addVirtualStylusIdForTestSession(in IInputMethodClient client); 216 217 /** Set a stylus idle-timeout after which handwriting {@code InkWindow} will be removed. */ 218 @EnforcePermission("TEST_INPUT_METHOD") 219 @JavaPassthrough(annotation="@android.annotation.RequiresPermission(value = " 220 + "android.Manifest.permission.TEST_INPUT_METHOD)") setStylusWindowIdleTimeoutForTest(in IInputMethodClient client, long timeout)221 void setStylusWindowIdleTimeoutForTest(in IInputMethodClient client, long timeout); 222 223 /** 224 * Returns the singleton instance for the Ime Tracker Service. 225 * {@hide} 226 */ getImeTrackerService()227 IImeTracker getImeTrackerService(); 228 } 229