From b63dc53330915dee803ede87c3b381793dc99ce4 Mon Sep 17 00:00:00 2001 From: Wilson Wu Date: Tue, 11 Oct 2022 17:57:18 +0800 Subject: [PATCH] Simplify IMM#hasActiveConnectionInternal(View) After CL[1] and CL[2], IMM#hasActiveConnectionInternal(View) only used by onPostWindowGainedFocus(View, LayoutParams). However, the condition only need to verify the given view is associated with current active input connection. Hence we can remove the mServedInputConnection.isActive() check to simplify the method. [1]: I64412e87c4881018ea67140f9472e10ea41836e4 [2]: I7fe8b18ffbb450fd1e272e15f06f2629518f320c Bug: 182259171 Test: atest CtsInputMethodTestCases Test: make -j CtsInputMethod1 \ CtsInputMethod2 \ CtsInputMethodServiceDeviceTests \ CtsInputMethodServiceEventProvider \ CtsInputMethodServiceHostTestCases \ EditTextApp && atest -it \ CtsInputMethodServiceHostTestCases:InputMethodServiceLifecycleTest Change-Id: Ib0c6827c58dd082a5f70b6ec508536b24cf42dcd --- core/java/android/view/inputmethod/InputMethodManager.java | 3 --- .../android/view/inputmethod/RemoteInputConnectionImpl.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 574d0356ae42f..975a78606dec1 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -903,8 +903,6 @@ public final class InputMethodManager { /** * Checks whether the active input connection (if any) is for the given view. * - * TODO(b/182259171): Clean-up hasActiveConnection to simplify the logic. - * * Note that this method is only intended for restarting input after focus gain * (e.g. b/160391516), DO NOT leverage this method to do another check. */ @@ -915,7 +913,6 @@ public final class InputMethodManager { } return mServedInputConnection != null - && mServedInputConnection.isActive() && mServedInputConnection.isAssociatedWith(view); } } diff --git a/core/java/android/view/inputmethod/RemoteInputConnectionImpl.java b/core/java/android/view/inputmethod/RemoteInputConnectionImpl.java index fa18eeceafd0a..f2b70997de63d 100644 --- a/core/java/android/view/inputmethod/RemoteInputConnectionImpl.java +++ b/core/java/android/view/inputmethod/RemoteInputConnectionImpl.java @@ -214,7 +214,7 @@ final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub { } } - public boolean isActive() { + private boolean isActive() { return mParentInputMethodManager.isActive() && !isFinished(); }