diff --git a/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java b/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java index 70269da..b6cc51f 100644 --- a/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java +++ b/android/src/main/java/com/finogeeks/mop/api/mop/ExtensionApiModule.java @@ -6,6 +6,7 @@ import android.os.Looper; import android.util.Log; import com.finogeeks.lib.applet.client.FinAppClient; +import com.finogeeks.lib.applet.client.FinAppTrace; import com.finogeeks.mop.api.BaseApi; import com.finogeeks.mop.interfaces.ICallback; import com.finogeeks.mop.service.MopPluginService; @@ -22,6 +23,8 @@ import io.flutter.plugin.common.MethodChannel; public class ExtensionApiModule extends BaseApi { + private static final String TAG = "ExtensionApiModule"; + private Handler handler = new Handler(Looper.getMainLooper()); public ExtensionApiModule(Context context) { @@ -52,18 +55,33 @@ public class ExtensionApiModule extends BaseApi { @Override public void success(Object result) { String json = GsonUtil.gson.toJson(result); + FinAppTrace.d(ExtensionApiModule.TAG, "channel invokeMethod:" + name + + " success, result=" + result + ", json=" + json); JSONObject ret = null; - if (json != null && !json.equals("null")) + if (json != null && !json.equals("null")) { try { ret = new JSONObject(json); + if (ret.has("errMsg")) { + String errMsg = ret.getString("errMsg"); + if (errMsg.startsWith(name + ":fail")) { + iCallback.onFail(ret); + return; + } + } } catch (JSONException e) { e.printStackTrace(); } + } + iCallback.onSuccess(ret); } @Override public void error(String errorCode, String errorMessage, Object errorDetails) { + FinAppTrace.e(ExtensionApiModule.TAG, "channel invokeMethod:" + name + + " error, errorCode=" + errorCode + + ", errorMessage=" + errorMessage + + ", errorDetails=" + errorDetails); iCallback.onFail(); }