summaryrefslogtreecommitdiff
path: root/base/src/main/java/com/smartdevicelink/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/com/smartdevicelink/protocol')
-rw-r--r--base/src/main/java/com/smartdevicelink/protocol/BaseSdlPacket.java (renamed from base/src/main/java/com/smartdevicelink/protocol/SdlPacket.java)108
-rw-r--r--base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java66
-rw-r--r--base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java49
-rw-r--r--base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java4
4 files changed, 70 insertions, 157 deletions
diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/base/src/main/java/com/smartdevicelink/protocol/BaseSdlPacket.java
index edc860a42..21362b53e 100644
--- a/base/src/main/java/com/smartdevicelink/protocol/SdlPacket.java
+++ b/base/src/main/java/com/smartdevicelink/protocol/BaseSdlPacket.java
@@ -31,13 +31,9 @@
*/
package com.smartdevicelink.protocol;
-import android.os.Parcel;
-import android.os.Parcelable;
-
import com.livio.BSON.BsonEncoder;
import com.smartdevicelink.protocol.enums.FrameType;
import com.smartdevicelink.transport.utl.TransportRecord;
-import com.smartdevicelink.util.DebugTool;
import java.nio.ByteBuffer;
import java.util.HashMap;
@@ -47,7 +43,7 @@ import java.util.HashMap;
* 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{
+class BaseSdlPacket {
/**
* 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{
int messagingVersion = 1;
TransportRecord transportRecord;
- public SdlPacket(int version, boolean encryption, int frameType,
- int serviceType, int frameInfo, int sessionId,
- int dataSize, int messageId, byte[] payload) {
+ BaseSdlPacket(int version, boolean encryption, int frameType,
+ int serviceType, int frameInfo, int sessionId,
+ int dataSize, int messageId, byte[] payload) {
this.version = version;
this.encryption = encryption;
this.frameType = frameType;
@@ -140,9 +136,9 @@ public class SdlPacket implements Parcelable{
}
}
- public SdlPacket(int version, boolean encryption, int frameType,
- int serviceType, int frameInfo, int sessionId,
- int dataSize, int messageId, byte[] payload, int offset,int bytesToWrite) {
+ BaseSdlPacket(int version, boolean encryption, int frameType,
+ int serviceType, int frameInfo, int sessionId,
+ int dataSize, int messageId, byte[] payload, int offset, int bytesToWrite) {
this.version = version;
this.encryption = encryption;
this.frameType = frameType;
@@ -166,7 +162,7 @@ public class SdlPacket implements Parcelable{
* <p>Frame Info
* <p>
*/
- protected SdlPacket(){
+ protected BaseSdlPacket(){
//Package only empty constructor
this.version = 1;
this.encryption = false;
@@ -183,7 +179,7 @@ public class SdlPacket implements Parcelable{
* Creates a new packet based on previous packet definitions. Will not copy payload.
* @param packet an instance of the packet that should be copied.
*/
- protected SdlPacket(SdlPacket packet){
+ protected BaseSdlPacket(BaseSdlPacket packet){
this.version = packet.version;
this.encryption = packet.encryption;
this.frameType = packet.frameType;
@@ -359,92 +355,6 @@ public class SdlPacket implements Parcelable{
public void setMessagingVersion(int version){
this.messagingVersion = version;
}
-
-
-
- /* ***************************************************************************************************************************************************
- * *********************************************************** Parceable Overrides *****************************************************************
- *****************************************************************************************************************************************************/
-
-
-
- //I think this is FIFO...right?
- public SdlPacket(Parcel p) {
- this.version = p.readInt();
- this.encryption = (p.readInt() == 0) ? false : true;
- this.frameType = p.readInt();
- this.serviceType = p.readInt();
- this.frameInfo = p.readInt();
- this.sessionId = p.readInt();
- this.dataSize = p.readInt();
- this.messageId = p.readInt();
- if(p.readInt() == 1){ //We should have a payload attached
- payload = new byte[dataSize];
- p.readByteArray(payload);
- }
-
- this.priorityCoefficient = p.readInt();
-
- 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 = (TransportRecord) p.readParcelable(TransportRecord.class.getClassLoader());
- }
- }
- }catch (RuntimeException e){
- DebugTool.logError("Error creating packet from parcel", e);
- }
- }
- }
-
-
- @Override
- public int describeContents() {
- return 0;
- }
-
- @Override
- public void writeToParcel(Parcel dest, int flags) {
-
- dest.writeInt(version);
- dest.writeInt(encryption? 1 : 0);
- dest.writeInt(frameType);
- dest.writeInt(serviceType);
- dest.writeInt(frameInfo);
- dest.writeInt(sessionId);
- dest.writeInt(dataSize);
- dest.writeInt(messageId);
- dest.writeInt(payload!=null? 1 : 0);
- if(payload!=null){
- dest.writeByteArray(payload);
- }
- dest.writeInt(priorityCoefficient);
-
- ///Additions after initial creation
- if(messagingVersion > 1){
- dest.writeInt(messagingVersion);
-
- dest.writeInt(transportRecord!=null? 1 : 0);
- if(transportRecord != null){
- dest.writeParcelable(transportRecord,0);
- }
- }
-
- }
-
- public static final Parcelable.Creator<SdlPacket> CREATOR = new Parcelable.Creator<SdlPacket>() {
- public SdlPacket createFromParcel(Parcel in) {
- return new SdlPacket(in);
- }
-
- @Override
- public SdlPacket[] newArray(int size) {
- return new SdlPacket[size];
- }
-
- };
public void putTag(String tag, Object data){
if(bsonPayload == null){
diff --git a/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java b/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java
index da6682918..ebf0353bc 100644
--- a/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java
+++ b/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java
@@ -1,39 +1,39 @@
-/*
- * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided with the
- * distribution.
- *
- * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
+/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.protocol;
-import android.util.Log;
import com.smartdevicelink.util.BitConverter;
+import com.smartdevicelink.util.DebugTool;
public class BinaryFrameHeader {
private static final String TAG = "BinaryFrameHeader";
@@ -76,7 +76,7 @@ public class BinaryFrameHeader {
msg.setBulkData(_bulkData);
}
} catch (OutOfMemoryError|ArrayIndexOutOfBoundsException e){
- Log.e(TAG, "Unable to process data to form header");
+ DebugTool.logError(TAG, "Unable to process data to form header");
return null;
}
diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java
index db342de39..1468f9477 100644
--- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java
+++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java
@@ -32,7 +32,6 @@
package com.smartdevicelink.protocol;
import android.support.annotation.NonNull;
-import android.util.Log;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
@@ -237,7 +236,7 @@ public class SdlProtocolBase {
activeTransportString.append("\n");
}
}
- Log.d(TAG, activeTransportString.toString());
+ DebugTool.logInfo(TAG, activeTransportString.toString());
}
protected void printSecondaryTransportDetails(List<String> secondary, List<Integer> audio, List<Integer> video){
@@ -251,7 +250,7 @@ public class SdlProtocolBase {
}
secondaryDetailsBldr.append("\n");
}else{
- Log.d(TAG, "Supported secondary transports list is empty!");
+ DebugTool.logInfo(TAG, "Supported secondary transports list is empty!");
}
if(audio != null){
secondaryDetailsBldr.append("Supported audio transports: ");
@@ -268,7 +267,7 @@ public class SdlProtocolBase {
secondaryDetailsBldr.append("\n");
}
- Log.d(TAG, secondaryDetailsBldr.toString());
+ DebugTool.logInfo(TAG, secondaryDetailsBldr.toString());
}
@@ -299,7 +298,7 @@ public class SdlProtocolBase {
private void handleSecondaryTransportRegistration(TransportRecord transportRecord, boolean registered){
if(registered) {
//Session has been registered on secondary transport
- Log.d(TAG, transportRecord.getType().toString() + " transport was registered!");
+ DebugTool.logInfo(TAG, transportRecord.getType().toString() + " transport was registered!");
if (supportedSecondaryTransports.contains(transportRecord.getType())) {
// If the transport type that is now available to be used it should be checked
// against the list of services that might be able to be started on it
@@ -325,7 +324,7 @@ public class SdlProtocolBase {
}
}
}else{
- Log.d(TAG, transportRecord.toString() + " transport was NOT registered!");
+ DebugTool.logInfo(TAG, transportRecord.toString() + " transport was NOT registered!");
}
//Notify any listeners for this secondary transport
List<ISecondaryTransportListener> listenerList = secondaryTransportListeners.remove(transportRecord.getType());
@@ -345,7 +344,7 @@ public class SdlProtocolBase {
}
private void onTransportsConnectedUpdate(List<TransportRecord> transports){
- //Log.d(TAG, "Connected transport update");
+ //DebugTool.logInfo(TAG, "Connected transport update");
//Temporary: this logic should all be changed to handle multiple transports of the same type
ArrayList<TransportType> connectedTransports = new ArrayList<>();
@@ -783,7 +782,7 @@ public class SdlProtocolBase {
header.setTransportRecord(connectedPrimaryTransport);
handlePacketToSend(header);
}else{
- Log.d(TAG, "Failed to connect secondary transport, threw away StartService");
+ DebugTool.logInfo(TAG, "Failed to connect secondary transport, threw away StartService");
}
}
};
@@ -799,13 +798,13 @@ public class SdlProtocolBase {
listenerList.add(secondaryListener);
transportManager.requestSecondaryTransportConnection(sessionID, secondaryTransportParams.get(secondaryTransportType));
} else {
- Log.w(TAG, "No params to connect to secondary transport");
+ DebugTool.logWarning(TAG, "No params to connect to secondary transport");
//Unable to register or start a secondary connection. Use the callback in case
//there is a chance to use the primary transport for this service.
secondaryListener.onConnectionFailure();
}
} else {
- Log.e(TAG, "transportManager is null");
+ DebugTool.logError(TAG, "transportManager is null");
}
}
@@ -877,7 +876,7 @@ public class SdlProtocolBase {
builder.append(rejectedParam);
builder.append(" ");
}
- DebugTool.logWarning(builder.toString());
+ DebugTool.logWarning(TAG, builder.toString());
}
}
@@ -999,7 +998,7 @@ public class SdlProtocolBase {
notifyDevTransportListener();
} else {
- DebugTool.logInfo("Received a start service ack for RPC service while already active on a different transport.");
+ DebugTool.logInfo(TAG, "Received a start service ack for RPC service while already active on a different transport.");
iSdlProtocol.onProtocolSessionStarted(serviceType, (byte) packet.getSessionId(), (byte)protocolVersion.getMajor(), "", hashID, packet.isEncrypted());
return;
}
@@ -1098,7 +1097,7 @@ public class SdlProtocolBase {
builder.append(rejectedParam);
builder.append(" ");
}
- DebugTool.logWarning(builder.toString());
+ DebugTool.logWarning(TAG, builder.toString());
}
}
@@ -1145,7 +1144,7 @@ public class SdlProtocolBase {
@Override
public void onTransportConnected(List<TransportRecord> connectedTransports) {
- Log.d(TAG, "onTransportConnected");
+ DebugTool.logInfo(TAG, "onTransportConnected");
//In the future we should move this logic into the Protocol Layer
TransportRecord transportRecord = getTransportForSession(SessionType.RPC);
if(transportRecord == null && !requestedSession){ //There is currently no transport registered
@@ -1163,14 +1162,14 @@ public class SdlProtocolBase {
@Override
public void onTransportDisconnected(String info, TransportRecord disconnectedTransport, List<TransportRecord> connectedTransports) {
if (disconnectedTransport == null) {
- Log.d(TAG, "onTransportDisconnected");
+ DebugTool.logInfo(TAG, "onTransportDisconnected");
if (transportManager != null) {
transportManager.close(iSdlProtocol.getSessionId());
}
iSdlProtocol.shutdown("No transports left connected");
return;
} else {
- Log.d(TAG, "onTransportDisconnected - " + disconnectedTransport.getType().name());
+ DebugTool.logInfo(TAG, "onTransportDisconnected - " + disconnectedTransport.getType().name());
}
//In the future we will actually compare the record but at this point we can assume only
@@ -1193,7 +1192,7 @@ public class SdlProtocolBase {
boolean primaryTransportAvailable = false;
if(requestedPrimaryTransports != null && requestedPrimaryTransports.size() > 1){
for (TransportType transportType: requestedPrimaryTransports){
- DebugTool.logInfo( "Checking " + transportType.name());
+ DebugTool.logInfo(TAG, "Checking " + transportType.name());
if(!disconnectedTransport.getType().equals(transportType)
&& transportManager != null
@@ -1210,7 +1209,7 @@ public class SdlProtocolBase {
&& requestedSecondaryTransports != null
&& supportedSecondaryTransports != null) {
for (TransportType secondaryTransport : requestedSecondaryTransports) {
- DebugTool.logInfo("Checking secondary " + secondaryTransport.name());
+ DebugTool.logInfo(TAG, "Checking secondary " + secondaryTransport.name());
if (supportedSecondaryTransports.contains(secondaryTransport)) {
//Should only be USB or TCP
highBandwidthAvailable = true;
@@ -1258,11 +1257,11 @@ public class SdlProtocolBase {
//Await a connection from the legacy transport
if(requestedPrimaryTransports!= null && requestedPrimaryTransports.contains(TransportType.BLUETOOTH)
&& !SdlProtocolBase.this.requiresHighBandwidth){
- Log.d(TAG, "Entering legacy mode; creating new protocol instance");
+ DebugTool.logInfo(TAG, "Entering legacy mode; creating new protocol instance");
reset();
return true;
}else{
- Log.d(TAG, "Bluetooth is not an acceptable transport; not moving to legacy mode");
+ DebugTool.logInfo(TAG, "Bluetooth is not an acceptable transport; not moving to legacy mode");
return false;
}
}
@@ -1283,7 +1282,7 @@ public class SdlProtocolBase {
try {
accumulator = new ByteArrayOutputStream(totalSize);
}catch(OutOfMemoryError e){
- DebugTool.logError("OutOfMemory error", e); //Garbled bits were received
+ DebugTool.logError(TAG, "OutOfMemory error", e); //Garbled bits were received
accumulator = null;
}
}
@@ -1321,7 +1320,7 @@ public class SdlProtocolBase {
try {
iSdlProtocol.onProtocolMessageReceived(message);
} catch (Exception excp) {
- DebugTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp);
+ DebugTool.logError(TAG, FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp);
} // end-catch
accumulator = null;
@@ -1374,7 +1373,7 @@ public class SdlProtocolBase {
private void handleProtocolHeartbeatACK(SdlPacket packet) {
//Heartbeat is not supported in the SdlProtocol class beyond responding with ACKs to
//heartbeat messages. Receiving this ACK is suspicious and should be logged
- DebugTool.logInfo("Received HeartbeatACK - " + packet.toString());
+ DebugTool.logInfo(TAG, "Received HeartbeatACK - " + packet.toString());
}
private void handleProtocolHeartbeat(SdlPacket packet) {
@@ -1427,7 +1426,7 @@ public class SdlProtocolBase {
} else if (frameInfo == FrameDataControlFrameType.RegisterSecondaryTransportNACK.getValue()) {
String reason = (String) packet.getTag(ControlFrameTags.RPC.RegisterSecondaryTransportNAK.REASON);
- DebugTool.logWarning(reason);
+ DebugTool.logWarning(TAG, reason);
handleSecondaryTransportRegistration(packet.getTransportRecord(),false);
} else if (frameInfo == FrameDataControlFrameType.TransportEventUpdate.getValue()) {
@@ -1492,7 +1491,7 @@ public class SdlProtocolBase {
try {
iSdlProtocol.onProtocolMessageReceived(message);
} catch (Exception ex) {
- DebugTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex);
+ DebugTool.logError(TAG, FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex);
handleProtocolError(FailurePropagating_Msg + "onProtocolMessageReceived: ", ex);
} // end-catch
} // end-method
diff --git a/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java b/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
index b82443414..928f0dade 100644
--- a/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
+++ b/base/src/main/java/com/smartdevicelink/protocol/enums/FunctionID.java
@@ -133,9 +133,13 @@ public enum FunctionID{
ON_SYSTEM_CAPABILITY_UPDATED(32787, "OnSystemCapabilityUpdated"),
// MOCKED FUNCTIONS (NOT SENT FROM HEAD-UNIT)
+ @Deprecated
ON_LOCK_SCREEN_STATUS(-1, "OnLockScreenStatus"),
+ @Deprecated
ON_SDL_CHOICE_CHOSEN(-1, "OnSdlChoiceChosen"),
+ @Deprecated
ON_STREAM_RPC(-1, "OnStreamRPC"),
+ @Deprecated
STREAM_RPC(-1, "StreamRPC"),
;