Search in sources :

Example 6 with IInputContext

use of com.android.internal.view.IInputContext in project android_frameworks_base by ParanoidAndroid.

the class IInputMethodWrapper method executeMessage.

@Override
public void executeMessage(Message msg) {
    InputMethod inputMethod = mInputMethod.get();
    // Need a valid reference to the inputMethod for everything except a dump.
    if (inputMethod == null && msg.what != DO_DUMP) {
        Log.w(TAG, "Input method reference was null, ignoring message: " + msg.what);
        return;
    }
    switch(msg.what) {
        case DO_DUMP:
            {
                AbstractInputMethodService target = mTarget.get();
                if (target == null) {
                    return;
                }
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    target.dump((FileDescriptor) args.arg1, (PrintWriter) args.arg2, (String[]) args.arg3);
                } catch (RuntimeException e) {
                    ((PrintWriter) args.arg2).println("Exception: " + e);
                }
                synchronized (args.arg4) {
                    ((CountDownLatch) args.arg4).countDown();
                }
                args.recycle();
                return;
            }
        case DO_ATTACH_TOKEN:
            {
                inputMethod.attachToken((IBinder) msg.obj);
                return;
            }
        case DO_SET_INPUT_CONTEXT:
            {
                inputMethod.bindInput((InputBinding) msg.obj);
                return;
            }
        case DO_UNSET_INPUT_CONTEXT:
            inputMethod.unbindInput();
            return;
        case DO_START_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(inputContext) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.startInput(ic, info);
                args.recycle();
                return;
            }
        case DO_RESTART_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(inputContext) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.restartInput(ic, info);
                args.recycle();
                return;
            }
        case DO_CREATE_SESSION:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                inputMethod.createSession(new InputMethodSessionCallbackWrapper(mCaller.mContext, (InputChannel) args.arg1, (IInputSessionCallback) args.arg2));
                args.recycle();
                return;
            }
        case DO_SET_SESSION_ENABLED:
            inputMethod.setSessionEnabled((InputMethodSession) msg.obj, msg.arg1 != 0);
            return;
        case DO_REVOKE_SESSION:
            inputMethod.revokeSession((InputMethodSession) msg.obj);
            return;
        case DO_SHOW_SOFT_INPUT:
            inputMethod.showSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_HIDE_SOFT_INPUT:
            inputMethod.hideSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_CHANGE_INPUTMETHOD_SUBTYPE:
            inputMethod.changeInputMethodSubtype((InputMethodSubtype) msg.obj);
            return;
    }
    Log.w(TAG, "Unhandled message code: " + msg.what);
}
Also used : IInputContext(com.android.internal.view.IInputContext) InputConnectionWrapper(com.android.internal.view.InputConnectionWrapper) FileDescriptor(java.io.FileDescriptor) InputConnection(android.view.inputmethod.InputConnection) IBinder(android.os.IBinder) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethod(com.android.internal.view.IInputMethod) InputMethod(android.view.inputmethod.InputMethod) InputBinding(android.view.inputmethod.InputBinding) PrintWriter(java.io.PrintWriter)

Example 7 with IInputContext

use of com.android.internal.view.IInputContext in project android_frameworks_base by DirtyUnicorns.

the class InputMethodManagerService method handleMessage.

@Override
public boolean handleMessage(Message msg) {
    SomeArgs args;
    switch(msg.what) {
        case MSG_SHOW_IM_SUBTYPE_PICKER:
            final boolean showAuxSubtypes;
            switch(msg.arg1) {
                case InputMethodManager.SHOW_IM_PICKER_MODE_AUTO:
                    // This is undocumented so far, but IMM#showInputMethodPicker() has been
                    // implemented so that auxiliary subtypes will be excluded when the soft
                    // keyboard is invisible.
                    showAuxSubtypes = mInputShown;
                    break;
                case InputMethodManager.SHOW_IM_PICKER_MODE_INCLUDE_AUXILIARY_SUBTYPES:
                    showAuxSubtypes = true;
                    break;
                case InputMethodManager.SHOW_IM_PICKER_MODE_EXCLUDE_AUXILIARY_SUBTYPES:
                    showAuxSubtypes = false;
                    break;
                default:
                    Slog.e(TAG, "Unknown subtype picker mode = " + msg.arg1);
                    return false;
            }
            showInputMethodMenu(showAuxSubtypes);
            return true;
        case MSG_SHOW_IM_SUBTYPE_ENABLER:
            showInputMethodAndSubtypeEnabler((String) msg.obj);
            return true;
        case MSG_SHOW_IM_CONFIG:
            showConfigureInputMethods();
            return true;
        case MSG_UNBIND_INPUT:
            try {
                ((IInputMethod) msg.obj).unbindInput();
            } catch (RemoteException e) {
            // There is nothing interesting about the method dying.
            }
            return true;
        case MSG_BIND_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                ((IInputMethod) args.arg1).bindInput((InputBinding) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_SHOW_SOFT_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Calling " + args.arg1 + ".showSoftInput(" + msg.arg1 + ", " + args.arg2 + ")");
                ((IInputMethod) args.arg1).showSoftInput(msg.arg1, (ResultReceiver) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_HIDE_SOFT_INPUT:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Calling " + args.arg1 + ".hideSoftInput(0, " + args.arg2 + ")");
                ((IInputMethod) args.arg1).hideSoftInput(0, (ResultReceiver) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_HIDE_CURRENT_INPUT_METHOD:
            synchronized (mMethodMap) {
                hideCurrentInputLocked(0, null);
            }
            return true;
        case MSG_ATTACH_TOKEN:
            args = (SomeArgs) msg.obj;
            try {
                if (DEBUG)
                    Slog.v(TAG, "Sending attach of token: " + args.arg2);
                ((IInputMethod) args.arg1).attachToken((IBinder) args.arg2);
            } catch (RemoteException e) {
            }
            args.recycle();
            return true;
        case MSG_CREATE_SESSION:
            {
                args = (SomeArgs) msg.obj;
                IInputMethod method = (IInputMethod) args.arg1;
                InputChannel channel = (InputChannel) args.arg2;
                try {
                    method.createSession(channel, (IInputSessionCallback) args.arg3);
                } catch (RemoteException e) {
                } finally {
                    // because the remote proxy will get its own copy when unparceled.
                    if (channel != null && Binder.isProxy(method)) {
                        channel.dispose();
                    }
                }
                args.recycle();
                return true;
            }
        case MSG_START_INPUT:
            {
                int missingMethods = msg.arg1;
                args = (SomeArgs) msg.obj;
                try {
                    SessionState session = (SessionState) args.arg1;
                    setEnabledSessionInMainThread(session);
                    session.method.startInput((IInputContext) args.arg2, missingMethods, (EditorInfo) args.arg3);
                } catch (RemoteException e) {
                }
                args.recycle();
                return true;
            }
        case MSG_RESTART_INPUT:
            {
                int missingMethods = msg.arg1;
                args = (SomeArgs) msg.obj;
                try {
                    SessionState session = (SessionState) args.arg1;
                    setEnabledSessionInMainThread(session);
                    session.method.restartInput((IInputContext) args.arg2, missingMethods, (EditorInfo) args.arg3);
                } catch (RemoteException e) {
                }
                args.recycle();
                return true;
            }
        case MSG_UNBIND_CLIENT:
            try {
                ((IInputMethodClient) msg.obj).onUnbindMethod(msg.arg1, msg.arg2);
            } catch (RemoteException e) {
            // There is nothing interesting about the last client dying.
            }
            return true;
        case MSG_BIND_CLIENT:
            {
                args = (SomeArgs) msg.obj;
                IInputMethodClient client = (IInputMethodClient) args.arg1;
                InputBindResult res = (InputBindResult) args.arg2;
                try {
                    client.onBindMethod(res);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Client died receiving input method " + args.arg2);
                } finally {
                    // because the remote proxy will get its own copy when unparceled.
                    if (res.channel != null && Binder.isProxy(client)) {
                        res.channel.dispose();
                    }
                }
                args.recycle();
                return true;
            }
        case MSG_SET_ACTIVE:
            try {
                ((ClientState) msg.obj).client.setActive(msg.arg1 != 0);
            } catch (RemoteException e) {
                Slog.w(TAG, "Got RemoteException sending setActive(false) notification to pid " + ((ClientState) msg.obj).pid + " uid " + ((ClientState) msg.obj).uid);
            }
            return true;
        case MSG_SET_INTERACTIVE:
            handleSetInteractive(msg.arg1 != 0);
            return true;
        case MSG_SWITCH_IME:
            handleSwitchInputMethod(msg.arg1 != 0);
            return true;
        case MSG_SET_USER_ACTION_NOTIFICATION_SEQUENCE_NUMBER:
            {
                final int sequenceNumber = msg.arg1;
                final ClientState clientState = (ClientState) msg.obj;
                try {
                    clientState.client.setUserActionNotificationSequenceNumber(sequenceNumber);
                } catch (RemoteException e) {
                    Slog.w(TAG, "Got RemoteException sending " + "setUserActionNotificationSequenceNumber(" + sequenceNumber + ") notification to pid " + clientState.pid + " uid " + clientState.uid);
                }
                return true;
            }
        // --------------------------------------------------------------
        case MSG_HARD_KEYBOARD_SWITCH_CHANGED:
            mHardKeyboardListener.handleHardKeyboardStatusChange(msg.arg1 == 1);
            return true;
        case MSG_SYSTEM_UNLOCK_USER:
            final int userId = msg.arg1;
            onUnlockUser(userId);
            return true;
    }
    return false;
}
Also used : IInputSessionCallback(com.android.internal.view.IInputSessionCallback) InputBindResult(com.android.internal.view.InputBindResult) IInputContext(com.android.internal.view.IInputContext) IInputMethod(com.android.internal.view.IInputMethod) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethodClient(com.android.internal.view.IInputMethodClient) InputChannel(android.view.InputChannel) RemoteException(android.os.RemoteException)

Example 8 with IInputContext

use of com.android.internal.view.IInputContext in project XobotOS by xamarin.

the class InputMethodManager method startInputInner.

void startInputInner() {
    final View view;
    synchronized (mH) {
        view = mServedView;
        // Make sure we have a window token for the served view.
        if (DEBUG)
            Log.v(TAG, "Starting input: view=" + view);
        if (view == null) {
            if (DEBUG)
                Log.v(TAG, "ABORT input: no served view!");
            return;
        }
    }
    // Now we need to get an input connection from the served view.
    // This is complicated in a couple ways: we can't be holding our lock
    // when calling out to the view, and we need to make sure we call into
    // the view on the same thread that is driving its view hierarchy.
    Handler vh = view.getHandler();
    if (vh == null) {
        // from under us, so just bail.
        if (DEBUG)
            Log.v(TAG, "ABORT input: no handler for view!");
        return;
    }
    if (vh.getLooper() != Looper.myLooper()) {
        // we need to reschedule our work for over there.
        if (DEBUG)
            Log.v(TAG, "Starting input: reschedule to view thread");
        vh.post(new Runnable() {

            public void run() {
                startInputInner();
            }
        });
        return;
    }
    // Okay we are now ready to call into the served view and have it
    // do its stuff.
    // Life is good: let's hook everything up!
    EditorInfo tba = new EditorInfo();
    tba.packageName = view.getContext().getPackageName();
    tba.fieldId = view.getId();
    InputConnection ic = view.onCreateInputConnection(tba);
    if (DEBUG)
        Log.v(TAG, "Starting input: tba=" + tba + " ic=" + ic);
    synchronized (mH) {
        // changed.
        if (mServedView != view || !mServedConnecting) {
            // Something else happened, so abort.
            if (DEBUG)
                Log.v(TAG, "Starting input: finished by someone else (view=" + mServedView + " conn=" + mServedConnecting + ")");
            return;
        }
        // If we already have a text box, then this view is already
        // connected so we want to restart it.
        final boolean initial = mCurrentTextBoxAttribute == null;
        // Hook 'em up and let 'er rip.
        mCurrentTextBoxAttribute = tba;
        mServedConnecting = false;
        mServedInputConnection = ic;
        IInputContext servedContext;
        if (ic != null) {
            mCursorSelStart = 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, true);
            if (DEBUG)
                Log.v(TAG, "Starting input: Bind result=" + res);
            if (res != null) {
                if (res.id != null) {
                    mBindSequence = res.sequence;
                    mCurMethod = res.method;
                } else if (mCurMethod == null) {
                    // 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);
        }
    }
}
Also used : InputBindResult(com.android.internal.view.InputBindResult) IInputContext(com.android.internal.view.IInputContext) Handler(android.os.Handler) RemoteException(android.os.RemoteException) View(android.view.View)

Example 9 with IInputContext

use of com.android.internal.view.IInputContext in project android_frameworks_base by DirtyUnicorns.

the class IInputMethodWrapper method executeMessage.

@Override
public void executeMessage(Message msg) {
    InputMethod inputMethod = mInputMethod.get();
    // Need a valid reference to the inputMethod for everything except a dump.
    if (inputMethod == null && msg.what != DO_DUMP) {
        Log.w(TAG, "Input method reference was null, ignoring message: " + msg.what);
        return;
    }
    switch(msg.what) {
        case DO_DUMP:
            {
                AbstractInputMethodService target = mTarget.get();
                if (target == null) {
                    return;
                }
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    target.dump((FileDescriptor) args.arg1, (PrintWriter) args.arg2, (String[]) args.arg3);
                } catch (RuntimeException e) {
                    ((PrintWriter) args.arg2).println("Exception: " + e);
                }
                synchronized (args.arg4) {
                    ((CountDownLatch) args.arg4).countDown();
                }
                args.recycle();
                return;
            }
        case DO_ATTACH_TOKEN:
            {
                inputMethod.attachToken((IBinder) msg.obj);
                return;
            }
        case DO_SET_INPUT_CONTEXT:
            {
                inputMethod.bindInput((InputBinding) msg.obj);
                return;
            }
        case DO_UNSET_INPUT_CONTEXT:
            inputMethod.unbindInput();
            return;
        case DO_START_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                int missingMethods = msg.arg1;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(mTarget, inputContext, missingMethods) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.startInput(ic, info);
                args.recycle();
                return;
            }
        case DO_RESTART_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                int missingMethods = msg.arg1;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(mTarget, inputContext, missingMethods) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.restartInput(ic, info);
                args.recycle();
                return;
            }
        case DO_CREATE_SESSION:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                inputMethod.createSession(new InputMethodSessionCallbackWrapper(mContext, (InputChannel) args.arg1, (IInputSessionCallback) args.arg2));
                args.recycle();
                return;
            }
        case DO_SET_SESSION_ENABLED:
            inputMethod.setSessionEnabled((InputMethodSession) msg.obj, msg.arg1 != 0);
            return;
        case DO_REVOKE_SESSION:
            inputMethod.revokeSession((InputMethodSession) msg.obj);
            return;
        case DO_SHOW_SOFT_INPUT:
            inputMethod.showSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_HIDE_SOFT_INPUT:
            inputMethod.hideSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_CHANGE_INPUTMETHOD_SUBTYPE:
            inputMethod.changeInputMethodSubtype((InputMethodSubtype) msg.obj);
            return;
    }
    Log.w(TAG, "Unhandled message code: " + msg.what);
}
Also used : IInputContext(com.android.internal.view.IInputContext) InputConnectionWrapper(com.android.internal.view.InputConnectionWrapper) FileDescriptor(java.io.FileDescriptor) InputConnection(android.view.inputmethod.InputConnection) IBinder(android.os.IBinder) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethod(com.android.internal.view.IInputMethod) InputMethod(android.view.inputmethod.InputMethod) InputBinding(android.view.inputmethod.InputBinding) PrintWriter(java.io.PrintWriter)

Example 10 with IInputContext

use of com.android.internal.view.IInputContext in project android_frameworks_base by AOSPA.

the class IInputMethodWrapper method executeMessage.

@Override
public void executeMessage(Message msg) {
    InputMethod inputMethod = mInputMethod.get();
    // Need a valid reference to the inputMethod for everything except a dump.
    if (inputMethod == null && msg.what != DO_DUMP) {
        Log.w(TAG, "Input method reference was null, ignoring message: " + msg.what);
        return;
    }
    switch(msg.what) {
        case DO_DUMP:
            {
                AbstractInputMethodService target = mTarget.get();
                if (target == null) {
                    return;
                }
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                    target.dump((FileDescriptor) args.arg1, (PrintWriter) args.arg2, (String[]) args.arg3);
                } catch (RuntimeException e) {
                    ((PrintWriter) args.arg2).println("Exception: " + e);
                }
                synchronized (args.arg4) {
                    ((CountDownLatch) args.arg4).countDown();
                }
                args.recycle();
                return;
            }
        case DO_ATTACH_TOKEN:
            {
                inputMethod.attachToken((IBinder) msg.obj);
                return;
            }
        case DO_SET_INPUT_CONTEXT:
            {
                inputMethod.bindInput((InputBinding) msg.obj);
                return;
            }
        case DO_UNSET_INPUT_CONTEXT:
            inputMethod.unbindInput();
            return;
        case DO_START_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                int missingMethods = msg.arg1;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(mTarget, inputContext, missingMethods) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.startInput(ic, info);
                args.recycle();
                return;
            }
        case DO_RESTART_INPUT:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                int missingMethods = msg.arg1;
                IInputContext inputContext = (IInputContext) args.arg1;
                InputConnection ic = inputContext != null ? new InputConnectionWrapper(mTarget, inputContext, missingMethods) : null;
                EditorInfo info = (EditorInfo) args.arg2;
                info.makeCompatible(mTargetSdkVersion);
                inputMethod.restartInput(ic, info);
                args.recycle();
                return;
            }
        case DO_CREATE_SESSION:
            {
                SomeArgs args = (SomeArgs) msg.obj;
                inputMethod.createSession(new InputMethodSessionCallbackWrapper(mContext, (InputChannel) args.arg1, (IInputSessionCallback) args.arg2));
                args.recycle();
                return;
            }
        case DO_SET_SESSION_ENABLED:
            inputMethod.setSessionEnabled((InputMethodSession) msg.obj, msg.arg1 != 0);
            return;
        case DO_REVOKE_SESSION:
            inputMethod.revokeSession((InputMethodSession) msg.obj);
            return;
        case DO_SHOW_SOFT_INPUT:
            inputMethod.showSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_HIDE_SOFT_INPUT:
            inputMethod.hideSoftInput(msg.arg1, (ResultReceiver) msg.obj);
            return;
        case DO_CHANGE_INPUTMETHOD_SUBTYPE:
            inputMethod.changeInputMethodSubtype((InputMethodSubtype) msg.obj);
            return;
    }
    Log.w(TAG, "Unhandled message code: " + msg.what);
}
Also used : IInputContext(com.android.internal.view.IInputContext) InputConnectionWrapper(com.android.internal.view.InputConnectionWrapper) FileDescriptor(java.io.FileDescriptor) InputConnection(android.view.inputmethod.InputConnection) IBinder(android.os.IBinder) EditorInfo(android.view.inputmethod.EditorInfo) SomeArgs(com.android.internal.os.SomeArgs) IInputMethod(com.android.internal.view.IInputMethod) InputMethod(android.view.inputmethod.InputMethod) InputBinding(android.view.inputmethod.InputBinding) PrintWriter(java.io.PrintWriter)

Aggregations

IInputContext (com.android.internal.view.IInputContext)13 EditorInfo (android.view.inputmethod.EditorInfo)12 IInputMethod (com.android.internal.view.IInputMethod)12 SomeArgs (com.android.internal.os.SomeArgs)11 IBinder (android.os.IBinder)7 InputBinding (android.view.inputmethod.InputBinding)7 InputConnection (android.view.inputmethod.InputConnection)7 InputMethod (android.view.inputmethod.InputMethod)7 InputConnectionWrapper (com.android.internal.view.InputConnectionWrapper)7 FileDescriptor (java.io.FileDescriptor)7 PrintWriter (java.io.PrintWriter)7 RemoteException (android.os.RemoteException)6 InputBindResult (com.android.internal.view.InputBindResult)6 InputChannel (android.view.InputChannel)5 IInputMethodClient (com.android.internal.view.IInputMethodClient)5 IInputSessionCallback (com.android.internal.view.IInputSessionCallback)5 Handler (android.os.Handler)1 View (android.view.View)1 HandlerCaller (com.android.internal.os.HandlerCaller)1