Fix osmo reconnect and give more information about exceptions
This commit is contained in:
parent
f324c6c263
commit
85a64d0d65
2 changed files with 24 additions and 6 deletions
|
@ -75,7 +75,7 @@ public class MainMenuActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
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.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
||||||
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
|
intent.setType("vnd.android.cursor.dir/email"); //$NON-NLS-1$
|
||||||
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
|
intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); //$NON-NLS-1$
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class OsMoThread {
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("Exception selecting socket", e);
|
log.info("Exception selecting socket", e);
|
||||||
cmd("ERROR HEARTBEAT" + e.getMessage(), true);
|
exc("ERROR HEARTBEAT : ", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (activeChannel != null && !activeChannel.isConnected()) {
|
if (activeChannel != null && !activeChannel.isConnected()) {
|
||||||
activeChannel = null;
|
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() {
|
private void stopChannel() {
|
||||||
if (activeChannel != null) {
|
if (activeChannel != null) {
|
||||||
try {
|
try {
|
||||||
|
@ -314,10 +322,14 @@ public class OsMoThread {
|
||||||
}
|
}
|
||||||
boolean processed = false;
|
boolean processed = false;
|
||||||
for (OsMoReactor o : listReactors) {
|
for (OsMoReactor o : listReactors) {
|
||||||
|
try {
|
||||||
if (o.acceptCommand(header, id, data, obj, this)) {
|
if (o.acceptCommand(header, id, data, obj, this)) {
|
||||||
processed = true;
|
processed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
exc("ERROR REACTOR:", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!processed) {
|
if (!processed) {
|
||||||
log.warn("Command not processed '" + cmd + "'");
|
log.warn("Command not processed '" + cmd + "'");
|
||||||
|
@ -385,11 +397,17 @@ public class OsMoThread {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (OsMoReactor s : listReactors) {
|
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) {
|
if (l != null) {
|
||||||
cmd(l, true);
|
cmd(l, true);
|
||||||
return ByteBuffer.wrap(prepareCommand(l).toString().getBytes("UTF-8"));
|
return ByteBuffer.wrap(prepareCommand(l).toString().getBytes("UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
final long interval = System.currentTimeMillis() - lastSendCommand;
|
final long interval = System.currentTimeMillis() - lastSendCommand;
|
||||||
if(interval > TIMEOUT_TO_PING) {
|
if(interval > TIMEOUT_TO_PING) {
|
||||||
|
|
Loading…
Reference in a new issue