From 1470099d337b4eadcc0135f8f96a3e6061492b9d Mon Sep 17 00:00:00 2001 From: mislead <867986737@qq.com> Date: Fri, 27 May 2016 10:09:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9=E4=BA=86DebugC?= =?UTF-8?q?onnection.java=EF=BC=8C=E5=8F=AF=E4=BB=A5=E8=AE=BE=E7=BD=AEDEVI?= =?UTF-8?q?CE=5FLOACALHOST=EF=BC=8C=E8=BF=99=E6=A0=B7=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E7=9C=9F=E6=9C=BA=E8=B0=83=E8=AF=95=E3=80=82?= =?UTF-8?q?=202=E3=80=81=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AAlog?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E6=96=B9=E6=B3=95=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=8F=91=E9=80=81log=E4=BF=A1=E6=81=AF=E5=88=B0LuaViewDebugger?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 要进行真机调试Android项目可以在Application或者是Activity的onCreate()中进行设置如下代码: LuaViewConfig.setDebug(true); LuaViewConfig.setOpenDebugger(true); DebugConnection.setDeviceLocalhost("your pc ip"); 在Activity中设置要在LuaView创建之前设置。 --- .../taobao/luaview/debug/DebugConnection.java | 6 +++++- .../com/taobao/luaview/vm/extend/BaseLib.java | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Android/LuaViewSDK/src/com/taobao/luaview/debug/DebugConnection.java b/Android/LuaViewSDK/src/com/taobao/luaview/debug/DebugConnection.java index 4b9fa275..b87ee15d 100644 --- a/Android/LuaViewSDK/src/com/taobao/luaview/debug/DebugConnection.java +++ b/Android/LuaViewSDK/src/com/taobao/luaview/debug/DebugConnection.java @@ -14,13 +14,17 @@ public class DebugConnection extends Socket { private static final String EMULATOR_LOCALHOST = "10.0.2.2"; private static final String GENYMOTION_LOCALHOST = "10.0.3.2"; - private static final String DEVICE_LOCALHOST = "localhost"; + private static String DEVICE_LOCALHOST = "localhost"; private static final int PORT = 9876; private DataInputStream input = null; private DataOutputStream output = null; public boolean sendingEnabled = true; + + public static void setDeviceLocalhost(String deviceLocalhost) { + DEVICE_LOCALHOST = deviceLocalhost; + } private static String getDebugServerHost() { // Since genymotion runs in vbox it use different hostname to refer to adb host. diff --git a/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java b/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java index 1a7a14eb..46a984c0 100644 --- a/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java +++ b/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java @@ -26,6 +26,7 @@ public BaseLib(org.luaj.vm2.lib.BaseLib baseLib, Globals globals) { public void extend(LuaValue env) { env.set("printLV", new printLV(baseLib)); + env.set("log", new log(baseLib)); } // "print", // (...) -> void @@ -56,4 +57,22 @@ public Varargs invoke(Varargs args) { return NONE; } } + + // "log(fileName, messsage)", send log info to LuaViewDebugger + final class log extends TwoArgFunction { + final org.luaj.vm2.lib.BaseLib baseLib; + + public log(org.luaj.vm2.lib.BaseLib baseLib) { + this.baseLib = baseLib; + } + + @Override public LuaValue call(LuaValue arg1, LuaValue arg2) { + String fileName = arg1.checkjstring(); + if (globals.debugConnection != null) { + globals.debugConnection.sendCmd("log", fileName, arg2.checkjstring()); + } + LogUtil.i(arg2); + return NONE; + } + } } From 089ef9f6f9c2ba08e1bfdf04e981303c1eb1d558 Mon Sep 17 00:00:00 2001 From: mislead <867986737@qq.com> Date: Fri, 27 May 2016 10:13:23 +0800 Subject: [PATCH 2/2] log-> printLog --- .../src/com/taobao/luaview/vm/extend/BaseLib.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java b/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java index 46a984c0..acfc55f8 100644 --- a/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java +++ b/Android/LuaViewSDK/src/com/taobao/luaview/vm/extend/BaseLib.java @@ -26,7 +26,7 @@ public BaseLib(org.luaj.vm2.lib.BaseLib baseLib, Globals globals) { public void extend(LuaValue env) { env.set("printLV", new printLV(baseLib)); - env.set("log", new log(baseLib)); + env.set("printLog", new printLog(baseLib)); } // "print", // (...) -> void @@ -58,8 +58,8 @@ public Varargs invoke(Varargs args) { } } - // "log(fileName, messsage)", send log info to LuaViewDebugger - final class log extends TwoArgFunction { + // "printLog(fileName, messsage)", send log info to LuaViewDebugger + final class printLog extends TwoArgFunction { final org.luaj.vm2.lib.BaseLib baseLib; public log(org.luaj.vm2.lib.BaseLib baseLib) {