提交 be976126 编写于 作者: A Adam Barth 提交者: GitHub

All the clients have migrated to platform messages (#3142)

上级 269fd75d
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//mojo/public/tools/bindings/mojom.gni")
mojom("interfaces") {
sources = [
"raw_keyboard.mojom",
]
deps = [
"//flutter/services/engine:interfaces"
]
}
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
android_library("raw_keyboard_lib") {
java_files = [
"src/org/domokit/raw_keyboard/RawKeyboardServiceImpl.java",
"src/org/domokit/raw_keyboard/RawKeyboardServiceState.java",
]
deps = [
"//base:base_java",
"//mojo/public/java:bindings",
"//mojo/public/java:system",
"//flutter/services/engine:interfaces_java",
":interfaces_java",
]
}
}
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[DartPackage="sky_services"]
module raw_keyboard;
import "flutter/services/engine/input_event.mojom";
interface RawKeyboardListener {
OnKey(sky.InputEvent event);
};
[ServiceName="raw_keyboard::RawKeyboardService"]
interface RawKeyboardService {
AddListener(RawKeyboardListener listener);
};
// Copyright 2015 The Chromium 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 org.domokit.raw_keyboard;
import org.chromium.mojo.system.MojoException;
import org.chromium.mojom.raw_keyboard.RawKeyboardListener;
import org.chromium.mojom.raw_keyboard.RawKeyboardService;
/**
* Android implementation of Keyboard.
*/
public class RawKeyboardServiceImpl implements RawKeyboardService {
private RawKeyboardServiceState mViewState;
public RawKeyboardServiceImpl(RawKeyboardServiceState state) {
mViewState = state;
}
@Override
public void addListener(RawKeyboardListener listener) {
mViewState.addListener((RawKeyboardListener.Proxy) listener);
}
@Override
public void onConnectionError(MojoException e) {}
@Override
public void close() {
mViewState.close();
}
}
// Copyright 2015 The Chromium 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 org.domokit.raw_keyboard;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import java.util.ArrayList;
import org.chromium.mojo.bindings.ConnectionErrorHandler;
import org.chromium.mojo.system.MojoException;
import org.chromium.mojom.raw_keyboard.RawKeyboardListener;
import org.chromium.mojom.raw_keyboard.RawKeyboardService;
import org.chromium.mojom.sky.InputEvent;
import org.chromium.mojom.sky.EventType;
import org.chromium.mojom.sky.KeyData;
/**
* Per-View raw keyboard state.
*/
public class RawKeyboardServiceState implements View.OnKeyListener {
private static final String TAG = "RawKeyboardServiceState";
private ArrayList<RawKeyboardListener.Proxy> mListeners = new ArrayList<RawKeyboardListener.Proxy>();
public RawKeyboardServiceState() {
}
public void addListener(final RawKeyboardListener.Proxy listener) {
mListeners.add(listener);
listener.getProxyHandler().setErrorHandler(new ConnectionErrorHandler() {
@Override
public void onConnectionError(MojoException e) {
mListeners.remove(listener);
}
});
}
public void close() {
}
@Override
public boolean onKey(View v, int keyCode, KeyEvent nativeEvent) {
if (mListeners.isEmpty())
return false;
InputEvent event = new InputEvent();
switch (nativeEvent.getAction()) {
case KeyEvent.ACTION_DOWN:
event.type = EventType.KEY_PRESSED;
break;
case KeyEvent.ACTION_UP:
event.type = EventType.KEY_RELEASED;
break;
default:
Log.w(TAG, "Unknown key event received");
return false;
}
KeyData keyData = new KeyData();
keyData.flags = nativeEvent.getFlags();
keyData.scanCode = nativeEvent.getScanCode();
keyData.metaState = nativeEvent.getMetaState();
keyData.keyCode = keyCode;
event.keyData = keyData;
for (RawKeyboardListener listener : mListeners)
listener.onKey(event);
return true;
}
}
...@@ -86,8 +86,6 @@ android_library("java") { ...@@ -86,8 +86,6 @@ android_library("java") {
"//flutter/services/editing:interfaces_java", "//flutter/services/editing:interfaces_java",
"//flutter/services/engine:interfaces_java", "//flutter/services/engine:interfaces_java",
"//flutter/services/platform:interfaces_java", "//flutter/services/platform:interfaces_java",
"//flutter/services/raw_keyboard:interfaces_java",
"//flutter/services/raw_keyboard:raw_keyboard_lib",
"//flutter/services/vsync:vsync_lib", "//flutter/services/vsync:vsync_lib",
"//mojo/android:system_java", "//mojo/android:system_java",
"//mojo/public/interfaces/application:application_java", "//mojo/public/interfaces/application:application_java",
......
...@@ -45,7 +45,6 @@ import org.chromium.mojo.system.impl.CoreImpl; ...@@ -45,7 +45,6 @@ import org.chromium.mojo.system.impl.CoreImpl;
import org.chromium.mojom.editing.Keyboard; import org.chromium.mojom.editing.Keyboard;
import org.chromium.mojom.flutter.platform.ApplicationMessages; import org.chromium.mojom.flutter.platform.ApplicationMessages;
import org.chromium.mojom.mojo.ServiceProvider; import org.chromium.mojom.mojo.ServiceProvider;
import org.chromium.mojom.raw_keyboard.RawKeyboardService;
import org.chromium.mojom.sky.AppLifecycleState; import org.chromium.mojom.sky.AppLifecycleState;
import org.chromium.mojom.sky.ServicesData; import org.chromium.mojom.sky.ServicesData;
import org.chromium.mojom.sky.SkyEngine; import org.chromium.mojom.sky.SkyEngine;
...@@ -65,8 +64,6 @@ import io.flutter.plugin.platform.PlatformPlugin; ...@@ -65,8 +64,6 @@ import io.flutter.plugin.platform.PlatformPlugin;
import org.domokit.editing.KeyboardImpl; import org.domokit.editing.KeyboardImpl;
import org.domokit.editing.KeyboardViewState; import org.domokit.editing.KeyboardViewState;
import org.domokit.raw_keyboard.RawKeyboardServiceImpl;
import org.domokit.raw_keyboard.RawKeyboardServiceState;
/** /**
* An Android view containing a Flutter app. * An Android view containing a Flutter app.
...@@ -92,7 +89,6 @@ public class FlutterView extends SurfaceView ...@@ -92,7 +89,6 @@ public class FlutterView extends SurfaceView
private final SurfaceHolder.Callback mSurfaceCallback; private final SurfaceHolder.Callback mSurfaceCallback;
private final ViewportMetrics mMetrics; private final ViewportMetrics mMetrics;
private final KeyboardViewState mKeyboardState; private final KeyboardViewState mKeyboardState;
private final RawKeyboardServiceState mRawKeyboardState;
private final AccessibilityManager mAccessibilityManager; private final AccessibilityManager mAccessibilityManager;
private BroadcastReceiver discoveryReceiver; private BroadcastReceiver discoveryReceiver;
private List<ActivityLifecycleListener> mActivityLifecycleListeners; private List<ActivityLifecycleListener> mActivityLifecycleListeners;
...@@ -142,7 +138,6 @@ public class FlutterView extends SurfaceView ...@@ -142,7 +138,6 @@ public class FlutterView extends SurfaceView
getHolder().addCallback(mSurfaceCallback); getHolder().addCallback(mSurfaceCallback);
mKeyboardState = new KeyboardViewState(this); mKeyboardState = new KeyboardViewState(this);
mRawKeyboardState = new RawKeyboardServiceState();
Core core = CoreImpl.getInstance(); Core core = CoreImpl.getInstance();
...@@ -173,6 +168,8 @@ public class FlutterView extends SurfaceView ...@@ -173,6 +168,8 @@ public class FlutterView extends SurfaceView
private void encodeKeyEvent(KeyEvent event, JSONObject message) throws JSONException { private void encodeKeyEvent(KeyEvent event, JSONObject message) throws JSONException {
message.put("flags", event.getFlags()); message.put("flags", event.getFlags());
message.put("codePoint", event.getUnicodeChar());
message.put("keyCode", event.getKeyCode());
message.put("scanCode", event.getScanCode()); message.put("scanCode", event.getScanCode());
message.put("metaState", event.getMetaState()); message.put("metaState", event.getMetaState());
} }
...@@ -188,8 +185,6 @@ public class FlutterView extends SurfaceView ...@@ -188,8 +185,6 @@ public class FlutterView extends SurfaceView
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG, "Failed to serialize key event", e); Log.e(TAG, "Failed to serialize key event", e);
} }
// TODO(abarth): Remove once clients are moved over to platform messages.
mRawKeyboardState.onKey(this, keyCode, event);
return true; return true;
} }
...@@ -204,7 +199,6 @@ public class FlutterView extends SurfaceView ...@@ -204,7 +199,6 @@ public class FlutterView extends SurfaceView
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG, "Failed to serialize key event", e); Log.e(TAG, "Failed to serialize key event", e);
} }
mRawKeyboardState.onKey(this, keyCode, event);
return true; return true;
} }
...@@ -469,13 +463,6 @@ public class FlutterView extends SurfaceView ...@@ -469,13 +463,6 @@ public class FlutterView extends SurfaceView
} }
}); });
registry.register(RawKeyboardService.MANAGER.getName(), new ServiceFactory() {
@Override
public Binding connectToService(FlutterView view, Core core, MessagePipeHandle pipe) {
return RawKeyboardService.MANAGER.bind(new RawKeyboardServiceImpl(mRawKeyboardState), pipe);
}
});
registry.register(ApplicationMessages.MANAGER.getName(), new ServiceFactory() { registry.register(ApplicationMessages.MANAGER.getName(), new ServiceFactory() {
@Override @Override
public Binding connectToService(FlutterView view, Core core, MessagePipeHandle pipe) { public Binding connectToService(FlutterView view, Core core, MessagePipeHandle pipe) {
......
...@@ -19,7 +19,6 @@ executable("linux") { ...@@ -19,7 +19,6 @@ executable("linux") {
"//base", "//base",
"//flutter/common", "//flutter/common",
"//flutter/services/engine:interfaces", "//flutter/services/engine:interfaces",
"//flutter/services/raw_keyboard:interfaces",
"//flutter/shell/common", "//flutter/shell/common",
"//flutter/shell/gpu", "//flutter/shell/gpu",
"//flutter/shell/testing", "//flutter/shell/testing",
......
/// Copyright 2016 The Chromium Authors. All rights reserved.
/// Use of this source code is governed by a BSD-style license that can be
/// found in the LICENSE file.
import 'package:sky_services/raw_keyboard/raw_keyboard.mojom.dart';
export 'package:sky_services/raw_keyboard/raw_keyboard.mojom.dart';
...@@ -25,6 +25,5 @@ dart_pkg("sky_services") { ...@@ -25,6 +25,5 @@ dart_pkg("sky_services") {
":copy_sky_services_license", ":copy_sky_services_license",
"//flutter/services/editing:interfaces", "//flutter/services/editing:interfaces",
"//flutter/services/platform:interfaces", "//flutter/services/platform:interfaces",
"//flutter/services/raw_keyboard:interfaces",
] ]
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册