diff options
author | Joey Grover <joeygrover@gmail.com> | 2016-11-03 10:08:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-03 10:08:39 -0400 |
commit | 43bcb357f37b248f9aa2c976e2de35eb1e74963a (patch) | |
tree | 3555d24673cdfe7c3f086ab84c6420a95f9b1a29 | |
parent | 952680d77a582bf265195c5dd0ef3f262e0b64c7 (diff) | |
parent | 72de52cb7583b02689c50ff35418f4742de59b85 (diff) | |
download | sdl_android-43bcb357f37b248f9aa2c976e2de35eb1e74963a.tar.gz |
Merge pull request #348 from smartdevicelink/bugfix/#338
Keep server socket alive until transport shutdown
-rw-r--r-- | sdl_android_lib/src/com/smartdevicelink/transport/MultiplexBluetoothTransport.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexBluetoothTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexBluetoothTransport.java index 95746b05a..f2ddf2a52 100644 --- a/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexBluetoothTransport.java +++ b/sdl_android_lib/src/com/smartdevicelink/transport/MultiplexBluetoothTransport.java @@ -90,7 +90,7 @@ public class MultiplexBluetoothTransport { //private BluetoothServerSocket serverSocket= null; - static boolean listening = false; + static boolean listening = false, keepSocketAlive = true; /** @@ -117,11 +117,17 @@ public class MultiplexBluetoothTransport { * Let's use this method from now on to get bluetooth service */ public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler){ + return getBluetoothSerialServerInstance(handler,true); + } + /* + * Let's use this method from now on to get bluetooth service + */ + public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(Handler handler, boolean keepSocketAlive){ if(serverInstance==null){ serverInstance = new MultiplexBluetoothTransport(handler); } - + MultiplexBluetoothTransport.keepSocketAlive = keepSocketAlive; return serverInstance; } public synchronized static MultiplexBluetoothTransport getBluetoothSerialServerInstance(){ @@ -159,6 +165,10 @@ public class MultiplexBluetoothTransport { return mState; } + public void setKeepSocketAlive(boolean keepSocketAlive){ + MultiplexBluetoothTransport.keepSocketAlive = keepSocketAlive; + } + /** * Start the chat service. Specifically start AcceptThread to begin a * session in listening (server) mode. Called by the Activity onResume() */ @@ -236,7 +246,7 @@ public class MultiplexBluetoothTransport { mConnectedWriteThread = null; } // Cancel the accept thread because we only want to connect to one device - if (getBluetoothSerialServerInstance().mSecureAcceptThread != null) { + if (!keepSocketAlive && getBluetoothSerialServerInstance().mSecureAcceptThread != null) { getBluetoothSerialServerInstance().mSecureAcceptThread.cancel(); getBluetoothSerialServerInstance().mSecureAcceptThread = null; } |