diff options
author | Joey Grover <joeygrover@gmail.com> | 2016-10-24 13:54:53 -0400 |
---|---|---|
committer | Joey Grover <joeygrover@gmail.com> | 2016-10-24 13:54:53 -0400 |
commit | 72de52cb7583b02689c50ff35418f4742de59b85 (patch) | |
tree | 40a804a30fa078c2576a5615d9cdae9e4a6327f2 | |
parent | 954045c778531897665a974fc9f6ad67356c0697 (diff) | |
download | sdl_android-72de52cb7583b02689c50ff35418f4742de59b85.tar.gz |
Adding a flag to MultiplexBluetoothTransport to keep server socket alive post connection until stoppedbugfix/#338
-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; } |