Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package com.android.internal.view; |
| 18 | |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 19 | import com.android.internal.annotations.GuardedBy; |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 20 | import com.android.internal.os.SomeArgs; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 21 | |
| 22 | import android.annotation.NonNull; |
| 23 | import android.annotation.Nullable; |
Mathew Inwood | af972c8 | 2018-08-20 14:13:20 +0100 | [diff] [blame^] | 24 | import android.annotation.UnsupportedAppUsage; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.os.Bundle; |
| 26 | import android.os.Handler; |
| 27 | import android.os.Looper; |
| 28 | import android.os.Message; |
| 29 | import android.os.RemoteException; |
| 30 | import android.util.Log; |
| 31 | import android.view.KeyEvent; |
| 32 | import android.view.inputmethod.CompletionInfo; |
Gilles Debunne | cf9cf2f | 2010-12-08 17:43:58 -0800 | [diff] [blame] | 33 | import android.view.inputmethod.CorrectionInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.view.inputmethod.ExtractedTextRequest; |
| 35 | import android.view.inputmethod.InputConnection; |
Yohei Yukawa | 9f9afe52 | 2016-03-30 12:03:51 -0700 | [diff] [blame] | 36 | import android.view.inputmethod.InputConnectionInspector; |
| 37 | import android.view.inputmethod.InputConnectionInspector.MissingMethodFlags; |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 38 | import android.view.inputmethod.InputContentInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | |
Yohei Yukawa | 159dd47 | 2016-01-07 16:52:33 -0800 | [diff] [blame] | 40 | public abstract class IInputConnectionWrapper extends IInputContext.Stub { |
Yohei Yukawa | 77e5183 | 2017-02-12 20:08:13 -0800 | [diff] [blame] | 41 | private static final String TAG = "IInputConnectionWrapper"; |
| 42 | private static final boolean DEBUG = false; |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 43 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | private static final int DO_GET_TEXT_AFTER_CURSOR = 10; |
| 45 | private static final int DO_GET_TEXT_BEFORE_CURSOR = 20; |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 46 | private static final int DO_GET_SELECTED_TEXT = 25; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | private static final int DO_GET_CURSOR_CAPS_MODE = 30; |
| 48 | private static final int DO_GET_EXTRACTED_TEXT = 40; |
| 49 | private static final int DO_COMMIT_TEXT = 50; |
| 50 | private static final int DO_COMMIT_COMPLETION = 55; |
Gilles Debunne | cf9cf2f | 2010-12-08 17:43:58 -0800 | [diff] [blame] | 51 | private static final int DO_COMMIT_CORRECTION = 56; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | private static final int DO_SET_SELECTION = 57; |
| 53 | private static final int DO_PERFORM_EDITOR_ACTION = 58; |
| 54 | private static final int DO_PERFORM_CONTEXT_MENU_ACTION = 59; |
| 55 | private static final int DO_SET_COMPOSING_TEXT = 60; |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 56 | private static final int DO_SET_COMPOSING_REGION = 63; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | private static final int DO_FINISH_COMPOSING_TEXT = 65; |
| 58 | private static final int DO_SEND_KEY_EVENT = 70; |
| 59 | private static final int DO_DELETE_SURROUNDING_TEXT = 80; |
Yohei Yukawa | c89e22a | 2016-01-13 22:48:14 -0800 | [diff] [blame] | 60 | private static final int DO_DELETE_SURROUNDING_TEXT_IN_CODE_POINTS = 81; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | private static final int DO_BEGIN_BATCH_EDIT = 90; |
| 62 | private static final int DO_END_BATCH_EDIT = 95; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | private static final int DO_PERFORM_PRIVATE_COMMAND = 120; |
| 64 | private static final int DO_CLEAR_META_KEY_STATES = 130; |
Yohei Yukawa | a277db2 | 2014-08-21 18:38:44 -0700 | [diff] [blame] | 65 | private static final int DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO = 140; |
Yohei Yukawa | 9f9afe52 | 2016-03-30 12:03:51 -0700 | [diff] [blame] | 66 | private static final int DO_CLOSE_CONNECTION = 150; |
Yohei Yukawa | adebb52 | 2016-06-17 10:10:39 -0700 | [diff] [blame] | 67 | private static final int DO_COMMIT_CONTENT = 160; |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 68 | |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 69 | @GuardedBy("mLock") |
| 70 | @Nullable |
Mathew Inwood | af972c8 | 2018-08-20 14:13:20 +0100 | [diff] [blame^] | 71 | @UnsupportedAppUsage |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 72 | private InputConnection mInputConnection; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | |
| 74 | private Looper mMainLooper; |
| 75 | private Handler mH; |
Mathew Inwood | af972c8 | 2018-08-20 14:13:20 +0100 | [diff] [blame^] | 76 | @UnsupportedAppUsage |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 77 | private Object mLock = new Object(); |
| 78 | @GuardedBy("mLock") |
| 79 | private boolean mFinished = false; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | class MyHandler extends Handler { |
| 82 | MyHandler(Looper looper) { |
| 83 | super(looper); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public void handleMessage(Message msg) { |
| 88 | executeMessage(msg); |
| 89 | } |
| 90 | } |
| 91 | |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 92 | public IInputConnectionWrapper(Looper mainLooper, @NonNull InputConnection inputConnection) { |
| 93 | mInputConnection = inputConnection; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | mMainLooper = mainLooper; |
| 95 | mH = new MyHandler(mMainLooper); |
| 96 | } |
| 97 | |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 98 | @Nullable |
| 99 | public InputConnection getInputConnection() { |
| 100 | synchronized (mLock) { |
| 101 | return mInputConnection; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | protected boolean isFinished() { |
| 106 | synchronized (mLock) { |
| 107 | return mFinished; |
| 108 | } |
| 109 | } |
| 110 | |
Yohei Yukawa | 159dd47 | 2016-01-07 16:52:33 -0800 | [diff] [blame] | 111 | abstract protected boolean isActive(); |
| 112 | |
| 113 | /** |
| 114 | * Called when the user took some actions that should be taken into consideration to update the |
| 115 | * LRU list for input method rotation. |
| 116 | */ |
| 117 | abstract protected void onUserAction(); |
| 118 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 119 | public void getTextAfterCursor(int length, int flags, int seq, IInputContextCallback callback) { |
| 120 | dispatchMessage(obtainMessageIISC(DO_GET_TEXT_AFTER_CURSOR, length, flags, seq, callback)); |
| 121 | } |
| 122 | |
| 123 | public void getTextBeforeCursor(int length, int flags, int seq, IInputContextCallback callback) { |
| 124 | dispatchMessage(obtainMessageIISC(DO_GET_TEXT_BEFORE_CURSOR, length, flags, seq, callback)); |
| 125 | } |
| 126 | |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 127 | public void getSelectedText(int flags, int seq, IInputContextCallback callback) { |
| 128 | dispatchMessage(obtainMessageISC(DO_GET_SELECTED_TEXT, flags, seq, callback)); |
| 129 | } |
| 130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 131 | public void getCursorCapsMode(int reqModes, int seq, IInputContextCallback callback) { |
| 132 | dispatchMessage(obtainMessageISC(DO_GET_CURSOR_CAPS_MODE, reqModes, seq, callback)); |
| 133 | } |
| 134 | |
| 135 | public void getExtractedText(ExtractedTextRequest request, |
| 136 | int flags, int seq, IInputContextCallback callback) { |
| 137 | dispatchMessage(obtainMessageIOSC(DO_GET_EXTRACTED_TEXT, flags, |
| 138 | request, seq, callback)); |
| 139 | } |
| 140 | |
| 141 | public void commitText(CharSequence text, int newCursorPosition) { |
| 142 | dispatchMessage(obtainMessageIO(DO_COMMIT_TEXT, newCursorPosition, text)); |
| 143 | } |
| 144 | |
| 145 | public void commitCompletion(CompletionInfo text) { |
| 146 | dispatchMessage(obtainMessageO(DO_COMMIT_COMPLETION, text)); |
| 147 | } |
| 148 | |
Gilles Debunne | cf9cf2f | 2010-12-08 17:43:58 -0800 | [diff] [blame] | 149 | public void commitCorrection(CorrectionInfo info) { |
| 150 | dispatchMessage(obtainMessageO(DO_COMMIT_CORRECTION, info)); |
| 151 | } |
| 152 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | public void setSelection(int start, int end) { |
| 154 | dispatchMessage(obtainMessageII(DO_SET_SELECTION, start, end)); |
| 155 | } |
| 156 | |
| 157 | public void performEditorAction(int id) { |
| 158 | dispatchMessage(obtainMessageII(DO_PERFORM_EDITOR_ACTION, id, 0)); |
| 159 | } |
| 160 | |
| 161 | public void performContextMenuAction(int id) { |
| 162 | dispatchMessage(obtainMessageII(DO_PERFORM_CONTEXT_MENU_ACTION, id, 0)); |
| 163 | } |
| 164 | |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 165 | public void setComposingRegion(int start, int end) { |
| 166 | dispatchMessage(obtainMessageII(DO_SET_COMPOSING_REGION, start, end)); |
| 167 | } |
| 168 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | public void setComposingText(CharSequence text, int newCursorPosition) { |
| 170 | dispatchMessage(obtainMessageIO(DO_SET_COMPOSING_TEXT, newCursorPosition, text)); |
| 171 | } |
| 172 | |
| 173 | public void finishComposingText() { |
| 174 | dispatchMessage(obtainMessage(DO_FINISH_COMPOSING_TEXT)); |
| 175 | } |
| 176 | |
| 177 | public void sendKeyEvent(KeyEvent event) { |
| 178 | dispatchMessage(obtainMessageO(DO_SEND_KEY_EVENT, event)); |
| 179 | } |
| 180 | |
| 181 | public void clearMetaKeyStates(int states) { |
| 182 | dispatchMessage(obtainMessageII(DO_CLEAR_META_KEY_STATES, states, 0)); |
| 183 | } |
| 184 | |
Yohei Yukawa | c89e22a | 2016-01-13 22:48:14 -0800 | [diff] [blame] | 185 | public void deleteSurroundingText(int beforeLength, int afterLength) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 186 | dispatchMessage(obtainMessageII(DO_DELETE_SURROUNDING_TEXT, |
Yohei Yukawa | c89e22a | 2016-01-13 22:48:14 -0800 | [diff] [blame] | 187 | beforeLength, afterLength)); |
| 188 | } |
| 189 | |
| 190 | public void deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { |
| 191 | dispatchMessage(obtainMessageII(DO_DELETE_SURROUNDING_TEXT_IN_CODE_POINTS, |
| 192 | beforeLength, afterLength)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | public void beginBatchEdit() { |
| 196 | dispatchMessage(obtainMessage(DO_BEGIN_BATCH_EDIT)); |
| 197 | } |
| 198 | |
| 199 | public void endBatchEdit() { |
| 200 | dispatchMessage(obtainMessage(DO_END_BATCH_EDIT)); |
| 201 | } |
| 202 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 203 | public void performPrivateCommand(String action, Bundle data) { |
| 204 | dispatchMessage(obtainMessageOO(DO_PERFORM_PRIVATE_COMMAND, action, data)); |
| 205 | } |
satok | adb4358 | 2011-03-09 10:08:47 +0900 | [diff] [blame] | 206 | |
Yohei Yukawa | a277db2 | 2014-08-21 18:38:44 -0700 | [diff] [blame] | 207 | public void requestUpdateCursorAnchorInfo(int cursorUpdateMode, int seq, |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 208 | IInputContextCallback callback) { |
Yohei Yukawa | a277db2 | 2014-08-21 18:38:44 -0700 | [diff] [blame] | 209 | dispatchMessage(obtainMessageISC(DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO, cursorUpdateMode, |
| 210 | seq, callback)); |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 211 | } |
| 212 | |
Yohei Yukawa | 9f9afe52 | 2016-03-30 12:03:51 -0700 | [diff] [blame] | 213 | public void closeConnection() { |
| 214 | dispatchMessage(obtainMessage(DO_CLOSE_CONNECTION)); |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Yohei Yukawa | 45700fa | 2016-06-23 17:12:59 -0700 | [diff] [blame] | 217 | public void commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts, |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 218 | int seq, IInputContextCallback callback) { |
Yohei Yukawa | 45700fa | 2016-06-23 17:12:59 -0700 | [diff] [blame] | 219 | dispatchMessage(obtainMessageIOOSC(DO_COMMIT_CONTENT, flags, inputContentInfo, opts, seq, |
| 220 | callback)); |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 221 | } |
| 222 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | void dispatchMessage(Message msg) { |
| 224 | // If we are calling this from the main thread, then we can call |
| 225 | // right through. Otherwise, we need to send the message to the |
| 226 | // main thread. |
| 227 | if (Looper.myLooper() == mMainLooper) { |
| 228 | executeMessage(msg); |
| 229 | msg.recycle(); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | mH.sendMessage(msg); |
| 234 | } |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 235 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | void executeMessage(Message msg) { |
| 237 | switch (msg.what) { |
| 238 | case DO_GET_TEXT_AFTER_CURSOR: { |
| 239 | SomeArgs args = (SomeArgs)msg.obj; |
| 240 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 241 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 242 | final int callbackSeq = args.argi6; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 243 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 244 | if (ic == null || !isActive()) { |
| 245 | Log.w(TAG, "getTextAfterCursor on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 246 | callback.setTextAfterCursor(null, callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 247 | return; |
| 248 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 249 | callback.setTextAfterCursor(ic.getTextAfterCursor( |
| 250 | msg.arg1, msg.arg2), callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 251 | } catch (RemoteException e) { |
| 252 | Log.w(TAG, "Got RemoteException calling setTextAfterCursor", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 253 | } finally { |
| 254 | args.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 255 | } |
| 256 | return; |
| 257 | } |
| 258 | case DO_GET_TEXT_BEFORE_CURSOR: { |
| 259 | SomeArgs args = (SomeArgs)msg.obj; |
| 260 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 261 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 262 | final int callbackSeq = args.argi6; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 263 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 264 | if (ic == null || !isActive()) { |
| 265 | Log.w(TAG, "getTextBeforeCursor on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 266 | callback.setTextBeforeCursor(null, callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 267 | return; |
| 268 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 269 | callback.setTextBeforeCursor(ic.getTextBeforeCursor( |
| 270 | msg.arg1, msg.arg2), callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 271 | } catch (RemoteException e) { |
| 272 | Log.w(TAG, "Got RemoteException calling setTextBeforeCursor", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 273 | } finally { |
| 274 | args.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 275 | } |
| 276 | return; |
| 277 | } |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 278 | case DO_GET_SELECTED_TEXT: { |
| 279 | SomeArgs args = (SomeArgs)msg.obj; |
| 280 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 281 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 282 | final int callbackSeq = args.argi6; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 283 | InputConnection ic = getInputConnection(); |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 284 | if (ic == null || !isActive()) { |
| 285 | Log.w(TAG, "getSelectedText on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 286 | callback.setSelectedText(null, callbackSeq); |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 287 | return; |
| 288 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 289 | callback.setSelectedText(ic.getSelectedText( |
| 290 | msg.arg1), callbackSeq); |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 291 | } catch (RemoteException e) { |
| 292 | Log.w(TAG, "Got RemoteException calling setSelectedText", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 293 | } finally { |
| 294 | args.recycle(); |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 295 | } |
| 296 | return; |
| 297 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 298 | case DO_GET_CURSOR_CAPS_MODE: { |
| 299 | SomeArgs args = (SomeArgs)msg.obj; |
| 300 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 301 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 302 | final int callbackSeq = args.argi6; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 303 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 304 | if (ic == null || !isActive()) { |
| 305 | Log.w(TAG, "getCursorCapsMode on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 306 | callback.setCursorCapsMode(0, callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 307 | return; |
| 308 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 309 | callback.setCursorCapsMode(ic.getCursorCapsMode(msg.arg1), |
| 310 | callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | } catch (RemoteException e) { |
| 312 | Log.w(TAG, "Got RemoteException calling setCursorCapsMode", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 313 | } finally { |
| 314 | args.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 315 | } |
| 316 | return; |
| 317 | } |
| 318 | case DO_GET_EXTRACTED_TEXT: { |
| 319 | SomeArgs args = (SomeArgs)msg.obj; |
| 320 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 321 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 322 | final int callbackSeq = args.argi6; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 323 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | if (ic == null || !isActive()) { |
| 325 | Log.w(TAG, "getExtractedText on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 326 | callback.setExtractedText(null, callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 327 | return; |
| 328 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 329 | callback.setExtractedText(ic.getExtractedText( |
| 330 | (ExtractedTextRequest)args.arg1, msg.arg1), callbackSeq); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 331 | } catch (RemoteException e) { |
| 332 | Log.w(TAG, "Got RemoteException calling setExtractedText", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 333 | } finally { |
| 334 | args.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 335 | } |
| 336 | return; |
| 337 | } |
| 338 | case DO_COMMIT_TEXT: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 339 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 340 | if (ic == null || !isActive()) { |
| 341 | Log.w(TAG, "commitText on inactive InputConnection"); |
| 342 | return; |
| 343 | } |
| 344 | ic.commitText((CharSequence)msg.obj, msg.arg1); |
Yohei Yukawa | 159dd47 | 2016-01-07 16:52:33 -0800 | [diff] [blame] | 345 | onUserAction(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 346 | return; |
| 347 | } |
| 348 | case DO_SET_SELECTION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 349 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 350 | if (ic == null || !isActive()) { |
| 351 | Log.w(TAG, "setSelection on inactive InputConnection"); |
| 352 | return; |
| 353 | } |
| 354 | ic.setSelection(msg.arg1, msg.arg2); |
| 355 | return; |
| 356 | } |
| 357 | case DO_PERFORM_EDITOR_ACTION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 358 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 359 | if (ic == null || !isActive()) { |
| 360 | Log.w(TAG, "performEditorAction on inactive InputConnection"); |
| 361 | return; |
| 362 | } |
| 363 | ic.performEditorAction(msg.arg1); |
| 364 | return; |
| 365 | } |
| 366 | case DO_PERFORM_CONTEXT_MENU_ACTION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 367 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 368 | if (ic == null || !isActive()) { |
| 369 | Log.w(TAG, "performContextMenuAction on inactive InputConnection"); |
| 370 | return; |
| 371 | } |
| 372 | ic.performContextMenuAction(msg.arg1); |
| 373 | return; |
| 374 | } |
| 375 | case DO_COMMIT_COMPLETION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 376 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 377 | if (ic == null || !isActive()) { |
| 378 | Log.w(TAG, "commitCompletion on inactive InputConnection"); |
| 379 | return; |
| 380 | } |
| 381 | ic.commitCompletion((CompletionInfo)msg.obj); |
| 382 | return; |
| 383 | } |
Gilles Debunne | cf9cf2f | 2010-12-08 17:43:58 -0800 | [diff] [blame] | 384 | case DO_COMMIT_CORRECTION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 385 | InputConnection ic = getInputConnection(); |
Gilles Debunne | cf9cf2f | 2010-12-08 17:43:58 -0800 | [diff] [blame] | 386 | if (ic == null || !isActive()) { |
| 387 | Log.w(TAG, "commitCorrection on inactive InputConnection"); |
| 388 | return; |
| 389 | } |
| 390 | ic.commitCorrection((CorrectionInfo)msg.obj); |
| 391 | return; |
| 392 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | case DO_SET_COMPOSING_TEXT: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 394 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 395 | if (ic == null || !isActive()) { |
| 396 | Log.w(TAG, "setComposingText on inactive InputConnection"); |
| 397 | return; |
| 398 | } |
| 399 | ic.setComposingText((CharSequence)msg.obj, msg.arg1); |
Yohei Yukawa | 159dd47 | 2016-01-07 16:52:33 -0800 | [diff] [blame] | 400 | onUserAction(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | return; |
| 402 | } |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 403 | case DO_SET_COMPOSING_REGION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 404 | InputConnection ic = getInputConnection(); |
Amith Yamasani | a90b7f0 | 2010-08-25 18:27:20 -0700 | [diff] [blame] | 405 | if (ic == null || !isActive()) { |
| 406 | Log.w(TAG, "setComposingRegion on inactive InputConnection"); |
| 407 | return; |
| 408 | } |
| 409 | ic.setComposingRegion(msg.arg1, msg.arg2); |
| 410 | return; |
| 411 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | case DO_FINISH_COMPOSING_TEXT: { |
Yohei Yukawa | 77e5183 | 2017-02-12 20:08:13 -0800 | [diff] [blame] | 413 | if (isFinished()) { |
| 414 | // In this case, #finishComposingText() is guaranteed to be called already. |
| 415 | // There should be no negative impact if we ignore this call silently. |
| 416 | if (DEBUG) { |
| 417 | Log.w(TAG, "Bug 35301295: Redundant finishComposingText."); |
| 418 | } |
| 419 | return; |
| 420 | } |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 421 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 422 | // Note we do NOT check isActive() here, because this is safe |
| 423 | // for an IME to call at any time, and we need to allow it |
| 424 | // through to clean up our state after the IME has switched to |
| 425 | // another client. |
| 426 | if (ic == null) { |
| 427 | Log.w(TAG, "finishComposingText on inactive InputConnection"); |
| 428 | return; |
| 429 | } |
| 430 | ic.finishComposingText(); |
| 431 | return; |
| 432 | } |
| 433 | case DO_SEND_KEY_EVENT: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 434 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 435 | if (ic == null || !isActive()) { |
| 436 | Log.w(TAG, "sendKeyEvent on inactive InputConnection"); |
| 437 | return; |
| 438 | } |
| 439 | ic.sendKeyEvent((KeyEvent)msg.obj); |
Yohei Yukawa | 159dd47 | 2016-01-07 16:52:33 -0800 | [diff] [blame] | 440 | onUserAction(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | return; |
| 442 | } |
| 443 | case DO_CLEAR_META_KEY_STATES: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 444 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 445 | if (ic == null || !isActive()) { |
| 446 | Log.w(TAG, "clearMetaKeyStates on inactive InputConnection"); |
| 447 | return; |
| 448 | } |
| 449 | ic.clearMetaKeyStates(msg.arg1); |
| 450 | return; |
| 451 | } |
| 452 | case DO_DELETE_SURROUNDING_TEXT: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 453 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 454 | if (ic == null || !isActive()) { |
| 455 | Log.w(TAG, "deleteSurroundingText on inactive InputConnection"); |
| 456 | return; |
| 457 | } |
| 458 | ic.deleteSurroundingText(msg.arg1, msg.arg2); |
| 459 | return; |
| 460 | } |
Yohei Yukawa | c89e22a | 2016-01-13 22:48:14 -0800 | [diff] [blame] | 461 | case DO_DELETE_SURROUNDING_TEXT_IN_CODE_POINTS: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 462 | InputConnection ic = getInputConnection(); |
Yohei Yukawa | c89e22a | 2016-01-13 22:48:14 -0800 | [diff] [blame] | 463 | if (ic == null || !isActive()) { |
| 464 | Log.w(TAG, "deleteSurroundingTextInCodePoints on inactive InputConnection"); |
| 465 | return; |
| 466 | } |
| 467 | ic.deleteSurroundingTextInCodePoints(msg.arg1, msg.arg2); |
| 468 | return; |
| 469 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 470 | case DO_BEGIN_BATCH_EDIT: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 471 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 472 | if (ic == null || !isActive()) { |
| 473 | Log.w(TAG, "beginBatchEdit on inactive InputConnection"); |
| 474 | return; |
| 475 | } |
| 476 | ic.beginBatchEdit(); |
| 477 | return; |
| 478 | } |
| 479 | case DO_END_BATCH_EDIT: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 480 | InputConnection ic = getInputConnection(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | if (ic == null || !isActive()) { |
| 482 | Log.w(TAG, "endBatchEdit on inactive InputConnection"); |
| 483 | return; |
| 484 | } |
| 485 | ic.endBatchEdit(); |
| 486 | return; |
| 487 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 488 | case DO_PERFORM_PRIVATE_COMMAND: { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 489 | final SomeArgs args = (SomeArgs) msg.obj; |
| 490 | try { |
| 491 | final String action = (String) args.arg1; |
| 492 | final Bundle data = (Bundle) args.arg2; |
| 493 | InputConnection ic = getInputConnection(); |
| 494 | if (ic == null || !isActive()) { |
| 495 | Log.w(TAG, "performPrivateCommand on inactive InputConnection"); |
| 496 | return; |
| 497 | } |
| 498 | ic.performPrivateCommand(action, data); |
| 499 | } finally { |
| 500 | args.recycle(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 501 | } |
Yohei Yukawa | 3dd5fbc | 2017-02-22 20:49:10 -0800 | [diff] [blame] | 502 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 503 | } |
Yohei Yukawa | a277db2 | 2014-08-21 18:38:44 -0700 | [diff] [blame] | 504 | case DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO: { |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 505 | SomeArgs args = (SomeArgs)msg.obj; |
| 506 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 507 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 508 | final int callbackSeq = args.argi6; |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 509 | InputConnection ic = getInputConnection(); |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 510 | if (ic == null || !isActive()) { |
| 511 | Log.w(TAG, "requestCursorAnchorInfo on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 512 | callback.setRequestUpdateCursorAnchorInfoResult(false, callbackSeq); |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 513 | return; |
| 514 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 515 | callback.setRequestUpdateCursorAnchorInfoResult( |
| 516 | ic.requestCursorUpdates(msg.arg1), callbackSeq); |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 517 | } catch (RemoteException e) { |
| 518 | Log.w(TAG, "Got RemoteException calling requestCursorAnchorInfo", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 519 | } finally { |
| 520 | args.recycle(); |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 521 | } |
| 522 | return; |
| 523 | } |
Yohei Yukawa | 9f9afe52 | 2016-03-30 12:03:51 -0700 | [diff] [blame] | 524 | case DO_CLOSE_CONNECTION: { |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 525 | // Note that we do not need to worry about race condition here, because 1) mFinished |
| 526 | // is updated only inside this block, and 2) the code here is running on a Handler |
Yohei Yukawa | 9f9afe52 | 2016-03-30 12:03:51 -0700 | [diff] [blame] | 527 | // hence we assume multiple DO_CLOSE_CONNECTION messages will not be handled at the |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 528 | // same time. |
| 529 | if (isFinished()) { |
| 530 | return; |
| 531 | } |
| 532 | try { |
| 533 | InputConnection ic = getInputConnection(); |
| 534 | // Note we do NOT check isActive() here, because this is safe |
| 535 | // for an IME to call at any time, and we need to allow it |
| 536 | // through to clean up our state after the IME has switched to |
| 537 | // another client. |
| 538 | if (ic == null) { |
| 539 | return; |
| 540 | } |
Yohei Yukawa | 9f9afe52 | 2016-03-30 12:03:51 -0700 | [diff] [blame] | 541 | @MissingMethodFlags |
| 542 | final int missingMethods = InputConnectionInspector.getMissingMethodFlags(ic); |
| 543 | if ((missingMethods & MissingMethodFlags.CLOSE_CONNECTION) == 0) { |
| 544 | ic.closeConnection(); |
Yohei Yukawa | aaa38c9 | 2016-03-27 23:46:04 -0700 | [diff] [blame] | 545 | } |
| 546 | } finally { |
| 547 | synchronized (mLock) { |
| 548 | mInputConnection = null; |
| 549 | mFinished = true; |
| 550 | } |
| 551 | } |
| 552 | return; |
| 553 | } |
Yohei Yukawa | adebb52 | 2016-06-17 10:10:39 -0700 | [diff] [blame] | 554 | case DO_COMMIT_CONTENT: { |
Yohei Yukawa | 45700fa | 2016-06-23 17:12:59 -0700 | [diff] [blame] | 555 | final int flags = msg.arg1; |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 556 | SomeArgs args = (SomeArgs) msg.obj; |
| 557 | try { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 558 | final IInputContextCallback callback = (IInputContextCallback) args.arg6; |
| 559 | final int callbackSeq = args.argi6; |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 560 | InputConnection ic = getInputConnection(); |
| 561 | if (ic == null || !isActive()) { |
Yohei Yukawa | adebb52 | 2016-06-17 10:10:39 -0700 | [diff] [blame] | 562 | Log.w(TAG, "commitContent on inactive InputConnection"); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 563 | callback.setCommitContentResult(false, callbackSeq); |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 564 | return; |
| 565 | } |
| 566 | final InputContentInfo inputContentInfo = (InputContentInfo) args.arg1; |
| 567 | if (inputContentInfo == null || !inputContentInfo.validate()) { |
Yohei Yukawa | adebb52 | 2016-06-17 10:10:39 -0700 | [diff] [blame] | 568 | Log.w(TAG, "commitContent with invalid inputContentInfo=" |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 569 | + inputContentInfo); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 570 | callback.setCommitContentResult(false, callbackSeq); |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 571 | return; |
| 572 | } |
Yohei Yukawa | f3806f5 | 2016-06-30 16:27:46 -0700 | [diff] [blame] | 573 | final boolean result = |
| 574 | ic.commitContent(inputContentInfo, flags, (Bundle) args.arg2); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 575 | callback.setCommitContentResult(result, callbackSeq); |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 576 | } catch (RemoteException e) { |
Yohei Yukawa | adebb52 | 2016-06-17 10:10:39 -0700 | [diff] [blame] | 577 | Log.w(TAG, "Got RemoteException calling commitContent", e); |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 578 | } finally { |
| 579 | args.recycle(); |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 580 | } |
| 581 | return; |
| 582 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | } |
| 584 | Log.w(TAG, "Unhandled message code: " + msg.what); |
| 585 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 586 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 587 | Message obtainMessage(int what) { |
| 588 | return mH.obtainMessage(what); |
| 589 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 590 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 591 | Message obtainMessageII(int what, int arg1, int arg2) { |
| 592 | return mH.obtainMessage(what, arg1, arg2); |
| 593 | } |
Yohei Yukawa | c89e22a | 2016-01-13 22:48:14 -0800 | [diff] [blame] | 594 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 595 | Message obtainMessageO(int what, Object arg1) { |
| 596 | return mH.obtainMessage(what, 0, 0, arg1); |
| 597 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 598 | |
| 599 | Message obtainMessageISC(int what, int arg1, int callbackSeq, IInputContextCallback callback) { |
| 600 | final SomeArgs args = SomeArgs.obtain(); |
| 601 | args.arg6 = callback; |
| 602 | args.argi6 = callbackSeq; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 603 | return mH.obtainMessage(what, arg1, 0, args); |
| 604 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 605 | |
| 606 | Message obtainMessageIISC(int what, int arg1, int arg2, int callbackSeq, |
| 607 | IInputContextCallback callback) { |
| 608 | final SomeArgs args = SomeArgs.obtain(); |
| 609 | args.arg6 = callback; |
| 610 | args.argi6 = callbackSeq; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 611 | return mH.obtainMessage(what, arg1, arg2, args); |
| 612 | } |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 613 | |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 614 | Message obtainMessageIOOSC(int what, int arg1, Object objArg1, Object objArg2, int callbackSeq, |
Yohei Yukawa | 152944f | 2016-06-10 19:04:34 -0700 | [diff] [blame] | 615 | IInputContextCallback callback) { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 616 | final SomeArgs args = SomeArgs.obtain(); |
Yohei Yukawa | 45700fa | 2016-06-23 17:12:59 -0700 | [diff] [blame] | 617 | args.arg1 = objArg1; |
| 618 | args.arg2 = objArg2; |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 619 | args.arg6 = callback; |
| 620 | args.argi6 = callbackSeq; |
Yohei Yukawa | 45700fa | 2016-06-23 17:12:59 -0700 | [diff] [blame] | 621 | return mH.obtainMessage(what, arg1, 0, args); |
Yohei Yukawa | 0023d0e | 2014-07-11 04:13:03 +0900 | [diff] [blame] | 622 | } |
| 623 | |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 624 | Message obtainMessageIOSC(int what, int arg1, Object arg2, int callbackSeq, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 625 | IInputContextCallback callback) { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 626 | final SomeArgs args = SomeArgs.obtain(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 627 | args.arg1 = arg2; |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 628 | args.arg6 = callback; |
| 629 | args.argi6 = callbackSeq; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 630 | return mH.obtainMessage(what, arg1, 0, args); |
| 631 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 632 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 633 | Message obtainMessageIO(int what, int arg1, Object arg2) { |
| 634 | return mH.obtainMessage(what, arg1, 0, arg2); |
| 635 | } |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 636 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 637 | Message obtainMessageOO(int what, Object arg1, Object arg2) { |
Yohei Yukawa | ce82eb2 | 2017-02-12 23:16:47 -0800 | [diff] [blame] | 638 | final SomeArgs args = SomeArgs.obtain(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 639 | args.arg1 = arg1; |
| 640 | args.arg2 = arg2; |
| 641 | return mH.obtainMessage(what, 0, 0, args); |
| 642 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 643 | } |