From 142218b1f9c2c9b07d25142bb315a91e077d528d Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Tue, 19 Jan 2021 15:55:44 +0100 Subject: [PATCH] IME Insets: Remove obsolete applyImeVisibility call Test: atest InsetsControllerTest ImeInsetsSourceConsumerTest Bug: 167947407 Change-Id: I8abb210eb20a17f5dfd6d071c57838afb9deb263 --- .../android/view/ImeInsetsSourceConsumer.java | 4 ---- core/java/android/view/InsetsController.java | 16 ++-------------- .../view/inputmethod/InputMethodManager.java | 18 ------------------ .../internal/view/IInputMethodClient.aidl | 1 - .../view/ImeInsetsSourceConsumerTest.java | 8 ++++---- .../src/android/view/InsetsControllerTest.java | 8 ++++---- .../inputmethod/InputMethodManagerService.java | 13 ------------- 7 files changed, 10 insertions(+), 58 deletions(-) diff --git a/core/java/android/view/ImeInsetsSourceConsumer.java b/core/java/android/view/ImeInsetsSourceConsumer.java index f4d5a7b695eba..98b7dbfa670fc 100644 --- a/core/java/android/view/ImeInsetsSourceConsumer.java +++ b/core/java/android/view/ImeInsetsSourceConsumer.java @@ -50,10 +50,6 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { super(ITYPE_IME, state, transactionSupplier, controller); } - public void applyImeVisibility(boolean setVisible) { - mController.applyImeVisibility(setVisible); - } - @Override public void onWindowFocusGained() { super.onWindowFocusGained(); diff --git a/core/java/android/view/InsetsController.java b/core/java/android/view/InsetsController.java index b4e1172f49aeb..cd5a7ecea044f 100644 --- a/core/java/android/view/InsetsController.java +++ b/core/java/android/view/InsetsController.java @@ -878,7 +878,8 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation hide(types, false /* fromIme */); } - void hide(@InsetsType int types, boolean fromIme) { + @VisibleForTesting + public void hide(@InsetsType int types, boolean fromIme) { if (fromIme) { ImeTracing.getInstance().triggerClientDump("InsetsController#hide", mHost.getInputMethodManager(), null /* icProto */); @@ -1270,19 +1271,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation getSourceConsumer(ITYPE_IME).onWindowFocusLost(); } - /** - * Used by {@link ImeInsetsSourceConsumer} when IME decides to be shown/hidden. - * @hide - */ - @VisibleForTesting - public void applyImeVisibility(boolean setVisible) { - if (setVisible) { - show(Type.IME, true /* fromIme */); - } else { - hide(Type.IME); - } - } - @VisibleForTesting public @AnimationType int getAnimationType(@InternalInsetsType int type) { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 90c8e17a69841..d60d8fe6e8954 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -492,7 +492,6 @@ public final class InputMethodManager { static final int MSG_TIMEOUT_INPUT_EVENT = 6; static final int MSG_FLUSH_INPUT_EVENT = 7; static final int MSG_REPORT_FULLSCREEN_MODE = 10; - static final int MSG_APPLY_IME_VISIBILITY = 20; static final int MSG_UPDATE_ACTIVITY_VIEW_TO_SCREEN_MATRIX = 30; private static boolean isAutofillUIShowing(View servedView) { @@ -954,17 +953,6 @@ public final class InputMethodManager { } return; } - case MSG_APPLY_IME_VISIBILITY: { - synchronized (mH) { - if (mImeInsetsConsumer != null) { - ImeTracing.getInstance().triggerClientDump( - "ImeInsetsSourceConsumer#applyImeVisibility", - InputMethodManager.this, null /* icProto */); - mImeInsetsConsumer.applyImeVisibility(msg.arg1 != 0); - } - } - return; - } case MSG_UPDATE_ACTIVITY_VIEW_TO_SCREEN_MATRIX: { final float[] matrixValues = (float[]) msg.obj; final int bindSequence = msg.arg1; @@ -1146,12 +1134,6 @@ public final class InputMethodManager { .sendToTarget(); } - @Override - public void applyImeVisibility(boolean setVisible) { - mH.obtainMessage(MSG_APPLY_IME_VISIBILITY, setVisible ? 1 : 0, 0) - .sendToTarget(); - } - @Override public void updateActivityViewToScreenMatrix(int bindSequence, float[] matrixValues) { mH.obtainMessage(MSG_UPDATE_ACTIVITY_VIEW_TO_SCREEN_MATRIX, bindSequence, 0, diff --git a/core/java/com/android/internal/view/IInputMethodClient.aidl b/core/java/com/android/internal/view/IInputMethodClient.aidl index ec9a0a2f48011..49dbbaaa17f72 100644 --- a/core/java/com/android/internal/view/IInputMethodClient.aidl +++ b/core/java/com/android/internal/view/IInputMethodClient.aidl @@ -28,7 +28,6 @@ oneway interface IInputMethodClient { void setActive(boolean active, boolean fullscreen, boolean reportToImeController); void scheduleStartInputIfNecessary(boolean fullscreen); void reportFullscreenMode(boolean fullscreen); - void applyImeVisibility(boolean setVisible); void updateActivityViewToScreenMatrix(int bindSequence, in float[] matrixValues); void setImeTraceEnabled(boolean enabled); } diff --git a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java index 7a2e6b75272f8..49024cc8ef2dd 100644 --- a/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java +++ b/core/tests/coretests/src/android/view/ImeInsetsSourceConsumerTest.java @@ -97,12 +97,12 @@ public class ImeInsetsSourceConsumerTest { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { // test if setVisibility can show IME mImeConsumer.onWindowFocusGained(); - mImeConsumer.applyImeVisibility(true); + mController.show(WindowInsets.Type.ime(), true /* fromIme */); mController.cancelExistingAnimations(); assertTrue(mController.getSourceConsumer(ime.getType()).isRequestedVisible()); // test if setVisibility can hide IME - mImeConsumer.applyImeVisibility(false); + mController.hide(WindowInsets.Type.ime(), true /* fromIme */); mController.cancelExistingAnimations(); assertFalse(mController.getSourceConsumer(ime.getType()).isRequestedVisible()); }); @@ -116,7 +116,7 @@ public class ImeInsetsSourceConsumerTest { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { // Request IME visible before control is available. mImeConsumer.onWindowFocusGained(); - mImeConsumer.applyImeVisibility(true /* setVisible */); + mController.show(WindowInsets.Type.ime(), true /* fromIme */); // set control and verify visibility is applied. InsetsSourceControl control = new InsetsSourceControl(ITYPE_IME, mLeash, new Point()); @@ -134,7 +134,7 @@ public class ImeInsetsSourceConsumerTest { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { // Request IME visible before control is available. mImeConsumer.onWindowFocusGained(); - mImeConsumer.applyImeVisibility(true /* setVisible */); + mController.show(WindowInsets.Type.ime(), true /* fromIme */); // set control and verify visibility is applied. InsetsSourceControl control = Mockito.spy( diff --git a/core/tests/coretests/src/android/view/InsetsControllerTest.java b/core/tests/coretests/src/android/view/InsetsControllerTest.java index 2770ed820562c..a9dca88291656 100644 --- a/core/tests/coretests/src/android/view/InsetsControllerTest.java +++ b/core/tests/coretests/src/android/view/InsetsControllerTest.java @@ -235,7 +235,7 @@ public class InsetsControllerTest { InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { mController.getSourceConsumer(ITYPE_IME).onWindowFocusGained(); // since there is no focused view, forcefully make IME visible. - mController.applyImeVisibility(true /* setVisible */); + mController.show(Type.ime(), true /* fromIme */); mController.show(Type.all()); // quickly jump to final state by cancelling it. mController.cancelExistingAnimations(); @@ -243,7 +243,7 @@ public class InsetsControllerTest { assertTrue(mController.getSourceConsumer(statusBar.getType()).isRequestedVisible()); assertTrue(mController.getSourceConsumer(ime.getType()).isRequestedVisible()); - mController.applyImeVisibility(false /* setVisible */); + mController.hide(Type.ime(), true /* fromIme */); mController.hide(Type.all()); mController.cancelExistingAnimations(); assertFalse(mController.getSourceConsumer(navBar.getType()).isRequestedVisible()); @@ -260,10 +260,10 @@ public class InsetsControllerTest { mController.onControlsChanged(new InsetsSourceControl[] { ime }); InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { mController.getSourceConsumer(ITYPE_IME).onWindowFocusGained(); - mController.applyImeVisibility(true); + mController.show(Type.ime(), true /* fromIme */); mController.cancelExistingAnimations(); assertTrue(mController.getSourceConsumer(ime.getType()).isRequestedVisible()); - mController.applyImeVisibility(false); + mController.hide(Type.ime(), true /* fromIme */); mController.cancelExistingAnimations(); assertFalse(mController.getSourceConsumer(ime.getType()).isRequestedVisible()); mController.getSourceConsumer(ITYPE_IME).onWindowFocusLost(); diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 6308ace260110..0d124a24dce9e 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -255,7 +255,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub static final int MSG_SET_ACTIVE = 3020; static final int MSG_SET_INTERACTIVE = 3030; static final int MSG_REPORT_FULLSCREEN_MODE = 3045; - static final int MSG_APPLY_IME_VISIBILITY = 3070; static final int MSG_HARD_KEYBOARD_SWITCH_CHANGED = 4000; @@ -4623,18 +4622,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub } return true; } - case MSG_APPLY_IME_VISIBILITY: { - final boolean setVisible = msg.arg1 != 0; - final ClientState clientState = (ClientState) msg.obj; - try { - clientState.client.applyImeVisibility(setVisible); - } catch (RemoteException e) { - Slog.w(TAG, "Got RemoteException sending " - + "applyImeVisibility(" + setVisible + ") notification to pid=" - + clientState.pid + " uid=" + clientState.uid); - } - return true; - } // -------------------------------------------------------------- case MSG_HARD_KEYBOARD_SWITCH_CHANGED: