Log errors returned from method channel invocations in the text input plugin (flutter/engine#7476)
See https://github.com/flutter/flutter/issues/25715
This commit is contained in:
@@ -424,6 +424,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ActivityL
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/BasicMessageChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/BinaryCodec.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/BinaryMessenger.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/ErrorLogResult.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/EventChannel.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/FlutterException.java
|
||||
FILE: ../../../flutter/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java
|
||||
|
||||
@@ -111,6 +111,7 @@ java_library("flutter_shell_java") {
|
||||
"io/flutter/plugin/common/BasicMessageChannel.java",
|
||||
"io/flutter/plugin/common/BinaryCodec.java",
|
||||
"io/flutter/plugin/common/BinaryMessenger.java",
|
||||
"io/flutter/plugin/common/ErrorLogResult.java",
|
||||
"io/flutter/plugin/common/EventChannel.java",
|
||||
"io/flutter/plugin/common/FlutterException.java",
|
||||
"io/flutter/plugin/common/JSONMessageCodec.java",
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// 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.common;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* An implementation of {@link MethodChannel.Result} that writes error results
|
||||
* to the Android log.
|
||||
*/
|
||||
public class ErrorLogResult implements MethodChannel.Result {
|
||||
private String tag;
|
||||
private int level;
|
||||
|
||||
public ErrorLogResult(String tag) {
|
||||
this(tag, Log.WARN);
|
||||
}
|
||||
|
||||
public ErrorLogResult(String tag, int level) {
|
||||
this.tag = tag;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void success(@Nullable Object result) {}
|
||||
|
||||
@Override
|
||||
public void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) {
|
||||
String details = (errorDetails != null) ? " details: " + errorDetails : "";
|
||||
Log.println(level, tag, errorMessage + details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notImplemented() {
|
||||
Log.println(level, tag, "method not implemented");
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.view.KeyEvent;
|
||||
import android.view.inputmethod.BaseInputConnection;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import io.flutter.plugin.common.ErrorLogResult;
|
||||
import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.view.FlutterView;
|
||||
|
||||
@@ -25,6 +26,9 @@ class InputConnectionAdaptor extends BaseInputConnection {
|
||||
private int mBatchCount;
|
||||
private InputMethodManager mImm;
|
||||
|
||||
private static final MethodChannel.Result logger =
|
||||
new ErrorLogResult("FlutterTextInput");
|
||||
|
||||
public InputConnectionAdaptor(FlutterView view, int client,
|
||||
MethodChannel flutterChannel, Editable editable) {
|
||||
super(view, true);
|
||||
@@ -58,7 +62,7 @@ class InputConnectionAdaptor extends BaseInputConnection {
|
||||
state.put("composingBase", composingStart);
|
||||
state.put("composingExtent", composingEnd);
|
||||
mFlutterChannel.invokeMethod("TextInputClient.updateEditingState",
|
||||
Arrays.asList(mClient, state));
|
||||
Arrays.asList(mClient, state), logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -177,36 +181,36 @@ class InputConnectionAdaptor extends BaseInputConnection {
|
||||
// TODO(mattcarroll): is newline an appropriate action for "none"?
|
||||
case EditorInfo.IME_ACTION_NONE:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.newline"));
|
||||
Arrays.asList(mClient, "TextInputAction.newline"), logger);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_UNSPECIFIED:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.unspecified"));
|
||||
Arrays.asList(mClient, "TextInputAction.unspecified"), logger);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_GO:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.go"));
|
||||
Arrays.asList(mClient, "TextInputAction.go"), logger);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_SEARCH:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.search"));
|
||||
Arrays.asList(mClient, "TextInputAction.search"), logger);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_SEND:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.send"));
|
||||
Arrays.asList(mClient, "TextInputAction.send"), logger);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_NEXT:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.next"));
|
||||
Arrays.asList(mClient, "TextInputAction.next"), logger);
|
||||
break;
|
||||
case EditorInfo.IME_ACTION_PREVIOUS:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.previous"));
|
||||
Arrays.asList(mClient, "TextInputAction.previous"), logger);
|
||||
break;
|
||||
default:
|
||||
case EditorInfo.IME_ACTION_DONE:
|
||||
mFlutterChannel.invokeMethod("TextInputClient.performAction",
|
||||
Arrays.asList(mClient, "TextInputAction.done"));
|
||||
Arrays.asList(mClient, "TextInputAction.done"), logger);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user