Loading services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +19 −1 Original line number Diff line number Diff line Loading @@ -116,6 +116,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.util.proto.ProtoOutputStream; import android.view.IWindowManager; import android.view.InputChannel; import android.view.InputDevice; import android.view.MotionEvent; Loading @@ -123,6 +124,7 @@ import android.view.WindowManager; import android.view.WindowManager.DisplayImePolicy; import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams.SoftInputModeFlags; import android.view.WindowManagerGlobal; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ImeTracker; import android.view.inputmethod.InputBinding; Loading Loading @@ -2988,7 +2990,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub "Waiting for the lazy init of mImeDrawsImeNavBarRes"); } final boolean canImeDrawsImeNavBar = mImeDrawsImeNavBarRes != null && mImeDrawsImeNavBarRes.get(); mImeDrawsImeNavBarRes != null && mImeDrawsImeNavBarRes.get() && hasNavigationBarOnCurrentDisplay(); final boolean shouldShowImeSwitcherWhenImeIsShown = shouldShowImeSwitcherLocked( InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE); return (canImeDrawsImeNavBar ? InputMethodNavButtonFlags.IME_DRAWS_IME_NAV_BAR : 0) Loading @@ -2996,6 +2999,21 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub ? InputMethodNavButtonFlags.SHOW_IME_SWITCHER_WHEN_IME_IS_SHOWN : 0); } /** * Whether the current display has a navigation bar. When this is {@code false} (e.g. emulator), * the IME should <em>not</em> draw the IME navigation bar. */ @GuardedBy("ImfLock.class") private boolean hasNavigationBarOnCurrentDisplay() { final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); try { return wm.hasNavigationBar(mCurTokenDisplayId != INVALID_DISPLAY ? mCurTokenDisplayId : DEFAULT_DISPLAY); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @GuardedBy("ImfLock.class") private boolean shouldShowImeSwitcherLocked(int visibility) { if (!mShowOngoingImeSwitcherForPhones) return false; Loading services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -16,15 +16,20 @@ package com.android.inputmethodservice; import static android.view.WindowInsets.Type.captionBar; import static com.android.compatibility.common.util.SystemUtil.eventually; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.junit.Assume.assumeFalse; import android.app.Instrumentation; import android.content.Context; import android.content.res.Configuration; import android.graphics.Insets; import android.os.RemoteException; import android.provider.Settings; import android.support.test.uiautomator.By; Loading @@ -32,6 +37,7 @@ import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject2; import android.support.test.uiautomator.Until; import android.util.Log; import android.view.WindowManagerGlobal; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; Loading Loading @@ -592,6 +598,20 @@ public class InputMethodServiceTest { false /* orientationPortrait */); } /** * This checks that when the system navigation bar is not created (e.g. emulator), * then the IME caption bar is also not created. */ @Test public void testNoNavigationBar_thenImeNoCaptionBar() throws Exception { boolean hasNavigationBar = WindowManagerGlobal.getWindowManagerService() .hasNavigationBar(mInputMethodService.getDisplayId()); assumeFalse("Must not have a navigation bar", hasNavigationBar); assertEquals(Insets.NONE, mInputMethodService.getWindow().getWindow().getDecorView() .getRootWindowInsets().getInsetsIgnoringVisibility(captionBar())); } private void verifyInputViewStatus( Runnable runnable, boolean expected, boolean inputViewStarted) throws InterruptedException { Loading Loading
services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +19 −1 Original line number Diff line number Diff line Loading @@ -116,6 +116,7 @@ import android.util.Slog; import android.util.SparseArray; import android.util.SparseBooleanArray; import android.util.proto.ProtoOutputStream; import android.view.IWindowManager; import android.view.InputChannel; import android.view.InputDevice; import android.view.MotionEvent; Loading @@ -123,6 +124,7 @@ import android.view.WindowManager; import android.view.WindowManager.DisplayImePolicy; import android.view.WindowManager.LayoutParams; import android.view.WindowManager.LayoutParams.SoftInputModeFlags; import android.view.WindowManagerGlobal; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ImeTracker; import android.view.inputmethod.InputBinding; Loading Loading @@ -2988,7 +2990,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub "Waiting for the lazy init of mImeDrawsImeNavBarRes"); } final boolean canImeDrawsImeNavBar = mImeDrawsImeNavBarRes != null && mImeDrawsImeNavBarRes.get(); mImeDrawsImeNavBarRes != null && mImeDrawsImeNavBarRes.get() && hasNavigationBarOnCurrentDisplay(); final boolean shouldShowImeSwitcherWhenImeIsShown = shouldShowImeSwitcherLocked( InputMethodService.IME_ACTIVE | InputMethodService.IME_VISIBLE); return (canImeDrawsImeNavBar ? InputMethodNavButtonFlags.IME_DRAWS_IME_NAV_BAR : 0) Loading @@ -2996,6 +2999,21 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub ? InputMethodNavButtonFlags.SHOW_IME_SWITCHER_WHEN_IME_IS_SHOWN : 0); } /** * Whether the current display has a navigation bar. When this is {@code false} (e.g. emulator), * the IME should <em>not</em> draw the IME navigation bar. */ @GuardedBy("ImfLock.class") private boolean hasNavigationBarOnCurrentDisplay() { final IWindowManager wm = WindowManagerGlobal.getWindowManagerService(); try { return wm.hasNavigationBar(mCurTokenDisplayId != INVALID_DISPLAY ? mCurTokenDisplayId : DEFAULT_DISPLAY); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } @GuardedBy("ImfLock.class") private boolean shouldShowImeSwitcherLocked(int visibility) { if (!mShowOngoingImeSwitcherForPhones) return false; Loading
services/tests/InputMethodSystemServerTests/src/com/android/inputmethodservice/InputMethodServiceTest.java +20 −0 Original line number Diff line number Diff line Loading @@ -16,15 +16,20 @@ package com.android.inputmethodservice; import static android.view.WindowInsets.Type.captionBar; import static com.android.compatibility.common.util.SystemUtil.eventually; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.junit.Assume.assumeFalse; import android.app.Instrumentation; import android.content.Context; import android.content.res.Configuration; import android.graphics.Insets; import android.os.RemoteException; import android.provider.Settings; import android.support.test.uiautomator.By; Loading @@ -32,6 +37,7 @@ import android.support.test.uiautomator.UiDevice; import android.support.test.uiautomator.UiObject2; import android.support.test.uiautomator.Until; import android.util.Log; import android.view.WindowManagerGlobal; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; Loading Loading @@ -592,6 +598,20 @@ public class InputMethodServiceTest { false /* orientationPortrait */); } /** * This checks that when the system navigation bar is not created (e.g. emulator), * then the IME caption bar is also not created. */ @Test public void testNoNavigationBar_thenImeNoCaptionBar() throws Exception { boolean hasNavigationBar = WindowManagerGlobal.getWindowManagerService() .hasNavigationBar(mInputMethodService.getDisplayId()); assumeFalse("Must not have a navigation bar", hasNavigationBar); assertEquals(Insets.NONE, mInputMethodService.getWindow().getWindow().getDecorView() .getRootWindowInsets().getInsetsIgnoringVisibility(captionBar())); } private void verifyInputViewStatus( Runnable runnable, boolean expected, boolean inputViewStarted) throws InterruptedException { Loading