Loading core/java/android/view/inputmethod/InputMethodManager.java +35 −78 Original line number Diff line number Diff line Loading @@ -93,12 +93,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; Loading Loading @@ -414,16 +409,6 @@ public final class InputMethodManager { int mCursorCandStart; int mCursorCandEnd; /** * Initial startInput with {@link StartInputReason.WINDOW_FOCUS_GAIN} is executed * in a background thread. Later, if there is an actual startInput it will wait on * main thread till the background thread completes. */ private Future<?> mWindowFocusGainFuture; private ExecutorService mStartInputWorker = Executors.newSingleThreadExecutor( new ImeThreadFactory("StartInputWorker")); /** * The instance that has previously been sent to the input method. */ Loading Loading @@ -612,10 +597,6 @@ public final class InputMethodManager { final boolean forceNewFocus1 = forceNewFocus; final int startInputFlags = getStartInputFlags(focusedView, 0); if (mWindowFocusGainFuture != null) { mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */); } mWindowFocusGainFuture = mStartInputWorker.submit(() -> { final ImeFocusController controller = getFocusController(); if (controller == null) { return; Loading Loading @@ -646,7 +627,6 @@ public final class InputMethodManager { throw e.rethrowFromSystemServer(); } } }); } /** Loading @@ -664,10 +644,6 @@ public final class InputMethodManager { */ @Override public void setCurrentRootView(ViewRootImpl rootView) { if (mWindowFocusGainFuture != null) { mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */); mWindowFocusGainFuture = null; } synchronized (mH) { if (mCurRootView != null) { // Reset the last served view and restart window focus state of the root view. Loading Loading @@ -845,13 +821,9 @@ public final class InputMethodManager { } catch (RemoteException e) { } } } // Check focus again in case that "onWindowFocus" is called before // handling this message. final View servedView; synchronized (mH) { servedView = getServedViewLocked(); } final View servedView = getServedViewLocked(); if (servedView != null && canStartInput(servedView)) { if (mCurRootView != null && mCurRootView.getImeFocusController() .checkFocus(mRestartOnNextWindowFocus, false)) { Loading @@ -860,6 +832,7 @@ public final class InputMethodManager { mDelegate.startInput(reason, null, 0, 0, 0); } } } return; } case MSG_SEND_INPUT_EVENT: { Loading Loading @@ -1430,10 +1403,6 @@ public final class InputMethodManager { */ void clearBindingLocked() { if (DEBUG) Log.v(TAG, "Clearing binding!"); if (mWindowFocusGainFuture != null) { mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */); mWindowFocusGainFuture = null; } clearConnectionLocked(); setInputChannelLocked(null); mBindSequence = -1; Loading Loading @@ -1826,18 +1795,6 @@ public final class InputMethodManager { boolean startInputInner(@StartInputReason int startInputReason, @Nullable IBinder windowGainingFocus, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags) { if (startInputReason != StartInputReason.WINDOW_FOCUS_GAIN && mWindowFocusGainFuture != null) { try { mWindowFocusGainFuture.get(); } catch (ExecutionException | InterruptedException e) { // do nothing } catch (CancellationException e) { // window no longer has focus. return true; } } final View view; synchronized (mH) { view = getServedViewLocked(); Loading Loading
core/java/android/view/inputmethod/InputMethodManager.java +35 −78 Original line number Diff line number Diff line Loading @@ -93,12 +93,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.concurrent.CancellationException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; Loading Loading @@ -414,16 +409,6 @@ public final class InputMethodManager { int mCursorCandStart; int mCursorCandEnd; /** * Initial startInput with {@link StartInputReason.WINDOW_FOCUS_GAIN} is executed * in a background thread. Later, if there is an actual startInput it will wait on * main thread till the background thread completes. */ private Future<?> mWindowFocusGainFuture; private ExecutorService mStartInputWorker = Executors.newSingleThreadExecutor( new ImeThreadFactory("StartInputWorker")); /** * The instance that has previously been sent to the input method. */ Loading Loading @@ -612,10 +597,6 @@ public final class InputMethodManager { final boolean forceNewFocus1 = forceNewFocus; final int startInputFlags = getStartInputFlags(focusedView, 0); if (mWindowFocusGainFuture != null) { mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */); } mWindowFocusGainFuture = mStartInputWorker.submit(() -> { final ImeFocusController controller = getFocusController(); if (controller == null) { return; Loading Loading @@ -646,7 +627,6 @@ public final class InputMethodManager { throw e.rethrowFromSystemServer(); } } }); } /** Loading @@ -664,10 +644,6 @@ public final class InputMethodManager { */ @Override public void setCurrentRootView(ViewRootImpl rootView) { if (mWindowFocusGainFuture != null) { mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */); mWindowFocusGainFuture = null; } synchronized (mH) { if (mCurRootView != null) { // Reset the last served view and restart window focus state of the root view. Loading Loading @@ -845,13 +821,9 @@ public final class InputMethodManager { } catch (RemoteException e) { } } } // Check focus again in case that "onWindowFocus" is called before // handling this message. final View servedView; synchronized (mH) { servedView = getServedViewLocked(); } final View servedView = getServedViewLocked(); if (servedView != null && canStartInput(servedView)) { if (mCurRootView != null && mCurRootView.getImeFocusController() .checkFocus(mRestartOnNextWindowFocus, false)) { Loading @@ -860,6 +832,7 @@ public final class InputMethodManager { mDelegate.startInput(reason, null, 0, 0, 0); } } } return; } case MSG_SEND_INPUT_EVENT: { Loading Loading @@ -1430,10 +1403,6 @@ public final class InputMethodManager { */ void clearBindingLocked() { if (DEBUG) Log.v(TAG, "Clearing binding!"); if (mWindowFocusGainFuture != null) { mWindowFocusGainFuture.cancel(false /* mayInterruptIfRunning */); mWindowFocusGainFuture = null; } clearConnectionLocked(); setInputChannelLocked(null); mBindSequence = -1; Loading Loading @@ -1826,18 +1795,6 @@ public final class InputMethodManager { boolean startInputInner(@StartInputReason int startInputReason, @Nullable IBinder windowGainingFocus, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags) { if (startInputReason != StartInputReason.WINDOW_FOCUS_GAIN && mWindowFocusGainFuture != null) { try { mWindowFocusGainFuture.get(); } catch (ExecutionException | InterruptedException e) { // do nothing } catch (CancellationException e) { // window no longer has focus. return true; } } final View view; synchronized (mH) { view = getServedViewLocked(); Loading