lStart = tba.initialSelStart; mCursorSelEnd = tba.initialSelEnd; mCursorCandStart = -1; mCursorCandEnd = -1; mCursorRect.setEmpty(); servedContext = new ControlledInputConnectionWrapper(vh.getLooper(), ic); } else { servedContext = null; } try { if (DEBUG) Log.v(TAG, "START INPUT: " + view + " ic=" + ic + " tba=" + tba + " initial=" + initial); InputBindResult res = mService.startInput(mClient, servedContext, tba, initial, mCurMethod == null); //启动IMEservice if (DEBUG) Log.v(TAG, "Starting input: Bind result=" + res); if (res != null) { if (res.id != null) { mBindSequence = res.sequence; mCurMethod = res.method; } else { // This means there is no input method available. if (DEBUG) Log.v(TAG, "ABORT input: no input method!"); return; } } if (mCurMethod != null && mCompletions != null) { try { mCurMethod.displayCompletions(mCompletions); } catch (RemoteException e) { } } } catch (RemoteException e) { Log.w(TAG, "IME died: " + mCurId, e); } }
那么到了IME部分的流程又是如何的呢?
首先收到configure change的event调用onConfigurationChanged->inputmethodservice.onConfigurationChanged(conf)
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); boolean visible = mWindowVisible; int showFlags = mShowInputFlags; boolean showingInput = mShowInputRequested; CompletionInfo[] completions = mCurCompletions; initViews(); mInputViewStarted = false; mCandidatesViewStarted = false; if (mInputStarted) { doStartInput(getCurrentInputConnection(), getCurrentInputEditorInfo(), true); //调用startinput,创建IME的input } if (visible) { if (showingInput) { // If we were last showing the soft keyboard, try to do so again. if (onShowInputRequested(showFlags, true)) { showWindow(true); if (completions != null) { mCurCompletions = completions; onDisplayCompletions(completions); } } else { hideWindow(); } } else if (mCandidatesVisibility == View.VISIBLE) { // If the candidates are currently visible, make sure the // window is shown for them. showWindow(false); } else { // Otherwise hide the window. hideWindow(); } } }
doStartInput->initial |