Revert "[Android] Return keyboard pressed state" (flutter/engine#42616)
Reverts flutter/engine#41695 due to internal bug report b/284945818. cc @bleroux let's investigate some day.
This commit is contained in:
@@ -2382,7 +2382,6 @@ ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/rend
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/DeferredComponentChannel.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/KeyEventChannel.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/KeyboardChannel.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/LifecycleChannel.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/MouseCursorChannel.java + ../../../flutter/LICENSE
|
||||
@@ -2416,7 +2415,6 @@ ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/Listen
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/SpellCheckPlugin.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/keyboard/KeyboardPlugin.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java + ../../../flutter/LICENSE
|
||||
ORIGIN: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/AccessibilityEventsDelegate.java + ../../../flutter/LICENSE
|
||||
@@ -5065,7 +5063,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/render
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/AccessibilityChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/DeferredComponentChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/KeyEventChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/KeyboardChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/LifecycleChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/systemchannels/MouseCursorChannel.java
|
||||
@@ -5102,7 +5099,6 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/Listenab
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/SpellCheckPlugin.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/keyboard/KeyboardPlugin.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/platform/AccessibilityEventsDelegate.java
|
||||
|
||||
@@ -250,7 +250,6 @@ android_java_sources = [
|
||||
"io/flutter/embedding/engine/systemchannels/AccessibilityChannel.java",
|
||||
"io/flutter/embedding/engine/systemchannels/DeferredComponentChannel.java",
|
||||
"io/flutter/embedding/engine/systemchannels/KeyEventChannel.java",
|
||||
"io/flutter/embedding/engine/systemchannels/KeyboardChannel.java",
|
||||
"io/flutter/embedding/engine/systemchannels/LifecycleChannel.java",
|
||||
"io/flutter/embedding/engine/systemchannels/LocalizationChannel.java",
|
||||
"io/flutter/embedding/engine/systemchannels/MouseCursorChannel.java",
|
||||
@@ -287,7 +286,6 @@ android_java_sources = [
|
||||
"io/flutter/plugin/editing/SpellCheckPlugin.java",
|
||||
"io/flutter/plugin/editing/TextEditingDelta.java",
|
||||
"io/flutter/plugin/editing/TextInputPlugin.java",
|
||||
"io/flutter/plugin/keyboard/KeyboardPlugin.java",
|
||||
"io/flutter/plugin/localization/LocalizationPlugin.java",
|
||||
"io/flutter/plugin/mouse/MouseCursorPlugin.java",
|
||||
"io/flutter/plugin/platform/AccessibilityEventsDelegate.java",
|
||||
|
||||
@@ -62,7 +62,6 @@ import io.flutter.embedding.engine.systemchannels.SettingsChannel;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.editing.SpellCheckPlugin;
|
||||
import io.flutter.plugin.editing.TextInputPlugin;
|
||||
import io.flutter.plugin.keyboard.KeyboardPlugin;
|
||||
import io.flutter.plugin.localization.LocalizationPlugin;
|
||||
import io.flutter.plugin.mouse.MouseCursorPlugin;
|
||||
import io.flutter.plugin.platform.PlatformViewsController;
|
||||
@@ -131,7 +130,6 @@ public class FlutterView extends FrameLayout
|
||||
@Nullable private MouseCursorPlugin mouseCursorPlugin;
|
||||
@Nullable private TextInputPlugin textInputPlugin;
|
||||
@Nullable private SpellCheckPlugin spellCheckPlugin;
|
||||
@Nullable private KeyboardPlugin keyboardPlugin;
|
||||
@Nullable private LocalizationPlugin localizationPlugin;
|
||||
@Nullable private KeyboardManager keyboardManager;
|
||||
@Nullable private AndroidTouchProcessor androidTouchProcessor;
|
||||
@@ -1179,8 +1177,6 @@ public class FlutterView extends FrameLayout
|
||||
localizationPlugin = this.flutterEngine.getLocalizationPlugin();
|
||||
|
||||
keyboardManager = new KeyboardManager(this);
|
||||
keyboardPlugin = new KeyboardPlugin(keyboardManager, this.flutterEngine.getKeyboardChannel());
|
||||
|
||||
androidTouchProcessor =
|
||||
new AndroidTouchProcessor(this.flutterEngine.getRenderer(), /*trackMotionEvents=*/ false);
|
||||
accessibilityBridge =
|
||||
@@ -1277,12 +1273,10 @@ public class FlutterView extends FrameLayout
|
||||
if (spellCheckPlugin != null) {
|
||||
spellCheckPlugin.destroy();
|
||||
}
|
||||
|
||||
if (mouseCursorPlugin != null) {
|
||||
mouseCursorPlugin.destroy();
|
||||
}
|
||||
if (keyboardPlugin != null) {
|
||||
keyboardPlugin.destroy();
|
||||
}
|
||||
|
||||
// Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface.
|
||||
FlutterRenderer flutterRenderer = flutterEngine.getRenderer();
|
||||
|
||||
@@ -11,9 +11,7 @@ import io.flutter.embedding.android.KeyboardMap.PressingGoal;
|
||||
import io.flutter.embedding.android.KeyboardMap.TogglingGoal;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A {@link KeyboardManager.Responder} of {@link KeyboardManager} that handles events by sending
|
||||
@@ -407,14 +405,4 @@ public class KeyEmbedderResponder implements KeyboardManager.Responder {
|
||||
onKeyEventHandledCallback.onKeyEventHandled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable view of the pressed state.
|
||||
*
|
||||
* @return A map whose keys are physical keyboard key IDs and values are the corresponding logical
|
||||
* keyboard key IDs.
|
||||
*/
|
||||
public Map<Long, Long> getPressedState() {
|
||||
return Collections.unmodifiableMap(pressingRecords);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.editing.InputConnectionAdaptor;
|
||||
import io.flutter.plugin.editing.TextInputPlugin;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Processes keyboard events and cooperate with {@link TextInputPlugin}.
|
||||
@@ -253,15 +252,4 @@ public class KeyboardManager implements InputConnectionAdaptor.KeyboardDelegate
|
||||
Log.w(TAG, "A redispatched key event was consumed before reaching KeyboardManager");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable view of the pressed state.
|
||||
*
|
||||
* @return A map whose keys are physical keyboard key IDs and values are the corresponding logical
|
||||
* keyboard key IDs.
|
||||
*/
|
||||
public Map<Long, Long> getPressedState() {
|
||||
KeyEmbedderResponder embedderResponder = (KeyEmbedderResponder) responders[0];
|
||||
return embedderResponder.getPressedState();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import io.flutter.embedding.engine.renderer.FlutterRenderer;
|
||||
import io.flutter.embedding.engine.renderer.RenderSurface;
|
||||
import io.flutter.embedding.engine.systemchannels.AccessibilityChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.DeferredComponentChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.KeyboardChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.LifecycleChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.LocalizationChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.MouseCursorChannel;
|
||||
@@ -90,7 +89,6 @@ public class FlutterEngine implements ViewUtils.DisplayUpdater {
|
||||
// System channels.
|
||||
@NonNull private final AccessibilityChannel accessibilityChannel;
|
||||
@NonNull private final DeferredComponentChannel deferredComponentChannel;
|
||||
@NonNull private final KeyboardChannel keyboardChannel;
|
||||
@NonNull private final LifecycleChannel lifecycleChannel;
|
||||
@NonNull private final LocalizationChannel localizationChannel;
|
||||
@NonNull private final MouseCursorChannel mouseCursorChannel;
|
||||
@@ -326,7 +324,6 @@ public class FlutterEngine implements ViewUtils.DisplayUpdater {
|
||||
|
||||
accessibilityChannel = new AccessibilityChannel(dartExecutor, flutterJNI);
|
||||
deferredComponentChannel = new DeferredComponentChannel(dartExecutor);
|
||||
keyboardChannel = new KeyboardChannel(dartExecutor);
|
||||
lifecycleChannel = new LifecycleChannel(dartExecutor);
|
||||
localizationChannel = new LocalizationChannel(dartExecutor);
|
||||
mouseCursorChannel = new MouseCursorChannel(dartExecutor);
|
||||
@@ -519,12 +516,6 @@ public class FlutterEngine implements ViewUtils.DisplayUpdater {
|
||||
return accessibilityChannel;
|
||||
}
|
||||
|
||||
/** System channel that allows querying the keyboard pressed state. */
|
||||
@NonNull
|
||||
public KeyboardChannel getKeyboardChannel() {
|
||||
return keyboardChannel;
|
||||
}
|
||||
|
||||
/** System channel that sends Android lifecycle events to Flutter. */
|
||||
@NonNull
|
||||
public LifecycleChannel getLifecycleChannel() {
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.embedding.engine.systemchannels;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import io.flutter.embedding.engine.dart.DartExecutor;
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Event message channel for keyboard events to/from the Flutter framework.
|
||||
*
|
||||
* <p>Receives asynchronous messages from the framework to query the engine known pressed state.
|
||||
*/
|
||||
public class KeyboardChannel {
|
||||
private static final String TAG = "KeyboardChannel";
|
||||
|
||||
public final MethodChannel channel;
|
||||
private KeyboardMethodHandler keyboardMethodHandler;
|
||||
|
||||
@NonNull
|
||||
public final MethodChannel.MethodCallHandler parsingMethodHandler =
|
||||
new MethodChannel.MethodCallHandler() {
|
||||
@Override
|
||||
public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) {
|
||||
if (keyboardMethodHandler == null) {
|
||||
return;
|
||||
}
|
||||
switch (call.method) {
|
||||
case "getKeyboardState":
|
||||
Map<Long, Long> pressedState = new HashMap<>();
|
||||
try {
|
||||
pressedState = keyboardMethodHandler.getKeyboardState();
|
||||
} catch (IllegalStateException exception) {
|
||||
result.error("error", exception.getMessage(), null);
|
||||
}
|
||||
result.success(pressedState);
|
||||
break;
|
||||
default:
|
||||
result.notImplemented();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public KeyboardChannel(@NonNull DartExecutor dartExecutor) {
|
||||
channel = new MethodChannel(dartExecutor, "flutter/keyboard", StandardMethodCodec.INSTANCE);
|
||||
channel.setMethodCallHandler(parsingMethodHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link KeyboardMethodHandler} which receives all requests to query the keyboard state.
|
||||
*/
|
||||
public void setKeyboardMethodHandler(@Nullable KeyboardMethodHandler keyboardMethodHandler) {
|
||||
this.keyboardMethodHandler = keyboardMethodHandler;
|
||||
}
|
||||
|
||||
public interface KeyboardMethodHandler {
|
||||
/**
|
||||
* Returns the keyboard pressed states.
|
||||
*
|
||||
* @return A map whose keys are physical keyboard key IDs and values are the corresponding
|
||||
* logical keyboard key IDs.
|
||||
*/
|
||||
Map<Long, Long> getKeyboardState();
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
package io.flutter.plugin.keyboard;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import io.flutter.embedding.android.KeyboardManager;
|
||||
import io.flutter.embedding.engine.systemchannels.KeyboardChannel;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* {@link KeyboardPlugin} is the implementation of all functionalities needed for querying keyboard
|
||||
* pressed state.
|
||||
*
|
||||
* <p>The plugin handles requests for querying keyboard pressed states by the {@link
|
||||
* io.flutter.embedding.engine.systemchannels.KeyboardChannel} via returning the {@link
|
||||
* io.flutter.embedding.android.KeyEmbedderResponder} pressed keys.
|
||||
*/
|
||||
public class KeyboardPlugin implements KeyboardChannel.KeyboardMethodHandler {
|
||||
|
||||
private final KeyboardChannel mKeyboardChannel;
|
||||
private final KeyboardManager mKeyboardManager;
|
||||
|
||||
@VisibleForTesting MethodChannel.Result pendingResult;
|
||||
|
||||
public KeyboardPlugin(
|
||||
@NonNull KeyboardManager keyboardManager, @NonNull KeyboardChannel keyboardChannel) {
|
||||
mKeyboardManager = keyboardManager;
|
||||
mKeyboardChannel = keyboardChannel;
|
||||
|
||||
mKeyboardChannel.setKeyboardMethodHandler(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this {@code KeyboardPlugin} as the {@code KeyboardChannel.KeyboardMethodHandler},
|
||||
* for the {@link io.flutter.embedding.engine.systemchannels.KeyboardChannel}.
|
||||
*
|
||||
* <p>Do not invoke any methods on a {@code KeyboardPlugin} after invoking this method.
|
||||
*/
|
||||
public void destroy() {
|
||||
mKeyboardChannel.setKeyboardMethodHandler(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keyboard pressed state.
|
||||
*
|
||||
* @return A map whose keys are physical keyboard key IDs and values are the corresponding logical
|
||||
* keyboard key IDs.
|
||||
*/
|
||||
@Override
|
||||
public Map<Long, Long> getKeyboardState() {
|
||||
return mKeyboardManager.getPressedState();
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,6 @@ import io.flutter.embedding.engine.dart.DartExecutor;
|
||||
import io.flutter.embedding.engine.renderer.FlutterRenderer;
|
||||
import io.flutter.embedding.engine.renderer.SurfaceTextureWrapper;
|
||||
import io.flutter.embedding.engine.systemchannels.AccessibilityChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.KeyboardChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.LifecycleChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.LocalizationChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.MouseCursorChannel;
|
||||
@@ -60,7 +59,6 @@ import io.flutter.embedding.engine.systemchannels.TextInputChannel;
|
||||
import io.flutter.plugin.common.ActivityLifecycleListener;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.editing.TextInputPlugin;
|
||||
import io.flutter.plugin.keyboard.KeyboardPlugin;
|
||||
import io.flutter.plugin.localization.LocalizationPlugin;
|
||||
import io.flutter.plugin.mouse.MouseCursorPlugin;
|
||||
import io.flutter.plugin.platform.PlatformPlugin;
|
||||
@@ -126,14 +124,12 @@ public class FlutterView extends SurfaceView
|
||||
private final FlutterRenderer flutterRenderer;
|
||||
private final NavigationChannel navigationChannel;
|
||||
private final LifecycleChannel lifecycleChannel;
|
||||
private final KeyboardChannel keyboardChannel;
|
||||
private final LocalizationChannel localizationChannel;
|
||||
private final PlatformChannel platformChannel;
|
||||
private final SettingsChannel settingsChannel;
|
||||
private final SystemChannel systemChannel;
|
||||
private final InputMethodManager mImm;
|
||||
private final TextInputPlugin mTextInputPlugin;
|
||||
private final KeyboardPlugin mKeyboardPlugin;
|
||||
private final LocalizationPlugin mLocalizationPlugin;
|
||||
private final MouseCursorPlugin mMouseCursorPlugin;
|
||||
private final KeyboardManager mKeyboardManager;
|
||||
@@ -217,7 +213,6 @@ public class FlutterView extends SurfaceView
|
||||
|
||||
// Create all platform channels
|
||||
navigationChannel = new NavigationChannel(dartExecutor);
|
||||
keyboardChannel = new KeyboardChannel(dartExecutor);
|
||||
lifecycleChannel = new LifecycleChannel(dartExecutor);
|
||||
localizationChannel = new LocalizationChannel(dartExecutor);
|
||||
platformChannel = new PlatformChannel(dartExecutor);
|
||||
@@ -238,9 +233,7 @@ public class FlutterView extends SurfaceView
|
||||
mNativeView.getPluginRegistry().getPlatformViewsController();
|
||||
mTextInputPlugin =
|
||||
new TextInputPlugin(this, new TextInputChannel(dartExecutor), platformViewsController);
|
||||
|
||||
mKeyboardManager = new KeyboardManager(this);
|
||||
mKeyboardPlugin = new KeyboardPlugin(mKeyboardManager, keyboardChannel);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
mMouseCursorPlugin = new MouseCursorPlugin(this, new MouseCursorChannel(dartExecutor));
|
||||
|
||||
@@ -39,7 +39,6 @@ import io.flutter.embedding.engine.plugins.activity.ActivityControlSurface;
|
||||
import io.flutter.embedding.engine.renderer.FlutterRenderer;
|
||||
import io.flutter.embedding.engine.renderer.FlutterUiDisplayListener;
|
||||
import io.flutter.embedding.engine.systemchannels.AccessibilityChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.KeyboardChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.LifecycleChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.LocalizationChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.MouseCursorChannel;
|
||||
@@ -1294,7 +1293,6 @@ public class FlutterActivityAndFragmentDelegateTest {
|
||||
when(engine.getAccessibilityChannel()).thenReturn(mock(AccessibilityChannel.class));
|
||||
when(engine.getActivityControlSurface()).thenReturn(mock(ActivityControlSurface.class));
|
||||
when(engine.getDartExecutor()).thenReturn(mock(DartExecutor.class));
|
||||
when(engine.getKeyboardChannel()).thenReturn(mock(KeyboardChannel.class));
|
||||
when(engine.getLifecycleChannel()).thenReturn(mock(LifecycleChannel.class));
|
||||
when(engine.getLocalizationChannel()).thenReturn(mock(LocalizationChannel.class));
|
||||
when(engine.getLocalizationPlugin()).thenReturn(mock(LocalizationPlugin.class));
|
||||
|
||||
@@ -25,7 +25,6 @@ import io.flutter.util.FakeKeyEvent;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -1565,22 +1564,4 @@ public class KeyboardManagerTest {
|
||||
calls.get(0).keyData, Type.kUp, PHYSICAL_CAPS_LOCK, LOGICAL_CAPS_LOCK, null, false);
|
||||
calls.clear();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPressedState() {
|
||||
final KeyboardTester tester = new KeyboardTester();
|
||||
|
||||
tester.respondToTextInputWith(true); // Suppress redispatching.
|
||||
|
||||
// Initial pressed state is empty.
|
||||
assertEquals(tester.keyboardManager.getPressedState(), Map.of());
|
||||
|
||||
tester.keyboardManager.handleEvent(
|
||||
new FakeKeyEvent(ACTION_DOWN, SCAN_KEY_A, KEYCODE_A, 1, 'a', 0));
|
||||
assertEquals(tester.keyboardManager.getPressedState(), Map.of(PHYSICAL_KEY_A, LOGICAL_KEY_A));
|
||||
|
||||
tester.keyboardManager.handleEvent(
|
||||
new FakeKeyEvent(ACTION_UP, SCAN_KEY_A, KEYCODE_A, 0, 'a', 0));
|
||||
assertEquals(tester.keyboardManager.getPressedState(), Map.of());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package io.flutter.plugin.keyboard;
|
||||
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import io.flutter.embedding.engine.dart.DartExecutor;
|
||||
import io.flutter.embedding.engine.systemchannels.KeyboardChannel;
|
||||
import io.flutter.plugin.common.BinaryMessenger;
|
||||
import io.flutter.plugin.common.MethodCall;
|
||||
import io.flutter.plugin.common.StandardMethodCodec;
|
||||
import java.nio.ByteBuffer;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class KeyboardPluginTest {
|
||||
|
||||
private static void sendToBinaryMessageHandler(
|
||||
BinaryMessenger.BinaryMessageHandler binaryMessageHandler, String method, Object args) {
|
||||
MethodCall methodCall = new MethodCall(method, args);
|
||||
ByteBuffer encodedMethodCall = StandardMethodCodec.INSTANCE.encodeMethodCall(methodCall);
|
||||
binaryMessageHandler.onMessage(
|
||||
(ByteBuffer) encodedMethodCall.flip(), mock(BinaryMessenger.BinaryReply.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void respondsToGetKeyboardStateChannelMessage() {
|
||||
ArgumentCaptor<BinaryMessenger.BinaryMessageHandler> binaryMessageHandlerCaptor =
|
||||
ArgumentCaptor.forClass(BinaryMessenger.BinaryMessageHandler.class);
|
||||
DartExecutor mockBinaryMessenger = mock(DartExecutor.class);
|
||||
KeyboardChannel.KeyboardMethodHandler mockHandler =
|
||||
mock(KeyboardChannel.KeyboardMethodHandler.class);
|
||||
KeyboardChannel keyboardChannel = new KeyboardChannel(mockBinaryMessenger);
|
||||
|
||||
keyboardChannel.setKeyboardMethodHandler(mockHandler);
|
||||
|
||||
verify(mockBinaryMessenger, times(1))
|
||||
.setMessageHandler(any(String.class), binaryMessageHandlerCaptor.capture());
|
||||
|
||||
BinaryMessenger.BinaryMessageHandler binaryMessageHandler =
|
||||
binaryMessageHandlerCaptor.getValue();
|
||||
|
||||
sendToBinaryMessageHandler(binaryMessageHandler, "getKeyboardState", null);
|
||||
|
||||
verify(mockHandler, times(1)).getKeyboardState();
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,6 @@ import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorView;
|
||||
import io.flutter.embedding.engine.mutatorsstack.FlutterMutatorsStack;
|
||||
import io.flutter.embedding.engine.renderer.FlutterRenderer;
|
||||
import io.flutter.embedding.engine.systemchannels.AccessibilityChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.KeyboardChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.MouseCursorChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.PlatformViewsChannel;
|
||||
import io.flutter.embedding.engine.systemchannels.SettingsChannel;
|
||||
@@ -1496,7 +1495,6 @@ public class PlatformViewsControllerTest {
|
||||
|
||||
final FlutterEngine engine = mock(FlutterEngine.class);
|
||||
when(engine.getRenderer()).thenReturn(new FlutterRenderer(jni));
|
||||
when(engine.getKeyboardChannel()).thenReturn(mock(KeyboardChannel.class));
|
||||
when(engine.getMouseCursorChannel()).thenReturn(mock(MouseCursorChannel.class));
|
||||
when(engine.getTextInputChannel()).thenReturn(mock(TextInputChannel.class));
|
||||
when(engine.getSettingsChannel()).thenReturn(new SettingsChannel(executor));
|
||||
|
||||
Reference in New Issue
Block a user