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

Commit b4778452 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Simplify FINISH_INPUT_NO_FALLBACK_CONNECTION handling"

parents 2e1bc7ca 3ca95072
Loading
Loading
Loading
Loading
+31 −13
Original line number Diff line number Diff line
@@ -650,6 +650,7 @@ public final class InputMethodManager {
    private static final int MSG_REPORT_FULLSCREEN_MODE = 10;
    private static final int MSG_BIND_ACCESSIBILITY_SERVICE = 11;
    private static final int MSG_UNBIND_ACCESSIBILITY_SERVICE = 12;
    private static final int MSG_SET_INTERACTIVE = 13;
    private static final int MSG_UPDATE_VIRTUAL_DISPLAY_TO_SCREEN_MATRIX = 30;
    private static final int MSG_ON_SHOW_REQUESTED = 31;

@@ -1161,7 +1162,6 @@ public final class InputMethodManager {
                case MSG_SET_ACTIVE: {
                    final boolean active = msg.arg1 != 0;
                    final boolean fullscreen = msg.arg2 != 0;
                    final boolean reportToImeController = msg.obj != null && (boolean) msg.obj;
                    if (DEBUG) {
                        Log.i(TAG, "handleMessage: MSG_SET_ACTIVE " + active + ", was " + mActive);
                    }
@@ -1169,15 +1169,6 @@ public final class InputMethodManager {
                        mActive = active;
                        mFullscreenMode = fullscreen;

                        // Report active state to ImeFocusController to handle IME input
                        // connection lifecycle callback when it allowed.
                        final ImeFocusController controller = getFocusController();
                        final View rootView = mCurRootView != null ? mCurRootView.getView() : null;
                        if (controller != null && rootView != null && reportToImeController) {
                            rootView.post(() -> controller.onInteractiveChanged(active));
                            return;
                        }

                        if (!active) {
                            // Some other client has starting using the IME, so note
                            // that this happened and make sure our own editor's
@@ -1201,6 +1192,28 @@ public final class InputMethodManager {
                    }
                    return;
                }
                case MSG_SET_INTERACTIVE: {
                    final boolean interactive = msg.arg1 != 0;
                    final boolean fullscreen = msg.arg2 != 0;
                    if (DEBUG) {
                        Log.i(TAG, "handleMessage: MSG_SET_INTERACTIVE " + interactive
                                + ", was " + mActive);
                    }
                    synchronized (mH) {
                        mActive = interactive;
                        mFullscreenMode = fullscreen;

                        // Report active state to ImeFocusController to handle IME input
                        // connection lifecycle callback when it allowed.
                        final ImeFocusController controller = getFocusController();
                        final View rootView = mCurRootView != null ? mCurRootView.getView() : null;
                        if (controller == null || rootView == null) {
                            return;
                        }
                        rootView.post(() -> controller.onInteractiveChanged(interactive));
                    }
                    return;
                }
                case MSG_SEND_INPUT_EVENT: {
                    sendInputEventAndReportResultOnMainLooper((PendingEvent)msg.obj);
                    return;
@@ -1318,9 +1331,14 @@ public final class InputMethodManager {
        }

        @Override
        public void setActive(boolean active, boolean fullscreen, boolean reportToImeController) {
            mH.obtainMessage(MSG_SET_ACTIVE, active ? 1 : 0, fullscreen ? 1 : 0,
                    reportToImeController).sendToTarget();
        public void setActive(boolean active, boolean fullscreen) {
            mH.obtainMessage(MSG_SET_ACTIVE, active ? 1 : 0, fullscreen ? 1 : 0).sendToTarget();
        }

        @Override
        public void setInteractive(boolean interactive, boolean fullscreen) {
            mH.obtainMessage(MSG_SET_INTERACTIVE, interactive ? 1 : 0, fullscreen ? 1 : 0)
                    .sendToTarget();
        }

        @Override
+2 −1
Original line number Diff line number Diff line
@@ -27,7 +27,8 @@ oneway interface IInputMethodClient {
    void onBindAccessibilityService(in InputBindResult res, int id);
    void onUnbindMethod(int sequence, int unbindReason);
    void onUnbindAccessibilityService(int sequence, int id);
    void setActive(boolean active, boolean fullscreen, boolean reportToImeController);
    void setActive(boolean active, boolean fullscreen);
    void setInteractive(boolean active, boolean fullscreen);
    void scheduleStartInputIfNecessary(boolean fullscreen);
    void reportFullscreenMode(boolean fullscreen);
    void updateVirtualDisplayToScreenMatrix(int bindSequence, in float[] matrixValues);
+23 −6
Original line number Diff line number Diff line
@@ -177,19 +177,36 @@ final class IInputMethodClientInvoker {
    }

    @AnyThread
    void setActive(boolean active, boolean fullscreen, boolean reportToImeController) {
    void setActive(boolean active, boolean fullscreen) {
        if (mIsProxy) {
            setActiveInternal(active, fullscreen, reportToImeController);
            setActiveInternal(active, fullscreen);
        } else {
            mHandler.post(() -> setActiveInternal(active, fullscreen, reportToImeController));
            mHandler.post(() -> setActiveInternal(active, fullscreen));
        }
    }

    @AnyThread
    private void setActiveInternal(boolean active, boolean fullscreen,
            boolean reportToImeController) {
    private void setActiveInternal(boolean active, boolean fullscreen) {
        try {
            mTarget.setActive(active, fullscreen, reportToImeController);
            mTarget.setActive(active, fullscreen);
        } catch (RemoteException e) {
            logRemoteException(e);
        }
    }

    @AnyThread
    void setInteractive(boolean interactive, boolean fullscreen) {
        if (mIsProxy) {
            setInteractiveInternal(interactive, fullscreen);
        } else {
            mHandler.post(() -> setInteractiveInternal(interactive, fullscreen));
        }
    }

    @AnyThread
    private void setInteractiveInternal(boolean interactive, boolean fullscreen) {
        try {
            mTarget.setInteractive(interactive, fullscreen);
        } catch (RemoteException e) {
            logRemoteException(e);
        }
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ final class ImePlatformCompatUtils {
     *
     * @param imeUid The uid of the IME application
     */
    public boolean shouldFinishInputWithReportToIme(int imeUid) {
    public boolean shouldUseSetInteractiveProtocol(int imeUid) {
        return isChangeEnabledByUid(FINISH_INPUT_NO_FALLBACK_CONNECTION, imeUid);
    }

+11 −8
Original line number Diff line number Diff line
@@ -2330,8 +2330,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            // Since we set active false to current client and set mCurClient to null, let's unbind
            // all accessibility too. That means, when input method get disconnected (including
            // switching ime), we also unbind accessibility
            mCurClient.mClient.setActive(false /* active */, false /* fullscreen */,
                    false /* reportToImeController */);
            mCurClient.mClient.setActive(false /* active */, false /* fullscreen */);
            mCurClient.mClient.onUnbindMethod(getSequenceNumberLocked(), unbindClientReason);
            mCurClient.mSessionRequested = false;
            mCurClient.mSessionRequestedForAccessibility = false;
@@ -2638,8 +2637,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
        unbindCurrentClientLocked(UnbindReason.SWITCH_CLIENT);
        // If the screen is on, inform the new client it is active
        if (mIsInteractive) {
            cs.mClient.setActive(true /* active */, false /* fullscreen */,
                    false /* reportToImeController */);
            cs.mClient.setActive(true /* active */, false /* fullscreen */);
        }
    }

@@ -5016,10 +5014,15 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
            updateSystemUiLocked(interactive ? mImeWindowVis : 0, mBackDisposition);

            // Inform the current client of the change in active status
            if (mCurClient != null && mCurClient.mClient != null) {
                mCurClient.mClient.setActive(mIsInteractive, mInFullscreenMode,
                        mImePlatformCompatUtils.shouldFinishInputWithReportToIme(
                                getCurMethodUidLocked()));
            if (mCurClient == null || mCurClient.mClient == null) {
                return;
            }
            if (mImePlatformCompatUtils.shouldUseSetInteractiveProtocol(getCurMethodUidLocked())) {
                // Eligible IME processes use new "setInteractive" protocol.
                mCurClient.mClient.setInteractive(mIsInteractive, mInFullscreenMode);
            } else {
                // Legacy IME processes continue using legacy "setActive" protocol.
                mCurClient.mClient.setActive(mIsInteractive, mInFullscreenMode);
            }
        }
    }