From 5f9f1ca560d8b9e0dd8811f80f991f126ea80518 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 7 Mar 2022 10:47:47 -0800 Subject: Introduce InputMethodNavButtonFlags This CL reworks my previous CL [1], which let InputMethodManagerService report whether the IME switcher icon needs to be shown or not to the IME process by using IInputMethod IPCs. It turns out that we need to propagate one more boolean value in order to address Bug 219820813. It'd be much clearer if we use bit flags rather than adding a new boolean parameter to each IPC method. Thus this CL rewrites my previous CL by using a bit flag defined in a newly introduced InputMethodNavButtonFlags. This is a purely mechanical refactroing. There should be no behavior change. [1]: I5de9ac0dc8670842edf66306bb4c281c77cea376 75b935a12b37ffa97447b9acd80f94a4172bf3e6 Bug: 215551357 Bug: 219820813 Test: Manually verified with for the following scenarios: * Enabling/disabling multiple IMEs * Attaching/detaching a hardware keyboard * Showing/hinding the IME switcher * Showing an IME on the lock screen Change-Id: I81cb062a08d484ec8ce5d7b2fea64ce19028f82e --- .../android/inputmethodservice/InputMethodService.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 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 fbc0732affe1..60cd4181e933 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -140,6 +140,7 @@ import com.android.internal.annotations.GuardedBy; import com.android.internal.inputmethod.IInputContentUriToken; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.inputmethod.ImeTracing; +import com.android.internal.inputmethod.InputMethodNavButtonFlags; import com.android.internal.inputmethod.InputMethodPrivilegedOperations; import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import com.android.internal.view.IInlineSuggestionsRequestCallback; @@ -660,7 +661,7 @@ public class InputMethodService extends AbstractInputMethodService { @Override public final void initializeInternal(@NonNull IBinder token, IInputMethodPrivilegedOperations privilegedOperations, int configChanges, - boolean stylusHwSupported, boolean shouldShowImeSwitcherWhenImeIsShown) { + boolean stylusHwSupported, @InputMethodNavButtonFlags int navButtonFlags) { if (mDestroyed) { Log.i(TAG, "The InputMethodService has already onDestroyed()." + "Ignore the initialization."); @@ -673,8 +674,7 @@ public class InputMethodService extends AbstractInputMethodService { if (stylusHwSupported) { mInkWindow = new InkWindow(mWindow.getContext()); } - mNavigationBarController.setShouldShowImeSwitcherWhenImeIsShown( - shouldShowImeSwitcherWhenImeIsShown); + mNavigationBarController.onNavButtonFlagsChanged(navButtonFlags); attachToken(token); Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER); } @@ -784,10 +784,9 @@ public class InputMethodService extends AbstractInputMethodService { @Override public final void dispatchStartInputWithToken(@Nullable InputConnection inputConnection, @NonNull EditorInfo editorInfo, boolean restarting, - @NonNull IBinder startInputToken, boolean shouldShowImeSwitcherWhenImeIsShown) { + @NonNull IBinder startInputToken, @InputMethodNavButtonFlags int navButtonFlags) { mPrivOps.reportStartInputAsync(startInputToken); - mNavigationBarController.setShouldShowImeSwitcherWhenImeIsShown( - shouldShowImeSwitcherWhenImeIsShown); + mNavigationBarController.onNavButtonFlagsChanged(navButtonFlags); if (restarting) { restartInput(inputConnection, editorInfo); } else { @@ -801,10 +800,8 @@ public class InputMethodService extends AbstractInputMethodService { */ @MainThread @Override - public void onShouldShowImeSwitcherWhenImeIsShownChanged( - boolean shouldShowImeSwitcherWhenImeIsShown) { - mNavigationBarController.setShouldShowImeSwitcherWhenImeIsShown( - shouldShowImeSwitcherWhenImeIsShown); + public void onNavButtonFlagsChanged(@InputMethodNavButtonFlags int navButtonFlags) { + mNavigationBarController.onNavButtonFlagsChanged(navButtonFlags); } /** -- cgit v1.2.3