summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikayla Ray <mikayla@livioconnect.com>2015-06-25 15:56:04 -0400
committerMikayla Ray <mikayla@livioconnect.com>2015-06-25 15:56:04 -0400
commit83ce0d6fbd02867f08b4a0be8a8ac4629164df5b (patch)
tree2ef653c293989ea6458898e5a6d3ff6183ca3c63
parent894e0e3dc2a250147c6fed62ed590b1a15b09581 (diff)
downloadsdl_android-feature/issue_220.tar.gz
Removed XML encoded trace logging, replaced with human readable native trace logging.feature/issue_220
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java11
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java11
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxy.java31
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java118
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java194
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/DiagLevel.java52
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/ISTListener.java5
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/Mime.java65
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/OpenRPCMessage.java86
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java458
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java124
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/enums/DetailLevel.java16
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/enums/InterfaceActivityDirection.java7
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/trace/enums/Mod.java18
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java24
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java14
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java38
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java276
18 files changed, 468 insertions, 1080 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java b/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java
index 841bf9153..7e2a5c329 100644
--- a/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java
+++ b/sdl_android_lib/src/com/smartdevicelink/marshal/JsonRPCMarshaller.java
@@ -11,9 +11,8 @@ import org.json.JSONObject;
import com.smartdevicelink.proxy.RPCMessage;
import com.smartdevicelink.proxy.RPCStruct;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
/*
* Responsible for marshalling and unmarshing between RPC Objects and byte streams that are sent
@@ -21,16 +20,14 @@ import com.smartdevicelink.util.SdlLog;
*/
public class JsonRPCMarshaller {
-
- private static final String SDL_LIB_PRIVATE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
-
+
public static byte[] marshall(RPCMessage msg, byte version) {
byte[] jsonBytes = null;
try {
JSONObject jsonObject = msg.serializeJSON(version);
jsonBytes = jsonObject.toString().getBytes();
- SdlTrace.logMarshallingEvent(InterfaceActivityDirection.Transmit, jsonBytes, SDL_LIB_PRIVATE_KEY);
+ SdlLog.t(Mod.MARSHALL, SdlLog.buildBasicTraceMessage("Transmit", null, jsonBytes));
} catch (JSONException e) {
SdlLog.e("Failed to encode messages to JSON.", e);
}
@@ -38,7 +35,7 @@ public class JsonRPCMarshaller {
}
public static Hashtable<String, Object> unmarshall(byte[] message) {
- SdlTrace.logMarshallingEvent(InterfaceActivityDirection.Receive, message, SDL_LIB_PRIVATE_KEY);
+ SdlLog.t(Mod.MARSHALL, SdlLog.buildBasicTraceMessage("Receive", null, message));
Hashtable<String, Object> ret = null;
try {
String jsonString = new String(message);
diff --git a/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java b/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java
index 8a58b51c8..4a2cf76c1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java
+++ b/sdl_android_lib/src/com/smartdevicelink/protocol/AbstractProtocol.java
@@ -2,11 +2,10 @@ package com.smartdevicelink.protocol;
import com.smartdevicelink.protocol.WiProProtocol.MessageFrameAssembler;
import com.smartdevicelink.protocol.enums.SessionType;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
+import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
public abstract class AbstractProtocol {
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
private IProtocolListener _protocolListener = null;
//protected IProtocolListener ProtocolListener() { return _protocolListener; }
@@ -60,8 +59,7 @@ public abstract class AbstractProtocol {
// This method is called whenever the protocol receives a complete frame
protected void handleProtocolFrameReceived(ProtocolFrameHeader header, byte[] data, MessageFrameAssembler assembler) {
- SdlTrace.logProtocolEvent(InterfaceActivityDirection.Receive, header, data,
- 0, data.length, SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.PROTOCOL, SdlLog.buildProtocolTraceMessage("Receive", null, data, header));
assembler.handleFrame(header, data);
}
@@ -74,8 +72,7 @@ public abstract class AbstractProtocol {
// This method is called whenever a protocol has an entire frame to send
protected void handleProtocolFrameToSend(ProtocolFrameHeader header, byte[] data, int offset, int length) {
- SdlTrace.logProtocolEvent(InterfaceActivityDirection.Transmit, header, data,
- offset, length, SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.PROTOCOL, SdlLog.buildProtocolTraceMessage("Transmit", null, data, header));
resetHeartbeat(header.getSessionType(), header.getSessionID());
synchronized(_frameLock) {
byte[] frameHeader = header.assembleHeaderBytes();
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxy.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxy.java
index 605fb245b..fe8f1ff04 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxy.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxy.java
@@ -6,14 +6,14 @@ import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
import com.smartdevicelink.proxy.rpc.enums.Language;
-import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.transport.BTTransportConfig;
import com.smartdevicelink.transport.BaseTransportConfig;
+import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
@Deprecated
public class SdlProxy extends SdlProxyBase<IProxyListener> {
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@SuppressWarnings("unused")
private static final String SDL_LIB_PRIVATE_TOKEN = "{DAE1A88C-6C16-4768-ACA5-6F1247EA01C2}";
@@ -42,7 +42,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
/*callbackToUIThread*/ true,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -72,7 +73,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
/*callbackToUIThread*/ true,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -102,7 +104,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
/*callbackToUIThread*/ true,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener, SdlProxyConfigurationResources.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via SdlProxyConfigurationResources.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -131,7 +134,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
callbackToUIThread,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener, callBackToUIThread.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener and callBackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -162,7 +166,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
callbackToUIThread,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener, callBackToUIThread.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener and callBackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/********************************************** TRANSPORT SWITCHING SUPPORT *****************************************/
@@ -193,7 +198,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
/*callbackToUIThread*/ true,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -225,7 +231,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
/*callbackToUIThread*/ true,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener, SdlProxyConfigurationResources.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener and SdlProxyConfigurationResources.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -255,7 +262,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
callbackToUIThread,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener, callBackToUIThread.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener and callBackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -287,7 +295,8 @@ public class SdlProxy extends SdlProxyBase<IProxyListener> {
callbackToUIThread,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxy instance passing in: IProxyListener, callBackToUIThread.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad SDL proxy via IProxyListener and callBackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/******************** Public Helper Methods *************************/
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
index b4e919e19..11bea739f 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyALM.java
@@ -7,7 +7,6 @@ import android.app.Service;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
-import com.smartdevicelink.proxy.Version;
import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities;
import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
@@ -24,14 +23,14 @@ import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech;
import com.smartdevicelink.proxy.rpc.enums.SdlDisconnectedReason;
import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
-import com.smartdevicelink.trace.SdlTrace;
import com.smartdevicelink.transport.BTTransportConfig;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
@SuppressWarnings("unused")
private static final String SDL_LIB_PRIVATE_TOKEN = "{DAE1A88C-6C16-4768-ACA5-6F1247EA01C2}";
@@ -62,7 +61,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/*callbackToUIThread*/ false,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, and isMediaApp.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -103,8 +103,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/*callbackToUIThread*/ false,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
- "vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -145,8 +145,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/*callbackToUIThread*/ false,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -188,9 +188,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
callbackToUIThread,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "and callbackToUIThread", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, and callbackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -233,9 +232,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
callbackToUIThread,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "and callbackToUIThread", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, and callbackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
public SdlProxyALM(IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
@@ -260,9 +258,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/********************************************** TRANSPORT SWITCHING SUPPORT *****************************************/
@@ -298,7 +295,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/*callbackToUIThread*/ false,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, appName, and isMediaApp.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, and isMediaApp.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -340,8 +338,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/*callbackToUIThread*/ false,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, appName, ngnMediaScreenAppName, " +
- "vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -384,8 +382,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
/*callbackToUIThread*/ false,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, and autoActivateID.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -429,9 +427,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
callbackToUIThread,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "and callbackToUIThread", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, and callbackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -475,9 +472,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
callbackToUIThread,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "and callbackToUIThread", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, and callbackToUIThread.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -526,9 +522,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -567,8 +562,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired" + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, isMediaApp, languageDesired, hmiDisplayLanguageDesired, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -601,8 +596,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
false,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, isMediaApp, appID.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
public SdlProxyALM(IProxyListenerALM listener, String appName, Boolean isMediaApp,String appID,BaseTransportConfig transportConfig) throws SdlException {
@@ -624,8 +619,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
false,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, isMediaApp, appID", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, isMediaApp, appID.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
@@ -662,8 +657,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, " +
- "appName, isMediaApp, " + "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, appName, isMediaApp, " + "callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -714,9 +709,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
this.setAppService(appService);
this.sendTransportBroadcast();
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
@@ -745,9 +739,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
this.setAppService(appService);
this.sendTransportBroadcast();
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
@@ -798,9 +791,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
@@ -851,9 +843,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -902,9 +893,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
new BTTransportConfig());
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using legacy constructor for BT transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
@@ -954,9 +944,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
preRegister,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
@@ -984,9 +973,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
this.setAppService(appService);
this.sendTransportBroadcast();
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
* Constructor for the SdlProxy object, the proxy for communicating between the App and SDL via specified transport.
@@ -1039,9 +1027,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
true,
transportConfig);
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
public SdlProxyALM(Service appService, IProxyListenerALM listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
String appName, Vector<TTSChunk> ttsName, String ngnMediaScreenAppName, Vector<String> vrSynonyms, Boolean isMediaApp,
@@ -1071,9 +1058,8 @@ public class SdlProxyALM extends SdlProxyBase<IProxyListenerALM> {
this.setAppService(appService);
this.sendTransportBroadcast();
- SdlTrace.logProxyEvent("Application constructed SdlProxyALM (using new constructor with specified transport) instance passing in: IProxyListener, sdlProxyConfigurationResources, " +
- "appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, " +
- "callbackToUIThread and version", SDL_LIB_TRACE_KEY);
+ String message = "Constructad legacy SDL proxy ALM via IProxyListener, sdlProxyConfigurationResources, appName, ngnMediaScreenAppName, vrSynonyms, isMediaApp, sdlMsgVersion, languageDesired, appType, appID, autoActivateID, callbackToUIThread and version.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/***************************************** END OF TRANSPORT SWITCHING SUPPORT ***************************************/
diff --git a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
index 7e438bc1e..25a72cbc1 100644
--- a/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
+++ b/sdl_android_lib/src/com/smartdevicelink/proxy/SdlProxyBase.java
@@ -1,9 +1,5 @@
package com.smartdevicelink.proxy;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
@@ -24,16 +20,17 @@ import java.util.List;
import java.util.Vector;
import java.util.concurrent.CopyOnWriteArrayList;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
-import android.telephony.TelephonyManager;
-import com.smartdevicelink.proxy.RPCRequestFactory;
-import com.smartdevicelink.proxy.rpc.PutFile;
import com.smartdevicelink.Dispatcher.IDispatchingStrategy;
import com.smartdevicelink.Dispatcher.IncomingProtocolMessageComparitor;
import com.smartdevicelink.Dispatcher.InternalProxyMessageComparitor;
@@ -56,7 +53,102 @@ import com.smartdevicelink.proxy.callbacks.OnProxyClosed;
import com.smartdevicelink.proxy.interfaces.IProxyListenerALM;
import com.smartdevicelink.proxy.interfaces.IProxyListenerBase;
import com.smartdevicelink.proxy.interfaces.IPutFileResponseListener;
-import com.smartdevicelink.proxy.rpc.*;
+import com.smartdevicelink.proxy.rpc.AddCommand;
+import com.smartdevicelink.proxy.rpc.AddCommandResponse;
+import com.smartdevicelink.proxy.rpc.AddSubMenu;
+import com.smartdevicelink.proxy.rpc.AddSubMenuResponse;
+import com.smartdevicelink.proxy.rpc.Alert;
+import com.smartdevicelink.proxy.rpc.AlertResponse;
+import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities;
+import com.smartdevicelink.proxy.rpc.ButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.ChangeRegistration;
+import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse;
+import com.smartdevicelink.proxy.rpc.Choice;
+import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSet;
+import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse;
+import com.smartdevicelink.proxy.rpc.DeleteCommand;
+import com.smartdevicelink.proxy.rpc.DeleteCommandResponse;
+import com.smartdevicelink.proxy.rpc.DeleteFile;
+import com.smartdevicelink.proxy.rpc.DeleteFileResponse;
+import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSet;
+import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSetResponse;
+import com.smartdevicelink.proxy.rpc.DeleteSubMenu;
+import com.smartdevicelink.proxy.rpc.DeleteSubMenuResponse;
+import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse;
+import com.smartdevicelink.proxy.rpc.DialNumberResponse;
+import com.smartdevicelink.proxy.rpc.DisplayCapabilities;
+import com.smartdevicelink.proxy.rpc.EndAudioPassThru;
+import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse;
+import com.smartdevicelink.proxy.rpc.GenericResponse;
+import com.smartdevicelink.proxy.rpc.GetDTCsResponse;
+import com.smartdevicelink.proxy.rpc.GetVehicleData;
+import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.Headers;
+import com.smartdevicelink.proxy.rpc.Image;
+import com.smartdevicelink.proxy.rpc.ListFiles;
+import com.smartdevicelink.proxy.rpc.ListFilesResponse;
+import com.smartdevicelink.proxy.rpc.OnAppInterfaceUnregistered;
+import com.smartdevicelink.proxy.rpc.OnAudioPassThru;
+import com.smartdevicelink.proxy.rpc.OnButtonEvent;
+import com.smartdevicelink.proxy.rpc.OnButtonPress;
+import com.smartdevicelink.proxy.rpc.OnCommand;
+import com.smartdevicelink.proxy.rpc.OnDriverDistraction;
+import com.smartdevicelink.proxy.rpc.OnHMIStatus;
+import com.smartdevicelink.proxy.rpc.OnHashChange;
+import com.smartdevicelink.proxy.rpc.OnKeyboardInput;
+import com.smartdevicelink.proxy.rpc.OnLanguageChange;
+import com.smartdevicelink.proxy.rpc.OnPermissionsChange;
+import com.smartdevicelink.proxy.rpc.OnSystemRequest;
+import com.smartdevicelink.proxy.rpc.OnTBTClientState;
+import com.smartdevicelink.proxy.rpc.OnTouchEvent;
+import com.smartdevicelink.proxy.rpc.OnVehicleData;
+import com.smartdevicelink.proxy.rpc.PerformAudioPassThru;
+import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse;
+import com.smartdevicelink.proxy.rpc.PerformInteraction;
+import com.smartdevicelink.proxy.rpc.PerformInteractionResponse;
+import com.smartdevicelink.proxy.rpc.PresetBankCapabilities;
+import com.smartdevicelink.proxy.rpc.PutFile;
+import com.smartdevicelink.proxy.rpc.PutFileResponse;
+import com.smartdevicelink.proxy.rpc.ReadDIDResponse;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterface;
+import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse;
+import com.smartdevicelink.proxy.rpc.ResetGlobalProperties;
+import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse;
+import com.smartdevicelink.proxy.rpc.ScrollableMessage;
+import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse;
+import com.smartdevicelink.proxy.rpc.SdlMsgVersion;
+import com.smartdevicelink.proxy.rpc.SendLocationResponse;
+import com.smartdevicelink.proxy.rpc.SetAppIcon;
+import com.smartdevicelink.proxy.rpc.SetAppIconResponse;
+import com.smartdevicelink.proxy.rpc.SetDisplayLayout;
+import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse;
+import com.smartdevicelink.proxy.rpc.SetGlobalProperties;
+import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse;
+import com.smartdevicelink.proxy.rpc.SetMediaClockTimer;
+import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse;
+import com.smartdevicelink.proxy.rpc.Show;
+import com.smartdevicelink.proxy.rpc.ShowResponse;
+import com.smartdevicelink.proxy.rpc.Slider;
+import com.smartdevicelink.proxy.rpc.SliderResponse;
+import com.smartdevicelink.proxy.rpc.SoftButton;
+import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities;
+import com.smartdevicelink.proxy.rpc.Speak;
+import com.smartdevicelink.proxy.rpc.SpeakResponse;
+import com.smartdevicelink.proxy.rpc.SubscribeButton;
+import com.smartdevicelink.proxy.rpc.SubscribeButtonResponse;
+import com.smartdevicelink.proxy.rpc.SubscribeVehicleData;
+import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.SystemRequest;
+import com.smartdevicelink.proxy.rpc.SystemRequestResponse;
+import com.smartdevicelink.proxy.rpc.TTSChunk;
+import com.smartdevicelink.proxy.rpc.UnregisterAppInterface;
+import com.smartdevicelink.proxy.rpc.UnregisterAppInterfaceResponse;
+import com.smartdevicelink.proxy.rpc.UnsubscribeButton;
+import com.smartdevicelink.proxy.rpc.UnsubscribeButtonResponse;
+import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleData;
+import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleDataResponse;
+import com.smartdevicelink.proxy.rpc.VehicleType;
+import com.smartdevicelink.proxy.rpc.VrHelpItem;
import com.smartdevicelink.proxy.rpc.enums.AppHMIType;
import com.smartdevicelink.proxy.rpc.enums.AudioStreamingState;
import com.smartdevicelink.proxy.rpc.enums.AudioType;
@@ -83,16 +175,13 @@ import com.smartdevicelink.proxy.rpc.enums.TextAlignment;
import com.smartdevicelink.proxy.rpc.enums.UpdateMode;
import com.smartdevicelink.proxy.rpc.enums.VrCapabilities;
import com.smartdevicelink.streaming.StreamRPCPacketizer;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.TraceDeviceInfo;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> {
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
private static final int PROX_PROT_VER_ONE = 1;
private SdlSession sdlSession = null;
@@ -122,10 +211,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
private boolean pcmServiceResponseReceived = false;
@SuppressWarnings("unused")
private boolean pcmServiceResponse = false;
-
- // Device Info for logging
- private TraceDeviceInfo _traceDeviceInterrogator = null;
-
+
// Declare Queuing Threads
private ProxyMessageDispatcher<ProtocolMessage> _incomingProxyMessageDispatcher;
private ProxyMessageDispatcher<ProtocolMessage> _outgoingProxyMessageDispatcher;
@@ -428,23 +514,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
_proxyListener = listener;
-
- // Get information from sdlProxyConfigurationResources
- TelephonyManager telephonyManager = null;
- if (sdlProxyConfigurationResources != null) {
- telephonyManager = sdlProxyConfigurationResources.getTelephonyManager();
- }
-
- // Use the telephonyManager to get and log phone info
- if (telephonyManager != null) {
- // Following is not quite thread-safe (because m_traceLogger could test null twice),
- // so we need to fix this, but vulnerability (i.e. two instances of listener) is
- // likely harmless.
- if (_traceDeviceInterrogator == null) {
- _traceDeviceInterrogator = new TraceDeviceInfo(sdlProxyConfigurationResources.getTelephonyManager());
- } // end-if
- } // end-if
-
+
// Setup Internal ProxyMessage Dispatcher
synchronized(INTERNAL_MESSAGE_QUEUE_THREAD_LOCK) {
// Ensure internalProxyMessageDispatcher is null
@@ -552,8 +622,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
throw e;
}
- // Trace that ctor has fired
- SdlTrace.logProxyEvent("SdlProxy Created, instanceID=" + this.toString(), SDL_LIB_TRACE_KEY);
+ String message = "SdlProxy created with instance id: " + this.toString();
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
protected SdlProxyBase(proxyListenerType listener, SdlProxyConfigurationResources sdlProxyConfigurationResources,
@@ -1105,7 +1175,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
} catch (SdlException e) {
throw e;
} finally {
- SdlTrace.logProxyEvent("SdlProxy cleaned.", SDL_LIB_TRACE_KEY);
+ String message = "SdlProxy cleaned.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
}
@@ -1120,7 +1191,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_proxyDisposed = true;
- SdlTrace.logProxyEvent("Application called dispose() method.", SDL_LIB_TRACE_KEY);
+ String message = "Application called the dispose() method.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
try{
// Clean the proxy
@@ -1148,13 +1220,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
_internalProxyMessageDispatcher.dispose();
_internalProxyMessageDispatcher = null;
}
- }
-
- _traceDeviceInterrogator = null;
+ }
} catch (SdlException e) {
throw e;
} finally {
- SdlTrace.logProxyEvent("SdlProxy disposed.", SDL_LIB_TRACE_KEY);
+ String msg = "SdlProxy disposed.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, msg, null));
}
} // end-method
@@ -1291,7 +1362,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sdlSession.sendMessage(message);
}
}
- SdlTrace.logProxyEvent("SdlProxy sending Protocol Message: " + message.toString(), SDL_LIB_TRACE_KEY);
+ String m = "SdlProxy sending protocol message.";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, m, null));
}
private void handleErrorsFromOutgoingMessageDispatcher(String info, Exception e) {
@@ -1341,12 +1413,12 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
/****************End Legacy Specific Call-backs************/
} else {
- // Diagnostics
- SdlTrace.logProxyEvent("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.", SDL_LIB_TRACE_KEY);
SdlLog.e("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
}
- SdlTrace.logProxyEvent("Proxy fired callback: " + message.getFunctionName(), SDL_LIB_TRACE_KEY);
+ String m = "SdlProxy fired callback for " + message.getFunctionName();
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, m, null));
+
} catch(final Exception e) {
// Pass error to application through listener
SdlLog.e("Error handing proxy event.", e);
@@ -1383,7 +1455,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// error checking.
private void sendRPCRequestPrivate(RPCRequest request) throws SdlException {
try {
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Transmit, request, SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.RPC, SdlLog.buildRpcTraceMessage("Transmit", null, null, request));
byte[] msgBytes = JsonRPCMarshaller.marshall(request, _wiproVersion);
@@ -1410,7 +1482,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
}
} catch (OutOfMemoryError e) {
- SdlTrace.logProxyEvent("OutOfMemory exception while sending request " + request.getFunctionName(), SDL_LIB_TRACE_KEY);
+ SdlLog.e("OutOfMemory exception while sending request " + request.getFunctionName() + ".");
throw new SdlException("OutOfMemory exception while sending request " + request.getFunctionName(), e, SdlExceptionCause.INVALID_ARGUMENT);
}
}
@@ -1421,7 +1493,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
String messageType = rpcMsg.getMessageType();
if (messageType.equals(RPCMessage.KEY_RESPONSE)) {
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCResponse(rpcMsg), SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.RPC, SdlLog.buildRpcTraceMessage("Receive", null, null, rpcMsg));
// Check to ensure response is not from an internal message (reserved correlation ID)
if (isCorrelationIDProtected((new RPCResponse(hash)).getCorrelationID())) {
@@ -2241,7 +2313,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
}
} // end-if
} else if (messageType.equals(RPCMessage.KEY_NOTIFICATION)) {
- SdlTrace.logRPCEvent(InterfaceActivityDirection.Receive, new RPCNotification(rpcMsg), SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.PROXY, SdlLog.buildRpcTraceMessage(null, null, null, rpcMsg));
if (functionName.equals(FunctionID.ON_HMI_STATUS.toString())) {
// OnHMIStatus
@@ -2587,7 +2659,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
} // end-if
} // end-if notification
- SdlTrace.logProxyEvent("Proxy received RPC Message: " + functionName, SDL_LIB_TRACE_KEY);
+ String message = "SDL proxy received RPC message: " + functionName + ".";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
}
/**
@@ -2603,32 +2676,31 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
// Test if request is null
if (request == null) {
- SdlTrace.logProxyEvent("Application called sendRPCRequest method with a null RPCRequest.", SDL_LIB_TRACE_KEY);
+ SdlLog.e("Application called sendRPCRequest method with a null RPCRequest.");
throw new IllegalArgumentException("sendRPCRequest cannot be called with a null request.");
}
- SdlTrace.logProxyEvent("Application called sendRPCRequest method for RPCRequest: ." + request.getFunctionName(), SDL_LIB_TRACE_KEY);
+ String message = "Application called sendRPCRequest method for RPCRequest: " + request.getFunctionName() + ".";
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, message, null));
// Test if SdlConnection is null
synchronized(CONNECTION_REFERENCE_LOCK) {
if (sdlSession == null || !sdlSession.getIsConnected()) {
- SdlTrace.logProxyEvent("Application attempted to send and RPCRequest without a connected transport.", SDL_LIB_TRACE_KEY);
+ SdlLog.e("Application attempted to send and RPCRequest without a connected transport.");
throw new SdlException("There is no valid connection to SDL. sendRPCRequest cannot be called until SDL has been connected.", SdlExceptionCause.SDL_UNAVAILABLE);
}
}
// Test for illegal correlation ID
if (isCorrelationIDProtected(request.getCorrelationID())) {
-
- SdlTrace.logProxyEvent("Application attempted to use the reserved correlation ID, " + request.getCorrelationID(), SDL_LIB_TRACE_KEY);
+ SdlLog.e("Application attempted to use the reserved correlation ID, " + request.getCorrelationID());
throw new SdlException("Invalid correlation ID. The correlation ID, " + request.getCorrelationID()
+ " , is a reserved correlation ID.", SdlExceptionCause.RESERVED_CORRELATION_ID);
}
// Throw exception if RPCRequest is sent when SDL is unavailable
- if (!_appInterfaceRegisterd && !request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString())) {
-
- SdlTrace.logProxyEvent("Application attempted to send an RPCRequest (non-registerAppInterface), before the interface was registerd.", SDL_LIB_TRACE_KEY);
+ if (!_appInterfaceRegisterd && !request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString())) {
+ SdlLog.e("Application attempted to send an RPCRequest (non-registerAppInterface), before the interface was registerd.");
throw new SdlException("SDL is currently unavailable. RPC Requests cannot be sent.", SdlExceptionCause.SDL_UNAVAILABLE);
}
@@ -2636,7 +2708,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
if (request.getFunctionName().equals(FunctionID.REGISTER_APP_INTERFACE.toString())
|| request.getFunctionName().equals(FunctionID.UNREGISTER_APP_INTERFACE.toString())) {
- SdlTrace.logProxyEvent("Application attempted to send a RegisterAppInterface or UnregisterAppInterface while using ALM.", SDL_LIB_TRACE_KEY);
+ SdlLog.e("Application attempted to send a RegisterAppInterface or UnregisterAppInterface while using ALM.");
throw new SdlException("The RPCRequest, " + request.getFunctionName() +
", is unallowed using the Advanced Lifecycle Management Model.", SdlExceptionCause.INCORRECT_LIFECYCLE_MODEL);
}
@@ -2645,8 +2717,8 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase>
sendRPCRequestPrivate(request);
} // end-method
- protected void notifyProxyClosed(final String info, final Exception e, final SdlDisconnectedReason reason) {
- SdlTrace.logProxyEvent("NotifyProxyClose", SDL_LIB_TRACE_KEY);
+ protected void notifyProxyClosed(final String info, final Exception e, final SdlDisconnectedReason reason) {
+ SdlLog.t(Mod.PROXY, SdlLog.buildBasicTraceMessage(null, "Notify SDL proxy closed.", null));
OnProxyClosed message = new OnProxyClosed(info, e, reason);
queueInternalMessage(message);
}
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/DiagLevel.java b/sdl_android_lib/src/com/smartdevicelink/trace/DiagLevel.java
deleted file mode 100644
index b77b34486..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/DiagLevel.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.smartdevicelink.trace;
-
-import com.smartdevicelink.trace.enums.DetailLevel;
-import com.smartdevicelink.trace.enums.Mod;
-
-
-public class DiagLevel {
-
- static private DetailLevel[] levels;
-
- static { // this is a static c-tor!!
- levels = new DetailLevel[Mod.values().length];
- setAllLevels(DetailLevel.OFF);
- }
-
- public static void setAllLevels(DetailLevel thisDetail) {
- for (int i=0; i < levels.length; i++) {
- levels[i] = thisDetail; //
- }
- }
-
- public static void setLevel(Mod thisMod, DetailLevel thisDetail) {
- levels[thisMod.ordinal()] = thisDetail;
- }
-
- public static DetailLevel getLevel(Mod thisMod) {
- return levels[thisMod.ordinal()];
- }
-
- public static boolean isValidDetailLevel(String dtString) {
- // Assume false
- Boolean isValid = false;
-
- if (dtString.equalsIgnoreCase("verbose"))
- isValid = true;
- else if (dtString.equalsIgnoreCase("terse"))
- isValid = true;
- else if (dtString.equalsIgnoreCase("off"))
- isValid = true;
-
- return isValid;
- }
-
- public static DetailLevel toDetailLevel(String dtString) {
- DetailLevel dt = DetailLevel.OFF;
- if (dtString.equalsIgnoreCase("verbose"))
- dt = DetailLevel.VERBOSE;
- else if (dtString.equalsIgnoreCase("terse"))
- dt = DetailLevel.TERSE;
- return dt;
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/ISTListener.java b/sdl_android_lib/src/com/smartdevicelink/trace/ISTListener.java
deleted file mode 100644
index 3af7d5020..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/ISTListener.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.smartdevicelink.trace;
-
-public interface ISTListener {
- void logXmlMsg(String msg, String token);
-} // end-interface \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java b/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java
deleted file mode 100644
index 026f31721..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/Mime.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.smartdevicelink.trace;
-
-// Borrowed from Dave Boll's infamous SdlLinkRelay.java
-
-public class Mime {
-
- private static String m_base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
- public static String base64Encode(String str) {
- String b64String = "";
- try {
- byte[] strBytes = str.getBytes("US-ASCII");
- b64String = base64Encode(strBytes);
- } catch (Exception ex) {
- // Don't care?
- }
- return b64String;
- }
-
- public static String base64Encode(byte bytesToEncode[]) {
- return base64Encode(bytesToEncode, 0, bytesToEncode.length);
- }
-
- public static String base64Encode(byte bytesToEncode[], int offset, int length) {
- StringBuilder sb = new StringBuilder();
-
- int idxin = 0;
- int b64idx = 0;
-
- for (idxin=offset;idxin < offset + length;idxin++) {
- switch ((idxin-offset) % 3) {
- case 0:
- b64idx = (bytesToEncode[idxin] >> 2) & 0x3f;
- break;
- case 1:
- b64idx = (bytesToEncode[idxin] >> 4) & 0x0f;
- b64idx |= ((bytesToEncode[idxin-1] << 4)& 0x30);
- break;
- case 2:
- b64idx = (bytesToEncode[idxin] >> 6) & 0x03;
- b64idx |= ((bytesToEncode[idxin-1] << 2)& 0x3c);
- sb.append(m_base64Chars.charAt(b64idx));
- b64idx = bytesToEncode[idxin] & 0x3f;
- break;
- }
- sb.append(m_base64Chars.charAt(b64idx));
- }
-
- switch ((idxin-offset) % 3) {
- case 0:
- break;
- case 1:
- b64idx = (bytesToEncode[idxin-1] << 4) & 0x30;
- sb.append(m_base64Chars.charAt(b64idx));
- sb.append("==");
- break;
- case 2:
- b64idx = ((bytesToEncode[idxin-1] << 2)& 0x3c);
- sb.append(m_base64Chars.charAt(b64idx));
- sb.append('=');
- break;
- }
- return sb.toString();
- }
-} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/OpenRPCMessage.java b/sdl_android_lib/src/com/smartdevicelink/trace/OpenRPCMessage.java
deleted file mode 100644
index 35a8de749..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/OpenRPCMessage.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.smartdevicelink.trace;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import com.smartdevicelink.proxy.RPCMessage;
-import com.smartdevicelink.proxy.RPCStruct;
-
-class OpenRPCMessage extends RPCMessage {
- private OpenRPCMessage() {super("");}
- public OpenRPCMessage(RPCMessage rpcm) {
- super(rpcm);
- } // end-method
-
- public OpenRPCMessage(RPCStruct rpcs) {
- super(rpcs);
- } // end-method
-
- public String msgDump() {
- StringBuilder pd = new StringBuilder();
-
- pd.append(this.getFunctionName() + " " + this.getMessageType());
-
- msgDump(pd);
-
- return pd.toString();
- } // end-method
-
- public void msgDump(StringBuilder pd) {
- pd.append("[");
-
- dumpParams(parameters, pd);
-
- pd.append("]");
-
- return;
- } // end-method
-
- private void dumpParams(Hashtable<String, Object> ht, StringBuilder pd) {
- Iterator<String> keySet = ht.keySet().iterator();
- Object obj = null;
- String key = "";
- boolean isFirstParam = true;
-
- while (keySet.hasNext()) {
- key = (String)keySet.next();
- obj = ht.get(key);
- if (isFirstParam) {
- isFirstParam = false;
- } else {
- pd.append(", ");
- } // end-if
-
- dumpParamNode(key, obj, pd);
-
- } // end-while
- } // end-method
-
- @SuppressWarnings("unchecked")
- private void dumpParamNode(String key, Object obj, StringBuilder pd) {
-
- if (obj instanceof Hashtable) {
- pd.append("[");
- dumpParams((Hashtable<String, Object>)obj, pd);
- pd.append("]");
- } else if (obj instanceof RPCStruct) {
- pd.append("[");
- OpenRPCMessage orpcm = new OpenRPCMessage((RPCStruct)obj);
- orpcm.msgDump(pd);
- pd.append("]");
- } else if (obj instanceof List) {
- pd.append("[");
- List<?> list = (List<?>)obj;
- for (int idx=0;idx < list.size();idx++) {
- if (idx > 0) {
- pd.append(", ");
- }
- dumpParamNode(key, list.get(idx), pd);
- } // end-for
- pd.append("]");
- } else {
- pd.append("\"" + key + "\" = \"" + obj.toString() + "\"");
- }
- } // end-method
-} // end-class OpenRPCMessage
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java b/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
deleted file mode 100644
index deaaa438c..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/SdlTrace.java
+++ /dev/null
@@ -1,458 +0,0 @@
-package com.smartdevicelink.trace;
-
-import java.sql.Timestamp;
-
-import android.bluetooth.BluetoothDevice;
-import android.os.Build;
-import android.os.Debug;
-import android.os.Process;
-import android.text.format.DateFormat;
-
-import com.smartdevicelink.protocol.ProtocolFrameHeader;
-import com.smartdevicelink.protocol.enums.FrameType;
-import com.smartdevicelink.proxy.RPCMessage;
-import com.smartdevicelink.proxy.RPCRequest;
-import com.smartdevicelink.proxy.RPCResponse;
-import com.smartdevicelink.trace.enums.DetailLevel;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
-import com.smartdevicelink.trace.enums.Mod;
-import com.smartdevicelink.util.BitConverter;
-import com.smartdevicelink.util.SdlLog;
-
-/* This class handles the global TraceSettings as requested by the users either through the combination of the following
- 1. System defaults
- 2. Application XML config
- 3. Programmatic requests from application itself
-
- It is manifested in the <SmartDeviceLink>...</SmartDeviceLink> tags
- */
-public class SdlTrace {
-
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
- public static final String SYSTEM_LOG_TAG = "SdlTrace";
- static final long BASE_TICS = java.lang.System.currentTimeMillis();
- private static boolean acceptAPITraceAdjustments = true;
- protected static ISTListener m_appTraceListener = null;
-
- // /
- // / The PUBLIC interface to SdlTrace starts here
- // /
-
- public static void setAcceptAPITraceAdjustments(
- Boolean APITraceAdjustmentsAccepted) {
- if (APITraceAdjustmentsAccepted != null) {
- acceptAPITraceAdjustments = APITraceAdjustmentsAccepted;
- }
- }
-
- public static boolean getAcceptAPITraceAdjustments() {
- return acceptAPITraceAdjustments;
- }
-
- public static void setAppTraceListener(ISTListener listener) {
- m_appTraceListener = listener;
- }
-
- public static void setAppTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.app, dt);
- }
-
- public static void setProxyTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.proxy, dt);
- }
-
- public static void setRpcTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.rpc, dt);
- }
-
- public static void setMarshallingTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.mar, dt);
- }
-
- public static void setProtocolTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.proto, dt);
- }
-
- public static void setTransportTraceLevel(DetailLevel dt) {
- if (dt != null && acceptAPITraceAdjustments)
- DiagLevel.setLevel(Mod.tran, dt);
- }
-
- private static String encodeTraceMessage(Mod module,
- InterfaceActivityDirection msgDirection, String msgBodyXml) {
- long timestamp = java.lang.System.currentTimeMillis() - BASE_TICS;
- StringBuilder sb = new StringBuilder("<msg><dms>");
- sb.append(timestamp);
- sb.append("</dms><pid>");
- sb.append(Process.myPid());
- sb.append("</pid><tid>");
- sb.append(Thread.currentThread().getId());
- sb.append("</tid><mod>");
- sb.append(module.toString());
- sb.append("</mod>");
- if (msgDirection != InterfaceActivityDirection.None) {
- sb.append("<dir>");
- sb.append(msgDirection.toString());
- sb.append("</dir>");
- }
- sb.append(msgBodyXml);
- sb.append("</msg>");
-
- return sb.toString();
- }
-
- public static boolean logProxyEvent(String eventText, String token) {
- if (DiagLevel.getLevel(Mod.proxy) == DetailLevel.OFF
- || !token.equals(SDL_LIB_TRACE_KEY)) {
- return false;
- }
-
- String msg = Mime.base64Encode(eventText);
- String xml = SdlTrace.encodeTraceMessage(Mod.proxy,
- InterfaceActivityDirection.None, "<d>" + msg + "</d>");
- return writeXmlTraceMessage(xml);
- }
-
- public static boolean logAppEvent(String eventText) {
- if (DiagLevel.getLevel(Mod.app) == DetailLevel.OFF) {
- return false;
- }
-
- String msg = Mime.base64Encode(eventText);
- String xml = SdlTrace.encodeTraceMessage(Mod.app,
- InterfaceActivityDirection.None, "<d>" + msg + "</d>");
- return writeXmlTraceMessage(xml);
- }
-
- public static boolean logRPCEvent(InterfaceActivityDirection msgDirection,
- RPCMessage rpcMsg, String token) {
- DetailLevel dl = DiagLevel.getLevel(Mod.rpc);
- if (dl == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
- return false;
- }
-
- String xml = SdlTrace.encodeTraceMessage(Mod.rpc, msgDirection,
- rpc2Xml(dl, rpcMsg));
- return writeXmlTraceMessage(xml);
- }
-
- private static String rpc2Xml(DetailLevel dl, RPCMessage rpcMsg) {
- StringBuilder rpcAsXml = new StringBuilder();
- rpcAsXml.append("<op>");
- rpcAsXml.append(rpcMsg.getFunctionName());
- rpcAsXml.append("</op>");
- boolean hasCorrelationID = false;
- Integer correlationID = -1;
- if (rpcMsg instanceof RPCRequest) {
- hasCorrelationID = true;
- correlationID = ((RPCRequest) rpcMsg).getCorrelationID();
- } else if (rpcMsg instanceof RPCResponse) {
- hasCorrelationID = true;
- correlationID = ((RPCResponse) rpcMsg).getCorrelationID();
- }
- if (hasCorrelationID) {
- rpcAsXml.append("<cid>");
- rpcAsXml.append(correlationID);
- rpcAsXml.append("</cid>");
- }
- rpcAsXml.append("<type>");
- rpcAsXml.append(rpcMsg.getMessageType());
- rpcAsXml.append("</type>");
-
- if (dl == DetailLevel.VERBOSE) {
- OpenRPCMessage orpcmsg = new OpenRPCMessage(rpcMsg);
- String rpcParamList = orpcmsg.msgDump();
- String msg = Mime.base64Encode(rpcParamList);
- rpcAsXml.append("<d>");
- rpcAsXml.append(msg);
- rpcAsXml.append("</d>");
- }
- return rpcAsXml.toString();
- }
-
- public static boolean logMarshallingEvent(
- InterfaceActivityDirection msgDirection, byte[] marshalledMessage,
- String token) {
- DetailLevel dl = DiagLevel.getLevel(Mod.mar);
- if (dl == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
- return false;
- }
-
- StringBuilder msg = new StringBuilder();
- msg.append("<sz>");
- msg.append(marshalledMessage.length);
- msg.append("</sz>");
- if (dl == DetailLevel.VERBOSE) {
- msg.append("<d>");
- msg.append(Mime.base64Encode(marshalledMessage));
- // Base64 only available in 2.2, when SmartDeviceLink base is 2.2
- // use: msg.append(Base64.encodeToString(marshalledMessage,
- // Base64.DEFAULT));
- msg.append("</d>");
- }
- String xml = SdlTrace.encodeTraceMessage(Mod.mar, msgDirection,
- msg.toString());
- return writeXmlTraceMessage(xml);
- }
-
- public static boolean logProtocolEvent(
- InterfaceActivityDirection frameDirection,
- ProtocolFrameHeader frameHeader, byte[] frameData,
- int frameDataOffset, int frameDataLength, String token) {
- DetailLevel dl = DiagLevel.getLevel(Mod.proto);
- if (dl == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
- return false;
- }
-
- StringBuffer protoMsg = new StringBuffer();
- protoMsg.append("<frame>");
- protoMsg.append(SdlTrace.getProtocolFrameHeaderInfo(frameHeader,
- frameData));
- if (dl == DetailLevel.VERBOSE) {
- if (frameData != null && frameDataLength > 0) {
- protoMsg.append("<d>");
- String bytesInfo = "";
- bytesInfo = Mime.base64Encode(frameData, frameDataOffset,
- frameDataLength);
- // Base64 only available in 2.2, when SmartDeviceLink base is
- // 2.2 use: bytesInfo = Base64.encodeToString(frameData,
- // frameDataOffset, frameDataLength, Base64.DEFAULT);
- protoMsg.append(bytesInfo);
- protoMsg.append("</d>");
- }
- }
- protoMsg.append("</frame>");
- String xml = SdlTrace.encodeTraceMessage(Mod.proto, frameDirection,
- protoMsg.toString());
- return writeXmlTraceMessage(xml);
- }
-
- private static String getProtocolFrameHeaderInfo(ProtocolFrameHeader hdr,
- byte[] buf) {
- StringBuilder sb = new StringBuilder();
- sb.append("<hdr>");
- sb.append("<ver>");
- sb.append(hdr.getVersion());
- sb.append("</ver><cmp>");
- sb.append(hdr.isCompressed());
- sb.append("</cmp><ft>");
- sb.append(hdr.getFrameType().toString());
- sb.append("</ft><st>");
- sb.append(hdr.getSessionType().toString());
- sb.append("</st><sid>");
- sb.append(hdr.getSessionID());
- sb.append("</sid><sz>");
- sb.append(hdr.getDataSize());
- sb.append("</sz>");
-
- if (hdr.getFrameType() == FrameType.Control) {
- sb.append("<ca>");
- sb.append(hdr);
- sb.append("</ca>");
- } else if (hdr.getFrameType() == FrameType.Consecutive) {
- sb.append("<fsn>");
- int frameData = hdr.getFrameData();
- if (frameData == 0)
- sb.append("lastFrame");
- else
- sb.append(String.format("%02X", frameData));
- sb.append("</fsn>");
- } else if (hdr.getFrameType() == FrameType.First) {
- int totalSize = BitConverter.intFromByteArray(buf, 0);
- int numFrames = BitConverter.intFromByteArray(buf, 4);
- sb.append("<total>" + totalSize + "</total><numframes>" + numFrames
- + "</numframes>");
- } else if (hdr.getFrameType() == FrameType.Single) {
- sb.append("<single/>");
- }
- sb.append("</hdr>");
-
- return sb.toString();
- }
-
- public static String getBTDeviceInfo(BluetoothDevice btDevice) {
- StringBuilder sb = new StringBuilder();
- sb.append("<btp>");
- String btdn = btDevice.getName();
- sb.append("<btn>");
- sb.append(Mime.base64Encode(btdn));
- sb.append("</btn>");
- sb.append("<bta>" + btDevice.getAddress() + "</bta>");
- sb.append("<bts>" + btDevice.getBondState() + "</bts>");
- sb.append("</btp>");
- return sb.toString();
- }
-
- public static boolean logTransportEvent(String preamble,
- String transportSpecificInfoXml,
- InterfaceActivityDirection msgDirection, byte buf[],
- int byteLength, String token) {
- return logTransportEvent(preamble, transportSpecificInfoXml,
- msgDirection, buf, 0, byteLength, token);
- }
-
- private static void checkB64(String x, byte[] buf, int offset,
- int byteLength) {
- if ((x.length() % 4) != 0) {
- SdlLog.w("b64 string length (" + x.length()
- + ") isn't multiple of 4: buf.length=" + buf.length
- + ", offset=" + offset + ", len=" + byteLength);
- }
- }
-
- public static boolean logTransportEvent(String preamble, String transportSpecificInfoXml, InterfaceActivityDirection msgDirection, byte buf[], int offset, int byteLength, String token) {
- if (DiagLevel.getLevel(Mod.tran) == DetailLevel.OFF || !token.equals(SDL_LIB_TRACE_KEY)) {
- return false;
- }
-
- StringBuilder msg = new StringBuilder();
- if (transportSpecificInfoXml != null
- && transportSpecificInfoXml.length() > 0) {
- msg.append(transportSpecificInfoXml);
- }
- if (preamble != null && preamble.length() > 0) {
- msg.append("<desc>");
- msg.append(preamble);
- msg.append("</desc>");
- }
- if (buf != null) {
- msg.append("<sz>");
- msg.append(byteLength);
- msg.append("</sz>");
- DetailLevel dl = DiagLevel.getLevel(Mod.tran);
- if (dl == DetailLevel.VERBOSE) {
- if (buf != null && byteLength > 0) {
- msg.append("<d>");
- String bytesInfo = Mime.base64Encode(buf, offset,
- byteLength);
- checkB64(bytesInfo, buf, offset, byteLength);
- msg.append(bytesInfo);
- msg.append("</d>");
- }
- }
- }
- String xml = SdlTrace.encodeTraceMessage(Mod.tran, msgDirection,
- msg.toString());
- return writeXmlTraceMessage(xml);
- }
-
- private static boolean writeXmlTraceMessage(String msg) {
-
- if (m_appTraceListener == null) {
- return false;
- }
-
- try {
- m_appTraceListener.logXmlMsg(msg, SDL_LIB_TRACE_KEY);
- } catch (Exception ex) {
- SdlLog.e("Failure writing XML trace message: " + ex.toString());
- return false;
- }
-
- return true;
- }
-
- public static String getLogHeader(String dumpReason, int seqNo) {
-
- // Indicates which version of XML to parse the message with.
- StringBuilder result = new StringBuilder("<?xml version=\"1.0\"?>");
-
- // The block that contains all of the XML information.
- result.append("<info>");
-
- // Hardware and carrier information.
- result.append("<host>");
- StringBuilder hostInfo = new StringBuilder(Build.BRAND);
- hostInfo.append("-");
- hostInfo.append(Build.MANUFACTURER);
- hostInfo.append("-");
- hostInfo.append(Build.MODEL);
- hostInfo.append("(");
- hostInfo.append(Build.HOST);
- hostInfo.append(")");
- result.append(Mime.base64Encode(hostInfo.toString()));
- result.append("</host>");
-
- // Release information.
- result.append("<osv>");
- StringBuilder osvInfo = new StringBuilder(Build.VERSION.RELEASE);
- osvInfo.append("(");
- osvInfo.append(Build.VERSION.CODENAME);
- osvInfo.append(")");
- result.append(Mime.base64Encode(osvInfo.toString()));
- result.append("</osv>");
-
- // Network information.
- result.append(TraceDeviceInfo.getTelephonyHeader());
-
- // Memory information.
- result.append("<mem>");
- result.append("<hf>");
- result.append((Debug.getNativeHeapFreeSize() / 1024));
- result.append("KB");
- result.append("</hf>");
- result.append("<ha>");
- result.append((Debug.getNativeHeapAllocatedSize() / 1024));
- result.append("KB");
- result.append("</ha>");
- result.append("</mem>");
-
- // Process and thread information.
- result.append("<np>");
- result.append(Runtime.getRuntime().availableProcessors());
- result.append("</np>");
- result.append("<pid>");
- result.append(Process.myPid());
- result.append("</pid>");
- result.append("<tid>");
- result.append(Thread.currentThread().getId());
- result.append("</tid>");
-
- // Time of message construction.
- result.append("<utc>");
- result.append(DateFormat.format("yy-MM-dd hh:mm:ss SSS", new Timestamp(
- java.lang.System.currentTimeMillis())));
- result.append("</utc>");
-
- // Bluetooth information.
- result.append(TraceDeviceInfo.getLogHeaderBluetoothPairs());
-
- // SDL specific information.
- result.append("<sdltraceroot>");
- result.append("<sequencenum>");
- result.append(seqNo);
- result.append("</sequencenum>");
- result.append("<dumpreason>");
- result.append(dumpReason);
- result.append("</dumpreason>");
- result.append("<tracelevel>");
- result.append("<tran>");
- result.append(DiagLevel.getLevel(Mod.tran));
- result.append("</tran>");
- result.append("<proto>");
- result.append(DiagLevel.getLevel(Mod.proto));
- result.append("</proto>");
- result.append("<mar>");
- result.append(DiagLevel.getLevel(Mod.mar));
- result.append("</mar>");
- result.append("<rpc>");
- result.append(DiagLevel.getLevel(Mod.rpc));
- result.append("</rpc>");
- result.append("<proxy>");
- result.append(DiagLevel.getLevel(Mod.proxy));
- result.append("</proxy>");
- result.append("<app>");
- result.append(DiagLevel.getLevel(Mod.app));
- result.append("</app>");
- result.append("</tracelevel>");
- result.append("</sdltraceroot>");
- result.append("</info>");
-
- return result.toString();
- }
-} \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java b/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java
deleted file mode 100644
index 702372a11..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/TraceDeviceInfo.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *
- */
-package com.smartdevicelink.trace;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.telephony.TelephonyManager;
-
-import com.smartdevicelink.util.SdlLog;
-
-/**
- * @author vvolkman
- *
- */
-public class TraceDeviceInfo {
- // http://developer.android.com/guide/topics/data/data-storage.html
-
- private static TelephonyManager m_telephonyManager;
-
- // Constructor
- public TraceDeviceInfo(TelephonyManager telephonyManager) {
- m_telephonyManager = telephonyManager;
- }
-
- public static void setTelephonyManager(TelephonyManager telephonyManager) {
- m_telephonyManager = telephonyManager;
- }
-
- public static TelephonyManager getTelephonyManager() {
- return m_telephonyManager;
- }
-
- // package scoped
- static String getTelephonyHeader() {
- // Telephony manager can tell us a few things...
- String info = "";
-
- if (m_telephonyManager != null) {
- try { // getDeviceId() requires android.permission.READ_PHONE_STATE
- info = "<deviceid>" + m_telephonyManager.getDeviceId() + "</deviceid>";
- } catch (Exception e1) {
- SdlLog.e("Failure getting telephony device ID: " + e1.toString(), e1);
- }
-
- info = "<pt>";
- switch (m_telephonyManager.getPhoneType()) {
- case TelephonyManager.PHONE_TYPE_NONE:
- info += "NONE";
- break;
- case TelephonyManager.PHONE_TYPE_GSM:
- info += "GSM";
- break;
- case TelephonyManager.PHONE_TYPE_CDMA:
- info += "CDMA";
- break;
- default:
- info += "UNKNOWN";
- } // end-switch
-
- info += "</pt>" + "<nt>";
-
- switch (m_telephonyManager.getNetworkType()) {
- case TelephonyManager.NETWORK_TYPE_UNKNOWN:
- info += "UKNOWN";
- break;
- case TelephonyManager.NETWORK_TYPE_GPRS:
- info += "GPRS";
- break;
- case TelephonyManager.NETWORK_TYPE_EDGE:
- info += "EDGE";
- break;
- case TelephonyManager.NETWORK_TYPE_UMTS:
- info += "UMTS";
- break;
- case TelephonyManager.NETWORK_TYPE_HSDPA:
- info += "HSDPA";
- break;
- case TelephonyManager.NETWORK_TYPE_HSUPA:
- info += "HSUPA";
- break;
- case TelephonyManager.NETWORK_TYPE_HSPA:
- info += "HSPA";
- break;
- case TelephonyManager.NETWORK_TYPE_CDMA:
- info += "CDMA";
- break;
- case TelephonyManager.NETWORK_TYPE_EVDO_0:
- info += "EVDO_O";
- break;
- case TelephonyManager.NETWORK_TYPE_EVDO_A:
- info += "EVDO_A";
- break;
- case TelephonyManager.NETWORK_TYPE_1xRTT:
- info += "1xRTT";
- break;
- default:
- info += "UNKNOWN";
- break;
- } // end-switch
-
- info += "</nt>";
- } // end-if
- return info;
- } // end-method
-
- // Package scoped
- static String getLogHeaderBluetoothPairs() {
- Set<BluetoothDevice> btDevices = BluetoothAdapter.getDefaultAdapter()
- .getBondedDevices();
-
- StringBuilder write = new StringBuilder("<btpairs>");
- Iterator<BluetoothDevice> iter = btDevices.iterator();
- while (iter.hasNext()) {
- write.append(SdlTrace.getBTDeviceInfo(iter.next()));
- }
- write.append("</btpairs>");
-
- return write.toString();
- } // end-method
-} // end-class \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/enums/DetailLevel.java b/sdl_android_lib/src/com/smartdevicelink/trace/enums/DetailLevel.java
deleted file mode 100644
index bd213679d..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/enums/DetailLevel.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.smartdevicelink.trace.enums;
-
-
-public enum DetailLevel {
- OFF,
- TERSE,
- VERBOSE;
-
- public static DetailLevel valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/enums/InterfaceActivityDirection.java b/sdl_android_lib/src/com/smartdevicelink/trace/enums/InterfaceActivityDirection.java
deleted file mode 100644
index c348d82b2..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/enums/InterfaceActivityDirection.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.smartdevicelink.trace.enums;
-
-public enum InterfaceActivityDirection {
- Transmit,
- Receive,
- None;
-}
diff --git a/sdl_android_lib/src/com/smartdevicelink/trace/enums/Mod.java b/sdl_android_lib/src/com/smartdevicelink/trace/enums/Mod.java
deleted file mode 100644
index b363473b2..000000000
--- a/sdl_android_lib/src/com/smartdevicelink/trace/enums/Mod.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.smartdevicelink.trace.enums;
-
-public enum Mod {
- tran,
- proto,
- mar,
- rpc,
- app,
- proxy;
-
- public static Mod valueForString(String value) {
- try{
- return valueOf(value);
- }catch(Exception e){
- return null;
- }
- }
-}; \ No newline at end of file
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java
index 2350d08e4..c0fa30b3e 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/BTTransport.java
@@ -14,10 +14,9 @@ import android.os.Build.VERSION;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
/**
* Bluetooth Transport Implementation. This transport advertises its existence to SDL by publishing an SDP record and waiting for an incoming connection from SDL. Connection is verified by checking for the SDL UUID. For more detailed information please refer to the <a href="#bluetoothTransport">Bluetooth Transport Guide</a>.
@@ -26,8 +25,6 @@ import com.smartdevicelink.util.SdlLog;
public class BTTransport extends SdlTransport {
//936DA01F9ABD4D9D80C702AF85C822A8
private final static UUID SDL_V4_MOBILE_APPLICATION_SVC_CLASS = new UUID(0x936DA01F9ABD4D9DL, 0x80C702AF85C822A8L);
-
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
private BluetoothAdapter _adapter = null;
private BluetoothSocket _activeSocket = null;
@@ -195,8 +192,9 @@ public class BTTransport extends SdlTransport {
throw new SdlException("Could not open connection to SDL.", SdlExceptionCause.SDL_CONNECTION_FAILED);
}
- SdlTrace.logTransportEvent("BTTransport: listening for incoming connect to service ID " + _listeningServiceUUID, null, InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY);
-
+ String message = "Bluetooth Transport: Listening for incoming connection to service (id: " + _listeningServiceUUID + ").";
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Receive", message, null));
+
// Setup transportReader thread
_transportReader = new TransportReaderThread();
_transportReader.setName("TransportReader");
@@ -227,9 +225,10 @@ public class BTTransport extends SdlTransport {
if (ex != null) {
disconnectMsg += ", " + ex.toString();
} // end-if
-
- SdlTrace.logTransportEvent("BTTransport.disconnect: " + disconnectMsg, null, InterfaceActivityDirection.Transmit, null, 0, SDL_LIB_TRACE_KEY);
-
+
+ String message = "Bluetooth Transport Disconnect: " + disconnectMsg;
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Transmit", message, null));
+
try {
if (_transportReader != null) {
_transportReader.halt();
@@ -326,7 +325,8 @@ public class BTTransport extends SdlTransport {
}
private void acceptConnection() {
- SdlTrace.logTransportEvent("BTTransport: Waiting for incoming RFCOMM connect", "", InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY);
+ String message = "Bluetooth Transport: Waiting for incoming RFCOMM connect.";
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Receive", message, null));
try {
// Blocks thread until connection established.
@@ -339,8 +339,8 @@ public class BTTransport extends SdlTransport {
// Log info of the connected device
BluetoothDevice btDevice = _activeSocket.getRemoteDevice();
- String btDeviceInfoXml = SdlTrace.getBTDeviceInfo(btDevice);
- SdlTrace.logTransportEvent("BTTransport: RFCOMM Connection Accepted", btDeviceInfoXml, InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY);
+ String msg = "Bluetooth Transport: RFCOMM connection accepted.";
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildTransportTraceMessage("Receive", msg, null, btDevice));
_output = _activeSocket.getOutputStream();
_input = _activeSocket.getInputStream();
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java
index 0543e71ad..3f9aa37d7 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlTransport.java
@@ -1,13 +1,11 @@
package com.smartdevicelink.transport;
import com.smartdevicelink.exception.SdlException;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
public abstract class SdlTransport {
- private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
private final static String FailurePropagating_Msg = "Failure propagating ";
private Boolean isConnected = false;
@@ -34,7 +32,7 @@ public abstract class SdlTransport {
try {
// Trace received data
if (receivedBytesLength > 0) {
- SdlTrace.logTransportEvent("", null, InterfaceActivityDirection.Receive, receivedBytes, receivedBytesLength, SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Receive", null, receivedBytes));
_transportListener.onTransportBytesReceived(receivedBytes, receivedBytesLength);
} // end-if
@@ -62,7 +60,7 @@ public abstract class SdlTransport {
synchronized (_sendLockObj) {
bytesWereSent = sendBytesOverTransport(message, offset, length);
}
- SdlTrace.logTransportEvent("", null, InterfaceActivityDirection.Transmit, message, offset, length, SDL_LIB_TRACE_KEY);
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Transmit", null, message));
return bytesWereSent;
} // end-method
@@ -73,7 +71,8 @@ public abstract class SdlTransport {
protected void handleTransportConnected() {
isConnected = true;
try {
- SdlTrace.logTransportEvent("Transport.connected", null, InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY);
+ String message = "SDL Transport: Connected.";
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Receive", message, null));
_transportListener.onTransportConnected();
} catch (Exception excp) {
SdlLog.e(FailurePropagating_Msg + "onTransportConnected: " + excp.toString(), excp);
@@ -87,7 +86,8 @@ public abstract class SdlTransport {
isConnected = false;
try {
- SdlTrace.logTransportEvent("Transport.disconnect: " + info, null, InterfaceActivityDirection.Transmit, null, 0, SDL_LIB_TRACE_KEY);
+ String message = "SDL Transport: Disconnected - " + info;
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Transmit", message, null));
_transportListener.onTransportDisconnected(info);
} catch (Exception excp) {
SdlLog.e(FailurePropagating_Msg + "onTransportDisconnected: " + excp.toString(), excp);
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java b/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java
index a066240fe..a6c0d6bf8 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/USBTransport.java
@@ -18,10 +18,9 @@ import android.os.ParcelFileDescriptor;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
-import com.smartdevicelink.trace.SdlTrace;
-import com.smartdevicelink.trace.enums.InterfaceActivityDirection;
import com.smartdevicelink.transport.enums.TransportType;
import com.smartdevicelink.util.SdlLog;
+import com.smartdevicelink.util.SdlLog.Mod;
/**
* Class that implements USB transport.
@@ -42,15 +41,6 @@ public class USBTransport extends SdlTransport {
public static final String ACTION_USB_ACCESSORY_ATTACHED =
"com.smartdevicelink.USB_ACCESSORY_ATTACHED";
/**
- * String tag for logging.
- */
- private static final String TAG = USBTransport.class.getSimpleName();
- /**
- * Key for SdlTrace.
- */
- private static final String SDL_LIB_TRACE_KEY =
- "42baba60-eb57-11df-98cf-0800200c9a66";
- /**
* Broadcast action: sent when the user has granted access to the USB
* accessory.
*/
@@ -208,11 +198,8 @@ public class USBTransport extends SdlTransport {
mOutputStream.write(msgBytes, offset, length);
result = true;
- SdlLog.i("Bytes successfully sent");
- SdlTrace.logTransportEvent(TAG + ": bytes sent",
- null, InterfaceActivityDirection.Transmit,
- msgBytes, offset, length,
- SDL_LIB_TRACE_KEY);
+ String message = "USB Transport: Bytes successfully sent.";
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Receive", message, msgBytes));
} catch (IOException e) {
final String msg = "Failed to send bytes over USB";
SdlLog.e(msg, e);
@@ -348,13 +335,10 @@ public class USBTransport extends SdlTransport {
case LISTENING:
case CONNECTED:
synchronized (this) {
- SdlLog.i("Disconnect from state " + getState() + "; message: " +
- msg + "; exception: " + ex);
setState(State.IDLE);
-
- SdlTrace.logTransportEvent(TAG + ": disconnect", null,
- InterfaceActivityDirection.None, null, 0,
- SDL_LIB_TRACE_KEY);
+
+ String message = "USB Transport: Disconnect from state " + getState() + ", message: " + msg + ", exception: " + ex;
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage(null, message, null));
stopReaderThread();
@@ -578,10 +562,6 @@ public class USBTransport extends SdlTransport {
* synchronized (USBTransport.this) { … }
*/
private class USBTransportReader implements Runnable {
- /**
- * String tag for logging inside the task.
- */
- private final String TAG = USBTransportReader.class.getSimpleName();
/**
* Checks if the thread has been interrupted.
@@ -699,10 +679,8 @@ public class USBTransport extends SdlTransport {
return;
}
- SdlLog.d("Read " + bytesRead + " bytes");
- SdlTrace.logTransportEvent(TAG + ": read bytes", null,
- InterfaceActivityDirection.Receive, buffer, bytesRead,
- SDL_LIB_TRACE_KEY);
+ String message = "USB Transport: Bytes successfully read.";
+ SdlLog.t(Mod.TRANSPORT, SdlLog.buildBasicTraceMessage("Receive", message, buffer));
if (isInterrupted()) {
SdlLog.i("Read some data, but thread is interrupted");
diff --git a/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java b/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
index abf6782f1..6738c945b 100644
--- a/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
+++ b/sdl_android_lib/src/com/smartdevicelink/util/SdlLog.java
@@ -3,10 +3,16 @@ package com.smartdevicelink.util;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import android.annotation.SuppressLint;
+import android.bluetooth.BluetoothDevice;
import android.util.Log;
import com.smartdevicelink.exception.SdlException;
+import com.smartdevicelink.protocol.ProtocolFrameHeader;
+import com.smartdevicelink.proxy.RPCMessage;
public class SdlLog {
@@ -36,37 +42,47 @@ public class SdlLog {
* occurs.
*/
private final static int ERROR = 4;
-
- /**
- * Should be used to log SDL specific information.
- */
- private final static int TRACE = 5; // Logs handled seperately.
-
+
private static int enabledLevel = 0;
- private static boolean isTraceEnabled = true;
private static boolean isFileLoggingEnabled = false;
private final static String TAG = "SDL Log";
private final static String SDL = "<SDL> ";
private final static String SDL_TRACE = "<SDL TRACE> ";
- /**
- * Provides whether trace logging is enabled or disabled.
- *
- * @return (boolean) The trace logging toggle.
- */
- public static boolean isTraceEnabled() {
- return isTraceEnabled;
- }
+ public static enum Mod {
+ TRANSPORT(true),
+ PROTOCOL(true),
+ MARSHALL(true),
+ RPC(true),
+ APP(true),
+ PROXY(true);
+
+ private boolean enabled = false;
+
+ Mod(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabledState) {
+ enabled = enabledState;
+ }
+ };
/**
- * Toggles the trace logging functionality.
+ * Sets whether all kinds of trace messages will be logged or not.
*
- * @param log Whether trace logging is to be enabled or disabled.
+ * @param enabledState The state to determine if trace messages will be
+ * logged or not.
*/
- public static void setTraceEnabled(boolean log) {
- isTraceEnabled = log;
- Log.i(TAG, "Trace Logging " + ((log) ? "On" : "Off"));
+ public static void setAllTraceLogging(boolean enabledState) {
+ for (Mod value : Mod.values()) {
+ value.setEnabled(enabledState);
+ }
}
/**
@@ -121,34 +137,12 @@ public class SdlLog {
* Logs messages to the native Android log tool if trace logging has been
* enabled.
*
+ * @param mod The type of trace message to be logged.
* @param message The message to be logged, may not be null or empty.
* @return (boolean) Whether the message was logged successfully.
*/
- public static boolean t(String message) {
- return log(TRACE, message, null);
- }
-
- /**
- * Logs messages to the native Android log tool if trace logging has been
- * enabled.
- *
- * @param message The message to be logged, may not be null or empty.
- * @param details The details of an exception or error, may be null.
- * @return (boolean) Whether the message was logged successfully.
- */
- public static boolean t(String message, Throwable details) {
- return log(TRACE, message, details);
- }
-
- /**
- * Logs messages to the native Android log tool if trace logging has been
- * enabled.
- *
- * @param exception An SDL specific exception.
- * @return (boolean) Whether the message was logged successfully.
- */
- public static boolean t(SdlException exception) {
- return log(TRACE, exception.toString(), null);
+ public static boolean t(Mod mod, String message) {
+ return log(mod, message);
}
/**
@@ -247,7 +241,6 @@ public class SdlLog {
try {
switch (level) {
- case TRACE: if (isTraceEnabled) Log.d(TAG, SDL_TRACE + message, details); break;
case VERBOSE: if (enabledLevel < 1) Log.v(TAG, SDL + message, details); break;
case INFO: if (enabledLevel < 2) Log.i(TAG, SDL + message, details); break;
case DEBUG: if (enabledLevel < 3) Log.d(TAG, SDL + message, details); break;
@@ -258,8 +251,7 @@ public class SdlLog {
if (isFileLoggingEnabled) {
StringBuilder build = new StringBuilder(TAG);
- if (level == TRACE) build.append(SDL_TRACE);
- else build.append(SDL);
+ build.append(SDL);
build.append(message);
build.append("\n");
if (details != null) build.append(details.getMessage());
@@ -274,6 +266,194 @@ public class SdlLog {
return true;
}
+ /**
+ * Logs trace messages that are allowed to the native Android log tool.
+ *
+ * @param type The trace type of the message.
+ * @param message The message to be logged, may not be null or empty.
+ * @return (boolean) Whether the message was logged successfully.
+ */
+ private static boolean log(Mod type, String message) {
+
+ // Do not log null or empty messages.
+ if (message == null || message.equals("")) {
+ return false;
+ }
+
+ // Do not log the message if the type of trace logging has been disabled.
+ if (!type.isEnabled()) {
+ return false;
+ }
+
+ // Prepend the type information to the trace message.
+ message = type + "\n" + message;
+
+ try {
+ switch (type) {
+ case APP: if (enabledLevel < 3) Log.d(SDL_TRACE, message); break;
+ case RPC: if (enabledLevel < 3) Log.d(SDL_TRACE, message); break;
+ case PROXY: if (enabledLevel < 3) Log.d(SDL_TRACE, message); break;
+ case PROTOCOL: if (enabledLevel < 3) Log.d(SDL_TRACE, message); break;
+ case MARSHALL: if (enabledLevel < 3) Log.d(SDL_TRACE, message); break;
+ case TRANSPORT: if (enabledLevel < 3) Log.d(SDL_TRACE, message); break;
+ default: return false;
+ }
+
+ if (isFileLoggingEnabled) {
+ StringBuilder build = new StringBuilder(TAG);
+ build.append(SDL_TRACE);
+ build.append(message);
+ build.append("\n");
+ x(build.toString());
+ }
+ } catch (Throwable t) {
+ // This should never happen!
+ Log.wtf(TAG, "Logging failure!", t);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Constructs the basic formatted trace message.
+ *
+ * @param direction Whether the message was incoming or outgoing, if it does
+ * not have a direction the value may be null.
+ * @param body The extra information to be logged, may be null.
+ * @param data The byte data to be logged, may be null.
+ * @return (String) A formatted trace message.
+ */
+ @SuppressLint("SimpleDateFormat")
+ public static String buildBasicTraceMessage(String direction, String body, byte[] data) {
+ StringBuilder builder = new StringBuilder();
+
+ try {
+ builder.append(new SimpleDateFormat("MM-dd-yyyy hh:mm:sssss").format(new Date()));
+ builder.append("\n");
+ } catch (Exception e) {
+ Log.e(SDL, "Could not parse timestamp for trace message.");
+ }
+
+ if (direction != null) {
+ builder.append("Direction: ");
+ builder.append(direction);
+ builder.append("\n");
+ }
+
+ if (body != null) {
+ builder.append(body);
+ }
+
+ if (data != null) {
+ builder.append("Bytes: \n");
+ builder.append(data);
+ builder.append("\n");
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Constructs the basic formatted protocol trace message.
+ *
+ * @param direction Whether the message was incoming or outgoing, if it does
+ * not have a direction the value may be null.
+ * @param body The extra information to be logged, may be null.
+ * @param data The byte data to be logged, may be null.
+ * @param header Protocol specific trace information.
+ * @return (String) A formatted trace message.
+ */
+ public static String buildProtocolTraceMessage(String direction, String body, byte[] data, ProtocolFrameHeader header) {
+ String basic = buildBasicTraceMessage(direction, body, data);
+ StringBuilder builder = new StringBuilder(basic);
+
+ if (header != null) {
+ builder.append("Version: ");
+ builder.append(header.getVersion());
+ builder.append("\n");
+ builder.append("Compressed State: ");
+ builder.append(header.isCompressed());
+ builder.append("\n");
+ builder.append("Frame Type: ");
+ builder.append(header.getFrameType());
+ builder.append("\n");
+ builder.append("Session Type: ");
+ builder.append(header.getSessionType());
+ builder.append("\n");
+ builder.append("Session Id: ");
+ builder.append(header.getSessionID());
+ builder.append("\n");
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Constructs the basic formatted transport trace message.
+ *
+ * @param direction Whether the message was incoming or outgoing, if it does
+ * not have a direction the value may be null.
+ * @param body The extra information to be logged, may be null.
+ * @param data The byte data to be logged, may be null.
+ * @param btDevice Bluetooth transport specific trace information.
+ * @return (String) A formatted trace message.
+ */
+ public static String buildTransportTraceMessage(String direction, String body, byte[] data, BluetoothDevice btDevice) {
+ String basic = buildBasicTraceMessage(direction, body, data);
+ StringBuilder builder = new StringBuilder(basic);
+
+ if (btDevice != null) {
+ builder.append("Bluetooth Data -- ");
+ builder.append("\n");
+ builder.append("Name: ");
+ builder.append(btDevice.getName());
+ builder.append("\n");
+ builder.append("Address: ");
+ builder.append(btDevice.getAddress());
+ builder.append("\n");
+ builder.append("Bond State: ");
+ builder.append(btDevice.getBondState());
+ builder.append("\n");
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Constructs the basic formatted rpc trace message.
+ *
+ * @param direction Whether the message was incoming or outgoing, if it does
+ * not have a direction the value may be null.
+ * @param body The extra information to be logged, may be null.
+ * @param data The byte data to be logged, may be null.
+ * @param rpc The specific rpc trace information.
+ * @return (String) A formatted trace message.
+ */
+ public static String buildRpcTraceMessage(String direction, String body, byte[] data, RPCMessage rpc) {
+ String basic = buildBasicTraceMessage(direction, body, data);
+ StringBuilder builder = new StringBuilder(basic);
+
+ if (rpc != null) {
+ builder.append("RPC Data -- ");
+ builder.append("\n");
+ builder.append("Function Name: ");
+ builder.append(rpc.getFunctionName());
+ builder.append("\n");
+ builder.append("Message Type: ");
+ builder.append(rpc.getMessageType());
+ builder.append("\n");
+ }
+
+ return builder.toString();
+ }
+
+ /**
+ * Logs a message to a file on the external storage (SD card) of the device.
+ *
+ * @param message The information to be logged to the file.
+ * @return (boolean) Whether the message was logged successfully.
+ */
private static boolean x(String message) {
File logFile = new File("sdcard/sdllog.txt");