summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Kast <julian@livio.com>2021-04-19 10:16:32 -0400
committerJulian Kast <julian@livio.com>2021-04-19 10:16:32 -0400
commit5f448b03ea12d5f40cf39e871c87686a6527b2c7 (patch)
treed95a4df885aed19326daf691d9b35d38fd52759e
parent7b2edb1ab0f62fee73795409eadb14f9ba7b945b (diff)
parent75512263f50748901b99487e8eb1bcdd9e551fb8 (diff)
downloadsdl_android-bugfix/issue_1647.tar.gz
Merge branch 'develop' into bugfix/issue_1647bugfix/issue_1647
-rw-r--r--.gitmodules2
-rw-r--r--CHANGELOG.md5
-rw-r--r--README.md20
-rw-r--r--VERSION2
-rw-r--r--android/README.md4
-rwxr-xr-xandroid/hello_sdl_android/src/main/AndroidManifest.xml10
-rw-r--r--android/sdl_android/build.gradle3
-rw-r--r--android/sdl_android/libs/bson_java_port-release.aarbin64082 -> 0 bytes
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java8
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java16
-rw-r--r--android/sdl_android/src/main/java/com/smartdevicelink/util/IntegrationValidator.java6
-rw-r--r--base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java6
-rw-r--r--base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java120
-rw-r--r--base/src/main/java/com/smartdevicelink/transport/SdlPsm.java13
m---------generator/rpc_spec0
-rw-r--r--javaEE/javaEE/README.md6
-rw-r--r--javaSE/javaSE/README.md4
-rw-r--r--javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java2
18 files changed, 141 insertions, 86 deletions
diff --git a/.gitmodules b/.gitmodules
index f9c6cdfd3..cd0213164 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
[submodule "generator/rpc_spec"]
path = generator/rpc_spec
url = https://github.com/smartdevicelink/rpc_spec.git
- branch = develop
+ branch = master
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e9fc24953..09260926b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -51,6 +51,8 @@
## Bug Fixes:
+- [Multiframe encryption is not implemented correctly](https://github.com/smartdevicelink/sdl_java_suite/issues/1642)
+
- [Empty string bug with Menu Cell](https://github.com/smartdevicelink/sdl_java_suite/issues/1623)
- [CRC is not set for PutFile in FileManager](https://github.com/smartdevicelink/sdl_java_suite/issues/1622)
@@ -91,5 +93,8 @@
- [BitConverter NullPointerExeptions](https://github.com/smartdevicelink/sdl_java_suite/issues/193)
+- [HelloSDL JavaEE 5.1 updates](https://github.com/smartdevicelink/sdl_java_suite/issues/1639)
+
+
diff --git a/README.md b/README.md
index 9ca1f7014..47ffcc3f0 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,7 @@ Contents and timing for SDL Java Suite releases can be tracked on the [GitHub Pr
Additional information about recent and upcoming SDL Releases can be found in the [SDL Evolution README](https://github.com/smartdevicelink/sdl_evolution#recent-and-upcoming-releases).
## SmartDeviceLink Android
-[ ![Download Android](https://api.bintray.com/packages/smartdevicelink/sdl_android/sdl_android/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_android/sdl_android/_latestVersion)
+[ ![Download Android](https://api.bintray.com/packages/smartdevicelink/sdl_android/sdl_android/images/download.svg) ](https://search.maven.org/artifact/com.smartdevicelink/sdl_android/5.1.0/aar)
### Installation
@@ -39,14 +39,14 @@ To compile with the latest release of SDL Android, include the following in your
```sh
repositories {
- jcenter()
+ mavenCentral()
}
dependencies {
- implementation 'com.smartdevicelink:sdl_android:4.+'
+ implementation 'com.smartdevicelink:sdl_android:5.1.0'
}
```
-For Maven or Ivy snippets please look at [Bintray](https://bintray.com/smartdevicelink/sdl_android/sdl_android)
+For Maven or Ivy snippets please look at [Maven Central](https://search.maven.org/artifact/com.smartdevicelink/sdl_android)
#### Manually
@@ -67,7 +67,7 @@ Developers using Proguard to shrink and obfuscate their code should be sure to i
### JavaSE
-[ ![Download JavaSE](https://api.bintray.com/packages/smartdevicelink/sdl_java_se/sdl_javase/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_java_se/sdl_javase/_latestVersion)
+[ ![Download JavaSE](https://api.bintray.com/packages/smartdevicelink/sdl_java_se/sdl_javase/images/download.svg) ](https://search.maven.org/artifact/com.smartdevicelink/sdl_java_se/5.1.0/jar)
The JavaSE project is meant to allow SDL compatibility for embedded applications.
@@ -77,16 +77,16 @@ To compile with the latest release of SDL JavaSE, include the following in your
```sh
repositories {
- jcenter()
+ mavenCentral()
}
dependencies {
- implementation 'com.smartdevicelink:sdl_java_se:4.+'
+ implementation 'com.smartdevicelink:sdl_java_se:5.1.0'
}
```
### JavaEE
-[ ![Download JavaEE](https://api.bintray.com/packages/smartdevicelink/sdl_java_ee/sdl_javaee/images/download.svg) ](https://bintray.com/smartdevicelink/sdl_java_ee/sdl_javaee/_latestVersion)
+[ ![Download JavaEE](https://api.bintray.com/packages/smartdevicelink/sdl_java_ee/sdl_javaee/images/download.svg) ](https://search.maven.org/artifact/com.smartdevicelink/sdl_java_ee/5.1.0/jar)
The JavaEE project is meant to allow SDL compatibility for web applications.
@@ -96,10 +96,10 @@ To compile with the latest release of SDL JavaEE, include the following in your
```sh
repositories {
- jcenter()
+ mavenCentral()
}
dependencies {
- implementation 'com.smartdevicelink:sdl_java_ee:4.+'
+ implementation 'com.smartdevicelink:sdl_java_ee:5.1.0'
}
```
diff --git a/VERSION b/VERSION
index f3ef53f28..831446cbd 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-RC_5.1.0
+5.1.0
diff --git a/android/README.md b/android/README.md
index e6a89c85e..822534f98 100644
--- a/android/README.md
+++ b/android/README.md
@@ -10,10 +10,10 @@ To compile with the latest release of SDL Android, include the following in your
```
repositories {
- jcenter()
+ mavenCentral()
}
dependencies {
- implementation 'com.smartdevicelink:sdl_android:4.+'
+ implementation 'com.smartdevicelink:sdl_android:5.1.0'
}
```
diff --git a/android/hello_sdl_android/src/main/AndroidManifest.xml b/android/hello_sdl_android/src/main/AndroidManifest.xml
index 289b4c7e7..1183e7b2c 100755
--- a/android/hello_sdl_android/src/main/AndroidManifest.xml
+++ b/android/hello_sdl_android/src/main/AndroidManifest.xml
@@ -12,6 +12,16 @@
<!-- Required to use the USB Accessory mode -->
<uses-feature android:name="android.hardware.usb.accessory" />
+ <!-- Required when targeting Android API 30+ -->
+ <queries>
+ <intent>
+ <action android:name="com.smartdevicelink.router.service" />
+ </intent>
+ <intent>
+ <action android:name="sdl.router.startservice" />
+ </intent>
+ </queries>
+
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
diff --git a/android/sdl_android/build.gradle b/android/sdl_android/build.gradle
index 87c4aff1d..46c1221ba 100644
--- a/android/sdl_android/build.gradle
+++ b/android/sdl_android/build.gradle
@@ -41,8 +41,9 @@ android {
}
dependencies {
- api fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
+ api fileTree(dir: 'libs', include: ['*.jar'])
//api 'com.livio.taskmaster:taskmaster:0.4.0'
+ api 'com.smartdevicelink:bson_java_port:1.2.4'
api 'androidx.lifecycle:lifecycle-extensions:2.2.0'
api 'androidx.annotation:annotation:1.1.0'
annotationProcessor 'androidx.lifecycle:lifecycle-compiler:2.2.0'
diff --git a/android/sdl_android/libs/bson_java_port-release.aar b/android/sdl_android/libs/bson_java_port-release.aar
deleted file mode 100644
index 0da8ec686..000000000
--- a/android/sdl_android/libs/bson_java_port-release.aar
+++ /dev/null
Binary files differ
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
index c7a7ca92c..cce131baa 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java
@@ -117,6 +117,7 @@ public class VideoStreamManager extends BaseVideoStreamManager {
private String vehicleMake = null;
private boolean isEncrypted = false;
private boolean withPendingRestart = false;
+ private boolean wasCapabilityListenerAdded = false;
private AbstractPacketizer videoPacketizer;
// INTERNAL INTERFACES
@@ -188,7 +189,10 @@ public class VideoStreamManager extends BaseVideoStreamManager {
if (VideoStreamManager.this.parameters == null) {
getVideoStreamingParams();
}
- internalInterface.getSystemCapabilityManager().addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, systemCapabilityListener);
+ if (!wasCapabilityListenerAdded) {
+ wasCapabilityListenerAdded = true;
+ internalInterface.getSystemCapabilityManager().addOnSystemCapabilityListener(SystemCapabilityType.VIDEO_STREAMING, systemCapabilityListener);
+ }
}
checkState();
if (hasStarted && (isHMIStateVideoStreamCapable(prevOnHMIStatus)) && (!isHMIStateVideoStreamCapable(currentOnHMIStatus))) {
@@ -872,7 +876,7 @@ public class VideoStreamManager extends BaseVideoStreamManager {
if (capability.getDiagonalScreenSize() != null) {
double diagonal = capability.getDiagonalScreenSize();
if (range.getMinimumDiagonal() != null) {
- if (range.getMinimumDiagonal() <= 0.0 || range.getMinimumDiagonal() > diagonal) {
+ if (range.getMinimumDiagonal() < 0.0 || range.getMinimumDiagonal() > diagonal) {
return false;
}
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java
index 851be4c15..f8c4238c0 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java
@@ -133,14 +133,16 @@ public abstract class SdlRemoteDisplay extends Presentation {
@Override
public void run() {
try {
- Constructor<? extends ViewGroup.LayoutParams> ctor =
- mainView.getLayoutParams().getClass().getDeclaredConstructor(int.class, int.class);
- mainView.setLayoutParams(ctor.newInstance(newWidth, newHeight));
- mainView.requestLayout();
- invalidate();
- onViewResized(newWidth, newHeight);
+ if (mainView != null) {
+ Constructor<? extends ViewGroup.LayoutParams> ctor =
+ mainView.getLayoutParams().getClass().getDeclaredConstructor(int.class, int.class);
+ mainView.setLayoutParams(ctor.newInstance(newWidth, newHeight));
+ mainView.requestLayout();
+ invalidate();
+ onViewResized(newWidth, newHeight);
+ }
} catch (Exception e) {
- e.printStackTrace();
+ DebugTool.logError(TAG, "Exception thrown during view resize", e);
}
}
});
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/IntegrationValidator.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/IntegrationValidator.java
index 44e6bca2f..ba15ff4aa 100644
--- a/android/sdl_android/src/main/java/com/smartdevicelink/util/IntegrationValidator.java
+++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/IntegrationValidator.java
@@ -52,9 +52,6 @@ public class IntegrationValidator {
private static final char CHECK_MARK = 0x2713;
private static final char FAIL_MARK = 0x2715;
- //FIXME When the CI is stable with API 30 use Manifest.permission.QUERY_ALL_PACKAGES instead
- private static final String QUERY_ALL_PACKAGES = "android.permission.QUERY_ALL_PACKAGES";
-
public static final int FLAG_SKIP_ROUTER_SERVICE_CHECK = 0x01;
@@ -117,9 +114,6 @@ public class IntegrationValidator {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
permissionList.add(Manifest.permission.FOREGROUND_SERVICE);
}
- if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
- permissionList.add(QUERY_ALL_PACKAGES);
- }
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getApplicationContext().getPackageName(), PackageManager.GET_PERMISSIONS);
String[] permissionInfos = packageInfo.requestedPermissions;
diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
index d24ca4d98..4372cda9f 100644
--- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
+++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java
@@ -742,15 +742,17 @@ abstract class BaseScreenManager extends BaseSubManager {
* @return True if ButtonID's are good, False if not.
*/
static boolean checkAndAssignButtonIds(List<SoftButtonObject> softButtonObjects, @ManagerLocation int location) {
+ HashSet<Integer> buttonIdsSetHashSet = new HashSet<>();
// Depending on location form which the softButtons came from, we will clear out the id list so they can be reset
if (location == ManagerLocation.ALERT_MANAGER) {
softButtonIDByAlertManager.clear();
+ buttonIdsSetHashSet = (HashSet) softButtonIDBySoftButtonManager.clone();
} else if (location == ManagerLocation.SOFTBUTTON_MANAGER) {
softButtonIDBySoftButtonManager.clear();
+ buttonIdsSetHashSet = (HashSet) softButtonIDByAlertManager.clone();
}
// Check if multiple soft button objects have the same id
- HashSet<Integer> buttonIdsSetHashSet = new HashSet<>();
- int currentSoftButtonId, numberOfButtonIdsSet = 0, maxButtonIdsSetByDev = SOFT_BUTTON_ID_MIN_VALUE;
+ int currentSoftButtonId, numberOfButtonIdsSet = buttonIdsSetHashSet.size(), maxButtonIdsSetByDev = SOFT_BUTTON_ID_MIN_VALUE;
for (SoftButtonObject softButtonObject : softButtonObjects) {
currentSoftButtonId = softButtonObject.getButtonId();
diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java
index d9e437548..5cac1302c 100644
--- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java
+++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java
@@ -71,6 +71,10 @@ public class SdlProtocolBase {
private final static String FailurePropagating_Msg = "Failure propagating ";
private static final int TLS_MAX_RECORD_SIZE = 16384;
+ private final static int TLS_RECORD_HEADER_SIZE = 5;
+ private final static int TLS_RECORD_MES_AUTH_CDE_SIZE = 32;
+ private final static int TLS_MAX_RECORD_PADDING_SIZE = 256;
+ private final static int TLS_MAX_DATA_TO_ENCRYPT_SIZE = TLS_MAX_RECORD_SIZE - TLS_RECORD_HEADER_SIZE - TLS_RECORD_MES_AUTH_CDE_SIZE - TLS_MAX_RECORD_PADDING_SIZE;
private static final int PRIMARY_TRANSPORT_ID = 1;
private static final int SECONDARY_TRANSPORT_ID = 2;
@@ -561,7 +565,8 @@ public class SdlProtocolBase {
public void sendMessage(ProtocolMessage protocolMsg) {
SessionType sessionType = protocolMsg.getSessionType();
byte sessionID = protocolMsg.getSessionID();
-
+ boolean requiresEncryption = protocolMsg.getPayloadProtected();
+ SdlSecurityBase sdlSec = null;
byte[] data;
if (protocolVersion.getMajor() > 1 && sessionType != SessionType.NAV && sessionType != SessionType.PCM) {
if (sessionType.eq(SessionType.CONTROL)) {
@@ -590,21 +595,15 @@ public class SdlProtocolBase {
data = protocolMsg.getData();
}
- if (iSdlProtocol != null && protocolMsg.getPayloadProtected()) {
-
- if (data != null && data.length > 0) {
- byte[] dataToRead = new byte[TLS_MAX_RECORD_SIZE];
- SdlSecurityBase sdlSec = iSdlProtocol.getSdlSecurity();
- if (sdlSec == null)
- return;
-
- Integer iNumBytes = sdlSec.encryptData(data, dataToRead);
- if ((iNumBytes == null) || (iNumBytes <= 0))
- return;
-
- byte[] encryptedData = new byte[iNumBytes];
- System.arraycopy(dataToRead, 0, encryptedData, 0, iNumBytes);
- data = encryptedData;
+ if (requiresEncryption) {
+ if (iSdlProtocol == null) {
+ DebugTool.logError(TAG, "Unable to encrypt packet, protocol callback was null");
+ return;
+ }
+ sdlSec = iSdlProtocol.getSdlSecurity();
+ if (sdlSec == null) {
+ DebugTool.logError(TAG, "Unable to encrypt packet, security library not found");
+ return;
}
}
@@ -616,24 +615,26 @@ public class SdlProtocolBase {
return;
}
- synchronized (messageLock) {
- if (data != null && data.length > getMtu(sessionType)) {
+ //Set the MTU according to service MTU provided by the IVI .
+ //If encryption is required the MTU will be set to lowest value between the max data size for encryption or service MTU
+ final Long mtu = requiresEncryption ? Math.min(TLS_MAX_DATA_TO_ENCRYPT_SIZE, getMtu(sessionType)) : getMtu(sessionType);
+ synchronized (messageLock) {
+ if (data != null && data.length > mtu) {
+ //Since the packet is larger than the mtu size, it will be sent as a multi-frame packet
messageID++;
// Assemble first frame.
- Long mtu = getMtu(sessionType);
- int frameCount = Long.valueOf(data.length / mtu).intValue();
- if (data.length % mtu > 0) {
- frameCount++;
- }
+ int frameCount = (int) Math.ceil(data.length / (double) mtu);
+
byte[] firstFrameData = new byte[8];
// First four bytes are data size.
System.arraycopy(BitConverter.intToByteArray(data.length), 0, firstFrameData, 0, 4);
// Second four bytes are frame count.
System.arraycopy(BitConverter.intToByteArray(frameCount), 0, firstFrameData, 4, 4);
- SdlPacket firstHeader = SdlPacketFactory.createMultiSendDataFirst(sessionType, sessionID, messageID, (byte) protocolVersion.getMajor(), firstFrameData, protocolMsg.getPayloadProtected());
+ //NOTE: First frames cannot be encrypted because their payloads need to be exactly 8 bytes
+ SdlPacket firstHeader = SdlPacketFactory.createMultiSendDataFirst(sessionType, sessionID, messageID, (byte) protocolVersion.getMajor(), firstFrameData, false);
firstHeader.setPriorityCoefficient(1 + protocolMsg.priorityCoefficient);
firstHeader.setTransportRecord(activeTransports.get(sessionType));
//Send the first frame
@@ -642,33 +643,65 @@ public class SdlProtocolBase {
int currentOffset = 0;
byte frameSequenceNumber = 0;
+ byte[] dataBuffer, encryptedData;
for (int i = 0; i < frameCount; i++) {
- if (i < (frameCount - 1)) {
+
+ frameSequenceNumber++;
+
+ if (frameSequenceNumber == SdlPacket.FRAME_INFO_FINAL_CONNESCUTIVE_FRAME) {
+ //If sequence numbers roll over to 0, increment again to avoid
+ //using the reserved sequence value for the final frame
++frameSequenceNumber;
- if (frameSequenceNumber ==
- SdlPacket.FRAME_INFO_FINAL_CONNESCUTIVE_FRAME) {
- // we can't use 0x00 as frameSequenceNumber, because
- // it's reserved for the last frame
- ++frameSequenceNumber;
- }
- } else {
+ }
+
+ if (i == frameCount - 1) {
frameSequenceNumber = SdlPacket.FRAME_INFO_FINAL_CONNESCUTIVE_FRAME;
- } // end-if
+ }
int bytesToWrite = data.length - currentOffset;
if (bytesToWrite > mtu) {
bytesToWrite = mtu.intValue();
}
- SdlPacket consecHeader = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, bytesToWrite, frameSequenceNumber, messageID, (byte) protocolVersion.getMajor(), data, currentOffset, bytesToWrite, protocolMsg.getPayloadProtected());
- consecHeader.setTransportRecord(activeTransports.get(sessionType));
- consecHeader.setPriorityCoefficient(i + 2 + protocolMsg.priorityCoefficient);
- handlePacketToSend(consecHeader);
+
+ SdlPacket consecutiveFrame;
+ if (requiresEncryption) {
+ //Retrieve a chunk of the data into a temporary buffer to be encrypted
+ dataBuffer = new byte[bytesToWrite];
+ System.arraycopy(data, currentOffset, dataBuffer, 0, bytesToWrite);
+
+ encryptedData = new byte[TLS_MAX_RECORD_SIZE];
+ Integer numberOfBytesEncrypted = sdlSec.encryptData(dataBuffer, encryptedData);
+ if (numberOfBytesEncrypted == null || (numberOfBytesEncrypted <= 0)) {
+ DebugTool.logError(TAG, "Unable to encrypt data");
+ return;
+ }
+
+ consecutiveFrame = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, numberOfBytesEncrypted, frameSequenceNumber, messageID, (byte) protocolVersion.getMajor(), encryptedData, 0, numberOfBytesEncrypted, true);
+ } else {
+ consecutiveFrame = SdlPacketFactory.createMultiSendDataRest(sessionType, sessionID, bytesToWrite, frameSequenceNumber, messageID, (byte) protocolVersion.getMajor(), data, currentOffset, bytesToWrite, false);
+ }
+
+ consecutiveFrame.setTransportRecord(activeTransports.get(sessionType));
+ consecutiveFrame.setPriorityCoefficient(i + 2 + protocolMsg.priorityCoefficient);
+ handlePacketToSend(consecutiveFrame);
currentOffset += bytesToWrite;
}
} else {
messageID++;
+ if (requiresEncryption && data != null && data.length > 0) {
+ //Encrypt the data before sending
+ byte[] encryptedData = new byte[TLS_MAX_RECORD_SIZE];
+ Integer numberOfBytesEncrypted = sdlSec.encryptData(data, encryptedData);
+ if (numberOfBytesEncrypted == null || (numberOfBytesEncrypted <= 0)) {
+ DebugTool.logError(TAG, "Unable to encrypt data");
+ return;
+ }
+ //Put the encrypted bytes back into the data array
+ data = new byte[numberOfBytesEncrypted];
+ System.arraycopy(encryptedData, 0, data, 0, numberOfBytesEncrypted);
+ }
int dataLength = data != null ? data.length : 0;
- SdlPacket header = SdlPacketFactory.createSingleSendData(sessionType, sessionID, dataLength, messageID, (byte) protocolVersion.getMajor(), data, protocolMsg.getPayloadProtected());
+ SdlPacket header = SdlPacketFactory.createSingleSendData(sessionType, sessionID, dataLength, messageID, (byte) protocolVersion.getMajor(), data, requiresEncryption);
header.setPriorityCoefficient(protocolMsg.priorityCoefficient);
header.setTransportRecord(activeTransports.get(sessionType));
handlePacketToSend(header);
@@ -1374,16 +1407,17 @@ public class SdlProtocolBase {
if (packet.getPayload() != null && packet.getDataSize() > 0 && packet.isEncrypted()) {
SdlSecurityBase sdlSec = iSdlProtocol.getSdlSecurity();
- byte[] dataToRead = new byte[4096];
+ byte[] dataToRead = new byte[TLS_MAX_RECORD_SIZE];
- Integer iNumBytes = sdlSec.decryptData(packet.getPayload(), dataToRead);
- if ((iNumBytes == null) || (iNumBytes <= 0)) {
+ Integer numberOfDecryptedBytes = sdlSec.decryptData(packet.getPayload(), dataToRead);
+ if ((numberOfDecryptedBytes == null) || (numberOfDecryptedBytes <= 0)) {
return;
}
- byte[] decryptedData = new byte[iNumBytes];
- System.arraycopy(dataToRead, 0, decryptedData, 0, iNumBytes);
+ byte[] decryptedData = new byte[numberOfDecryptedBytes];
+ System.arraycopy(dataToRead, 0, decryptedData, 0, numberOfDecryptedBytes);
packet.payload = decryptedData;
+ packet.dataSize = numberOfDecryptedBytes;
}
if (packet.getFrameType().equals(FrameType.Control)) {
diff --git a/base/src/main/java/com/smartdevicelink/transport/SdlPsm.java b/base/src/main/java/com/smartdevicelink/transport/SdlPsm.java
index a142cebad..99510b061 100644
--- a/base/src/main/java/com/smartdevicelink/transport/SdlPsm.java
+++ b/base/src/main/java/com/smartdevicelink/transport/SdlPsm.java
@@ -61,14 +61,14 @@ public class SdlPsm {
private static final byte FIRST_FRAME_DATA_SIZE = 0x08;
private static final int VERSION_MASK = 0xF0; //4 highest bits
- private static final int COMPRESSION_MASK = 0x08; //4th lowest bit
+ private static final int ENCRYPTION_MASK = 0x08; //4th lowest bit
private static final int FRAME_TYPE_MASK = 0x07; //3 lowest bits
int state;
int version;
- boolean compression;
+ boolean encrypted;
int frameType;
int serviceType;
int controlFrameInfo;
@@ -97,7 +97,7 @@ public class SdlPsm {
if (version == 0) { //It should never be 0
return ERROR_STATE;
}
- compression = (1 == ((rawByte & (byte) COMPRESSION_MASK) >> 3));
+ encrypted = (1 == ((rawByte & (byte) ENCRYPTION_MASK) >> 3));
frameType = rawByte & (byte) FRAME_TYPE_MASK;
@@ -194,7 +194,10 @@ public class SdlPsm {
break;
case SdlPacket.FRAME_TYPE_FIRST:
- if (dataLength == FIRST_FRAME_DATA_SIZE) {
+ if (dataLength == FIRST_FRAME_DATA_SIZE || this.encrypted) {
+ //In a few production releases of core the first frame could be
+ //encrypted. Therefore it is not an error state if the first frame data
+ //length is greater than 8 in that case alone.
break;
}
default:
@@ -263,7 +266,7 @@ public class SdlPsm {
public SdlPacket getFormedPacket() {
if (state == FINISHED_STATE) {
//Log.trace(TAG, "Finished packet.");
- return new SdlPacket(version, compression, frameType,
+ return new SdlPacket(version, encrypted, frameType,
serviceType, controlFrameInfo, sessionId,
dataLength, messageId, payload);
} else {
diff --git a/generator/rpc_spec b/generator/rpc_spec
-Subproject 6b98355357b5b1893bbb59cb668d28545023457
+Subproject 72632f946941d63a57ee5e99896e3eae3627f7d
diff --git a/javaEE/javaEE/README.md b/javaEE/javaEE/README.md
index 8e7c3699d..24f921bc4 100644
--- a/javaEE/javaEE/README.md
+++ b/javaEE/javaEE/README.md
@@ -8,10 +8,10 @@ To compile with the latest release of SDL JavaSE, include the following in your
```sh
repositories {
- jcenter()
+ mavenCentral()
}
dependencies {
- implementation 'com.smartdevicelink:sdl_java_se:4.+'
+ implementation 'com.smartdevicelink:sdl_java_se:5.1.0'
}
```
@@ -22,4 +22,4 @@ If you prefer making a JAR, simply call:
```sh
gradle build
```
-from within the project and a JAR should be generated in the `build/libs` folder \ No newline at end of file
+from within the project and a JAR should be generated in the `build/libs` folder
diff --git a/javaSE/javaSE/README.md b/javaSE/javaSE/README.md
index e40e9ca4a..8198c8d77 100644
--- a/javaSE/javaSE/README.md
+++ b/javaSE/javaSE/README.md
@@ -8,10 +8,10 @@ To compile with the latest release of SDL JavaSE, include the following in your
```sh
repositories {
- jcenter()
+ mavenCentral()
}
dependencies {
- implementation 'com.smartdevicelink:sdl_java_se:4.+'
+ implementation 'com.smartdevicelink:sdl_java_se:5.1.0'
}
```
diff --git a/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java b/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java
index b256a6156..d3770a95c 100644
--- a/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java
+++ b/javaSE/javaSE/src/main/java/com/smartdevicelink/BuildConfig.java
@@ -32,5 +32,5 @@ package com.smartdevicelink;
// THIS FILE IS AUTO GENERATED, DO NOT MODIFY!!
public final class BuildConfig {
- public static final String VERSION_NAME = "RC_5.1.0";
+ public static final String VERSION_NAME = "5.1.0";
} \ No newline at end of file