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

Commit 73f9f9bf authored by Tarandeep Singh's avatar Tarandeep Singh Committed by Android (Google) Code Review
Browse files

Merge changes Ib3997487,Ifed8351b

* changes:
  Link InsetsController to IME (IME transitons 4/n)
  Send IME control to client
parents d58aa257 46d59f0e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
    private static final int DO_TOGGLE_SOFT_INPUT = 105;
    private static final int DO_FINISH_SESSION = 110;
    private static final int DO_VIEW_CLICKED = 115;
    private static final int DO_NOTIFY_IME_HIDDEN = 120;

    HandlerCaller mCaller;
    InputMethodSession mInputMethodSession;
@@ -129,6 +130,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                mInputMethodSession.viewClicked(msg.arg1 == 1);
                return;
            }
            case DO_NOTIFY_IME_HIDDEN: {
                mInputMethodSession.notifyImeHidden();
                return;
            }
        }
        Log.w(TAG, "Unhandled message code: " + msg.what);
    }
@@ -171,6 +176,11 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
                mCaller.obtainMessageI(DO_VIEW_CLICKED, focusChanged ? 1 : 0));
    }

    @Override
    public void notifyImeHidden() {
        mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_NOTIFY_IME_HIDDEN));
    }

    @Override
    public void updateCursor(Rect newCursor) {
        mCaller.executeOrSendMessage(
+13 −1
Original line number Diff line number Diff line
@@ -592,7 +592,6 @@ public class InputMethodService extends AbstractInputMethodService {
            final boolean wasVisible = mIsPreRendered
                    ? mDecorViewVisible && mWindowVisible : isInputViewShown();
            if (mIsPreRendered) {
                // TODO: notify visibility to insets consumer.
                if (DEBUG) {
                    Log.v(TAG, "Making IME window invisible");
                }
@@ -658,6 +657,11 @@ public class InputMethodService extends AbstractInputMethodService {
        }
    }

    private void notifyImeHidden() {
        setImeWindowStatus(IME_ACTIVE | IME_INVISIBLE, mBackDisposition);
        onPreRenderedWindowVisibilityChanged(false /* setVisible */);
    }

    private void setImeWindowStatus(int visibilityFlags, int backDisposition) {
        mPrivOps.setImeWindowStatus(visibilityFlags, backDisposition);
    }
@@ -760,6 +764,14 @@ public class InputMethodService extends AbstractInputMethodService {
            }
            InputMethodService.this.onUpdateCursorAnchorInfo(info);
        }

        /**
         * Notify IME that window is hidden.
         * @hide
         */
        public final void notifyImeHidden() {
            InputMethodService.this.notifyImeHidden();
        }
    }
    
    /**
+6 −0
Original line number Diff line number Diff line
@@ -290,6 +290,12 @@ final class MultiClientInputMethodClientCallbackAdaptor {
                        CallbackImpl::updateCursorAnchorInfo, mCallbackImpl, info));
            }
        }

        @Override
        public final void notifyImeHidden() {
            // no-op for multi-session since IME is responsible controlling navigation bar buttons.
            reportNotSupported();
        }
    }

    private static final class MultiClientInputMethodSessionImpl
+26 −6
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@ package android.view;

import static android.view.InsetsState.TYPE_IME;

import android.inputmethodservice.InputMethodService;
import android.os.Parcel;
import android.text.TextUtils;
import android.view.SurfaceControl.Transaction;
import android.view.WindowInsets.Type;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;

@@ -73,11 +73,7 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
            return;
        }

        if (setVisible) {
            mController.show(Type.IME);
        } else {
            mController.hide(Type.IME);
        }
        mController.applyImeVisibility(setVisible);
    }

    @Override
@@ -91,6 +87,30 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer {
        mHasWindowFocus = false;
    }

    /**
     * Request {@link InputMethodManager} to show the IME.
     * @return @see {@link android.view.InsetsSourceConsumer.ShowResult}.
     */
    @Override
    @ShowResult int requestShow(boolean fromIme) {
        // TODO: ResultReceiver for IME.
        // TODO: Set mShowOnNextImeRender to automatically show IME and guard it with a flag.
        if (fromIme) {
            return ShowResult.SHOW_IMMEDIATELY;
        }

        return getImm().requestImeShow(null /* resultReceiver */)
                ? ShowResult.SHOW_DELAYED : ShowResult.SHOW_FAILED;
    }

    /**
     * Notify {@link InputMethodService} that IME window is hidden.
     */
    @Override
    void notifyHidden() {
        getImm().notifyImeHidden();
    }

    private boolean isDummyOrEmptyEditor(EditorInfo info) {
        // TODO(b/123044812): Handle dummy input gracefully in IME Insets API
        return info == null || (info.fieldId <= 0 && info.inputType <= 0);
+2 −1
Original line number Diff line number Diff line
@@ -180,9 +180,10 @@ public class InsetsAnimationControlImpl implements WindowInsetsAnimationControll
        for (int i = items.size() - 1; i >= 0; i--) {
            final InsetsSourceConsumer consumer = items.valueAt(i);
            final InsetsSource source = mInitialInsetsState.getSource(consumer.getType());
            final InsetsSourceControl control = consumer.getControl();
            final SurfaceControl leash = consumer.getControl().getLeash();
            mTmpMatrix.setTranslate(source.getFrame().left, source.getFrame().top);

            mTmpMatrix.setTranslate(control.getSurfacePosition().x, control.getSurfacePosition().y);
            mTmpFrame.set(source.getFrame());
            addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame);

Loading