From d4d895e2f8a9493bc0c5831f453866eb861d5404 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 24 Sep 2018 16:01:20 -0700 Subject: Remove a special optimization for a quite rare scenario This CL effectively reverts the following 3 CLs. * Reduce window resizing during IME transition I5723f627ce323b0d12bd7b93f5b35fc4d342b50c 792faa2c16d319e874a1d633f964a78266d5f3f2 * Clear the inset of previous IME when necessary Ib04967f39b2529251e4835c42e9f99dba2cf43f2 2977eb7b6ce82309a1bb1ba4ab698f503cb0388a * Make IMS#clearInsetOfPreviousIme() reliable Ib567daa009c1139858dccadcfc6a04465ebecf36 833bdcedceee60a873694a77587393abfc830eb5 The main idea behind the first CL is that the target application can skil avoid layout resizing if the following two conditions are met. A. WindowManagerService (WMS) can remember the last IME's inset until the next IME's window is fully shown. B. Both the last IME and the new IME have the same inset. Basically the first CL implements the above A part with an assumption that some IMEs would do the B part. However, in reality it is quite unlikely that two random IMEs have the same inset size. At the same time, maintaining this kind of special optimization is getting harder and harder as more and more use cases and form factors need to be supported. Let's remove this optimization given that no one is benefited by it. Fix: 116492038 Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases Test: do not see any noticeable visual difference Change-Id: I8ffbf9bf7c3a8be54df0ca8eac1a1f041ef7d3c9 --- .../inputmethodservice/InputMethodService.java | 43 ---------------------- 1 file changed, 43 deletions(-) (limited to 'core/java/android/inputmethodservice/InputMethodService.java') diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index b94840279cea..ae12f93285a8 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -410,14 +410,6 @@ public class InputMethodService extends AbstractInputMethodService { @GuardedBy("mLock") private boolean mNotifyUserActionSent; - /** - * {@code true} when the previous IME had non-empty inset at the bottom of the screen and we - * have not shown our own window yet. In this situation, the previous inset continues to be - * shown as an empty region until it is explicitly updated. Basically we can trigger the update - * by calling 1) {@code mWindow.show()} or 2) {@link #clearInsetOfPreviousIme()}. - */ - boolean mShouldClearInsetOfPreviousIme; - @UnsupportedAppUsage final Insets mTmpInsets = new Insets(); final int[] mTmpLocation = new int[2]; @@ -581,7 +573,6 @@ public class InputMethodService extends AbstractInputMethodService { mShowInputFlags = 0; mShowInputRequested = false; doHideWindow(); - clearInsetOfPreviousIme(); if (resultReceiver != null) { resultReceiver.send(wasVis != isInputViewShown() ? InputMethodManager.RESULT_HIDDEN @@ -601,7 +592,6 @@ public class InputMethodService extends AbstractInputMethodService { if (dispatchOnShowInputRequested(flags, false)) { showWindow(true); } - clearInsetOfPreviousIme(); // If user uses hard keyboard, IME button should always be shown. setImeWindowStatus(mapToImeWindowStatus(isInputViewShown()), mBackDisposition); @@ -946,9 +936,6 @@ public class InputMethodService extends AbstractInputMethodService { super.onCreate(); mImm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); mSettingsObserver = SettingsObserver.createAndRegister(this); - // If the previous IME has occupied non-empty inset in the screen, we need to decide whether - // we continue to use the same size of the inset or update it - mShouldClearInsetOfPreviousIme = (mImm.getInputMethodWindowVisibleHeight() > 0); // TODO(b/111364446) Need to address context lifecycle issue if need to re-create // for update resources & configuration correctly when show soft input // in non-default display. @@ -1882,9 +1869,6 @@ public class InputMethodService extends AbstractInputMethodService { if (DEBUG) Log.v(TAG, "showWindow: showing!"); onWindowShown(); mWindow.show(); - // Put here rather than in onWindowShown() in case people forget to call - // super.onWindowShown(). - mShouldClearInsetOfPreviousIme = false; } } @@ -1933,32 +1917,6 @@ public class InputMethodService extends AbstractInputMethodService { // Intentionally empty } - /** - * Reset the inset occupied the previous IME when and only when - * {@link #mShouldClearInsetOfPreviousIme} is {@code true}. - */ - private void clearInsetOfPreviousIme() { - if (DEBUG) Log.v(TAG, "clearInsetOfPreviousIme() " - + " mShouldClearInsetOfPreviousIme=" + mShouldClearInsetOfPreviousIme); - if (!mShouldClearInsetOfPreviousIme) return; - - clearLastInputMethodWindowForTransition(); - mShouldClearInsetOfPreviousIme = false; - } - - /** - * Tells the system that the IME decided to not show a window and the system no longer needs to - * use the previous IME's inset. - * - *

Caveat: {@link android.inputmethodservice.InputMethodService#clearInsetOfPreviousIme()} - * is the only expected caller of this method. Do not depend on this anywhere else.

- * - *

TODO: We probably need to reconsider how IME should be handled.

- */ - private void clearLastInputMethodWindowForTransition() { - mPrivOps.clearLastInputMethodWindowForTransition(); - } - /** * Called when a new client has bound to the input method. This * may be followed by a series of {@link #onStartInput(EditorInfo, boolean)} @@ -2980,7 +2938,6 @@ public class InputMethodService extends AbstractInputMethodService { + " visibleTopInsets=" + mTmpInsets.visibleTopInsets + " touchableInsets=" + mTmpInsets.touchableInsets + " touchableRegion=" + mTmpInsets.touchableRegion); - p.println(" mShouldClearInsetOfPreviousIme=" + mShouldClearInsetOfPreviousIme); p.println(" mSettingsObserver=" + mSettingsObserver); } } -- cgit v1.2.3