Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90120a8b authored by lumark's avatar lumark
Browse files

Support IME Window to show in secondary display.

1) Moving WMS.setInputMethodWindowLocked to DisplayContent,
   each display can have its own IME window.
2) Add getDisplayIdFromWindow in WindowManagerInternal,
   used for InputMethodManagerService to know which display
   for given IME window token.
3) Support add / remove IME window according displayId.
4) Modify WMS.inputMethodClientHasFocus to traverse all active display
   if inputMethodClient focused.
5) Add displayId parameter for IInputMethod.initializeInternal to
   update context display then client can addView to right display.

Note: 1) There should be zero behavior difference as long as the target
         app is running on the default display.
      2) The current implementation is not final and there are still
         chances that the current IME may not work well or even crash
	 depending on how the IME is implemented.

Bug: 111364446
Test: manual, use ActivityView & launch Messages in VirtualDisplay,
      tap search icon to see if soft input keyboard shown &
      app window size is adjusted by soft input.
Change-Id: I8da315936caebdc8b2c16cff4e24192c06743251
parent b1e6e256
Loading
Loading
Loading
Loading
+0 −3
Original line number Original line Diff line number Diff line
@@ -24288,7 +24288,6 @@ HSPLandroid/inputmethodservice/AbstractInputMethodService;->onCreateInputMethodS
HSPLandroid/inputmethodservice/IInputMethodSessionWrapper;->getInternalInputMethodSession()Landroid/view/inputmethod/InputMethodSession;
HSPLandroid/inputmethodservice/IInputMethodSessionWrapper;->getInternalInputMethodSession()Landroid/view/inputmethod/InputMethodSession;
HSPLandroid/inputmethodservice/IInputMethodWrapper$InputMethodSessionCallbackWrapper;->sessionCreated(Landroid/view/inputmethod/InputMethodSession;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper$InputMethodSessionCallbackWrapper;->sessionCreated(Landroid/view/inputmethod/InputMethodSession;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;-><init>(Landroid/inputmethodservice/AbstractInputMethodService;Landroid/view/inputmethod/InputMethod;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;-><init>(Landroid/inputmethodservice/AbstractInputMethodService;Landroid/view/inputmethod/InputMethod;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->attachToken(Landroid/os/IBinder;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->bindInput(Landroid/view/inputmethod/InputBinding;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->bindInput(Landroid/view/inputmethod/InputBinding;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->createSession(Landroid/view/InputChannel;Lcom/android/internal/view/IInputSessionCallback;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->createSession(Landroid/view/InputChannel;Lcom/android/internal/view/IInputSessionCallback;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->executeMessage(Landroid/os/Message;)V
HSPLandroid/inputmethodservice/IInputMethodWrapper;->executeMessage(Landroid/os/Message;)V
@@ -42280,11 +42279,9 @@ HSPLcom/android/internal/view/IInputContextCallback;->setSelectedText(Ljava/lang
HSPLcom/android/internal/view/IInputContextCallback;->setTextAfterCursor(Ljava/lang/CharSequence;I)V
HSPLcom/android/internal/view/IInputContextCallback;->setTextAfterCursor(Ljava/lang/CharSequence;I)V
HSPLcom/android/internal/view/IInputContextCallback;->setTextBeforeCursor(Ljava/lang/CharSequence;I)V
HSPLcom/android/internal/view/IInputContextCallback;->setTextBeforeCursor(Ljava/lang/CharSequence;I)V
HSPLcom/android/internal/view/IInputMethod$Stub$Proxy;->asBinder()Landroid/os/IBinder;
HSPLcom/android/internal/view/IInputMethod$Stub$Proxy;->asBinder()Landroid/os/IBinder;
HSPLcom/android/internal/view/IInputMethod$Stub$Proxy;->attachToken(Landroid/os/IBinder;)V
HSPLcom/android/internal/view/IInputMethod$Stub;-><init>()V
HSPLcom/android/internal/view/IInputMethod$Stub;-><init>()V
HSPLcom/android/internal/view/IInputMethod$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/view/IInputMethod;
HSPLcom/android/internal/view/IInputMethod$Stub;->asInterface(Landroid/os/IBinder;)Lcom/android/internal/view/IInputMethod;
HSPLcom/android/internal/view/IInputMethod$Stub;->onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z
HSPLcom/android/internal/view/IInputMethod$Stub;->onTransact(ILandroid/os/Parcel;Landroid/os/Parcel;I)Z
HSPLcom/android/internal/view/IInputMethod;->attachToken(Landroid/os/IBinder;)V
HSPLcom/android/internal/view/IInputMethod;->bindInput(Landroid/view/inputmethod/InputBinding;)V
HSPLcom/android/internal/view/IInputMethod;->bindInput(Landroid/view/inputmethod/InputBinding;)V
HSPLcom/android/internal/view/IInputMethod;->changeInputMethodSubtype(Landroid/view/inputmethod/InputMethodSubtype;)V
HSPLcom/android/internal/view/IInputMethod;->changeInputMethodSubtype(Landroid/view/inputmethod/InputMethodSubtype;)V
HSPLcom/android/internal/view/IInputMethod;->createSession(Landroid/view/InputChannel;Lcom/android/internal/view/IInputSessionCallback;)V
HSPLcom/android/internal/view/IInputMethod;->createSession(Landroid/view/InputChannel;Lcom/android/internal/view/IInputSessionCallback;)V
+4 −4
Original line number Original line Diff line number Diff line
@@ -160,11 +160,10 @@ class IInputMethodWrapper extends IInputMethod.Stub
                args.recycle();
                args.recycle();
                return;
                return;
            }
            }

            case DO_INITIALIZE_INTERNAL: {
            case DO_INITIALIZE_INTERNAL: {
                SomeArgs args = (SomeArgs) msg.obj;
                SomeArgs args = (SomeArgs) msg.obj;
                try {
                try {
                    inputMethod.initializeInternal((IBinder) args.arg1,
                    inputMethod.initializeInternal((IBinder) args.arg1, msg.arg1,
                            (IInputMethodPrivilegedOperations) args.arg2);
                            (IInputMethodPrivilegedOperations) args.arg2);
                } finally {
                } finally {
                    args.recycle();
                    args.recycle();
@@ -253,9 +252,10 @@ class IInputMethodWrapper extends IInputMethod.Stub


    @BinderThread
    @BinderThread
    @Override
    @Override
    public void initializeInternal(IBinder token, IInputMethodPrivilegedOperations privOps) {
    public void initializeInternal(IBinder token, int displayId,
            IInputMethodPrivilegedOperations privOps) {
        mCaller.executeOrSendMessage(
        mCaller.executeOrSendMessage(
                mCaller.obtainMessageOO(DO_INITIALIZE_INTERNAL, token, privOps));
                mCaller.obtainMessageIOO(DO_INITIALIZE_INTERNAL, displayId, token, privOps));
    }
    }


    @BinderThread
    @BinderThread
+22 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package android.inputmethodservice;
package android.inputmethodservice;


import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
@@ -461,10 +462,11 @@ public class InputMethodService extends AbstractInputMethodService {
         */
         */
        @MainThread
        @MainThread
        @Override
        @Override
        public final void initializeInternal(IBinder token,
        public final void initializeInternal(IBinder token, int displayId,
                IInputMethodPrivilegedOperations privilegedOperations) {
                IInputMethodPrivilegedOperations privilegedOperations) {
            mPrivOps.set(privilegedOperations);
            mPrivOps.set(privilegedOperations);
            mImm.registerInputMethodPrivOps(token, mPrivOps);
            mImm.registerInputMethodPrivOps(token, mPrivOps);
            updateInputMethodDisplay(displayId);
            attachToken(token);
            attachToken(token);
        }
        }


@@ -482,6 +484,22 @@ public class InputMethodService extends AbstractInputMethodService {
            mWindow.setToken(token);
            mWindow.setToken(token);
        }
        }


        /**
         * {@inheritDoc}
         * @hide
         */
        @MainThread
        @Override
        public void updateInputMethodDisplay(int displayId) {
            // Update display for adding IME window to the right display.
            if (displayId != DEFAULT_DISPLAY) {
                // TODO(b/111364446) Need to address context lifecycle issue if need to re-create
                // for update resources & configuration correctly when show soft input
                // in non-default display.
                updateDisplay(displayId);
            }
        }

        /**
        /**
         * {@inheritDoc}
         * {@inheritDoc}
         *
         *
@@ -930,6 +948,9 @@ public class InputMethodService extends AbstractInputMethodService {
        // If the previous IME has occupied non-empty inset in the screen, we need to decide whether
        // If the previous IME has occupied non-empty inset in the screen, we need to decide whether
        // we continue to use the same size of the inset or update it
        // we continue to use the same size of the inset or update it
        mShouldClearInsetOfPreviousIme = (mImm.getInputMethodWindowVisibleHeight() > 0);
        mShouldClearInsetOfPreviousIme = (mImm.getInputMethodWindowVisibleHeight() > 0);
        // TODO(b/111364446) Need to address context lifecycle issue if need to re-create
        // for update resources & configuration correctly when show soft input
        // in non-default display.
        mInflater = (LayoutInflater)getSystemService(
        mInflater = (LayoutInflater)getSystemService(
                Context.LAYOUT_INFLATER_SERVICE);
                Context.LAYOUT_INFLATER_SERVICE);
        mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState,
        mWindow = new SoftInputWindow(this, "InputMethod", mTheme, null, null, mDispatcherState,
+13 −1
Original line number Original line Diff line number Diff line
@@ -89,14 +89,17 @@ public interface InputMethod {
     *
     *
     * @param token special token for the system to identify
     * @param token special token for the system to identify
     *              {@link InputMethodService}
     *              {@link InputMethodService}
     * @param displayId The id of the display that current IME shown.
     *                  Used for {{@link #updateInputMethodDisplay(int)}}
     * @param privilegedOperations IPC endpoint to do some privileged
     * @param privilegedOperations IPC endpoint to do some privileged
     *                             operations that are allowed only to the
     *                             operations that are allowed only to the
     *                             current IME.
     *                             current IME.
     * @hide
     * @hide
     */
     */
    @MainThread
    @MainThread
    default void initializeInternal(IBinder token,
    default void initializeInternal(IBinder token, int displayId,
            IInputMethodPrivilegedOperations privilegedOperations) {
            IInputMethodPrivilegedOperations privilegedOperations) {
        updateInputMethodDisplay(displayId);
        attachToken(token);
        attachToken(token);
    }
    }


@@ -114,6 +117,15 @@ public interface InputMethod {
    @MainThread
    @MainThread
    public void attachToken(IBinder token);
    public void attachToken(IBinder token);


    /**
     * Update context display according to given displayId.
     *
     * @param displayId The id of the display that need to update for context.
     * @hide
     */
    @MainThread
    public void updateInputMethodDisplay(int displayId);

    /**
    /**
     * Bind a new application environment in to the input method, so that it
     * Bind a new application environment in to the input method, so that it
     * can later start and stop input processing.
     * can later start and stop input processing.
+1 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@ import com.android.internal.view.IInputSessionCallback;
 * {@hide}
 * {@hide}
 */
 */
oneway interface IInputMethod {
oneway interface IInputMethod {
    void initializeInternal(IBinder token, IInputMethodPrivilegedOperations privOps);
    void initializeInternal(IBinder token, int displayId, IInputMethodPrivilegedOperations privOps);


    void bindInput(in InputBinding binding);
    void bindInput(in InputBinding binding);


Loading