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

Commit 01490688 authored by Cosmin Băieș's avatar Cosmin Băieș Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE in IMM setInteractive" into main

parents db19ba5c cf741ea8
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -1176,24 +1176,33 @@ public final class InputMethodManager {
                        mActive = interactive;
                        mFullscreenMode = fullscreen;
                        if (interactive) {
                            // Find the next view focus to start the input connection when the
                            // device was interactive.
                            final View rootView =
                                    mCurRootView != null ? mCurRootView.getView() : null;
                            if (rootView == null) {
                                // No window focused or view was removed, ignore request.
                                return;
                            }
                            // Find the next view focus to start the input connection when the
                            // device was interactive.
                            final ViewRootImpl currentViewRootImpl = mCurRootView;
                            // Post this on UI thread as required for view focus code.
                            rootView.post(() -> {
                                synchronized (mH) {
                                    if (mCurRootView != currentViewRootImpl) {
                                        // Focused window changed since posting, ignore request.
                                        return;
                                    }
                                }
                                final View focusedView = currentViewRootImpl.getView().findFocus();
                                final View curRootView = currentViewRootImpl.getView();
                                if (curRootView == null) {
                                    // View was removed, ignore request.
                                    return;
                                }
                                final View focusedView = curRootView.findFocus();
                                onViewFocusChangedInternal(focusedView, focusedView != null);
                            });
                        } else {
                            // Finish input connection when device becomes non-interactive.
                            finishInputLocked();
                            if (isImeSessionAvailableLocked()) {
                                mCurBindState.mImeSession.finishInput();