3131 */
3232package com .smartdevicelink .protocol ;
3333
34- import android .os .Parcel ;
35- import android .os .Parcelable ;
36-
3734import com .livio .BSON .BsonEncoder ;
3835import com .smartdevicelink .protocol .enums .FrameType ;
3936import com .smartdevicelink .transport .utl .TransportRecord ;
40- import com .smartdevicelink .util .DebugTool ;
4137
4238import java .nio .ByteBuffer ;
4339import java .util .HashMap ;
4743 * Any other binder transactions must include an additional int flag into their bundle or the parsing
4844 * of this object will fail.
4945 */
50- public class SdlPacket implements Parcelable {
46+ class BaseSdlPacket {
5147
5248 /**
5349 * This is the amount of bytes added to the bundle from the router service for a specific int
@@ -122,9 +118,9 @@ public class SdlPacket implements Parcelable{
122118 int messagingVersion = 1 ;
123119 TransportRecord transportRecord ;
124120
125- public SdlPacket (int version , boolean encryption , int frameType ,
126- int serviceType , int frameInfo , int sessionId ,
127- int dataSize , int messageId , byte [] payload ) {
121+ BaseSdlPacket (int version , boolean encryption , int frameType ,
122+ int serviceType , int frameInfo , int sessionId ,
123+ int dataSize , int messageId , byte [] payload ) {
128124 this .version = version ;
129125 this .encryption = encryption ;
130126 this .frameType = frameType ;
@@ -140,9 +136,9 @@ public SdlPacket(int version, boolean encryption, int frameType,
140136 }
141137 }
142138
143- public SdlPacket (int version , boolean encryption , int frameType ,
144- int serviceType , int frameInfo , int sessionId ,
145- int dataSize , int messageId , byte [] payload , int offset ,int bytesToWrite ) {
139+ BaseSdlPacket (int version , boolean encryption , int frameType ,
140+ int serviceType , int frameInfo , int sessionId ,
141+ int dataSize , int messageId , byte [] payload , int offset , int bytesToWrite ) {
146142 this .version = version ;
147143 this .encryption = encryption ;
148144 this .frameType = frameType ;
@@ -166,7 +162,7 @@ public SdlPacket(int version, boolean encryption, int frameType,
166162 * <p>Frame Info
167163 * <p>
168164 */
169- protected SdlPacket (){
165+ protected BaseSdlPacket (){
170166 //Package only empty constructor
171167 this .version = 1 ;
172168 this .encryption = false ;
@@ -183,7 +179,7 @@ protected SdlPacket(){
183179 * Creates a new packet based on previous packet definitions. Will not copy payload.
184180 * @param packet an instance of the packet that should be copied.
185181 */
186- protected SdlPacket ( SdlPacket packet ){
182+ protected BaseSdlPacket ( BaseSdlPacket packet ){
187183 this .version = packet .version ;
188184 this .encryption = packet .encryption ;
189185 this .frameType = packet .frameType ;
@@ -359,92 +355,6 @@ public String toString() {
359355 public void setMessagingVersion (int version ){
360356 this .messagingVersion = version ;
361357 }
362-
363-
364-
365- /* ***************************************************************************************************************************************************
366- * *********************************************************** Parceable Overrides *****************************************************************
367- *****************************************************************************************************************************************************/
368-
369-
370-
371- //I think this is FIFO...right?
372- public SdlPacket (Parcel p ) {
373- this .version = p .readInt ();
374- this .encryption = (p .readInt () == 0 ) ? false : true ;
375- this .frameType = p .readInt ();
376- this .serviceType = p .readInt ();
377- this .frameInfo = p .readInt ();
378- this .sessionId = p .readInt ();
379- this .dataSize = p .readInt ();
380- this .messageId = p .readInt ();
381- if (p .readInt () == 1 ){ //We should have a payload attached
382- payload = new byte [dataSize ];
383- p .readByteArray (payload );
384- }
385-
386- this .priorityCoefficient = p .readInt ();
387-
388- if (p .dataAvail () > EXTRA_PARCEL_DATA_LENGTH ) { //See note on constant for why not 0
389- try {
390- messagingVersion = p .readInt ();
391- if (messagingVersion >= 2 ) {
392- if (p .readInt () == 1 ) { //We should have a transport type attached
393- this .transportRecord = (TransportRecord ) p .readParcelable (TransportRecord .class .getClassLoader ());
394- }
395- }
396- }catch (RuntimeException e ){
397- DebugTool .logError ("Error creating packet from parcel" , e );
398- }
399- }
400- }
401-
402-
403- @ Override
404- public int describeContents () {
405- return 0 ;
406- }
407-
408- @ Override
409- public void writeToParcel (Parcel dest , int flags ) {
410-
411- dest .writeInt (version );
412- dest .writeInt (encryption ? 1 : 0 );
413- dest .writeInt (frameType );
414- dest .writeInt (serviceType );
415- dest .writeInt (frameInfo );
416- dest .writeInt (sessionId );
417- dest .writeInt (dataSize );
418- dest .writeInt (messageId );
419- dest .writeInt (payload !=null ? 1 : 0 );
420- if (payload !=null ){
421- dest .writeByteArray (payload );
422- }
423- dest .writeInt (priorityCoefficient );
424-
425- ///Additions after initial creation
426- if (messagingVersion > 1 ){
427- dest .writeInt (messagingVersion );
428-
429- dest .writeInt (transportRecord !=null ? 1 : 0 );
430- if (transportRecord != null ){
431- dest .writeParcelable (transportRecord ,0 );
432- }
433- }
434-
435- }
436-
437- public static final Parcelable .Creator <SdlPacket > CREATOR = new Parcelable .Creator <SdlPacket >() {
438- public SdlPacket createFromParcel (Parcel in ) {
439- return new SdlPacket (in );
440- }
441-
442- @ Override
443- public SdlPacket [] newArray (int size ) {
444- return new SdlPacket [size ];
445- }
446-
447- };
448358
449359 public void putTag (String tag , Object data ){
450360 if (bsonPayload == null ){
0 commit comments