summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2017-02-16 14:28:03 -0500
committerJoey Grover <joeygrover@gmail.com>2017-02-16 14:28:03 -0500
commit1f6f6a232009f02e632635adb4b0555f56747b5b (patch)
tree24c39d02b223c020d5f31949da5be193df4ce512
parent7a94cc908ae37ab4ee497abaf558f45218033fe3 (diff)
downloadsdl_android-1f6f6a232009f02e632635adb4b0555f56747b5b.tar.gz
StreamPacketizer will now use MTU if not encrypted session
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java8
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java7
2 files changed, 14 insertions, 1 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
index 09f029fca..1a9d051a6 100644
--- a/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
+++ b/sdl_android_lib/src/com/smartdevicelink/SdlConnection/SdlSession.java
@@ -105,6 +105,14 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList
return this._sdlConnection;
}
+ public int getMtu(){
+ if(this._sdlConnection!=null){
+ return this._sdlConnection.getWiProProtocol().getMtu();
+ }else{
+ return 0;
+ }
+ }
+
public void close() {
if (sdlSecurity != null)
{
diff --git a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
index a05fb9c52..a71da63f1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
+++ b/sdl_android_lib/src/com/smartdevicelink/streaming/StreamPacketizer.java
@@ -20,12 +20,17 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
private Object mPauseLock;
private boolean mPaused;
private boolean isServiceProtected = false;
+ private int bufferSize = BUFF_READ_SIZE;
public StreamPacketizer(IStreamListener streamListener, InputStream is, SessionType sType, byte rpcSessionID, SdlSession session) throws IOException {
super(streamListener, is, sType, rpcSessionID, session);
mPauseLock = new Object();
mPaused = false;
isServiceProtected = _session.isServiceProtected(_serviceType);
+ if(!isServiceProtected){ //If our service is encrypted we can only use 1024 as the max buffer size. If it's not, we can use the default MTU for the current session
+ bufferSize = _session.getMtu();
+ }
+ buffer = new byte[bufferSize];
}
public void start() throws IOException {
@@ -63,7 +68,7 @@ public class StreamPacketizer extends AbstractPacketizer implements Runnable{
}
}
- length = is.read(buffer, 0, BUFF_READ_SIZE);
+ length = is.read(buffer, 0, bufferSize);
if (length >= 0)
{