From 1f0431ae8cd94c7ff3b0883ddf27d4555f169333 Mon Sep 17 00:00:00 2001 From: Kurt Nelson Date: Tue, 30 Sep 2014 12:48:00 -0700 Subject: [PATCH 1/5] Specific lib versions --- WearScript/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WearScript/build.gradle b/WearScript/build.gradle index 00410f71..73884bea 100644 --- a/WearScript/build.gradle +++ b/WearScript/build.gradle @@ -30,8 +30,8 @@ android { dependencies { compile 'com.android.support:support-v4:20.0.0' - compile 'com.android.support:support-v13:20.0.+' - compile 'com.crittercism:crittercism-android-agent:+' + compile 'com.android.support:support-v13:20.0.0' + compile 'com.crittercism:crittercism-android-agent:4.5.3' compile 'de.greenrobot:eventbus:2.2.0' compile 'com.polysfactory.lib.glass.bluetooth:glass-bluetooth:0.1.2' compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7.6@aar' From e0d49208be5af55cfb57ac975e521c7594920bb7 Mon Sep 17 00:00:00 2001 From: Kurt Nelson Date: Tue, 30 Sep 2014 13:34:05 -0700 Subject: [PATCH 2/5] Break apart connection --- .../managers/ConnectionManager.java | 10 +- .../wearscript/network/SocketController.java | 158 ++++++++++++ .../{ => network}/WearScriptConnection.java | 243 +++--------------- 3 files changed, 200 insertions(+), 211 deletions(-) create mode 100644 WearScript/src/main/java/com/dappervision/wearscript/network/SocketController.java rename WearScript/src/main/java/com/dappervision/wearscript/{ => network}/WearScriptConnection.java (54%) diff --git a/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java b/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java index f7b3a4c1..095b4c74 100644 --- a/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java +++ b/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java @@ -6,7 +6,7 @@ import com.dappervision.wearscript.HardwareDetector; import com.dappervision.wearscript.Log; import com.dappervision.wearscript.Utils; -import com.dappervision.wearscript.WearScriptConnection; +import com.dappervision.wearscript.network.WearScriptConnection; import com.dappervision.wearscript.events.ChannelSubscribeEvent; import com.dappervision.wearscript.events.ChannelUnsubscribeEvent; import com.dappervision.wearscript.events.GistSyncEvent; @@ -23,7 +23,6 @@ import org.json.simple.JSONValue; import org.msgpack.MessagePack; import org.msgpack.type.Value; -import org.msgpack.util.json.JSON; import java.util.List; import java.util.TreeMap; @@ -210,6 +209,7 @@ class WearScriptConnectionImpl extends WearScriptConnection { @Override public void onConnect() { + super.onConnect(); makeCall(ONCONNECT, ""); // NOTE(brandyn): This ensures that we are only calling the function once unregisterCallback(ONCONNECT); @@ -227,6 +227,7 @@ private TreeMap toMap(Value map) { @Override public void onReceive(String channel, byte[] dataRaw, List data) { + super.onReceive(channel, dataRaw, data); // BUG(brandyn): If the channel should go to a subchannel now it won't make it, // we should modify channel name before this call makeCall(channel, "'" + Base64.encodeToString(dataRaw, Base64.NO_WRAP) + "'"); @@ -343,10 +344,5 @@ public void onReceive(String channel, byte[] dataRaw, List data) { Utils.eventBusPost(new WarpHEvent(h)); } } - - @Override - public void onDisconnect() { - - } } } diff --git a/WearScript/src/main/java/com/dappervision/wearscript/network/SocketController.java b/WearScript/src/main/java/com/dappervision/wearscript/network/SocketController.java new file mode 100644 index 00000000..b90736df --- /dev/null +++ b/WearScript/src/main/java/com/dappervision/wearscript/network/SocketController.java @@ -0,0 +1,158 @@ +package com.dappervision.wearscript.network; + +import com.codebutler.android_websockets.WebSocketClient; +import com.dappervision.wearscript.Log; + +import org.apache.http.message.BasicNameValuePair; +import org.msgpack.MessagePack; +import org.msgpack.type.Value; +import org.msgpack.type.ValueFactory; + +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Queue; +import java.util.concurrent.SynchronousQueue; + +import static org.msgpack.template.Templates.TValue; +import static org.msgpack.template.Templates.tList; + +public class SocketController { + private static final String TAG = "SocketController"; + + private static MessagePack mMsgpack = new MessagePack(); + + private WebSocketClient mSocketClient; + private Listener mListener; + private boolean mConnected, mInUse; + private Queue mBuffer; + + public SocketController(URI uri) { + mInUse = true; + mConnected = false; + mBuffer = new SynchronousQueue(); + List extraHeaders = Arrays.asList(); + mSocketClient = new WebSocketClient(uri, mLocalListener, extraHeaders); + mSocketClient.connect(); + } + + public void send(byte[] msg) { + if(isConnected()) { + mSocketClient.send(msg); + }else { + mBuffer.add(msg); + } + } + + public boolean isConnected() { + return mConnected; + } + + public void disconnect() { + mInUse = false; + mBuffer.clear(); + mSocketClient.disconnect(); + mSocketClient.getHandlerThread().quit(); + } + + public void setListener(Listener listener) { + mListener = listener; + } + + private void reconnect() { + mSocketClient.connect(); + } + + private WebSocketClient.Listener mLocalListener = new WebSocketClient.Listener() { + @Override + public void onConnect() { + mConnected = true; + while(!mBuffer.isEmpty()) { + mSocketClient.send(mBuffer.poll()); + } + if(mInUse && mListener != null) { + mListener.onConnect(); + } + } + + @Override + public void onMessage(String s) { + // Unused + } + + @Override + public void onDisconnect(int i, String s) { + Log.w(TAG, "Lifecycle: Underlying socket disconnected: i: " + i + " s: " + s); + mConnected = false; + if(mInUse) { + mListener.onDisconnect(); + reconnect(); + } + } + + @Override + public void onError(Exception e) { + Log.w(TAG, "Lifecycle: Underlying socket errored: " + e.getLocalizedMessage()); + mConnected = false; + if(mInUse) { + mListener.onDisconnect(); + reconnect(); + } + } + + @Override + public void onMessage(byte[] message) { + if (!mInUse) return; + try { + handleMessage(message); + } catch (Exception e) { + Log.e(TAG, String.format("onMessage: %s", e.toString())); + } + } + + private void handleMessage(byte[] message) throws IOException { + String channel = ""; + List input = mMsgpack.read(message, tList(TValue)); + channel = input.get(0).asRawValue().getString(); + Log.d(TAG, String.format("Got %s", channel)); + + mListener.onMessage(channel, message, input); + } + }; + + interface Listener { + + void onConnect(); + + void onDisconnect(); + + void onMessage(String channel, byte[] message, List input); + } + + public static byte[] encode(Object... data) { + List out = new ArrayList(); + for (Object i : data) { + Class c = i.getClass(); + if (c.equals(String.class)) + out.add(ValueFactory.createRawValue((String) i)); + else if (c.equals(Double.class)) + out.add(ValueFactory.createFloatValue((Double) i)); + else if (Value.class.isAssignableFrom(c)) + out.add((Value) i); + else if (c.equals(Boolean.class)) + out.add(ValueFactory.createBooleanValue((Boolean) i)); + else { + android.util.Log.e(TAG, "Unhandled class: " + c); + return null; + } + } + try { + return mMsgpack.write(out); + } catch (IOException e) { + android.util.Log.e(TAG, "Could not encode msgpack"); + } + return null; + } +} diff --git a/WearScript/src/main/java/com/dappervision/wearscript/WearScriptConnection.java b/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java similarity index 54% rename from WearScript/src/main/java/com/dappervision/wearscript/WearScriptConnection.java rename to WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java index eba58205..23326c9b 100644 --- a/WearScript/src/main/java/com/dappervision/wearscript/WearScriptConnection.java +++ b/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java @@ -1,11 +1,8 @@ -package com.dappervision.wearscript; +package com.dappervision.wearscript.network; import android.util.Base64; import android.util.Log; -import com.codebutler.android_websockets.WebSocketClient; - -import org.apache.http.message.BasicNameValuePair; import org.msgpack.MessagePack; import org.msgpack.type.Value; import org.msgpack.type.ValueFactory; @@ -13,7 +10,7 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; + import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -22,28 +19,21 @@ import static org.msgpack.template.Templates.TValue; import static org.msgpack.template.Templates.tList; -public abstract class WearScriptConnection { +public abstract class WearScriptConnection implements SocketController.Listener { private static final String TAG = "WearScriptConnection"; private static final String LISTEN_CHAN = "subscriptions"; - private final int sleepTimeMax = 6000; - static MessagePack msgpack = new MessagePack(); + + private static MessagePack mMsgpack = new MessagePack(); + protected String device, group, groupDevice; - private WebSocketClient client; - private LocalListener listener; - private boolean shutdown; private URI uri; - private boolean connected; - private boolean callOnConnect; // deviceToChannels is always updated, then externalChannels is rebuilt private TreeMap> deviceToChannels; private TreeSet externalChannels; private TreeSet scriptChannels; - private boolean reconnecting; + private SocketController mSocket; public WearScriptConnection(String group, String device) { - shutdown = false; - callOnConnect = false; - reconnecting = false; this.group = group; this.device = device; groupDevice = channel(group, device); @@ -52,31 +42,6 @@ public WearScriptConnection(String group, String device) { pinger(); } - public static byte[] encode(Object... data) { - List out = new ArrayList(); - for (Object i : data) { - Class c = i.getClass(); - if (c.equals(String.class)) - out.add(ValueFactory.createRawValue((String) i)); - else if (c.equals(Double.class)) - out.add(ValueFactory.createFloatValue((Double) i)); - else if (Value.class.isAssignableFrom(c)) - out.add((Value) i); - else if (c.equals(Boolean.class)) - out.add(ValueFactory.createBooleanValue((Boolean) i)); - else { - Log.e(TAG, "Unhandled class: " + c); - return null; - } - } - try { - return msgpack.write(out); - } catch (IOException e) { - Log.e(TAG, "Could not encode msgpack"); - } - return null; - } - public static Value listValue(Iterable channels) { ArrayList channelsArray = new ArrayList(); for (String c : channels) @@ -93,11 +58,26 @@ public static Value mapValue(Map> data) { return ValueFactory.createMapValue(mapArray.toArray(new Value[mapArray.size()])); } - public abstract void onConnect(); + public void onConnect() { + publishChannels(); + } + + public void onReceive(String channel, byte[] dataRaw, List data) { + + } + + public void onDisconnect() { - public abstract void onReceive(String channel, byte[] dataRaw, List data); + } - public abstract void onDisconnect(); + public void onMessage(String channel, byte[] message, List input) { + if (channel.equals(LISTEN_CHAN)) { + String d = input.get(1).asRawValue().getString(); + Value[] channels = input.get(2).asArrayValue().getElementArray(); + setDeviceChannels(d, channels); + } + onReceiveDispatch(channel, message, input); + } private void onReceiveDispatch(String channel, byte[] dataRaw, List data) { String channelPart = existsInternal(channel); @@ -105,7 +85,7 @@ private void onReceiveDispatch(String channel, byte[] dataRaw, List data) Log.i(TAG, "ScriptChannel: " + channelPart); if (dataRaw != null && data == null) { try { - data = msgpack.read(dataRaw, tList(TValue)); + data = mMsgpack.read(dataRaw, tList(TValue)); } catch (IOException e) { Log.e(TAG, "Could not decode msgpack"); return; @@ -126,29 +106,23 @@ public void publish(Object... data) { return; Log.d(TAG, "Publishing...: " + channel); if (channel.equals(LISTEN_CHAN)) { - Log.d(TAG, "Channels: " + Base64.encodeToString(encode(data), Base64.NO_WRAP)); + Log.d(TAG, "Channels: " + Base64.encodeToString(SocketController.encode(data), Base64.NO_WRAP)); } - publish(channel, encode(data)); + publish(channel, SocketController.encode(data)); } public void publish(String channel, byte[] outBytes) { if (!exists(channel)) { - Log.d(TAG, String.format("Not publishing[%s] Client: %s outBytes: %s", channel, client != null, outBytes != null)); + Log.d(TAG, String.format("Not publishing[%s] Client: %s outBytes: %s", channel, mSocket != null, outBytes != null)); return; } if (outBytes != null) { onReceiveDispatch(channel, outBytes, null); - if (client != null && existsExternal(channel)) - client.send(outBytes); + if (mSocket != null && existsExternal(channel)) + mSocket.send(outBytes); } } - private Value oneStringArray(String channel) { - Value[] array = new Value[1]; - array[0] = ValueFactory.createRawValue(channel); - return ValueFactory.createArrayValue(array); - } - private Value channelsValue() { synchronized (this) { return listValue(scriptChannels); @@ -231,22 +205,15 @@ private void setDeviceChannels(String device, Value[] channels) { public void connect(URI uri) { Log.d(TAG, "Lifecycle: Connect called"); synchronized (this) { - if (shutdown) { - Log.w(TAG, "Trying to connect while shutdown"); - return; - } Log.i(TAG, uri.toString()); - if (uri.equals(this.uri) && connected) { + if (uri.equals(this.uri) && mSocket != null && mSocket.isConnected()) { onConnect(); return; } this.uri = uri; - List extraHeaders = Arrays.asList(); Log.i(TAG, "Lifecycle: Socket connecting"); - if (client != null) - client.disconnect(); - client = new WebSocketClient(uri, new LocalListener(), extraHeaders); - reconnect(); + mSocket = new SocketController(uri); + mSocket.setListener(this); } } @@ -316,24 +283,19 @@ public boolean exists(String channel) { } public void disconnect() { - if (client != null) - client.disconnect(); + mSocket.disconnect(); } public void shutdown() { - synchronized (this) { - this.shutdown = true; - disconnect(); - if (client != null) - client.getHandlerThread().getLooper().quit(); - } + disconnect(); + mSocket = null; } private void pinger() { new Thread(new Runnable() { public void run() { while (true) { - if (shutdown) + if (mSocket == null) return; Log.w(TAG, "Lifecycle: Pinger..."); publish(LISTEN_CHAN, WearScriptConnection.this.groupDevice, channelsValue()); @@ -346,7 +308,7 @@ public void run() { }).start(); } - private void publishChannels(int delay) { + private void publishChannels() { new Thread(new Runnable() { public void run() { Log.w(TAG, "Lifecycle: Pinger..."); @@ -359,131 +321,4 @@ public void run() { } }).start(); } - - private void reconnect() { - synchronized (this) { - if (shutdown) - return; - if (reconnecting) - return; - reconnecting = true; - } - new Thread(new Runnable() { - public void run() { - try { - int sleepTime = 1000; - while (true) { - Log.w(TAG, "Lifecycle: Trying to reconnect..."); - synchronized (WearScriptConnection.this) { - if (connected || shutdown) { - reconnecting = false; - break; - } - Log.w(TAG, "Lifecycle: Reconnecting..."); - // NOTE(brandyn): Reset channelToDevices, server will refresh on connect - resetExternalChannels(); - client.connect(); - } - try { - Thread.sleep(sleepTime); - } catch (InterruptedException e) { - } - sleepTime *= 2; - if (sleepTime > sleepTimeMax) { - sleepTime = sleepTimeMax; - } - } - } finally { - synchronized (WearScriptConnection.this) { - reconnecting = false; - // NOTE(brandyn): This ensures that we at least leave this thread with one of... - // 1.) socket connected (disconnect after this would trigger a reconnect) - // 2.) another thread that will try again - if (!connected && !shutdown) - reconnect(); - } - } - } - }).start(); - } - - private class LocalListener implements WebSocketClient.Listener { - - LocalListener() { - - } - - @Override - public void onConnect() { - if (shutdown) - return; - connected = true; - callOnConnect = true; - } - - @Override - public void onMessage(String s) { - // Unused - } - - @Override - public void onDisconnect(int i, String s) { - Log.w(TAG, "Lifecycle: Underlying socket disconnected: i: " + i + " s: " + s); - synchronized (this) { - connected = false; - callOnConnect = false; - if (shutdown) - return; - } - WearScriptConnection.this.onDisconnect(); - reconnect(); - } - - @Override - public void onError(Exception e) { - Log.w(TAG, "Lifecycle: Underlying socket errored: " + e.getLocalizedMessage()); - synchronized (this) { - connected = false; - callOnConnect = false; - if (shutdown) - return; - } - WearScriptConnection.this.onDisconnect(); - reconnect(); - } - - @Override - public void onMessage(byte[] message) { - if (shutdown) - return; - synchronized (this) { - try { - handleMessage(message); - } catch (Exception e) { - Log.e(TAG, String.format("onMessage: %s", e.toString())); - } - } - } - - private void handleMessage(byte[] message) throws IOException { - String channel = ""; - List input = msgpack.read(message, tList(TValue)); - channel = input.get(0).asRawValue().getString(); - Log.d(TAG, String.format("Got %s", channel)); - if (channel.equals(LISTEN_CHAN)) { - String d = input.get(1).asRawValue().getString(); - Value[] channels = input.get(2).asArrayValue().getElementArray(); - setDeviceChannels(d, channels); - if (callOnConnect) { - callOnConnect = false; - Log.i(TAG, "Lifecycle: Calling server callback"); - //publish(LISTEN_CHAN, groupDevice, channelsValue()); - WearScriptConnection.this.onConnect(); - publishChannels(500); - } - } - WearScriptConnection.this.onReceiveDispatch(channel, message, input); - } - } - } From 38e763d973bf9e433917326a4846c1fc9cb4fd1e Mon Sep 17 00:00:00 2001 From: Kurt Nelson Date: Tue, 30 Sep 2014 13:42:16 -0700 Subject: [PATCH 3/5] Move into interface --- .../managers/ConnectionManager.java | 20 ++++--- .../network/WearScriptConnection.java | 57 +++++++++++-------- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java b/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java index 095b4c74..2e98b823 100644 --- a/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java +++ b/WearScript/src/main/java/com/dappervision/wearscript/managers/ConnectionManager.java @@ -209,25 +209,18 @@ class WearScriptConnectionImpl extends WearScriptConnection { @Override public void onConnect() { - super.onConnect(); makeCall(ONCONNECT, ""); // NOTE(brandyn): This ensures that we are only calling the function once unregisterCallback(ONCONNECT); } + @Override + protected void onDisconnect() { - private TreeMap toMap(Value map) { - TreeMap mapOut = new TreeMap(); - Value[] kv = map.asMapValue().getKeyValueArray(); - for (int i = 0; i < kv.length / 2; i++) { - mapOut.put(kv[i * 2].asRawValue().getString(), kv[i * 2 + 1]); - } - return mapOut; } @Override public void onReceive(String channel, byte[] dataRaw, List data) { - super.onReceive(channel, dataRaw, data); // BUG(brandyn): If the channel should go to a subchannel now it won't make it, // we should modify channel name before this call makeCall(channel, "'" + Base64.encodeToString(dataRaw, Base64.NO_WRAP) + "'"); @@ -345,4 +338,13 @@ public void onReceive(String channel, byte[] dataRaw, List data) { } } } + + private static TreeMap toMap(Value map) { + TreeMap mapOut = new TreeMap(); + Value[] kv = map.asMapValue().getKeyValueArray(); + for (int i = 0; i < kv.length / 2; i++) { + mapOut.put(kv[i * 2].asRawValue().getString(), kv[i * 2 + 1]); + } + return mapOut; + } } diff --git a/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java b/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java index 23326c9b..4e10fa5b 100644 --- a/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java +++ b/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java @@ -19,7 +19,7 @@ import static org.msgpack.template.Templates.TValue; import static org.msgpack.template.Templates.tList; -public abstract class WearScriptConnection implements SocketController.Listener { +public abstract class WearScriptConnection { private static final String TAG = "WearScriptConnection"; private static final String LISTEN_CHAN = "subscriptions"; @@ -58,26 +58,11 @@ public static Value mapValue(Map> data) { return ValueFactory.createMapValue(mapArray.toArray(new Value[mapArray.size()])); } - public void onConnect() { - publishChannels(); - } - - public void onReceive(String channel, byte[] dataRaw, List data) { + protected abstract void onReceive(String channel, byte[] dataRaw, List data); - } + protected abstract void onConnect(); - public void onDisconnect() { - - } - - public void onMessage(String channel, byte[] message, List input) { - if (channel.equals(LISTEN_CHAN)) { - String d = input.get(1).asRawValue().getString(); - Value[] channels = input.get(2).asArrayValue().getElementArray(); - setDeviceChannels(d, channels); - } - onReceiveDispatch(channel, message, input); - } + protected abstract void onDisconnect(); private void onReceiveDispatch(String channel, byte[] dataRaw, List data) { String channelPart = existsInternal(channel); @@ -213,7 +198,7 @@ public void connect(URI uri) { this.uri = uri; Log.i(TAG, "Lifecycle: Socket connecting"); mSocket = new SocketController(uri); - mSocket.setListener(this); + mSocket.setListener(mSocketListener); } } @@ -295,10 +280,11 @@ private void pinger() { new Thread(new Runnable() { public void run() { while (true) { - if (mSocket == null) - return; - Log.w(TAG, "Lifecycle: Pinger..."); - publish(LISTEN_CHAN, WearScriptConnection.this.groupDevice, channelsValue()); + if (mSocket == null) return; + Log.i(TAG, "Lifecycle: Pinger..."); + if(mSocket.isConnected()) { + publish(LISTEN_CHAN, WearScriptConnection.this.groupDevice, channelsValue()); + } try { Thread.sleep(60000); } catch (InterruptedException e) { @@ -321,4 +307,27 @@ public void run() { } }).start(); } + + private SocketController.Listener mSocketListener = new SocketController.Listener() { + @Override + public void onConnect() { + publishChannels(); + WearScriptConnection.this.onConnect(); + } + + @Override + public void onDisconnect() { + WearScriptConnection.this.onDisconnect(); + } + + @Override + public void onMessage(String channel, byte[] message, List input) { + if (channel.equals(LISTEN_CHAN)) { + String d = input.get(1).asRawValue().getString(); + Value[] channels = input.get(2).asArrayValue().getElementArray(); + setDeviceChannels(d, channels); + } + onReceiveDispatch(channel, message, input); + } + }; } From 259bb0947f468005a1e775397dee84d95a1770e7 Mon Sep 17 00:00:00 2001 From: Kurt Nelson Date: Tue, 30 Sep 2014 14:02:51 -0700 Subject: [PATCH 4/5] No more msgpack bleeding through --- .../wearscript/network/WearScriptConnection.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java b/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java index 4e10fa5b..79c1df05 100644 --- a/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java +++ b/WearScript/src/main/java/com/dappervision/wearscript/network/WearScriptConnection.java @@ -23,8 +23,6 @@ public abstract class WearScriptConnection { private static final String TAG = "WearScriptConnection"; private static final String LISTEN_CHAN = "subscriptions"; - private static MessagePack mMsgpack = new MessagePack(); - protected String device, group, groupDevice; private URI uri; // deviceToChannels is always updated, then externalChannels is rebuilt @@ -67,15 +65,6 @@ public static Value mapValue(Map> data) { private void onReceiveDispatch(String channel, byte[] dataRaw, List data) { String channelPart = existsInternal(channel); if (channelPart != null) { - Log.i(TAG, "ScriptChannel: " + channelPart); - if (dataRaw != null && data == null) { - try { - data = mMsgpack.read(dataRaw, tList(TValue)); - } catch (IOException e) { - Log.e(TAG, "Could not decode msgpack"); - return; - } - } onReceive(channelPart, dataRaw, data); } } From 605670a411ed07fc88282209d454dad5a49232ac Mon Sep 17 00:00:00 2001 From: Kurt Nelson Date: Tue, 7 Oct 2014 17:24:10 -0400 Subject: [PATCH 5/5] Travis Config --- .travis.yml | 2 ++ WearScript/build.gradle | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9c464db0..36a36efd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: android +script: ./gradlew build check android: components: + - build-tools-20.0.0 - build-tools-19.1.0 diff --git a/WearScript/build.gradle b/WearScript/build.gradle index 73884bea..8fea40bd 100644 --- a/WearScript/build.gradle +++ b/WearScript/build.gradle @@ -17,7 +17,7 @@ repositories { android { compileSdkVersion 19 - buildToolsVersion "19.1.0" + buildToolsVersion "20.0.0" defaultConfig { applicationId "com.dappervision.wearscript" @@ -26,6 +26,9 @@ android { versionCode 2 versionName "0.3.0" } + lintOptions { + abortOnError false + } } dependencies {