Skip to content

Commit 8b7d5ca

Browse files
committed
Fix feedback from review
1 parent 363dbca commit 8b7d5ca

5 files changed

Lines changed: 33 additions & 31 deletions

File tree

android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77

88
public class TransportRecord extends BaseTransportRecord implements Parcelable {
99

10-
private TransportType type;
11-
private String address;
12-
1310
public TransportRecord(TransportType transportType, String address) {
1411
super(transportType, address);
15-
this.type = transportType;
16-
this.address = address;
12+
}
13+
14+
public TransportRecord(Parcel p) {
15+
super(p);
1716
}
1817

1918
@Override
@@ -36,19 +35,7 @@ public void writeToParcel(Parcel dest, int flags) {
3635

3736
public static final Parcelable.Creator<TransportRecord> CREATOR = new Parcelable.Creator<TransportRecord>() {
3837
public TransportRecord createFromParcel(Parcel in) {
39-
TransportType type = null;
40-
String address = "";
41-
if (in.readInt() == 1) { //We should have a transport type attached
42-
String transportName = in.readString();
43-
if(transportName != null){
44-
type = TransportType.valueOf(transportName);
45-
}
46-
}
47-
48-
if (in.readInt() == 1) { //We should have a transport address attached
49-
address = in.readString();
50-
}
51-
return new TransportRecord(type, address);
38+
return new TransportRecord(in);
5239
}
5340

5441
@Override

base/src/main/java/com/smartdevicelink/protocol/BaseSdlPacket.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,9 @@
3131
*/
3232
package com.smartdevicelink.protocol;
3333

34-
import android.os.Parcel;
35-
import android.os.Parcelable;
36-
3734
import com.livio.BSON.BsonEncoder;
3835
import com.smartdevicelink.protocol.enums.FrameType;
3936
import com.smartdevicelink.transport.utl.TransportRecord;
40-
import com.smartdevicelink.util.DebugTool;
4137

4238
import java.nio.ByteBuffer;
4339
import java.util.HashMap;

base/src/main/java/com/smartdevicelink/transport/utl/BaseTransportRecord.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@
3232

3333
package com.smartdevicelink.transport.utl;
3434

35+
import android.os.Parcel;
3536
import com.smartdevicelink.transport.enums.TransportType;
3637

3738
class BaseTransportRecord{
3839

39-
private TransportType type;
40-
private String address;
40+
protected TransportType type;
41+
protected String address;
4142

4243
BaseTransportRecord(TransportType transportType, String address){
4344
this.type = transportType;
@@ -77,4 +78,17 @@ public String toString(){
7778
builder.append(address);
7879
return builder.toString();
7980
}
81+
82+
BaseTransportRecord(Parcel p) {
83+
if (p.readInt() == 1) { //We should have a transport type attached
84+
String transportName = p.readString();
85+
if(transportName != null){
86+
this.type = TransportType.valueOf(transportName);
87+
}
88+
}
89+
90+
if (p.readInt() == 1) { //We should have a transport address attached
91+
address = p.readString();
92+
}
93+
}
8094
}

javaSE/src/main/java/com/smartdevicelink/protocol/SdlPacket.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import android.os.Parcelable;
3636

3737
public class SdlPacket extends BaseSdlPacket {
38-
private static final int EXTRA_PARCEL_DATA_LENGTH = 24;
3938

4039
public SdlPacket(int version, boolean encryption, int frameType,
4140
int serviceType, int frameInfo, int sessionId,

javaSE/src/main/java/com/smartdevicelink/transport/utl/TransportRecord.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,14 @@
3636
import com.smartdevicelink.transport.enums.TransportType;
3737

3838
public class TransportRecord extends BaseTransportRecord {
39-
private TransportType type;
40-
private String address;
4139

4240
public TransportRecord(TransportType transportType, String address) {
4341
super(transportType, address);
44-
this.type = transportType;
45-
this.address = address;
4642
}
4743

4844
@Deprecated
4945
public TransportRecord(Parcel p) {
50-
super(null, "");
46+
super(p);
5147
}
5248

5349
@Deprecated
@@ -56,7 +52,17 @@ public int describeContents() {
5652
};
5753

5854
@Deprecated
59-
public void writeToParcel(Parcel dest, int flags) {}
55+
public void writeToParcel(Parcel dest, int flags) {
56+
dest.writeInt(type!=null? 1 : 0);
57+
if(type != null){
58+
dest.writeString(type.name());
59+
}
60+
61+
dest.writeInt(address !=null? 1 : 0);
62+
if(address != null){
63+
dest.writeString(address);
64+
}
65+
}
6066

6167
@Deprecated
6268
public static final Parcelable.Creator<TransportRecord> CREATOR = new Parcelable.Creator<TransportRecord>() {

0 commit comments

Comments
 (0)