summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Grover <joeygrover@gmail.com>2018-11-19 11:56:52 -0500
committerJoey Grover <joeygrover@gmail.com>2018-11-19 11:56:52 -0500
commitc850edb54857d329b7da454c923d2248c3efa26a (patch)
treecee359e543327f22f94bbb9f66941d080da9b8e0
parentd1c588d27a8abcee222f8104a88ec3d7cc9acdd7 (diff)
downloadsdl_android-c850edb54857d329b7da454c923d2248c3efa26a.tar.gz
Added comments explaining SdlParcket Parcel bug
Add comments to explain how 24 extra bytes appear when parsing the SdlPacket. This is going to have ot be an known issue to support legacy router services.
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java27
-rw-r--r--sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java23
2 files changed, 39 insertions, 11 deletions
diff --git a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
index eff296c20..b635ab3f5 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
@@ -8,10 +8,23 @@ import com.smartdevicelink.protocol.enums.FrameType;
import com.smartdevicelink.transport.utl.TransportRecord;
import android.os.Parcel;
+import android.os.ParcelFormatException;
import android.os.Parcelable;
+/**
+ * This class is only intended to be parcelable from the transport broker to the SDL Router Service.
+ * Any other binder transactions must include an additional int flag into their bundle or the parsing
+ * of this object will fail.
+ */
public class SdlPacket implements Parcelable{
+ /**
+ * This is the amount of bytes added to the bundle from the router service for a specific int
+ * flag; this data will always and must be included. This flag is the
+ * TransportConstants.BYTES_TO_SEND_FLAGS.
+ *
+ * @see com.smartdevicelink.transport.TransportConstants#BYTES_TO_SEND_FLAGS
+ */
private static final int EXTRA_PARCEL_DATA_LENGTH = 24;
public static final int HEADER_SIZE = 12;
@@ -340,12 +353,16 @@ public class SdlPacket implements Parcelable{
this.priorityCoefficient = p.readInt();
- if(p.dataAvail() > EXTRA_PARCEL_DATA_LENGTH) {
- messagingVersion = p.readInt();
- if(messagingVersion >= 2) {
- if (p.readInt() == 1) { //We should have a transport type attached
- this.transportRecord = p.readParcelable(TransportRecord.class.getClassLoader());
+ if(p.dataAvail() > EXTRA_PARCEL_DATA_LENGTH) { //See note on constant for why not 0
+ try {
+ messagingVersion = p.readInt();
+ if (messagingVersion >= 2) {
+ if (p.readInt() == 1) { //We should have a transport type attached
+ this.transportRecord = p.readParcelable(TransportRecord.class.getClassLoader());
+ }
}
+ }catch (ParcelFormatException e){
+
}
}
}
diff --git a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
index 50c5b5412..a6069c8e1 100644
--- a/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
+++ b/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java
@@ -2037,10 +2037,16 @@ public class SdlRouterService extends Service{
if(packetSize < ByteArrayMessageSpliter.MAX_BINDER_SIZE){ //This is a small enough packet just send on through
//Log.w(TAG, " Packet size is just right " + packetSize + " is smaller than " + ByteArrayMessageSpliter.MAX_BINDER_SIZE + " = " + (packetSize<ByteArrayMessageSpliter.MAX_BINDER_SIZE));
message.what = TransportConstants.ROUTER_RECEIVED_PACKET;
- packet.setMessagingVersion(app.routerMessagingVersion);
+
+ // !!!! ADD ADDITIONAL ITEMS TO BUNDLE HERE !!!
+
+ packet.setMessagingVersion(app.routerMessagingVersion);
bundle.putParcelable(FORMED_PACKET_EXTRA_NAME, packet);
- bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_NONE);
- message.setData(bundle);
+ /* !!!!!! DO NOT ADD ANY ADDITIONAL ITEMS TO THE BUNDLE AFTER PACKET. ONLY BYTES_TO_SEND_FLAG !!!!!!!*/
+ bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_NONE);
+ /* !!!!!! DO NOT ADD ANY ADDITIONAL ITEMS TO THE BUNDLE AFTER PACKET. ONLY BYTES_TO_SEND_FLAG !!!!!!!*/
+
+ message.setData(bundle);
return sendPacketMessageToClient(app,message, version);
}else{
//Log.w(TAG, "Packet too big for IPC buffer. Breaking apart and then sending to client.");
@@ -2051,9 +2057,14 @@ public class SdlRouterService extends Service{
packet.getServiceType(),packet.getFrameInfo(), session,
(int)packet.getDataSize(),packet.getMessageId(),null);
message.what = TransportConstants.ROUTER_RECEIVED_PACKET;
- bundle.putParcelable(FORMED_PACKET_EXTRA_NAME, copyPacket);
- bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_SDL_PACKET_INCLUDED);
- message.setData(bundle);
+ // !!!! ADD ADDITIONAL ITEMS TO BUNDLE HERE !!!
+
+ bundle.putParcelable(FORMED_PACKET_EXTRA_NAME, copyPacket);
+ /* !!!!!! DO NOT ADD ANY ADDITIONAL ITEMS TO THE BUNDLE AFTER PACKET. ONLY BYTES_TO_SEND_FLAG !!!!!!!*/
+ bundle.putInt(TransportConstants.BYTES_TO_SEND_FLAGS, TransportConstants.BYTES_TO_SEND_FLAG_SDL_PACKET_INCLUDED);
+ /* !!!!!! DO NOT ADD ANY ADDITIONAL ITEMS TO THE BUNDLE AFTER PACKET. ONLY BYTES_TO_SEND_FLAG !!!!!!!*/
+
+ message.setData(bundle);
//Log.d(TAG, "First packet before sending: " + message.getData().toString());
if(!sendPacketMessageToClient(app, message, version)){
Log.w(TAG, "Error sending first message of split packet to client " + app.appId);