aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/src/main/java/org/connectbot/service/TerminalManager.java26
2 files changed, 12 insertions, 15 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 06facf9..9032374 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- ECDH would sometimes fail because the shared secret would be encoded
as a negative integer.
- DSA host key support was broken from the beginning of the v1.8 series.
+- Connections would sometimes close when leaving ConnectBot.
### Added
- More context is given for failures to connect via SSH which should
diff --git a/app/src/main/java/org/connectbot/service/TerminalManager.java b/app/src/main/java/org/connectbot/service/TerminalManager.java
index 928c5f5..3bf9841 100644
--- a/app/src/main/java/org/connectbot/service/TerminalManager.java
+++ b/app/src/main/java/org/connectbot/service/TerminalManager.java
@@ -476,16 +476,18 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
@Override
public IBinder onBind(Intent intent) {
- Log.i(TAG, "Someone bound to TerminalManager");
-
+ Log.i(TAG, "Someone bound to TerminalManager with " + bridges.size() + " bridges active");
+ keepServiceAlive();
setResizeAllowed(true);
+ return binder;
+ }
+ /**
+ * Make sure we stay running to maintain the bridges. Later {@link #stopNow} should be called to stop the service.
+ */
+ private void keepServiceAlive() {
stopIdleTimer();
-
- // Make sure we stay running to maintain the bridges
startService(new Intent(this, TerminalManager.class));
-
- return binder;
}
@Override
@@ -500,17 +502,14 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
@Override
public void onRebind(Intent intent) {
super.onRebind(intent);
-
+ Log.i(TAG, "Someone rebound to TerminalManager with " + bridges.size() + " bridges active");
+ keepServiceAlive();
setResizeAllowed(true);
-
- Log.i(TAG, "Someone rebound to TerminalManager");
-
- stopIdleTimer();
}
@Override
public boolean onUnbind(Intent intent) {
- Log.i(TAG, "Someone unbound from TerminalManager");
+ Log.i(TAG, "Someone unbound from TerminalManager with " + bridges.size() + " bridges active");
setResizeAllowed(true);
@@ -522,9 +521,6 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen
}
private class IdleTask extends TimerTask {
- /* (non-Javadoc)
- * @see java.util.TimerTask#run()
- */
@Override
public void run() {
Log.d(TAG, String.format("Stopping service after timeout of ~%d seconds", IDLE_TIMEOUT / 1000));