diff options
| author | 2019-10-29 17:47:16 +0800 | |
|---|---|---|
| committer | 2019-10-29 21:40:45 +0800 | |
| commit | 847a7d97e9c31e0075e1766cb7601329ea47df0f (patch) | |
| tree | e01ffd785b61c9acda883941da7f1214bc9ef2bc | |
| parent | d6e55406ffeed0bf3742d547f0358606ad52e6b2 (diff) | |
Remove StartInputFlags.FIRST_WINDOW_FOCUS_GAIN
Since this flag does not do any check during start input,
Remove this flag and the related parameter for IMM#onPostWindowFocus
to keep the logic simpler (included removing
ViewRootImpl#mHasHadWindowFocus).
This is refector CL and does not impact any behavior change.
Bug: 141738570
Test: Refector CL, make sure all existing test passed.
Change-Id: I9119f4846cbbd2b15246dea9a3b1fc5845dce951
4 files changed, 6 insertions, 28 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 20dc23492ae5..85bf19f855bb 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -439,7 +439,6 @@ public final class ViewRootImpl implements ViewParent, boolean mReportNextDraw; boolean mFullRedrawNeeded; boolean mNewSurfaceNeeded; - boolean mHasHadWindowFocus; boolean mLastWasImTarget; boolean mForceNextWindowRelayout; CountDownLatch mWindowDrawCountDown; @@ -2123,11 +2122,6 @@ public final class ViewRootImpl implements ViewParent, endDragResizing(); destroyHardwareResources(); } - if (viewVisibility == View.GONE) { - // After making a window gone, we will count it as being - // shown for the first time the next time it gets focus. - mHasHadWindowFocus = false; - } } // Non-visible windows can't hold accessibility focus. @@ -2823,8 +2817,7 @@ public final class ViewRootImpl implements ViewParent, if (imm != null && imTarget) { imm.onPreWindowFocus(mView, hasWindowFocus); imm.onPostWindowFocus(mView, mView.findFocus(), - mWindowAttributes.softInputMode, - !mHasHadWindowFocus, mWindowAttributes.flags); + mWindowAttributes.softInputMode, mWindowAttributes.flags); } } } @@ -3017,8 +3010,7 @@ public final class ViewRootImpl implements ViewParent, if (hasWindowFocus) { if (imm != null && mLastWasImTarget && !isInLocalFocusMode()) { imm.onPostWindowFocus(mView, mView.findFocus(), - mWindowAttributes.softInputMode, - !mHasHadWindowFocus, mWindowAttributes.flags); + mWindowAttributes.softInputMode, mWindowAttributes.flags); } // Clear the forward bit. We can just do this directly, since // the window manager doesn't care about it. @@ -3028,7 +3020,6 @@ public final class ViewRootImpl implements ViewParent, .softInputMode &= ~WindowManager.LayoutParams .SOFT_INPUT_IS_FORWARD_NAVIGATION; - mHasHadWindowFocus = true; // Refocusing a window that has a focused view should fire a // focus event for the view since the global focused view changed. diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 6420d71216cd..7ee53f26b1f8 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -358,7 +358,7 @@ public final class InputMethodManager { boolean mActive = false; /** - * {@code true} if next {@link #onPostWindowFocus(View, View, int, boolean, int)} needs to + * {@code true} if next {@link #onPostWindowFocus(View, View, int, int)} needs to * restart input. */ boolean mRestartOnNextWindowFocus = true; @@ -1925,13 +1925,12 @@ public final class InputMethodManager { * @hide */ public void onPostWindowFocus(View rootView, View focusedView, - @SoftInputModeFlags int softInputMode, boolean first, int windowFlags) { + @SoftInputModeFlags int softInputMode, int windowFlags) { boolean forceNewFocus = false; synchronized (mH) { if (DEBUG) Log.v(TAG, "onWindowFocus: " + focusedView + " softInputMode=" + InputMethodDebug.softInputModeToString(softInputMode) - + " first=" + first + " flags=#" - + Integer.toHexString(windowFlags)); + + " flags=#" + Integer.toHexString(windowFlags)); if (mRestartOnNextWindowFocus) { if (DEBUG) Log.v(TAG, "Restarting due to mRestartOnNextWindowFocus"); mRestartOnNextWindowFocus = false; @@ -1947,9 +1946,6 @@ public final class InputMethodManager { startInputFlags |= StartInputFlags.IS_TEXT_EDITOR; } } - if (first) { - startInputFlags |= StartInputFlags.FIRST_WINDOW_FOCUS_GAIN; - } if (checkFocusNoStartInput(forceNewFocus)) { // We need to restart input on the current focus view. This diff --git a/core/java/com/android/internal/inputmethod/InputMethodDebug.java b/core/java/com/android/internal/inputmethod/InputMethodDebug.java index 025e27bc45c9..382a254b67a6 100644 --- a/core/java/com/android/internal/inputmethod/InputMethodDebug.java +++ b/core/java/com/android/internal/inputmethod/InputMethodDebug.java @@ -168,9 +168,6 @@ public final class InputMethodDebug { if ((startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0) { joiner.add("IS_TEXT_EDITOR"); } - if ((startInputFlags & StartInputFlags.FIRST_WINDOW_FOCUS_GAIN) != 0) { - joiner.add("FIRST_WINDOW_FOCUS_GAIN"); - } if ((startInputFlags & StartInputFlags.INITIAL_CONNECTION) != 0) { joiner.add("INITIAL_CONNECTION"); } diff --git a/core/java/com/android/internal/inputmethod/StartInputFlags.java b/core/java/com/android/internal/inputmethod/StartInputFlags.java index ba26d8db533c..5a8d2c227256 100644 --- a/core/java/com/android/internal/inputmethod/StartInputFlags.java +++ b/core/java/com/android/internal/inputmethod/StartInputFlags.java @@ -30,7 +30,6 @@ import java.lang.annotation.Retention; @IntDef(flag = true, value = { StartInputFlags.VIEW_HAS_FOCUS, StartInputFlags.IS_TEXT_EDITOR, - StartInputFlags.FIRST_WINDOW_FOCUS_GAIN, StartInputFlags.INITIAL_CONNECTION}) public @interface StartInputFlags { /** @@ -44,13 +43,8 @@ public @interface StartInputFlags { int IS_TEXT_EDITOR = 2; /** - * This is the first time the window has gotten focus. - */ - int FIRST_WINDOW_FOCUS_GAIN = 4; - - /** * An internal concept to distinguish "start" and "restart". This concept doesn't look well * documented hence we probably need to revisit this though. */ - int INITIAL_CONNECTION = 8; + int INITIAL_CONNECTION = 4; } |