diff options
| author | Adrian Roos <roosa@google.com> | 2022-01-31 18:18:09 +0100 |
|---|---|---|
| committer | Adrian Roos <roosa@google.com> | 2022-02-03 14:08:56 +0000 |
| commit | 92fbace14b87538b1da8b9f7496ab3584b59938a (patch) | |
| tree | 59f6d36981b0448fb0ab57478d09785249c897b9 /core/java/android/inputmethodservice/InputMethodService.java | |
| parent | 9aac3354b2fa6c0205f5802bdcfdbaa22ed9739a (diff) | |
Fix IMS window visibility
Fixes an issue with IMS window visibility, where an unfortunate timing
of removeImeSurface() and showWindow() could result in the window being
hidden without resetting mDecorViewVisible.
Root cause is the scheduled removeImeSurface() not being cancelled in
all code paths that end up calling showWindow().
To avoid this we
- consolidate calls to cancelImeSurfaceRemoval
and applyVisibilityInInsetsConsumerIfNecessary into showWindow()
- inline the now unnecessary doHideWindow
- unconditionally call mWindow.show() in showWindow, since View.java
already avoids unnecessary work if the decor visibility won't change
Fixes: 203137087
Test: manual
Change-Id: Iaef9efd4f1a89fe6da27fc6396b62ff3b4ca11f4
Diffstat (limited to 'core/java/android/inputmethodservice/InputMethodService.java')
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 223b8ccf44c8..60ff6afc3cae 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -839,10 +839,9 @@ public class InputMethodService extends AbstractInputMethodService { final boolean wasVisible = isInputViewShown(); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "IMS.hideSoftInput"); - applyVisibilityInInsetsConsumerIfNecessary(false /* setVisible */); mShowInputFlags = 0; mShowInputRequested = false; - doHideWindow(); + hideWindow(); final boolean isVisible = isInputViewShown(); final boolean visibilityChanged = isVisible != wasVisible; if (resultReceiver != null) { @@ -891,7 +890,6 @@ public class InputMethodService extends AbstractInputMethodService { final boolean wasVisible = isInputViewShown(); if (dispatchOnShowInputRequested(flags, false)) { showWindow(true); - applyVisibilityInInsetsConsumerIfNecessary(true /* setVisible */); } setImeWindowStatus(mapToImeWindowStatus(), mBackDisposition); @@ -1666,7 +1664,7 @@ public class InputMethodService extends AbstractInputMethodService { onDisplayCompletions(completions); } } else { - doHideWindow(); + hideWindow(); } } else if (mCandidatesVisibility == View.VISIBLE) { // If the candidates are currently visible, make sure the @@ -1674,7 +1672,7 @@ public class InputMethodService extends AbstractInputMethodService { showWindow(false); } else { // Otherwise hide the window. - doHideWindow(); + hideWindow(); } // If user uses hard keyboard, IME button should always be shown. boolean showing = onEvaluateInputViewShown(); @@ -2119,7 +2117,7 @@ public class InputMethodService extends AbstractInputMethodService { if (shown) { showWindow(false); } else { - doHideWindow(); + hideWindow(); } } } @@ -2540,12 +2538,11 @@ public class InputMethodService extends AbstractInputMethodService { mWindowVisible = true; // request draw for the IME surface. - // When IME is not pre-rendered, this will actually show the IME. - if ((previousImeWindowStatus & IME_ACTIVE) == 0) { - if (DEBUG) Log.v(TAG, "showWindow: draw decorView!"); - mWindow.show(); - } + if (DEBUG) Log.v(TAG, "showWindow: draw decorView!"); + mWindow.show(); mDecorViewWasVisible = true; + applyVisibilityInInsetsConsumerIfNecessary(true); + cancelImeSurfaceRemoval(); mInShowWindow = false; Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } @@ -2602,9 +2599,6 @@ public class InputMethodService extends AbstractInputMethodService { ImeTracing.getInstance().triggerServiceDump( "InputMethodService#applyVisibilityInInsetsConsumerIfNecessary", mDumper, null /* icProto */); - if (setVisible) { - cancelImeSurfaceRemoval(); - } mPrivOps.applyImeVisibilityAsync(setVisible ? mCurShowInputToken : mCurHideInputToken, setVisible); } @@ -2622,15 +2616,12 @@ public class InputMethodService extends AbstractInputMethodService { mCandidatesViewStarted = false; } - private void doHideWindow() { - setImeWindowStatus(0, mBackDisposition); - hideWindow(); - } - public void hideWindow() { if (DEBUG) Log.v(TAG, "CALL: hideWindow"); ImeTracing.getInstance().triggerServiceDump("InputMethodService#hideWindow", mDumper, null /* icProto */); + setImeWindowStatus(0, mBackDisposition); + applyVisibilityInInsetsConsumerIfNecessary(false); mWindowVisible = false; finishViews(false /* finishingInput */); if (mDecorViewVisible) { @@ -2916,7 +2907,7 @@ public class InputMethodService extends AbstractInputMethodService { // If we have the window visible for some other reason -- // most likely to show candidates -- then just get rid // of it. This really shouldn't happen, but just in case... - if (doIt) doHideWindow(); + if (doIt) hideWindow(); } return true; } |
