From 85a64d0d65822b457ed4d136af089e6a154d750d Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 29 Sep 2014 23:35:20 +0300 Subject: [PATCH] Fix osmo reconnect and give more information about exceptions --- .../plus/activities/MainMenuActivity.java | 2 +- .../src/net/osmand/plus/osmo/OsMoThread.java | 28 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java index ea3afea27f..385fe9f31a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MainMenuActivity.java @@ -75,7 +75,7 @@ public class MainMenuActivity extends Activity { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_SEND); - intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osmand.app@gmail.com" }); //$NON-NLS-1$ + intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "osmand.app+crash@gmail.com" }); //$NON-NLS-1$ intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$ intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$ diff --git a/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java b/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java index b6730bc16b..c6c17ec752 100644 --- a/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java +++ b/OsmAnd/src/net/osmand/plus/osmo/OsMoThread.java @@ -165,7 +165,7 @@ public class OsMoThread { } } catch (Exception e) { log.info("Exception selecting socket", e); - cmd("ERROR HEARTBEAT" + e.getMessage(), true); + exc("ERROR HEARTBEAT : ", e); e.printStackTrace(); if (activeChannel != null && !activeChannel.isConnected()) { activeChannel = null; @@ -185,6 +185,14 @@ public class OsMoThread { } } + protected void exc(String header, Exception e) { + String eMsg = e.getMessage(); + if(e.getStackTrace() != null && e.getStackTrace().length > 0) { + eMsg += " " + e.getStackTrace()[0].toString(); + } + cmd(header + eMsg, true); + } + private void stopChannel() { if (activeChannel != null) { try { @@ -314,9 +322,13 @@ public class OsMoThread { } boolean processed = false; for (OsMoReactor o : listReactors) { - if (o.acceptCommand(header, id, data, obj, this)) { - processed = true; - break; + try { + if (o.acceptCommand(header, id, data, obj, this)) { + processed = true; + break; + } + } catch (Exception e) { + exc("ERROR REACTOR:", e); } } if (!processed) { @@ -385,11 +397,17 @@ public class OsMoThread { return null; } for (OsMoReactor s : listReactors) { - String l = s.nextSendCommand(this); + String l = null; + try { + l = s.nextSendCommand(this); + } catch (Exception e) { + exc("ERROR SENDER:", e); + } if (l != null) { cmd(l, true); return ByteBuffer.wrap(prepareCommand(l).toString().getBytes("UTF-8")); } + } final long interval = System.currentTimeMillis() - lastSendCommand; if(interval > TIMEOUT_TO_PING) {