diff options
author | Bilal Alsharifi <599206+bilal-alsharifi@users.noreply.github.com> | 2020-06-30 16:27:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 16:27:33 -0400 |
commit | e6e55f14333e1f894e35bf6c20a6271a4cfd9019 (patch) | |
tree | 251e5cfafdcbc6a5e149687fe8d6373a6256f55d | |
parent | 7a2f581925c213a07fbbe0fac2eb7aa6a40e738d (diff) | |
parent | d43a9492a34fb0f446e51fc2f70d8a31223ff696 (diff) | |
download | sdl_android-e6e55f14333e1f894e35bf6c20a6271a4cfd9019.tar.gz |
Merge pull request #1378 from smartdevicelink/bugfix/issue_1377_logging
Create Log Wrapper and Replace Base library logging
98 files changed, 1336 insertions, 1280 deletions
diff --git a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java index bedeb0a39..c850f388c 100755 --- a/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java +++ b/android/hello_sdl_android/src/main/java/com/sdl/hellosdlandroid/SdlReceiver.java @@ -3,17 +3,17 @@ package com.sdl.hellosdlandroid; import android.content.Context; import android.content.Intent; import android.os.Build; -import android.util.Log; import com.smartdevicelink.transport.SdlBroadcastReceiver; import com.smartdevicelink.transport.SdlRouterService; +import com.smartdevicelink.util.DebugTool; public class SdlReceiver extends SdlBroadcastReceiver { private static final String TAG = "SdlBroadcastReciever"; @Override public void onSdlEnabled(Context context, Intent intent) { - Log.d(TAG, "SDL Enabled"); + DebugTool.logInfo(TAG, "SDL Enabled"); intent.setClass(context, SdlService.class); // SdlService needs to be foregrounded in Android O and above diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java index f5265ccf0..cdba04757 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlConnection.java @@ -1,39 +1,38 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.SdlConnection;
import android.content.ComponentName;
-import android.util.Log;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.protocol.AbstractProtocol;
@@ -56,6 +55,7 @@ import com.smartdevicelink.transport.TCPTransportConfig; import com.smartdevicelink.transport.USBTransport;
import com.smartdevicelink.transport.USBTransportConfig;
import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.DebugTool;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -127,10 +127,10 @@ public class SdlConnection implements IProtocolListener, ITransportListener { //rsvp = new RouterServiceValidator(((MultiplexTransportConfig)transportConfig).getContext());
//vlad.setFlags(RouterServiceValidator.FLAG_DEBUG_VERSION_CHECK);
if(rsvp.validate()){
- Log.w(TAG, "SDL Router service is valid; attempting to connect");
+ DebugTool.logWarning(TAG, "SDL Router service is valid; attempting to connect");
((MultiplexTransportConfig)transportConfig).setService(rsvp.getService());//Let thes the transport broker know which service to connect to
}else{
- Log.w(TAG, "SDL Router service isn't trusted. Enabling legacy bluetooth connection.");
+ DebugTool.logWarning(TAG, "SDL Router service isn't trusted. Enabling legacy bluetooth connection.");
if(cachedMultiConfig == null){
cachedMultiConfig = (MultiplexTransportConfig) transportConfig;
cachedMultiConfig.setService(null);
@@ -573,7 +573,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener { public void forceHardwareConnectEvent(TransportType type){
if(_transport == null){
- Log.w(TAG, "Unable to force connect, transport was null!");
+ DebugTool.logWarning(TAG, "Unable to force connect, transport was null!");
return;
}
if(isLegacyModeEnabled()){//We know we should no longer be in legacy mode for future connections, so lets clear out that flag
@@ -594,7 +594,7 @@ public class SdlConnection implements IProtocolListener, ITransportListener { }
}else if(tempCompName!=null){
//We have a conflicting service request
- Log.w(TAG, "Conflicting services. Disconnecting from current and connecting to new");
+ DebugTool.logWarning(TAG, "Conflicting services. Disconnecting from current and connecting to new");
//Log.w(TAG, "Old service " + config.getService().toShortString());
//Log.w(TAG, "New Serivce " + tempCompName.toString());
multi.disconnect();
@@ -626,9 +626,9 @@ public class SdlConnection implements IProtocolListener, ITransportListener { //_transport.disconnect();
return;
}
- Log.w(TAG, "Using own transport, but not connected. Attempting to join multiplexing");
+ DebugTool.logWarning(TAG, "Using own transport, but not connected. Attempting to join multiplexing");
}else{
- Log.w(TAG, "Currently in legacy mode connected to own transport service. Nothing will take place on trnasport cycle");
+ DebugTool.logWarning(TAG, "Currently in legacy mode connected to own transport service. Nothing will take place on trnasport cycle");
}
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java index 7b6f67e6b..86488cca0 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java @@ -33,7 +33,6 @@ package com.smartdevicelink.SdlConnection; import android.annotation.SuppressLint;
import android.os.Build;
-import android.util.Log;
import android.view.Surface;
import com.smartdevicelink.encoder.SdlEncoder;
@@ -61,6 +60,7 @@ import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.transport.BaseTransportConfig;
import com.smartdevicelink.transport.MultiplexTransport;
import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.Version;
import java.io.IOException;
@@ -264,7 +264,7 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList return packetizer;
}
default:
- Log.e(TAG, "Protocol " + protocol + " is not supported.");
+ DebugTool.logError(TAG, "Protocol " + protocol + " is not supported.");
return null;
}
} catch (IOException e) {
@@ -291,7 +291,7 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList mRPCPacketizer = new StreamRPCPacketizer(null, this, is, request, sType, rpcSessionID, wiproVersion, 0, this);
mRPCPacketizer.start();
} catch (Exception e) {
- Log.e(TAG, "Unable to start streaming:" + e.toString());
+ DebugTool.logError(TAG, "Unable to start streaming:" + e.toString());
}
}
@@ -304,7 +304,7 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList mRPCPacketizer.start();
return os;
} catch (Exception e) {
- Log.e(TAG, "Unable to start streaming:" + e.toString());
+ DebugTool.logError(TAG, "Unable to start streaming:" + e.toString());
}
return null;
}
@@ -638,7 +638,7 @@ public class SdlSession implements ISdlConnectionListener, IHeartbeatMonitorList @Override
public void sendHeartbeat(IHeartbeatMonitor monitor) {
- Log.d(TAG, "Asked to send heartbeat");
+ DebugTool.logInfo(TAG, "Asked to send heartbeat");
if (_sdlConnection != null)
_sdlConnection.sendHeartbeat(this);
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java index 14258cbfe..44bb1fbfc 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/SdlConnection/SdlSession2.java @@ -33,7 +33,6 @@ package com.smartdevicelink.SdlConnection; import android.content.Context; -import android.util.Log; import com.smartdevicelink.exception.SdlException; import com.smartdevicelink.protocol.ISdlProtocol; @@ -47,6 +46,7 @@ import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.MultiplexTransportConfig; import com.smartdevicelink.transport.TCPTransportConfig; import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.MediaStreamingStatus; import com.smartdevicelink.util.Version; @@ -210,7 +210,7 @@ public class SdlSession2 extends SdlSession implements ISdlProtocol{ public void shutdown(String info){ - Log.d(TAG, "Shutdown - " + info); + DebugTool.logInfo(TAG, "Shutdown - " + info); if(mediaStreamingStatus != null) { mediaStreamingStatus.clear(); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java index 362564da8..8f3001294 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/EncoderUtils.java @@ -33,7 +33,8 @@ package com.smartdevicelink.encoder; import android.annotation.TargetApi; import android.media.MediaFormat; import android.os.Build; -import android.util.Log; + +import com.smartdevicelink.util.DebugTool; import java.nio.ByteBuffer; @@ -63,7 +64,7 @@ public final class EncoderUtils { if (name.equals("video/avc")) { return getAVCCodecSpecificData(format); } else { - Log.w(TAG, "Retrieving codec-specific data for " + name + " is not supported"); + DebugTool.logWarning(TAG, "Retrieving codec-specific data for " + name + " is not supported"); return null; } } @@ -81,7 +82,7 @@ public final class EncoderUtils { // For H.264, "csd-0" contains SPS and "csd-1" contains PPS. Refer to the documentation // of MediaCodec. if (!(format.containsKey("csd-0") && format.containsKey("csd-1"))) { - Log.w(TAG, "H264 codec specific data not found"); + DebugTool.logWarning(TAG, "H264 codec specific data not found"); return null; } @@ -96,7 +97,7 @@ public final class EncoderUtils { pps.get(output, spsLen, ppsLen); } catch (Exception e) { // should not happen - Log.w(TAG, "Error while copying H264 codec specific data: " + e); + DebugTool.logWarning(TAG, "Error while copying H264 codec specific data: " + e); return null; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java index dafb3207c..7172b0225 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/SdlEncoder.java @@ -36,10 +36,10 @@ import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.os.Build; -import android.util.Log; import android.view.Surface; import com.smartdevicelink.proxy.interfaces.IVideoStreamListener; +import com.smartdevicelink.util.DebugTool; import java.io.IOException; import java.io.PipedOutputStream; @@ -198,7 +198,7 @@ public class SdlEncoder { MediaFormat format = mEncoder.getOutputFormat(); mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format); } else { - Log.w(TAG, "Output format change notified more than once, ignoring."); + DebugTool.logWarning(TAG, "Output format change notified more than once, ignoring."); } } else if (encoderStatus < 0) { } else { @@ -208,7 +208,7 @@ public class SdlEncoder { if (mH264CodecSpecificData != null) { mBufferInfo.size = 0; } else { - Log.i(TAG, "H264 codec specific data not retrieved yet."); + DebugTool.logInfo(TAG, "H264 codec specific data not retrieved yet."); } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java index 6b7f2a686..766e10aaa 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java @@ -40,7 +40,6 @@ import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.os.Build; -import android.util.Log; import android.view.Display; import android.view.Surface; @@ -49,6 +48,7 @@ import com.smartdevicelink.proxy.rpc.ImageResolution; import com.smartdevicelink.proxy.rpc.VideoStreamingFormat; import com.smartdevicelink.proxy.rpc.enums.VideoStreamingCodec; import com.smartdevicelink.streaming.video.VideoStreamingParameters; +import com.smartdevicelink.util.DebugTool; import java.nio.ByteBuffer; @@ -83,12 +83,12 @@ public class VirtualDisplayEncoder { */ public void init(Context context, IVideoStreamListener outputListener, VideoStreamingParameters streamingParams) throws Exception { if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - Log.e(TAG, "API level of 19 required for VirtualDisplayEncoder"); + DebugTool.logError(TAG, "API level of 19 required for VirtualDisplayEncoder"); throw new Exception("API level of 19 required"); } if (context == null || outputListener == null || streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) { - Log.e(TAG, "init parameters cannot be null for VirtualDisplayEncoder"); + DebugTool.logError(TAG, "init parameters cannot be null for VirtualDisplayEncoder"); throw new Exception("init parameters cannot be null"); } @@ -122,7 +122,7 @@ public class VirtualDisplayEncoder { */ public void start() throws Exception { if (!initPassed) { - Log.e(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method."); + DebugTool.logError(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method."); return; } if (streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) { @@ -142,7 +142,7 @@ public class VirtualDisplayEncoder { startEncoder(); } catch (Exception ex) { - Log.e(TAG, "Unable to create Virtual Display."); + DebugTool.logError(TAG, "Unable to create Virtual Display."); throw new RuntimeException(ex); } } @@ -150,7 +150,7 @@ public class VirtualDisplayEncoder { public void shutDown() { if (!initPassed) { - Log.e(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method."); + DebugTool.logError(TAG, "VirtualDisplayEncoder was not properly initialized with the init() method."); return; } try { @@ -175,7 +175,7 @@ public class VirtualDisplayEncoder { inputSurface = null; } } catch (Exception ex) { - Log.e(TAG, "shutDown() failed"); + DebugTool.logError(TAG, "shutDown() failed"); } } @@ -266,7 +266,7 @@ public class VirtualDisplayEncoder { encoderThread = new Thread(new EncoderCompat()); } else { - Log.e(TAG, "Unable to start encoder. Android OS version " + Build.VERSION.SDK_INT + "is not supported"); + DebugTool.logError(TAG, "Unable to start encoder. Android OS version " + Build.VERSION.SDK_INT + "is not supported"); } return surface; @@ -315,7 +315,7 @@ public class VirtualDisplayEncoder { try { drainEncoder(false); } catch (Exception e) { - Log.w(TAG, "Error attempting to drain encoder"); + DebugTool.logWarning(TAG, "Error attempting to drain encoder"); } finally { mVideoEncoder.release(); } @@ -349,7 +349,7 @@ public class VirtualDisplayEncoder { MediaFormat format = mVideoEncoder.getOutputFormat(); mH264CodecSpecificData = EncoderUtils.getCodecSpecificData(format); } else { - Log.w(TAG, "Output format change notified more than once, ignoring."); + DebugTool.logWarning(TAG, "Output format change notified more than once, ignoring."); } } } else { @@ -359,7 +359,7 @@ public class VirtualDisplayEncoder { if (mH264CodecSpecificData != null) { mVideoBufferInfo.size = 0; } else { - Log.i(TAG, "H264 codec specific data not retrieved yet."); + DebugTool.logInfo(TAG, "H264 codec specific data not retrieved yet."); } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java index b993724ba..06b9abd7b 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java @@ -39,7 +39,6 @@ import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.util.Log; import com.smartdevicelink.managers.audio.AudioStreamManager; import com.smartdevicelink.managers.file.FileManager; @@ -155,22 +154,22 @@ public class SdlManager extends BaseSdlManager { void checkState() { if (permissionManager != null && fileManager != null && screenManager != null && (!lockScreenConfig.isEnabled() || lockScreenManager != null)) { if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY && (!lockScreenConfig.isEnabled() || lockScreenManager.getState() == BaseSubManager.READY)) { - DebugTool.logInfo("Starting sdl manager, all sub managers are in ready state"); + DebugTool.logInfo(TAG, "Starting sdl manager, all sub managers are in ready state"); transitionToState(BaseSubManager.READY); handleQueuedNotifications(); notifyDevListener(null); onReady(); } else if (permissionManager.getState() == BaseSubManager.ERROR && fileManager.getState() == BaseSubManager.ERROR && screenManager.getState() == BaseSubManager.ERROR && (!lockScreenConfig.isEnabled() || lockScreenManager.getState() == BaseSubManager.ERROR)) { String info = "ERROR starting sdl manager, all sub managers are in error state"; - Log.e(TAG, info); + DebugTool.logError(TAG, info); transitionToState(BaseSubManager.ERROR); notifyDevListener(info); } else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP || (lockScreenConfig.isEnabled() && lockScreenManager != null && lockScreenManager.getState() == BaseSubManager.SETTING_UP)) { - DebugTool.logInfo("SETTING UP sdl manager, some sub managers are still setting up"); + DebugTool.logInfo(TAG, "SETTING UP sdl manager, some sub managers are still setting up"); transitionToState(BaseSubManager.SETTING_UP); // No need to notify developer here! } else { - Log.w(TAG, "LIMITED starting sdl manager, some sub managers are in error or limited state and the others finished setting up"); + DebugTool.logWarning(TAG, "LIMITED starting sdl manager, some sub managers are in error or limited state and the others finished setting up"); transitionToState(BaseSubManager.LIMITED); handleQueuedNotifications(); notifyDevListener(null); @@ -179,7 +178,7 @@ public class SdlManager extends BaseSdlManager { } else { // We should never be here, but somehow one of the sub-sub managers is null String info = "ERROR one of the sdl sub managers is null"; - Log.e(TAG, info); + DebugTool.logError(TAG, info); transitionToState(BaseSubManager.ERROR); notifyDevListener(info); } @@ -204,7 +203,7 @@ public class SdlManager extends BaseSdlManager { @Override public void run() { checkLifecycleConfiguration(); - DebugTool.logInfo("Retry Change Registration Count: " + changeRegistrationRetry); + DebugTool.logInfo(TAG, "Retry Change Registration Count: " + changeRegistrationRetry); } }, 3000); } @@ -294,7 +293,7 @@ public class SdlManager extends BaseSdlManager { */ public LockScreenManager getLockScreenManager() { if (lockScreenManager.getState() != BaseSubManager.READY && lockScreenManager.getState() != BaseSubManager.LIMITED) { - Log.e(TAG, "LockScreenManager should not be accessed because it is not in READY/LIMITED state"); + DebugTool.logError(TAG, "LockScreenManager should not be accessed because it is not in READY/LIMITED state"); } checkSdlManagerState(); return lockScreenManager; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoder.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoder.java index e88313036..cba0d212b 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoder.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.managers.audio;
import android.content.Context;
@@ -38,9 +38,9 @@ import android.net.Uri; import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
-import android.util.Log;
import com.smartdevicelink.managers.audio.AudioStreamManager.SampleType;
+import com.smartdevicelink.util.DebugTool;
import java.nio.ByteBuffer;
@@ -89,7 +89,7 @@ public class AudioDecoder extends BaseAudioDecoder { SampleBuffer targetSampleBuffer = AudioDecoder.super.onOutputBufferAvailable(outputBuffer);
AudioDecoder.this.listener.onAudioDataAvailable(targetSampleBuffer);
} else {
- Log.w(TAG, "output buffer empty. Chance that silence was detected");
+ DebugTool.logWarning(TAG, "output buffer empty. Chance that silence was detected");
}
mediaCodec.releaseOutputBuffer(i, false);
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoderCompat.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoderCompat.java index 984475eaf..1fdf5b219 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoderCompat.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioDecoderCompat.java @@ -38,9 +38,9 @@ import android.net.Uri; import android.os.Build; import android.support.annotation.NonNull; import android.support.annotation.RequiresApi; -import android.util.Log; import com.smartdevicelink.managers.audio.AudioStreamManager.SampleType; +import com.smartdevicelink.util.DebugTool; import java.lang.ref.WeakReference; import java.nio.ByteBuffer; @@ -107,7 +107,7 @@ public class AudioDecoderCompat extends BaseAudioDecoder { public void run() { final AudioDecoderCompat reference = weakReference.get(); if (reference == null) { - Log.w(TAG, "AudioDecoderCompat reference was null"); + DebugTool.logWarning(TAG, "AudioDecoderCompat reference was null"); return; } final ByteBuffer[] inputBuffersArray = reference.decoder.getInputBuffers(); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java index 55bff7bba..bb78741c7 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/AudioStreamManager.java @@ -41,7 +41,6 @@ import android.os.Looper; import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
-import android.util.Log;
import com.smartdevicelink.SdlConnection.SdlSession;
import com.smartdevicelink.managers.CompletionListener;
@@ -60,6 +59,7 @@ import com.smartdevicelink.proxy.rpc.enums.PredefinedWindows; import com.smartdevicelink.proxy.rpc.enums.SystemCapabilityType;
import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener;
import com.smartdevicelink.transport.utl.TransportRecord;
+import com.smartdevicelink.util.DebugTool;
import com.smartdevicelink.util.Version;
import java.lang.annotation.Retention;
@@ -145,7 +145,7 @@ public class AudioStreamManager extends BaseAudioStreamManager { serviceCompletionHandler.removeCallbacks(serviceCompletionTimeoutCallback);
streamingStateMachine.transitionToState(StreamingStateMachine.ERROR);
- Log.e(TAG, "OnServiceError: " + reason);
+ DebugTool.logError(TAG, "OnServiceError: " + reason);
streamingStateMachine.transitionToState(StreamingStateMachine.NONE);
if (serviceCompletionListener != null) {
@@ -229,7 +229,7 @@ public class AudioStreamManager extends BaseAudioStreamManager { @Override
public void onError(String info) {
- Log.e(TAG, "Error retrieving audio streaming capability: " + info);
+ DebugTool.logError(TAG, "Error retrieving audio streaming capability: " + info);
streamingStateMachine.transitionToState(StreamingStateMachine.ERROR);
transitionToState(ERROR);
}
@@ -256,14 +256,14 @@ public class AudioStreamManager extends BaseAudioStreamManager { public void startAudioStream(boolean encrypted, final CompletionListener completionListener) {
// audio stream cannot be started without a connected internal interface
if (!internalInterface.isConnected()) {
- Log.w(TAG, "startAudioStream called without being connected.");
+ DebugTool.logWarning(TAG, "startAudioStream called without being connected.");
finish(completionListener, false);
return;
}
// streaming state must be NONE (starting the service is ready. starting stream is started)
if (streamingStateMachine.getState() != StreamingStateMachine.NONE) {
- Log.w(TAG, "startAudioStream called but streamingStateMachine is not in state NONE (current: " + streamingStateMachine.getState() + ")");
+ DebugTool.logWarning(TAG, "startAudioStream called but streamingStateMachine is not in state NONE (current: " + streamingStateMachine.getState() + ")");
finish(completionListener, false);
return;
}
@@ -333,14 +333,14 @@ public class AudioStreamManager extends BaseAudioStreamManager { */
public void stopAudioStream(final CompletionListener completionListener) {
if (!internalInterface.isConnected()) {
- Log.w(TAG, "stopAudioStream called without being connected");
+ DebugTool.logWarning(TAG, "stopAudioStream called without being connected");
finish(completionListener, false);
return;
}
// streaming state must be STARTED (starting the service is ready. starting stream is started)
if (streamingStateMachine.getState() != StreamingStateMachine.STARTED) {
- Log.w(TAG, "stopAudioStream called but streamingStateMachine is not STARTED (current: " + streamingStateMachine.getState() + ")");
+ DebugTool.logWarning(TAG, "stopAudioStream called but streamingStateMachine is not STARTED (current: " + streamingStateMachine.getState() + ")");
finish(completionListener, false);
return;
}
@@ -414,7 +414,7 @@ public class AudioStreamManager extends BaseAudioStreamManager { @Override
public void onDecoderError(Exception e) {
- Log.e(TAG, "decoder error", e);
+ DebugTool.logError(TAG, "decoder error", e);
}
};
@@ -444,7 +444,7 @@ public class AudioStreamManager extends BaseAudioStreamManager { public void pushBuffer(ByteBuffer data, CompletionListener completionListener) {
// streaming state must be STARTED (starting the service is ready. starting stream is started)
if (streamingStateMachine.getState() != StreamingStateMachine.STARTED) {
- Log.w(TAG, "AudioStreamManager is not ready!");
+ DebugTool.logWarning(TAG, "AudioStreamManager is not ready!");
return;
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/BaseAudioDecoder.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/BaseAudioDecoder.java index f0a04dc7b..14ad46620 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/BaseAudioDecoder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/BaseAudioDecoder.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.managers.audio;
import android.content.Context;
@@ -40,10 +40,10 @@ import android.net.Uri; import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
-import android.util.Log;
import com.smartdevicelink.managers.audio.AudioStreamManager.SampleType;
import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities;
+import com.smartdevicelink.util.DebugTool;
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
@@ -252,7 +252,7 @@ public abstract class BaseAudioDecoder { }
protected void onMediaCodecError(@NonNull MediaCodec.CodecException e) {
- Log.e(TAG, "MediaCodec.onError: " + e.getLocalizedMessage());
+ DebugTool.logError(TAG, "MediaCodec.onError: " + e.getLocalizedMessage());
if (listener != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
listener.onDecoderError(e);
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/SampleBuffer.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/SampleBuffer.java index af618c696..05a9cc285 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/SampleBuffer.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/audio/SampleBuffer.java @@ -1,39 +1,38 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.managers.audio;
-import android.util.Log;
-
import com.smartdevicelink.managers.audio.AudioStreamManager.SampleType;
+import com.smartdevicelink.util.DebugTool;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@@ -210,7 +209,7 @@ public class SampleBuffer { return avg;
}
default: {
- Log.e(TAG, "SampleBuffer.get(int): The sample type is not known: " + sampleType);
+ DebugTool.logError(TAG, "SampleBuffer.get(int): The sample type is not known: " + sampleType);
return 0.0;
}
}
@@ -274,7 +273,7 @@ public class SampleBuffer { break;
}
default: {
- Log.e(TAG, "SampleBuffer.set(int): The sample type is not known: " + sampleType);
+ DebugTool.logError(TAG, "SampleBuffer.set(int): The sample type is not known: " + sampleType);
}
}
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java index 3e1702346..a29ce1536 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/file/FileManager.java @@ -36,11 +36,11 @@ import android.content.Context; import android.content.res.Resources; import android.net.Uri; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.managers.file.filetypes.SdlFile; import com.smartdevicelink.proxy.interfaces.ISdl; import com.smartdevicelink.proxy.rpc.PutFile; +import com.smartdevicelink.util.DebugTool; import java.io.IOException; import java.io.InputStream; @@ -142,7 +142,7 @@ public class FileManager extends BaseFileManager { is = context.get().getResources().openRawResource(resource); return contentsOfInputStream(is); } catch (Resources.NotFoundException e) { - Log.w(TAG, "Can't read from resource", e); + DebugTool.logError(TAG, "Can't read from resource", e); return null; } finally { if (is != null) { @@ -166,7 +166,7 @@ public class FileManager extends BaseFileManager { is = context.get().getContentResolver().openInputStream(uri); return contentsOfInputStream(is); } catch (IOException e){ - Log.w(TAG, "Can't read from Uri", e); + DebugTool.logError(TAG, "Can't read from Uri", e); return null; } finally { if (is != null) { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java index 38c8e4c26..021e5d49a 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java @@ -35,7 +35,6 @@ package com.smartdevicelink.managers.lifecycle; import android.app.Service; import android.content.Context; import android.support.annotation.RestrictTo; -import android.util.Log; import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.SdlConnection.SdlSession2; @@ -83,7 +82,7 @@ public class LifecycleManager extends BaseLifecycleManager { //A USB transport config was provided USBTransportConfig usbTransportConfig = (USBTransportConfig) _transportConfig; if (usbTransportConfig.getUsbAccessory() == null) { - DebugTool.logInfo("Legacy USB transport config was used, but received null for accessory. Attempting to connect with router service"); + DebugTool.logInfo(TAG,"Legacy USB transport config was used, but received null for accessory. Attempting to connect with router service"); //The accessory was null which means it came from a router service MultiplexTransportConfig multiplexTransportConfig = new MultiplexTransportConfig(usbTransportConfig.getUSBContext(), appConfig.getAppID()); multiplexTransportConfig.setRequiresHighBandwidth(true); @@ -156,7 +155,7 @@ public class LifecycleManager extends BaseLifecycleManager { super.onTransportDisconnected(info, availablePrimary, transportConfig); if (availablePrimary) { _transportConfig = transportConfig; - Log.d(TAG, "notifying RPC session ended, but potential primary transport available"); + DebugTool.logInfo(TAG, "notifying RPC session ended, but potential primary transport available"); cycle(SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST); } else { onClose(info, null, null); @@ -182,11 +181,11 @@ public class LifecycleManager extends BaseLifecycleManager { @Override void startVideoService(boolean isEncrypted, VideoStreamingParameters parameters) { if (session == null) { - DebugTool.logWarning("SdlSession is not created yet."); + DebugTool.logWarning(TAG, "SdlSession is not created yet."); return; } if (!session.getIsConnected()) { - DebugTool.logWarning("Connection is not available."); + DebugTool.logWarning(TAG, "Connection is not available."); return; } @@ -207,15 +206,15 @@ public class LifecycleManager extends BaseLifecycleManager { */ private void tryStartVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) { if (session == null) { - DebugTool.logWarning("SdlSession is not created yet."); + DebugTool.logWarning(TAG, "SdlSession is not created yet."); return; } if (getProtocolVersion() != null && getProtocolVersion().getMajor() >= 5 && !systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)) { - DebugTool.logWarning("Module doesn't support video streaming."); + DebugTool.logWarning(TAG, "Module doesn't support video streaming."); return; } if (parameters == null) { - DebugTool.logWarning("Video parameters were not supplied."); + DebugTool.logWarning(TAG, "Video parameters were not supplied."); return; } @@ -270,11 +269,11 @@ public class LifecycleManager extends BaseLifecycleManager { @Override void endVideoStream() { if (session == null) { - DebugTool.logWarning("SdlSession is not created yet."); + DebugTool.logWarning(TAG, "SdlSession is not created yet."); return; } if (!session.getIsConnected()) { - DebugTool.logWarning("Connection is not available."); + DebugTool.logWarning(TAG, "Connection is not available."); return; } @@ -284,11 +283,11 @@ public class LifecycleManager extends BaseLifecycleManager { @Override void startAudioService(boolean isEncrypted) { if (session == null) { - DebugTool.logWarning("SdlSession is not created yet."); + DebugTool.logWarning(TAG, "SdlSession is not created yet."); return; } if (!session.getIsConnected()) { - DebugTool.logWarning("Connection is not available."); + DebugTool.logWarning(TAG, "Connection is not available."); return; } session.startService(SessionType.PCM, session.getSessionId(), isEncrypted); @@ -302,11 +301,11 @@ public class LifecycleManager extends BaseLifecycleManager { @Override void endAudioStream() { if (session == null) { - DebugTool.logWarning("SdlSession is not created yet."); + DebugTool.logWarning(TAG, "SdlSession is not created yet."); return; } if (!session.getIsConnected()) { - DebugTool.logWarning("Connection is not available."); + DebugTool.logWarning(TAG, "Connection is not available."); return; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManager.java index b2b8e6b14..711afcc72 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenDeviceIconManager.java @@ -27,6 +27,7 @@ class LockScreenDeviceIconManager { private Context context; private static final String SDL_DEVICE_STATUS_SHARED_PREFS = "sdl.lockScreenIcon"; private static final String STORED_ICON_DIRECTORY_PATH = "sdl/lock_screen_icon/"; + private static final String TAG = "LockScreenDeviceIconManager"; interface OnIconRetrievedListener { void onImageRetrieved(Bitmap icon); @@ -49,10 +50,10 @@ class LockScreenDeviceIconManager { Bitmap icon = null; try { if (isIconCachedAndValid(iconURL)) { - DebugTool.logInfo("Icon Is Up To Date"); + DebugTool.logInfo(TAG, "Icon Is Up To Date"); icon = getFileFromCache(iconURL); if (icon == null) { - DebugTool.logInfo("Icon from cache was null, attempting to re-download"); + DebugTool.logInfo(TAG, "Icon from cache was null, attempting to re-download"); icon = AndroidTools.downloadImage(iconURL); if (icon != null) { saveFileToCache(icon, iconURL); @@ -64,7 +65,7 @@ class LockScreenDeviceIconManager { iconRetrievedListener.onImageRetrieved(icon); } else { // The icon is unknown or expired. Download the image, save it to the cache, and update the archive file - DebugTool.logInfo("Lock Screen Icon Update Needed"); + DebugTool.logInfo(TAG, "Lock Screen Icon Update Needed"); icon = AndroidTools.downloadImage(iconURL); if (icon != null) { saveFileToCache(icon, iconURL); @@ -94,15 +95,15 @@ class LockScreenDeviceIconManager { SharedPreferences sharedPref = this.context.getSharedPreferences(SDL_DEVICE_STATUS_SHARED_PREFS, Context.MODE_PRIVATE); String iconLastUpdatedTime = sharedPref.getString(iconHash, null); if(iconLastUpdatedTime == null) { - DebugTool.logInfo("No Icon Details Found In Shared Preferences"); + DebugTool.logInfo(TAG, "No Icon Details Found In Shared Preferences"); return false; } else { - DebugTool.logInfo("Icon Details Found"); + DebugTool.logInfo(TAG, "Icon Details Found"); long lastUpdatedTime = 0; try { lastUpdatedTime = Long.parseLong(iconLastUpdatedTime); } catch (NumberFormatException e) { - DebugTool.logInfo("Invalid time stamp stored to shared preferences, clearing cache and share preferences"); + DebugTool.logInfo(TAG, "Invalid time stamp stored to shared preferences, clearing cache and share preferences"); clearIconDirectory(); sharedPref.edit().clear().commit(); } @@ -134,7 +135,7 @@ class LockScreenDeviceIconManager { fos.close(); writeDeviceIconParametersToSharedPreferences(iconHash); } catch (Exception e) { - DebugTool.logError("Failed to save icon to cache"); + DebugTool.logError(TAG, "Failed to save icon to cache"); e.printStackTrace(); } } @@ -152,7 +153,7 @@ class LockScreenDeviceIconManager { if (iconLastUpdatedTime != null) { Bitmap cachedIcon = BitmapFactory.decodeFile(this.context.getCacheDir() + "/" + STORED_ICON_DIRECTORY_PATH + "/" + iconHash); if(cachedIcon == null) { - DebugTool.logError("Failed to get Bitmap from decoding file cache"); + DebugTool.logError(TAG, "Failed to get Bitmap from decoding file cache"); clearIconDirectory(); sharedPref.edit().clear().commit(); return null; @@ -160,7 +161,7 @@ class LockScreenDeviceIconManager { return cachedIcon; } } else { - DebugTool.logError("Failed to get shared preferences"); + DebugTool.logError(TAG, "Failed to get shared preferences"); return null; } } @@ -194,7 +195,7 @@ class LockScreenDeviceIconManager { } iconHash = hashtext; } catch (NoSuchAlgorithmException e) { - DebugTool.logError("Unable to hash icon url"); + DebugTool.logError(TAG, "Unable to hash icon url"); e.printStackTrace(); } return iconHash; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java index 2e81894ed..9e63b9fb8 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/lockscreen/LockScreenManager.java @@ -38,7 +38,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; import android.os.Build; -import android.util.Log; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -192,7 +191,7 @@ public class LockScreenManager extends BaseSubManager { if (notification != null) { OnDriverDistraction ddState = (OnDriverDistraction) notification; Boolean isDismissible = ddState.getLockscreenDismissibility(); - Log.i(TAG, "Lock screen dismissible: "+ isDismissible); + DebugTool.logInfo(TAG, "Lock screen dismissible: "+ isDismissible); if (isDismissible != null) { // both of these conditions must be met to be able to dismiss lockscreen if (isDismissible && enableDismissGesture){ @@ -393,7 +392,7 @@ public class LockScreenManager extends BaseSubManager { @Override public void onError(String info) { - DebugTool.logError(info); + DebugTool.logError(TAG, info); } }); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java index b6f49a9a4..a9225e0eb 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java @@ -36,7 +36,6 @@ import android.annotation.TargetApi; import android.content.Context; import android.os.SystemClock; import android.util.DisplayMetrics; -import android.util.Log; import android.view.Display; import android.view.InputDevice; import android.view.MotionEvent; @@ -110,7 +109,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { } if (VideoStreamManager.this.streamListener == null) { - Log.e(TAG, "Error starting video stream"); + DebugTool.logError(TAG, "Error starting video stream"); stateMachine.transitionToState(StreamingStateMachine.ERROR); return; } @@ -137,7 +136,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { @Override public void onServiceError(SdlSession session, SessionType type, String reason) { - DebugTool.logError("Unable to start video service: " + reason); + DebugTool.logError(TAG, "Unable to start video service: " + reason); stateMachine.transitionToState(StreamingStateMachine.ERROR); transitionToState(BaseSubManager.ERROR); } @@ -236,7 +235,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { @Override public void onError(String info) { - Log.e(TAG, "Error retrieving video streaming capability: " + info); + DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info); stateMachine.transitionToState(StreamingStateMachine.ERROR); transitionToState(ERROR); } @@ -269,7 +268,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { this.remoteDisplayClass = remoteDisplayClass; int majorProtocolVersion = internalInterface.getProtocolVersion().getMajor(); if(majorProtocolVersion >= 5 && !internalInterface.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){ - Log.e(TAG, "Video streaming not supported on this module"); + DebugTool.logError(TAG, "Video streaming not supported on this module"); stateMachine.transitionToState(StreamingStateMachine.ERROR); return; } @@ -286,7 +285,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { @Override public void onError(String info) { stateMachine.transitionToState(StreamingStateMachine.ERROR); - Log.e(TAG, "Error retrieving video streaming capability: " + info); + DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info); } }); }else{ @@ -313,7 +312,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { protected void startStreaming(VideoStreamingParameters parameters, boolean encrypted){ this.parameters = parameters; if (!isHMIStateVideoStreamCapable(currentOnHMIStatus)) { - Log.e(TAG, "Cannot start video service in the current HMI status"); + DebugTool.logError(TAG, "Cannot start video service in the current HMI status"); return; } //Start the video service @@ -496,7 +495,7 @@ public class VideoStreamManager extends BaseVideoStreamManager { showPresentation.start(); } catch (Exception ex) { - Log.e(TAG, "Unable to create Virtual Display."); + DebugTool.logError(TAG, "Unable to create Virtual Display."); if(DebugTool.isDebugEnabled()){ ex.printStackTrace(); } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java b/android/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java index 7a6292505..21a34c695 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/protocol/SdlPacket.java @@ -7,6 +7,7 @@ import com.smartdevicelink.transport.utl.TransportRecord; import com.smartdevicelink.util.DebugTool; public class SdlPacket extends BaseSdlPacket implements Parcelable { + private static final String TAG = "SdlPacket"; private static final int EXTRA_PARCEL_DATA_LENGTH = 24; public SdlPacket(int version, boolean encryption, int frameType, @@ -61,7 +62,7 @@ public class SdlPacket extends BaseSdlPacket implements Parcelable { } } }catch (RuntimeException e){ - DebugTool.logError("Error creating packet from parcel", e); + DebugTool.logError(TAG, "Error creating packet from parcel", e); } } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java b/android/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java index 4a9c68dc5..ad887929a 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/protocol/WiProProtocol.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.protocol;
import com.smartdevicelink.SdlConnection.SdlConnection;
@@ -60,6 +60,7 @@ import java.util.List; */
@Deprecated
public class WiProProtocol extends AbstractProtocol {
+ private static final String TAG = "WiProProtocol";
private final static String FailurePropagating_Msg = "Failure propagating ";
//If increasing MAX PROTOCOL VERSION major version, make sure to alter it in SdlPsm
public static final Version MAX_PROTOCOL_VERSION = new Version("5.0.0");
@@ -365,7 +366,7 @@ public class WiProProtocol extends AbstractProtocol { try {
accumulator = new ByteArrayOutputStream(totalSize);
}catch(OutOfMemoryError e){
- DebugTool.logError("OutOfMemory error", e); //Garbled bits were received
+ DebugTool.logError(TAG, "OutOfMemory error", e); //Garbled bits were received
accumulator = null;
}
}
@@ -405,7 +406,7 @@ public class WiProProtocol extends AbstractProtocol { try {
handleProtocolMessageReceived(message);
} catch (Exception excp) {
- DebugTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp);
+ DebugTool.logError(TAG, FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp);
} // end-catch
hasFirstFrame = false;
@@ -631,7 +632,7 @@ public class WiProProtocol extends AbstractProtocol { try {
handleProtocolMessageReceived(message);
} catch (Exception ex) {
- DebugTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex);
+ DebugTool.logError(TAG,FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex);
handleProtocolError(FailurePropagating_Msg + "onProtocolMessageReceived: ", ex);
} // end-catch
} // end-method
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java index b42360019..b3d6df61d 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java @@ -43,7 +43,6 @@ import android.os.SystemClock; import android.support.annotation.NonNull;
import android.telephony.TelephonyManager;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.util.SparseArray;
import android.view.Display;
import android.view.InputDevice;
@@ -416,7 +415,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> try{
SdlProxyBase.this.sendSequentialRequests(rpcs,listener);
}catch (SdlException e ){
- DebugTool.logError("Issue sending sequential RPCs ", e);
+ DebugTool.logError(TAG, "Issue sending sequential RPCs ", e);
}
}
@@ -592,7 +591,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> //if (!_advancedLifecycleManagementEnabled) {
// If original model, notify app the proxy is closed so it will delete and reinstanciate
- Log.d(TAG, "notifying proxy of closed");
+ DebugTool.logInfo(TAG, "notifying proxy of closed");
notifyProxyClosed(info, new SdlException("Transport disconnected.", SdlExceptionCause.SDL_UNAVAILABLE), SdlDisconnectedReason.TRANSPORT_DISCONNECT);
//}// else If ALM, nothing is required to be done here
@@ -605,7 +604,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (altTransportAvailable){
SdlProxyBase.this._transportConfig = transportConfig;
- Log.d(TAG, "notifying RPC session ended, but potential primary transport available");
+ DebugTool.logInfo(TAG, "notifying RPC session ended, but potential primary transport available");
cycleProxy(SdlDisconnectedReason.PRIMARY_TRANSPORT_CYCLE_REQUEST);
}else{
notifyProxyClosed(info, new SdlException("Transport disconnected.", SdlExceptionCause.SDL_UNAVAILABLE), SdlDisconnectedReason.TRANSPORT_DISCONNECT);
@@ -614,7 +613,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @Override
public void onTransportError(String info, Exception e) {
- DebugTool.logError("Transport failure: " + info, e);
+ DebugTool.logError(TAG, "Transport failure: " + info, e);
notifyPutFileStreamError(e, info);
@@ -661,7 +660,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (minimumProtocolVersion != null && minimumProtocolVersion.isNewerThan(getProtocolVersion()) == 1){
- Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion()));
+ DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion()));
try {
disposeInternal(SdlDisconnectedReason.MINIMUM_PROTOCOL_VERSION_HIGHER_THAN_SUPPORTED);
} catch (SdlException e) {
@@ -769,7 +768,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @Override
public void onHeartbeatTimedOut(byte sessionID) {
final String msg = "Heartbeat timeout";
- DebugTool.logInfo(msg);
+ DebugTool.logInfo(TAG, msg);
Intent sendIntent = createBroadcastIntent();
updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "onHeartbeatTimedOut");
@@ -895,7 +894,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> boolean callbackToUIThread, Boolean preRegister, String sHashID, Boolean bAppResumeEnab,
BaseTransportConfig transportConfig) throws SdlException
{
- Log.i(TAG, "SDL_LIB_VERSION: " + BuildConfig.VERSION_NAME);
+ DebugTool.logInfo(TAG, "SDL_LIB_VERSION: " + BuildConfig.VERSION_NAME);
setProtocolVersion(new Version(PROX_PROT_VER_ONE,0,0));
if (preRegister != null && preRegister)
@@ -1392,7 +1391,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (urlConnection == null)
{
- Log.i(TAG, "urlConnection is null, check RPC input parameters");
+ DebugTool.logInfo(TAG, "urlConnection is null, check RPC input parameters");
updateBroadcastIntent(sendIntent, "COMMENT2", "urlConnection is null, check RPC input parameters");
return;
}
@@ -1419,7 +1418,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (iResponseCode != HttpURLConnection.HTTP_OK)
{
- Log.i(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl.");
+ DebugTool.logInfo(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl.");
updateBroadcastIntent(sendIntent, "COMMENT2", "Response code not HTTP_OK, aborting request. ");
return;
}
@@ -1446,7 +1445,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> updateBroadcastIntent(sendIntent, "DATA", "Data from cloud response: " + response.toString());
sendRPCMessagePrivate(putFile);
- Log.i("sendSystemRequestToUrl", "sent to sdl");
+ DebugTool.logInfo(TAG, "sendSystemRequestToUrl sent to sdl");
updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.PUT_FILE.toString());
updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
@@ -1478,7 +1477,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
else
{
- DebugTool.logError("sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
//Log.i("sendSystemRequestToUrl", "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string.");
return;
}
@@ -1513,7 +1512,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (getIsConnected())
{
sendRPCMessagePrivate(mySystemRequest);
- Log.i("sendSystemRequestToUrl", "sent to sdl");
+ DebugTool.logInfo(TAG, "sendSystemRequestToUrl sent to sdl");
updateBroadcastIntent(sendIntent2, "RPC_NAME", FunctionID.SYSTEM_REQUEST.toString());
updateBroadcastIntent(sendIntent2, "TYPE", RPCMessage.KEY_REQUEST);
@@ -1523,43 +1522,43 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
catch (SdlException e)
{
- DebugTool.logError("sendSystemRequestToUrl: Could not get data from JSONObject received.", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not get data from JSONObject received.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " SdlException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Could not get data from JSONObject received."+ e);
}
catch (JSONException e)
{
- DebugTool.logError("sendSystemRequestToUrl: JSONException: ", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: JSONException: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " JSONException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: JSONException: "+ e);
}
catch (UnsupportedEncodingException e)
{
- DebugTool.logError("sendSystemRequestToUrl: Could not encode string.", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not encode string.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " UnsupportedEncodingException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Could not encode string."+ e);
}
catch (ProtocolException e)
{
- DebugTool.logError("sendSystemRequestToUrl: Could not set request method to post.", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not set request method to post.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " ProtocolException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Could not set request method to post."+ e);
}
catch (MalformedURLException e)
{
- DebugTool.logError("sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " MalformedURLException encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server."+ e);
}
catch (IOException e)
{
- DebugTool.logError("sendSystemRequestToUrl: IOException: ", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: IOException: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " IOException while sending to cloud: IOException: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: IOException: "+ e);
}
catch (Exception e)
{
- DebugTool.logError("sendSystemRequestToUrl: Unexpected Exception: ", e);
+ DebugTool.logError(TAG, "sendSystemRequestToUrl: Unexpected Exception: ", e);
updateBroadcastIntent(sendIntent, "COMMENT3", " Exception encountered sendOnSystemRequestToUrl: "+ e);
//Log.i("pt", "sendSystemRequestToUrl: Unexpected Exception: " + e);
}
@@ -1634,7 +1633,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> //A USB transport config was provided
USBTransportConfig usbTransportConfig = (USBTransportConfig) _transportConfig;
if (usbTransportConfig.getUsbAccessory() == null) {
- DebugTool.logInfo("Legacy USB transport config was used, but received null for accessory. Attempting to connect with router service");
+ DebugTool.logInfo(TAG, "Legacy USB transport config was used, but received null for accessory. Attempting to connect with router service");
//The accessory was null which means it came from a router service
MultiplexTransportConfig multiplexTransportConfig = new MultiplexTransportConfig(usbTransportConfig.getUSBContext(), _appID);
multiplexTransportConfig.setRequiresHighBandwidth(true);
@@ -1666,7 +1665,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> public void forceOnConnected(){
synchronized(CONNECTION_REFERENCE_LOCK) {
if (sdlSession != null) {
- Log.d(TAG, "Forcing on connected.... might actually need this"); //FIXME
+ DebugTool.logInfo(TAG, "Forcing on connected.... might actually need this"); //FIXME
/*if(sdlSession.getSdlConnection()==null){ //There is an issue when switching from v1 to v2+ where the connection is closed. So we restart the session during this call.
try {
sdlSession.startSession();
@@ -1994,7 +1993,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (functionName != null) {
hashTemp.put(RPCMessage.KEY_FUNCTION_NAME, functionName);
} else {
- DebugTool.logWarning("Dispatch Incoming Message - function name is null unknown RPC. FunctionId: " + message.getFunctionID());
+ DebugTool.logWarning(TAG, "Dispatch Incoming Message - function name is null unknown RPC. FunctionId: " + message.getFunctionID());
return;
}
if (message.getRPCType() == 0x00) {
@@ -2011,13 +2010,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
handleRPCMessage(hash);
} catch (final Exception excp) {
- DebugTool.logError("Failure handling protocol message: " + excp.toString(), excp);
+ DebugTool.logError(TAG, "Failure handling protocol message: " + excp.toString(), excp);
passErrorToProxyListener("Error handing incoming protocol message.", excp);
} // end-catch
} //else { Handle other protocol message types here}
} catch (final Exception e) {
// Pass error to application through listener
- DebugTool.logError("Error handing proxy event.", e);
+ DebugTool.logError(TAG, "Error handing proxy event.", e);
passErrorToProxyListener("Error handing incoming protocol message.", e);
}
}
@@ -2045,7 +2044,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
catch (final Exception e)
{
- DebugTool.logError("Error handing proxy event.", e);
+ DebugTool.logError(TAG, "Error handing proxy event.", e);
passErrorToProxyListener("Error serializing message.", e);
return null;
}
@@ -2150,14 +2149,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> default:
// Diagnostics
SdlTrace.logProxyEvent("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.", SDL_LIB_TRACE_KEY);
- DebugTool.logError("Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
+ DebugTool.logError(TAG, "Unknown RPC Message encountered. Check for an updated version of the SDL Proxy.");
break;
}
SdlTrace.logProxyEvent("Proxy fired callback: " + message.getFunctionName(), SDL_LIB_TRACE_KEY);
} catch(final Exception e) {
// Pass error to application through listener
- DebugTool.logError("Error handing proxy event.", e);
+ DebugTool.logError(TAG, "Error handing proxy event.", e);
if (_callbackToUIThread) {
// Run in UI thread
_mainUIHandler.post(new Runnable() {
@@ -2173,11 +2172,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
private void handleErrorsFromInternalMessageDispatcher(String info, Exception e) {
- DebugTool.logError(info, e);
+ DebugTool.logError(TAG, info, e);
// This error cannot be passed to the user, as it indicates an error
// in the communication between the proxy and the application.
- DebugTool.logError("InternalMessageDispatcher failed.", e);
+ DebugTool.logError(TAG, "InternalMessageDispatcher failed.", e);
// Note, this is the only place where the _proxyListener should be referenced asdlhronously,
// with an error on the internalMessageDispatcher, we have no other reliable way of
@@ -2214,7 +2213,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @Override
public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
if(_proxyDisposed){
- DebugTool.logInfo("Ignoring start service packet, proxy is disposed");
+ DebugTool.logInfo(TAG, "Ignoring start service packet, proxy is disposed");
return;
}
if(SessionType.RPC.equals(type)){
@@ -2223,13 +2222,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (serviceEncryptionListener != null) {
serviceEncryptionListener.onEncryptionServiceUpdated(type, isEncrypted, null);
}
- DebugTool.logInfo("onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted);
+ DebugTool.logInfo(TAG, "onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted);
}
@Override
public void onServiceEnded(SdlSession session, SessionType type) {
if(_proxyDisposed){
- DebugTool.logInfo("Ignoring end service packet, proxy is disposed");
+ DebugTool.logInfo(TAG, "Ignoring end service packet, proxy is disposed");
return;
}
if (SessionType.RPC.equals(type)) {
@@ -2238,13 +2237,13 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (serviceEncryptionListener != null) {
serviceEncryptionListener.onEncryptionServiceUpdated(type, false, null);
}
- DebugTool.logInfo("onServiceEnded, session Type: " + type.getName());
+ DebugTool.logInfo(TAG, "onServiceEnded, session Type: " + type.getName());
}
@Override
public void onServiceError(SdlSession session, SessionType type, String reason) {
if(_proxyDisposed){
- DebugTool.logInfo("Ignoring start service error, proxy is disposed");
+ DebugTool.logInfo(TAG, "Ignoring start service error, proxy is disposed");
return;
}
if (SessionType.RPC.equals(type)) {
@@ -2253,7 +2252,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (serviceEncryptionListener != null) {
serviceEncryptionListener.onEncryptionServiceUpdated(type, false, "onServiceError: " + reason);
}
- DebugTool.logError("onServiceError, session Type: " + type.getName() + ", reason: " + reason);
+ DebugTool.logError(TAG, "onServiceError, session Type: " + type.getName() + ", reason: " + reason);
}
};
@@ -2338,7 +2337,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> listener.onError(request.getCorrelationID(), Result.ABORTED, errorInfo);
}
}
- DebugTool.logWarning(errorInfo);
+ DebugTool.logWarning(TAG, errorInfo);
return;
}
@@ -2661,14 +2660,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> private void handleRPCMessage(Hashtable<String, Object> hash) {
if (hash == null){
- DebugTool.logError("handleRPCMessage: hash is null, returning.");
+ DebugTool.logError(TAG, "handleRPCMessage: hash is null, returning.");
return;
}
RPCMessage rpcMsg = RpcConverter.convertTableToRpc(hash);
if (rpcMsg == null){
- DebugTool.logError("handleRPCMessage: rpcMsg is null, returning.");
+ DebugTool.logError(TAG, "handleRPCMessage: rpcMsg is null, returning.");
return;
}
@@ -2726,7 +2725,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }else{
rpcSpecVersion = MAX_SUPPORTED_RPC_VERSION;
}
- DebugTool.logInfo("Negotiated RPC Spec version = " + rpcSpecVersion);
+ DebugTool.logInfo(TAG, "Negotiated RPC Spec version = " + rpcSpecVersion);
_vehicleType = msg.getVehicleType();
_systemSoftwareVersion = msg.getSystemSoftwareVersion();
@@ -2754,11 +2753,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (!isDebugEnabled())
{
enableDebugTool();
- DebugTool.logInfo(sVersionInfo, false);
+ DebugTool.logInfo(TAG, sVersionInfo, false);
disableDebugTool();
}
else
- DebugTool.logInfo(sVersionInfo, false);
+ DebugTool.logInfo(TAG, sVersionInfo, false);
sendIntent = createBroadcastIntent();
updateBroadcastIntent(sendIntent, "FUNCTION_NAME", "RAI_RESPONSE");
@@ -2776,7 +2775,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> //If the RPC version is too low we should simply dispose this proxy
if (minimumRPCVersion != null && minimumRPCVersion.isNewerThan(rpcSpecVersion) == 1) {
- Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion));
+ DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion));
try {
disposeInternal(SdlDisconnectedReason.MINIMUM_RPC_VERSION_HIGHER_THAN_SUPPORTED);
} catch (SdlException e) {
@@ -2806,7 +2805,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> } else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
&& functionName.equals(FunctionID.ON_ENCODED_SYNC_P_DATA.toString())) {
- Log.i("pt", "POLICIES_CORRELATION_ID SystemRequest Notification (Legacy)");
+ DebugTool.logInfo(TAG, "POLICIES_CORRELATION_ID SystemRequest Notification (Legacy)");
final OnSystemRequest msg = new OnSystemRequest(hash);
@@ -2827,7 +2826,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> else if ((new RPCResponse(hash)).getCorrelationID() == POLICIES_CORRELATION_ID
&& functionName.equals(FunctionID.ENCODED_SYNC_P_DATA.toString())) {
- Log.i("pt", "POLICIES_CORRELATION_ID SystemRequest Response (Legacy)");
+ DebugTool.logInfo(TAG, "POLICIES_CORRELATION_ID SystemRequest Response (Legacy)");
final SystemRequestResponse msg = new SystemRequestResponse(hash);
Intent sendIntent = createBroadcastIntent();
@@ -2895,7 +2894,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> } else {
rpcSpecVersion = MAX_SUPPORTED_RPC_VERSION;
}
- DebugTool.logInfo("Negotiated RPC Spec version = " + rpcSpecVersion);
+ DebugTool.logInfo(TAG, "Negotiated RPC Spec version = " + rpcSpecVersion);
_vehicleType = msg.getVehicleType();
_systemSoftwareVersion = msg.getSystemSoftwareVersion();
@@ -2917,11 +2916,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (!isDebugEnabled())
{
enableDebugTool();
- DebugTool.logInfo("SDL Proxy Version: " + _proxyVersionInfo);
+ DebugTool.logInfo(TAG, "SDL Proxy Version: " + _proxyVersionInfo);
disableDebugTool();
}
else
- DebugTool.logInfo("SDL Proxy Version: " + _proxyVersionInfo);
+ DebugTool.logInfo(TAG, "SDL Proxy Version: " + _proxyVersionInfo);
// RegisterAppInterface
if (_advancedLifecycleManagementEnabled) {
@@ -2936,7 +2935,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
//If the RPC version is too low we should simply dispose this proxy
if (minimumRPCVersion != null && minimumRPCVersion.isNewerThan(rpcSpecVersion) == 1) {
- Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion));
+ DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion));
try {
disposeInternal(SdlDisconnectedReason.MINIMUM_RPC_VERSION_HIGHER_THAN_SUPPORTED);
} catch (SdlException e) {
@@ -4037,10 +4036,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
} else {
if (_sdlMsgVersion != null) {
- DebugTool.logError("Unrecognized response Message: " + functionName +
+ DebugTool.logError(TAG, "Unrecognized response Message: " + functionName +
" SDL Message Version = " + _sdlMsgVersion);
} else {
- DebugTool.logError("Unrecognized response Message: " + functionName);
+ DebugTool.logError(TAG, "Unrecognized response Message: " + functionName);
}
} // end-if
@@ -4160,7 +4159,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> updateBroadcastIntent(sendIntent, "COMMENT1", "Sending to cloud: " + msg.getUrl());
sendBroadcastIntent(sendIntent);
- Log.i("pt", "send to url");
+ DebugTool.logInfo(TAG, "send to url");
if ( (msg.getUrl() != null) )
{
@@ -4348,7 +4347,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> e.printStackTrace();
}
} else {
- DebugTool.logError("File was null at: " + urlHttps);
+ DebugTool.logError(TAG, "File was null at: " + urlHttps);
}
}
};
@@ -4572,10 +4571,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
} else {
if (_sdlMsgVersion != null) {
- DebugTool.logInfo("Unrecognized notification Message: " + functionName +
+ DebugTool.logInfo(TAG, "Unrecognized notification Message: " + functionName +
" connected to SDL using message version: " + _sdlMsgVersion.getMajorVersion() + "." + _sdlMsgVersion.getMinorVersion());
} else {
- DebugTool.logInfo("Unrecognized notification Message: " + functionName);
+ DebugTool.logInfo(TAG, "Unrecognized notification Message: " + functionName);
}
} // end-if
} // end-if notification
@@ -4902,7 +4901,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> protected void notifyProxyClosed(final String info, final Exception e, final SdlDisconnectedReason reason) {
SdlTrace.logProxyEvent("NotifyProxyClose", SDL_LIB_TRACE_KEY);
- Log.d(TAG, "notifyProxyClosed: " + info);
+ DebugTool.logInfo(TAG, "notifyProxyClosed: " + info);
OnProxyClosed message = new OnProxyClosed(info, e, reason);
queueInternalMessage(message);
}
@@ -5022,7 +5021,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> rpcPacketizer.start();
return new RPCStreamController(rpcPacketizer, request.getCorrelationID());
} catch (Exception e) {
- Log.e("SyncConnection", "Unable to start streaming:" + e.toString());
+ DebugTool.logError(TAG, "SyncConnectionUnable to start streaming:", e);
return null;
}
}
@@ -5043,7 +5042,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> rpcPacketizer.start();
return new RPCStreamController(rpcPacketizer, request.getCorrelationID());
} catch (Exception e) {
- Log.e("SyncConnection", "Unable to start streaming:" + e.toString());
+ DebugTool.logError(TAG, "SyncConnection Unable to start streaming:", e);
return null;
}
}
@@ -5328,10 +5327,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
builder.append(paramName);
}
- DebugTool.logWarning("StartService for nav failed. Rejected params: " + builder.toString());
+ DebugTool.logWarning(TAG, "StartService for nav failed. Rejected params: " + builder.toString());
} else {
- DebugTool.logWarning("StartService for nav failed (rejected params not supplied)");
+ DebugTool.logWarning(TAG, "StartService for nav failed (rejected params not supplied)");
}
return null;
}
@@ -5368,11 +5367,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @SuppressWarnings("unused")
public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) {
if (sdlSession == null) {
- DebugTool.logWarning("SdlSession is not created yet.");
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
return null;
}
if (!sdlSession.getIsConnected()) {
- DebugTool.logWarning("Connection is not available.");
+ DebugTool.logWarning(TAG, "Connection is not available.");
return null;
}
@@ -5394,11 +5393,11 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> */
public void startVideoService(boolean isEncrypted, VideoStreamingParameters parameters) {
if (sdlSession == null) {
- DebugTool.logWarning("SdlSession is not created yet.");
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
return;
}
if (!sdlSession.getIsConnected()) {
- DebugTool.logWarning("Connection is not available.");
+ DebugTool.logWarning(TAG, "Connection is not available.");
return;
}
@@ -5496,7 +5495,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @TargetApi(19)
public void startRemoteDisplayStream(Context context, final Class<? extends SdlRemoteDisplay> remoteDisplay, final VideoStreamingParameters parameters, final boolean encrypted){
if(protocolVersion!= null && protocolVersion.getMajor() >= 5 && !_systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){
- Log.e(TAG, "Video streaming not supported on this module");
+ DebugTool.logError(TAG, "Video streaming not supported on this module");
return;
}
//Create streaming manager
@@ -5517,7 +5516,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @Override
public void onError(String info) {
- Log.e(TAG, "Error retrieving video streaming capability: " + info);
+ DebugTool.logError(TAG, "Error retrieving video streaming capability: " + info);
}
});
@@ -5563,15 +5562,15 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> @SuppressWarnings("unused")
private VideoStreamingParameters tryStartVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) {
if (sdlSession == null) {
- DebugTool.logWarning("SdlSession is not created yet.");
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
return null;
}
if(protocolVersion!= null && protocolVersion.getMajor() >= 5 && !_systemCapabilityManager.isCapabilitySupported(SystemCapabilityType.VIDEO_STREAMING)){
- DebugTool.logWarning("Module doesn't support video streaming.");
+ DebugTool.logWarning(TAG, "Module doesn't support video streaming.");
return null;
}
if (parameters == null) {
- DebugTool.logWarning("Video parameters were not supplied.");
+ DebugTool.logWarning(TAG, "Video parameters were not supplied.");
return null;
}
@@ -5610,10 +5609,10 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> builder.append(paramName);
}
- DebugTool.logWarning("StartService for nav failed. Rejected params: " + builder.toString());
+ DebugTool.logWarning(TAG, "StartService for nav failed. Rejected params: " + builder.toString());
} else {
- DebugTool.logWarning("StartService for nav failed (rejected params not supplied)");
+ DebugTool.logWarning(TAG, "StartService for nav failed (rejected params not supplied)");
}
return null;
@@ -5701,15 +5700,15 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec,
AudioStreamingParams params) {
if (sdlSession == null) {
- DebugTool.logWarning("SdlSession is not created yet.");
+ DebugTool.logWarning(TAG, "SdlSession is not created yet.");
return null;
}
if (!sdlSession.getIsConnected()) {
- DebugTool.logWarning("Connection is not available.");
+ DebugTool.logWarning(TAG, "Connection is not available.");
return null;
}
if (codec != AudioStreamingCodec.LPCM) {
- DebugTool.logWarning("Audio codec " + codec + " is not supported.");
+ DebugTool.logWarning(TAG, "Audio codec " + codec + " is not supported.");
return null;
}
@@ -5726,7 +5725,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> scheduler.shutdown();
if (pcmServiceStartResponse) {
- DebugTool.logInfo("StartService for audio succeeded");
+ DebugTool.logInfo(TAG, "StartService for audio succeeded");
return sdlSession.startAudioStream();
} else {
if (pcmServiceStartRejectedParams != null) {
@@ -5737,9 +5736,9 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> }
builder.append(paramName);
}
- DebugTool.logWarning("StartService for audio failed. Rejected params: " + builder.toString());
+ DebugTool.logWarning(TAG, "StartService for audio failed. Rejected params: " + builder.toString());
} else {
- DebugTool.logWarning("StartService for audio failed (rejected params not supplied)");
+ DebugTool.logWarning(TAG, "StartService for audio failed (rejected params not supplied)");
}
return null;
}
@@ -6775,7 +6774,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> if (sdlMsgVersion == null) {
sdlMsgVersion = new SdlMsgVersion();
if(protocolVersion.getMajor() == 1) {
- DebugTool.logInfo("Connected to an older module, must send 1.0.0 as RPC spec");
+ DebugTool.logInfo(TAG, "Connected to an older module, must send 1.0.0 as RPC spec");
sdlMsgVersion.setMajorVersion(1);
sdlMsgVersion.setMinorVersion(0);
}else {
@@ -8411,7 +8410,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> //streamListener = startVideoStream(encrypted,parameters);d
streamListener = sdlSession.startVideoStream();
if(streamListener == null){
- Log.e(TAG, "Error starting video service");
+ DebugTool.logError(TAG, "Error starting video service");
return;
}
VideoStreamingCapability capability = (VideoStreamingCapability)_systemCapabilityManager.getCapability(SystemCapabilityType.VIDEO_STREAMING);
@@ -8428,7 +8427,7 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> } catch (Exception e) {
e.printStackTrace();
}
- Log.d(TAG, parameters.toString());
+ DebugTool.logInfo(TAG, parameters.toString());
}
public void stopStreaming(){
@@ -8517,14 +8516,14 @@ public abstract class SdlProxyBase<proxyListenerType extends IProxyListenerBase> showPresentation.start();
} catch (Exception ex) {
- Log.e(TAG, "Unable to create Virtual Display.");
+ DebugTool.logError(TAG, "Unable to create Virtual Display.");
}
}
@Override
public void onServiceStarted(SdlSession session, SessionType type, boolean isEncrypted) {
if(SessionType.NAV.equals(type) && session != null ){
- DebugTool.logInfo("Video service has been started. Starting video stream from proxy");
+ DebugTool.logInfo(TAG, "Video service has been started. Starting video stream from proxy");
if(session.getAcceptedVideoParams() != null){
videoStreamingParameters = session.getAcceptedVideoParams();
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java index c720cd22c..cdb80ef1e 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/streaming/video/SdlRemoteDisplay.java @@ -39,13 +39,14 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; -import android.util.Log; import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.Window; import android.view.WindowManager; +import com.smartdevicelink.util.DebugTool; + import java.lang.reflect.Constructor; import java.util.concurrent.Callable; @@ -183,7 +184,7 @@ public abstract class SdlRemoteDisplay extends Presentation { remoteDisplay = (SdlRemoteDisplay) constructor.newInstance(context, mDisplay); } catch (Exception e) { e.printStackTrace(); - Log.e(TAG, "Unable to create Presentation Class"); + DebugTool.logError(TAG, "Unable to create Presentation Class"); presentationShowError = true; return; } @@ -196,7 +197,7 @@ public abstract class SdlRemoteDisplay extends Presentation { } } catch (WindowManager.InvalidDisplayException ex) { - Log.e(TAG, "Couldn't show presentation! Display was removed in the meantime.", ex); + DebugTool.logError(TAG, "Couldn't show presentation! Display was removed in the meantime.", ex); remoteDisplay = null; presentationShowError = true; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/trace/SdlTrace.java b/android/sdl_android/src/main/java/com/smartdevicelink/trace/SdlTrace.java index 531f02831..e3bedd6a2 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/trace/SdlTrace.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/trace/SdlTrace.java @@ -433,7 +433,7 @@ public class SdlTrace { try {
localTraceListener.logXmlMsg(msg, SDL_LIB_TRACE_KEY);
} catch (Exception ex) {
- DebugTool.logError("Failure calling ISTListener: " + ex.toString(), ex);
+ DebugTool.logError(SYSTEM_LOG_TAG, "Failure calling ISTListener: " + ex.toString(), ex);
return false;
}
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/trace/TraceDeviceInfo.java b/android/sdl_android/src/main/java/com/smartdevicelink/trace/TraceDeviceInfo.java index 587a6ae2b..584b388ef 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/trace/TraceDeviceInfo.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/trace/TraceDeviceInfo.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
/**
*
*/
@@ -50,6 +50,7 @@ import java.util.Set; public class TraceDeviceInfo {
// http://developer.android.com/guide/topics/data/data-storage.html
+ private static final String TAG = "TraceDeviceInfo";
private static TelephonyManager m_telephonyManager;
// Constructor
@@ -74,7 +75,7 @@ public class TraceDeviceInfo { try { // getDeviceId() requires android.permission.READ_PHONE_STATE
info = "<deviceid>" + m_telephonyManager.getDeviceId() + "</deviceid>";
} catch (Exception e1) {
- DebugTool.logError("Failure getting telephony device ID: " + e1.toString(), e1);
+ DebugTool.logError(TAG, "Failure getting telephony device ID: " + e1.toString(), e1);
}
info = "<pt>";
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransport.java index bc204ebaf..f86a3f062 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/BTTransport.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.transport;
import android.bluetooth.BluetoothAdapter;
@@ -58,7 +58,8 @@ import java.util.UUID; *
*/
@Deprecated
-public class BTTransport extends SdlTransport {
+public class BTTransport extends SdlTransport {
+ private static final String TAG = "BTTransport";
//936DA01F9ABD4D9D80C702AF85C822A8
private final static UUID SDL_V4_MOBILE_APPLICATION_SVC_CLASS = new UUID(0x936DA01F9ABD4D9DL, 0x80C702AF85C822A8L);
@@ -296,7 +297,7 @@ public class BTTransport extends SdlTransport { _transportReader = null;
}
} catch (Exception e) {
- DebugTool.logError("Failed to stop transport reader thread.", e);
+ DebugTool.logError(TAG, "Failed to stop transport reader thread.", e);
} // end-catch
try {
@@ -305,7 +306,7 @@ public class BTTransport extends SdlTransport { _bluetoothAdapterMonitor = null;
}
} catch (Exception e) {
- DebugTool.logError("Failed to stop adapter monitor thread.", e);
+ DebugTool.logError(TAG, "Failed to stop adapter monitor thread.", e);
}
try {
@@ -314,7 +315,7 @@ public class BTTransport extends SdlTransport { _serverSocket = null;
}
} catch (Exception e) {
- DebugTool.logError("Failed to close serverSocket", e);
+ DebugTool.logError(TAG, "Failed to close serverSocket", e);
} // end-catch
try {
@@ -323,7 +324,7 @@ public class BTTransport extends SdlTransport { _activeSocket = null;
}
} catch (Exception e) {
- DebugTool.logError("Failed to close activeSocket", e);
+ DebugTool.logError(TAG, "Failed to close activeSocket", e);
} // end-catch
@@ -334,7 +335,7 @@ public class BTTransport extends SdlTransport { _output = null;
}
} catch (Exception e) {
- DebugTool.logError("Failed to close output stream", e);
+ DebugTool.logError(TAG, "Failed to close output stream", e);
} // end-catch
if (ex == null) {
@@ -361,7 +362,7 @@ public class BTTransport extends SdlTransport { _output.write(msgBytes, 0, msgBytes.length);
sendResult = true;
} catch (Exception ex) {
- DebugTool.logError("Error writing to Bluetooth socket: " + ex.toString(), ex);
+ DebugTool.logError(TAG, "Error writing to Bluetooth socket: " + ex.toString(), ex);
handleTransportError("Error writing to Bluetooth socket:", ex);
sendResult = false;
} // end-catch
@@ -461,7 +462,7 @@ public class BTTransport extends SdlTransport { if(currentByte == -1){ //If we read a -1 and the psm didn't move forward, then there is a problem
if (!isHalted) {
// Only call disconnect if the thread has not been halted
- DebugTool.logError("End of stream reached!");
+ DebugTool.logError(TAG, "End of stream reached!");
disconnect("End of stream reached.", null);
}
}
@@ -479,7 +480,7 @@ public class BTTransport extends SdlTransport { // Only call disconnect if the thread has not been halted
clearInputStream();
String errString = "Failure in BTTransport reader thread: " + excp.toString();
- DebugTool.logError(errString, excp);
+ DebugTool.logError(TAG, errString, excp);
disconnect(errString, excp);
}
return;
@@ -493,7 +494,7 @@ public class BTTransport extends SdlTransport { _input = null;
}
} catch (Exception e) {
- DebugTool.logError("Failed to close input stream", e);
+ DebugTool.logError(TAG, "Failed to close input stream", e);
} // end-catch
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java index ba34a3f58..5b67fa444 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexBluetoothTransport.java @@ -30,7 +30,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.support.annotation.RequiresPermission; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; @@ -273,7 +272,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ @Override protected synchronized void stop(int stateToTransitionTo, byte error) { super.stop(stateToTransitionTo, error); - Log.d(TAG, "Attempting to close the bluetooth serial server"); + DebugTool.logInfo(TAG, "Attempting to close the bluetooth serial server"); if (mConnectThread != null) { mConnectThread.cancel(); mConnectThread = null; @@ -404,7 +403,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ @RequiresPermission(Manifest.permission.BLUETOOTH) public void run() { synchronized(THREAD_LOCK){ - Log.d(TAG, "Socket Type: " + mSocketType + + DebugTool.logInfo(TAG, "Socket Type: " + mSocketType + " BEGIN mAcceptThread" + this); setName("AcceptThread" + mSocketType); @@ -415,12 +414,12 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ while (mState != STATE_CONNECTED) { try { if(listenAttempts>=5){ - Log.e(TAG, "Complete failure in attempting to listen for Bluetooth connection, erroring out."); + DebugTool.logError(TAG, "Complete failure in attempting to listen for Bluetooth connection, erroring out."); MultiplexBluetoothTransport.this.stop(STATE_ERROR, REASON_NONE); return; } listenAttempts++; - Log.d(TAG, "SDL Bluetooth Accept thread is running."); + DebugTool.logInfo(TAG, "SDL Bluetooth Accept thread is running."); // This is a blocking call and will only return on a // successful connection or an exception @@ -430,12 +429,12 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ } else{ - Log.e(TAG, "Listening Socket was null, stopping the bluetooth serial server."); + DebugTool.logError(TAG, "Listening Socket was null, stopping the bluetooth serial server."); MultiplexBluetoothTransport.this.stop(STATE_ERROR, REASON_NONE); return; } } catch (IOException e) { - Log.e(TAG, "Socket Type: " + mSocketType + "accept() failed"); + DebugTool.logError(TAG, "Socket Type: " + mSocketType + "accept() failed"); MultiplexBluetoothTransport.this.stop(STATE_ERROR, REASON_SPP_ERROR); return; } @@ -454,29 +453,29 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ case STATE_CONNECTED: // Either not ready or already connected. Terminate new socket. try { - Log.d(TAG, "Close unwanted socket"); + DebugTool.logInfo(TAG, "Close unwanted socket"); socket.close(); } catch (IOException e) { - Log.e(TAG, "Could not close unwanted socket", e); + DebugTool.logError(TAG, "Could not close unwanted socket", e); } break; } } } } - Log.d(TAG, mState + " END mAcceptThread, socket Type: " + mSocketType); + DebugTool.logInfo(TAG, mState + " END mAcceptThread, socket Type: " + mSocketType); } } public synchronized void cancel() { - Log.d(TAG, mState + " Socket Type " + mSocketType + " cancel "); + DebugTool.logInfo(TAG, mState + " Socket Type " + mSocketType + " cancel "); try { if(mmServerSocket != null){ mmServerSocket.close(); } } catch (IOException e) { - Log.e(TAG, mState + " Socket Type " + mSocketType + " close() of server failed "+ Arrays.toString(e.getStackTrace())); + DebugTool.logError(TAG, mState + " Socket Type " + mSocketType + " close() of server failed "+ Arrays.toString(e.getStackTrace())); } } } @@ -502,7 +501,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ try{ mAdapter.cancelDiscovery(); }catch(SecurityException e2){ - Log.e(TAG, "Don't have required permision to cancel discovery. Moving on"); + DebugTool.logError(TAG, "Don't have required permision to cancel discovery. Moving on"); } } @@ -589,11 +588,11 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ }else{tryInsecure = true;} } catch (IOException io) { tryInsecure = true; - Log.e(TAG,"createRfcommSocketToServiceRecord exception - " + io.toString()); + DebugTool.logError(TAG, "createRfcommSocketToServiceRecord exception - " + io.toString()); SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); } catch (Exception e){ - Log.e(TAG,"createRfcommSocketToServiceRecord exception - " + e.toString()); + DebugTool.logError(TAG, "createRfcommSocketToServiceRecord exception - " + e.toString()); SdlRouterService.setBluetoothPrefs(0,SHARED_PREFS); } @@ -654,13 +653,13 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ } } catch (IOException e) { connectionFailed(); - Log.e(TAG,e.getClass().getSimpleName() + DebugTool.logError(TAG,e.getClass().getSimpleName() + " caught connecting to the bluetooth socket: " + e.toString()); try { mmSocket.close(); } catch (IOException e2) { - Log.e(TAG,"unable to close() socket during connection failure" + e2); + DebugTool.logError(TAG, "unable to close() socket during connection failure" + e2); } return; } @@ -679,13 +678,13 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ } else { - Log.e(TAG, "There was a problem opening up RFCOMM"); + DebugTool.logError(TAG, "There was a problem opening up RFCOMM"); } } public void cancel() { try { - Log.d(TAG, "Calling Cancel in the connect thread"); + DebugTool.logInfo(TAG, "Calling Cancel in the connect thread"); mmSocket.close(); } catch (IOException e) { // close() of connect socket failed @@ -715,7 +714,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ tmpOut = socket.getOutputStream(); } catch (IOException e) { // temp sockets not created - Log.e(TAG, "Connected Write Thread: " + e.getMessage()); + DebugTool.logError(TAG, "Connected Write Thread: " + e.getMessage()); } mmOutStream = tmpOut; @@ -728,7 +727,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ public void write(byte[] buffer, int offset, int count) { try { if(buffer==null){ - Log.w(TAG, "Can't write to device, nothing to send"); + DebugTool.logWarning(TAG, "Can't write to device, nothing to send"); return; } //This would be a good spot to log out all bytes received @@ -737,7 +736,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ } catch (IOException|NullPointerException e) { // STRICTLY to catch mmOutStream NPE // Exception during write //OMG! WE MUST NOT BE CONNECTED ANYMORE! LET THE USER KNOW - Log.e(TAG, "Error sending bytes to connected device!"); + DebugTool.logError(TAG, "Error sending bytes to connected device!"); connectionLost(); } } @@ -754,7 +753,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ } } catch (IOException e) { // close() of connect socket failed - Log.d(TAG, "Write Thread: " + e.getMessage()); + DebugTool.logInfo(TAG, "Write Thread: " + e.getMessage()); } } } @@ -774,7 +773,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ tmpIn = socket.getInputStream(); } catch (IOException e) { // temp sockets not created - Log.e(TAG, "Connected Read Thread: "+e.getMessage()); + DebugTool.logError(TAG, "Connected Read Thread: "+e.getMessage()); } mmInStream = tmpIn; @@ -782,7 +781,7 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ @SuppressLint("NewApi") public void run() { - Log.d(TAG, "Running the Connected Thread"); + DebugTool.logInfo(TAG, "Running the Connected Thread"); byte input = 0; int bytesRead = 0; byte[] buffer = new byte[READ_BUFFER_SIZE]; @@ -815,11 +814,11 @@ public class MultiplexBluetoothTransport extends MultiplexBaseTransport{ } } } catch (IOException|NullPointerException e) { // NPE is ONLY to catch error on mmInStream - Log.e(TAG, "Lost connection in the Connected Thread"); + DebugTool.logError(TAG, "Lost connection in the Connected Thread"); if(DebugTool.isDebugEnabled()){ e.printStackTrace(); } - connectionLost(); + connectionLost(); break; } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java index 0fa211bd9..50d6ba051 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTcpTransport.java @@ -36,11 +36,11 @@ import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.transport.utl.WiFiSocketFactory; +import com.smartdevicelink.util.DebugTool; import java.io.IOException; import java.io.InputStream; @@ -99,7 +99,7 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { } } catch (Exception e) { - logError("TCPTransport: Exception during transport thread starting", e); + logError(TAG, "TCPTransport: Exception during transport thread starting", e); } } } else { @@ -134,7 +134,7 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { } mSocket = null; } catch (IOException e) { - logError("TCPTransport.disconnect: Exception during disconnect: " + e.getMessage()); + logError(TAG,"TCPTransport.disconnect: Exception during disconnect: " + e.getMessage()); } setState(state); @@ -227,7 +227,7 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { mInputStream = mSocket.getInputStream(); startWriteThread(); } catch (IOException e) { - logError("TCPTransport.connect: Exception during connect stage: " + e.getMessage()); + logError(TAG, "TCPTransport.connect: Exception during connect stage: " + e.getMessage()); } bConnected = (null != mSocket) && mSocket.isConnected(); @@ -314,7 +314,7 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { if (psm.getState() == SdlPsm.FINISHED_STATE) { synchronized (MultiplexTcpTransport.this) { - Log.d(TAG, "Packet formed, sending off"); + DebugTool.logInfo(TAG, "Packet formed, sending off"); SdlPacket packet = psm.getFormedPacket(); packet.setTransportRecord(getTransportRecord()); handler.obtainMessage(SdlRouterService.MESSAGE_READ, packet).sendToTarget(); @@ -348,9 +348,9 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { */ private void internalHandleStreamReadError() { if(isHalted){ - logError("TCPTransport.run: Exception during reading data, but thread already halted"); + logError(TAG, "TCPTransport.run: Exception during reading data, but thread already halted"); } else { - logError("TCPTransport.run: Exception during reading data"); + logError(TAG, "TCPTransport.run: Exception during reading data"); MultiplexTcpTransport.this.stop(STATE_NONE); } } @@ -382,13 +382,13 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { logInfo("TCPTransport.sendBytesOverTransport: successfully sent data"); } } catch (IOException e) { - logError("TCPTransport.sendBytesOverTransport: error during sending data: " + e.getMessage()); + logError(TAG, "TCPTransport.sendBytesOverTransport: error during sending data: " + e.getMessage()); } } else { if (isHalted) { - logError("TCPTransport: sendBytesOverTransport request accepted, thread is cancelled"); + logError(TAG, "TCPTransport: sendBytesOverTransport request accepted, thread is cancelled"); } else { - logError("TCPTransport: sendBytesOverTransport request accepted, but output stream is null"); + logError(TAG, "TCPTransport: sendBytesOverTransport request accepted, but output stream is null"); } } @@ -418,13 +418,13 @@ public class MultiplexTcpTransport extends MultiplexBaseTransport { try { mOutputStream.flush(); } catch (IOException e) { - logError("TCPTransport flushing output stream failed: " + e.getMessage()); + logError(TAG, "TCPTransport flushing output stream failed: " + e.getMessage()); } try { mOutputStream.close(); } catch (IOException e) { - logError("TCPTransport closing output stream failed: " + e.getMessage()); + logError(TAG, "TCPTransport closing output stream failed: " + e.getMessage()); } mOutputStream = null; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java index eac5a27e0..0bacd3a2f 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexTransport.java @@ -38,13 +38,13 @@ import android.content.Context; import android.os.Build; import android.os.Looper; import android.os.Parcelable; -import android.util.Log; import com.smartdevicelink.SdlConnection.SdlConnection; import com.smartdevicelink.exception.SdlException; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.transport.utl.TransportRecord; +import com.smartdevicelink.util.DebugTool; import java.util.List; @@ -122,7 +122,7 @@ public class MultiplexTransport extends SdlTransport{ @Override public void openConnection() throws SdlException { - Log.d(TAG, "Open connection"); + DebugTool.logInfo(TAG, "Open connection"); if(brokerThread!=null){ brokerThread.startConnection(); }//else should log out @@ -134,7 +134,7 @@ public class MultiplexTransport extends SdlTransport{ if(isDisconnecting){ return; } - Log.d(TAG, "Close connection"); + DebugTool.logInfo(TAG, "Close connection"); this.isDisconnecting= true; if(brokerThread!= null){ brokerThread.cancel(); @@ -275,7 +275,7 @@ public class MultiplexTransport extends SdlTransport{ @Override public boolean onHardwareConnected(TransportType type) { if(super.onHardwareConnected(type)){ - Log.d(TAG, "On transport connected..."); + DebugTool.logInfo(TAG, "On transport connected..."); if(!connected){ connected = true; handleTransportConnected(); @@ -299,17 +299,17 @@ public class MultiplexTransport extends SdlTransport{ public void onHardwareDisconnected(TransportType type) { super.onHardwareDisconnected(type); if(connected){ - Log.d(TAG, "Handling disconnect"); + DebugTool.logInfo(TAG, "Handling disconnect"); connected = false; SdlConnection.enableLegacyMode(isLegacyModeEnabled(), TransportType.BLUETOOTH); if(isLegacyModeEnabled()){ - Log.d(TAG, "Handle transport disconnect, legacy mode enabled"); + DebugTool.logInfo(TAG, "Handle transport disconnect, legacy mode enabled"); this.stop(); isDisconnecting = true; //handleTransportDisconnected(""); handleTransportError("",null); //This seems wrong, but it works }else{ - Log.d(TAG, "Handle transport Error"); + DebugTool.logInfo(TAG, "Handle transport Error"); isDisconnecting = true; handleTransportError("",null); //This seems wrong, but it works } @@ -321,7 +321,7 @@ public class MultiplexTransport extends SdlTransport{ super.onLegacyModeEnabled(); SdlConnection.enableLegacyMode(isLegacyModeEnabled(), TransportType.BLUETOOTH); if(isLegacyModeEnabled()){ - Log.d(TAG, "Handle on legacy mode enabled"); + DebugTool.logInfo(TAG, "Handle on legacy mode enabled"); this.stop(); isDisconnecting = true; //handleTransportDisconnected(""); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java index d72987a88..42bbc29a4 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/MultiplexUsbTransport.java @@ -36,10 +36,10 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.ParcelFileDescriptor; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.util.DebugTool; import java.io.FileDescriptor; import java.io.FileInputStream; @@ -68,7 +68,7 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ MultiplexUsbTransport(ParcelFileDescriptor parcelFileDescriptor, Handler handler, Bundle bundle){ super(handler, TransportType.USB); if(parcelFileDescriptor == null){ - Log.e(TAG, "Error with object"); + DebugTool.logError(TAG, "Error with object"); this.parcelFileDescriptor = null; throw new ExceptionInInitializerError("ParcelFileDescriptor can't be null"); }else{ @@ -101,7 +101,7 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ setState(STATE_CONNECTING); FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); if(fileDescriptor == null || !fileDescriptor.valid()){ - Log.e(TAG, "USB FD was null or not valid,"); + DebugTool.logError(TAG, "USB FD was null or not valid,"); setState(STATE_NONE); return; } @@ -228,15 +228,15 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ bytesRead = inputStream.read(buffer); if (bytesRead == -1) { if (isInterrupted()) { - Log.e(TAG,"EOF reached, and thread is interrupted"); + DebugTool.logError(TAG,"EOF reached, and thread is interrupted"); } else { - Log.i(TAG,"EOF reached, disconnecting!"); + DebugTool.logInfo(TAG,"EOF reached, disconnecting!"); connectionLost(); } return; } if (isInterrupted()) { - Log.w(TAG,"Read some data, but thread is interrupted"); + DebugTool.logWarning(TAG,"Read some data, but thread is interrupted"); return; } if(connectionSuccessful != null && connectionSuccessful == false){ @@ -268,9 +268,9 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ } } catch (IOException e) { if (isInterrupted()) { - Log.w(TAG,"Can't read data, and thread is interrupted"); + DebugTool.logWarning(TAG,"Can't read data, and thread is interrupted"); } else { - Log.w(TAG,"Can't read data, disconnecting!"); + DebugTool.logWarning(TAG,"Can't read data, disconnecting!"); connectionLost(); } return; @@ -319,7 +319,7 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ public void write(byte[] buffer, int offset, int count) { try { if(buffer==null){ - Log.w(TAG, "Can't write to device, nothing to send"); + DebugTool.logWarning(TAG, "Can't write to device, nothing to send"); return; } //This would be a good spot to log out all bytes received @@ -331,7 +331,7 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ } catch (IOException|NullPointerException e) { // STRICTLY to catch mmOutStream NPE // Exception during write //OMG! WE MUST NOT BE CONNECTED ANYMORE! LET THE USER KNOW - Log.e(TAG, "Error sending bytes to connected device!"); + DebugTool.logError(TAG, "Error sending bytes to connected device!"); connectionLost(); } } @@ -345,7 +345,7 @@ public class MultiplexUsbTransport extends MultiplexBaseTransport{ } } catch (IOException e) { // close() of connect socket failed - Log.d(TAG, "Write Thread: " + e.getMessage()); + DebugTool.logInfo(TAG, "Write Thread: " + e.getMessage()); } } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java index 227b0b894..a9aca1ff4 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/RouterServiceValidator.java @@ -48,7 +48,6 @@ import android.os.Build; import android.os.Handler; import android.os.Looper; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.util.AndroidTools; import com.smartdevicelink.util.DebugTool; @@ -172,11 +171,11 @@ public class RouterServiceValidator { String packageName = null; if(this.service != null){ - Log.d(TAG, "Supplied service name of " + this.service.getClassName()); + DebugTool.logInfo(TAG, "Supplied service name of " + this.service.getClassName()); if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O && !isServiceRunning(context,this.service)){ //This means our service isn't actually running, so set to null. Hopefully we can find a real router service after this. service = null; - Log.w(TAG, "Supplied service is not actually running."); + DebugTool.logWarning(TAG, "Supplied service is not actually running."); } else { // If the running router service is created by this app, the validation is good by default if (this.service.getPackageName().equals(context.getPackageName())) { @@ -227,11 +226,11 @@ public class RouterServiceValidator { //Grab the package for the currently running router service. We need this call regardless of if we are in debug mode or not. if(this.service != null){ - DebugTool.logInfo("Supplied service name of " + this.service.getClassName()); + DebugTool.logInfo(TAG, "Supplied service name of " + this.service.getClassName()); if(Build.VERSION.SDK_INT < Build.VERSION_CODES.O && !isServiceRunning(context,this.service)){ //This means our service isn't actually running, so set to null. Hopefully we can find a real router service after this. service = null; - DebugTool.logWarning("Supplied service is not actually running."); + DebugTool.logWarning(TAG, "Supplied service is not actually running."); } else { // If the running router service is created by this app, the validation is good by default if (this.service.getPackageName().equals(context.getPackageName()) && callback != null) { @@ -242,17 +241,17 @@ public class RouterServiceValidator { } if(this.service == null){ - DebugTool.logInfo("about finding the best Router by using retrieveBestRouterServiceName"); + DebugTool.logInfo(TAG, "about finding the best Router by using retrieveBestRouterServiceName"); new FindRouterTask(new FindConnectedRouterCallback() { @Override public void onFound(ComponentName component) { - DebugTool.logInfo("FindConnectedRouterCallback.onFound got called. Package=" + component); + DebugTool.logInfo(TAG, "FindConnectedRouterCallback.onFound got called. Package=" + component); checkTrustedRouter(callback, pm, component); } @Override public void onFailed() { - DebugTool.logInfo("FindConnectedRouterCallback.onFailed was called"); + DebugTool.logInfo(TAG, "FindConnectedRouterCallback.onFailed was called"); if (callback != null) { callback.onFinishedValidation(false, null); } @@ -342,17 +341,17 @@ public class RouterServiceValidator { public void run() { _counter.incrementAndGet(); if (connected) { - DebugTool.logInfo("We found the connected service (" + service + "); currentThread is " + Thread.currentThread().getName()); + DebugTool.logInfo(TAG, "We found the connected service (" + service + "); currentThread is " + Thread.currentThread().getName()); serviceQueue.add(service); } else if (_counter.get() == numServices) { - DebugTool.logInfo("SdlRouterStatusProvider returns service=" + service + "; connected=" + connected); + DebugTool.logInfo(TAG, "SdlRouterStatusProvider returns service=" + service + "; connected=" + connected); _currentThread.interrupt(); } } }); } }); - DebugTool.logInfo("about checkIsConnected; thread=" + Thread.currentThread().getName()); + DebugTool.logInfo(TAG, "about checkIsConnected; thread=" + Thread.currentThread().getName()); provider.checkIsConnected(); } } @@ -362,14 +361,14 @@ public class RouterServiceValidator { ComponentName found = serviceQueue.poll(TIMEOUT_MSEC, TimeUnit.MILLISECONDS); return found; } catch(InterruptedException e) { - DebugTool.logInfo("FindRouterTask was interrupted because connected Router cannot be found"); + DebugTool.logInfo(TAG,"FindRouterTask was interrupted because connected Router cannot be found"); } return null; } @Override protected void onPostExecute(ComponentName componentName) { - DebugTool.logInfo("onPostExecute componentName=" + componentName); + DebugTool.logInfo(TAG,"onPostExecute componentName=" + componentName); super.onPostExecute(componentName); if (mCallback != null) { if (componentName != null && componentName.getPackageName() != null && componentName.getPackageName().length() != 0) { @@ -622,7 +621,7 @@ public class RouterServiceValidator { return apps; }else{ - Log.i(TAG, "No SDL apps, list was null"); + DebugTool.logInfo(TAG, "No SDL apps, list was null"); return null; } } @@ -635,7 +634,7 @@ public class RouterServiceValidator { public static boolean createTrustedListRequest(final Context context, boolean forceRefresh){ return createTrustedListRequest(context,forceRefresh,null,null); } - public static boolean createTrustedListRequest(final Context context, boolean forceRefresh, TrustedListCallback listCallback){Log.d(TAG,"Checking to make sure we have a list"); + public static boolean createTrustedListRequest(final Context context, boolean forceRefresh, TrustedListCallback listCallback){DebugTool.logInfo(TAG,"Checking to make sure we have a list"); return createTrustedListRequest(context,forceRefresh,null,listCallback); } @@ -691,7 +690,7 @@ public class RouterServiceValidator { } return false; }else{ - Log.d(TAG, "Sdl apps have changed. Need to request new trusted router service list."); + DebugTool.logInfo(TAG, "Sdl apps have changed. Need to request new trusted router service list."); } } @@ -710,7 +709,7 @@ public class RouterServiceValidator { @Override public void httpFailure(int statusCode) { - Log.e(TAG, "Error while requesting trusted app list: " + DebugTool.logError(TAG, "Error while requesting trusted app list: " + statusCode); pendingListRefresh = false; if(listCallback!=null){listCallback.onListObtained(false);} diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java index 3baabc74a..dff9efb0d 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlBroadcastReceiver.java @@ -48,7 +48,6 @@ import android.os.Build; import android.os.Looper; import android.os.Parcelable; import android.util.AndroidRuntimeException; -import android.util.Log; import com.smartdevicelink.R; import com.smartdevicelink.transport.RouterServiceValidator.TrustedListCallback; @@ -119,7 +118,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ } if(action.equalsIgnoreCase(USBTransport.ACTION_USB_ACCESSORY_ATTACHED)){ - Log.d(TAG, "Usb connected"); + DebugTool.logInfo(TAG,"Usb connected"); intent.setAction(null); onSdlEnabled(context, intent); return; @@ -146,23 +145,23 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ } } if (!serviceFilterHasAction){ - Log.e(TAG, "WARNING: This application has not specified its intent-filter for the SdlRouterService. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); + DebugTool.logError(TAG, "WARNING: This application has not specified its intent-filter for the SdlRouterService. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); } // Check if the service declaration in AndroidManifest has the router service version metadata specified correctly ResolveInfo info = context.getPackageManager().resolveService(new Intent(context, localRouterClass), PackageManager.GET_META_DATA); if (info != null) { if (info.serviceInfo.metaData == null || !info.serviceInfo.metaData.containsKey(context.getString(R.string.sdl_router_service_version_name))) { - Log.e(TAG, "WARNING: This application has not specified its metadata tags for the SdlRouterService. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); + DebugTool.logError(TAG, "WARNING: This application has not specified its metadata tags for the SdlRouterService. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); } } else { - Log.e(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); + DebugTool.logError(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); } } } if(localRouterClass != null && localRouterClass.getName().equalsIgnoreCase(com.smartdevicelink.transport.SdlRouterService.class.getName())){ - Log.e(TAG, "You cannot use the default SdlRouterService class, it must be extended in your project. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); + DebugTool.logError(TAG, "You cannot use the default SdlRouterService class, it must be extended in your project. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); } //This will only be true if we are being told to reopen our SDL service because SDL is enabled @@ -192,7 +191,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ }); } - + } return; }else if(intent.getBooleanExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA, false)){ @@ -204,10 +203,10 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ } - Log.d(TAG, "Check for local router"); + DebugTool.logInfo(TAG, "Check for local router"); if(localRouterClass!=null){ //If there is a supplied router service lets run some logic regarding starting one - if(!didStart){Log.d(TAG, "attempting to wake up router service"); + if(!didStart){DebugTool.logInfo(TAG, "attempting to wake up router service"); didStart = wakeUpRouterService(context, true,false, device); } @@ -268,7 +267,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ context.sendBroadcast(restart); } catch (SecurityException e) { - Log.e(TAG, "Security exception, process is bad"); + DebugTool.logError(TAG, "Security exception, process is bad"); } } @@ -290,15 +289,15 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty() && sdlAppInfoList.get(0).getRouterServiceComponentName() != null) { routerServicePackage = sdlAppInfoList.get(0).getRouterServiceComponentName().getPackageName(); } - DebugTool.logInfo(TAG + ": This app's package: " + myPackage); - DebugTool.logInfo(TAG + ": Router service app's package: " + routerServicePackage); + DebugTool.logInfo(TAG, ": This app's package: " + myPackage); + DebugTool.logInfo(TAG, ": Router service app's package: " + routerServicePackage); if (myPackage != null && myPackage.equalsIgnoreCase(routerServicePackage)) { SdlDeviceListener sdlDeviceListener = getSdlDeviceListener(context, device); if (!sdlDeviceListener.isRunning()) { sdlDeviceListener.start(); } } else { - DebugTool.logInfo(TAG + ": Not the app to start the router service nor device listener"); + DebugTool.logInfo(TAG, ": Not the app to start the router service nor device listener"); } return; } @@ -307,8 +306,8 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ if (sdlAppInfoList != null && !sdlAppInfoList.isEmpty()) { startRouterService(context, sdlAppInfoList.get(0).getRouterServiceComponentName(), altTransportWake, device, false); } else{ - Log.d(TAG, "No SDL Router Services found"); - Log.d(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); + DebugTool.logInfo(TAG, "No SDL Router Services found"); + DebugTool.logInfo(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!"); return; } @@ -341,7 +340,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ try{ context.startService(serviceIntent); } catch (Exception e){ - DebugTool.logError("Can't start router service for alt transport"); + DebugTool.logError(TAG, "Can't start router service for alt transport"); } } @@ -367,7 +366,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ && "android.app.RemoteServiceException".equals(e.getClass().getName()) //android.app.RemoteServiceException is a private class && e.getMessage().contains("SdlRouterService")) { - Log.i(TAG, "Handling failed startForegroundService call"); + DebugTool.logInfo(TAG, "Handling failed startForegroundService call"); Looper.loop(); } else if (defaultUncaughtExceptionHandler != null) { //No other exception should be handled defaultUncaughtExceptionHandler.uncaughtException(t, e); @@ -386,7 +385,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ */ private static boolean isRouterServiceRunning(Context context){ if(context == null){ - Log.e(TAG, "Can't look for router service, context supplied was null"); + DebugTool.logError(TAG, "Can't look for router service, context supplied was null"); return false; } if (runningBluetoothServicePackage == null) { @@ -400,7 +399,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ try { runningServices = manager.getRunningServices(Integer.MAX_VALUE); } catch (NullPointerException e) { - Log.e(TAG, "Can't get list of running services"); + DebugTool.logError(TAG, "Can't get list of running services"); return false; } for (RunningServiceInfo service : runningServices) { @@ -431,14 +430,14 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ intent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA, true); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ intent.putExtra(FOREGROUND_EXTRA, true); - DebugTool.logInfo("Attempting to startForegroundService - " + System.currentTimeMillis()); + DebugTool.logInfo(TAG, "Attempting to startForegroundService - " + System.currentTimeMillis()); setForegroundExceptionHandler(); //Prevent ANR in case the OS takes too long to start the service context.startForegroundService(intent); }else { context.startService(intent); } }catch(SecurityException e){ - Log.e(TAG, "Security exception, process is bad"); + DebugTool.logError(TAG, "Security exception, process is bad"); // This service could not be started } } @@ -493,9 +492,9 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ provider.checkIsConnected(); }else{ if(service!=null){ - Log.d(TAG, service.getPackageName() + " is connected = " + connected); + DebugTool.logInfo(TAG, service.getPackageName() + " is connected = " + connected); }else{ - Log.d(TAG,"No service is connected/running"); + DebugTool.logInfo(TAG, "No service is connected/running"); } if(callback!=null){ callback.onConnectionStatusUpdate(connected, service,context); @@ -519,9 +518,9 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{ }); }else{ - Log.w(TAG, "Router service isn't running, returning false."); + DebugTool.logWarning(TAG, "Router service isn't running, returning false."); if(isBluetoothConnected()){ - Log.d(TAG, "Bluetooth is connected. Attempting to ping Router Service"); + DebugTool.logInfo(TAG, "Bluetooth is connected. Attempting to ping Router Service"); Intent serviceIntent = new Intent(); serviceIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION); serviceIntent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA, true); diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java index 2e3317661..5168bf50b 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterService.java @@ -73,7 +73,6 @@ import android.os.RemoteException; import android.support.annotation.NonNull; import android.support.v4.app.NotificationCompat; import android.util.AndroidRuntimeException; -import android.util.Log; import android.util.SparseArray; import android.util.SparseIntArray; @@ -276,16 +275,16 @@ public class SdlRouterService extends Service{ if(startSequenceComplete && !connectAsClient && (bluetoothTransport ==null || bluetoothTransport.getState() == MultiplexBluetoothTransport.STATE_NONE)){ - Log.e(TAG, "Serial service not initialized while registering app"); + DebugTool.logError(TAG, "Serial service not initialized while registering app"); //Maybe we should try to do a connect here instead - Log.d(TAG, "Serial service being restarted"); + DebugTool.logInfo(TAG, "Serial service being restarted"); initBluetoothSerialService(); } } - Log.i(TAG, app.appId + " has just been registered with SDL Router Service"); + DebugTool.logInfo(TAG, app.appId + " has just been registered with SDL Router Service"); } /** @@ -300,9 +299,9 @@ public class SdlRouterService extends Service{ { String action = intent.getAction(); if(action == null){ - Log.d(TAG, "Disconnect received with no action."); + DebugTool.logInfo(TAG, "Disconnect received with no action."); }else { - Log.d(TAG, "Disconnect received. Action: " + intent.getAction()); + DebugTool.logInfo(TAG, "Disconnect received. Action: " + intent.getAction()); if(action.equalsIgnoreCase(BluetoothAdapter.ACTION_STATE_CHANGED)){ int bluetoothState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1); @@ -313,7 +312,7 @@ public class SdlRouterService extends Service{ return; case BluetoothAdapter.STATE_TURNING_OFF: case BluetoothAdapter.STATE_OFF: - Log.d(TAG, "Bluetooth is shutting off, SDL Router Service is closing."); + DebugTool.logInfo(TAG, "Bluetooth is shutting off, SDL Router Service is closing."); connectAsClient = false; if(!shouldServiceRemainOpen(intent)){ closeSelf(); @@ -326,7 +325,7 @@ public class SdlRouterService extends Service{ //Otherwise connectAsClient = false; if (legacyModeEnabled) { - Log.d(TAG, "Legacy mode enabled and bluetooth d/c'ed, restarting router service bluetooth."); + DebugTool.logInfo(TAG, "Legacy mode enabled and bluetooth d/c'ed, restarting router service bluetooth."); enableLegacyMode(false); onTransportDisconnected(new TransportRecord(TransportType.BLUETOOTH,null)); initBluetoothSerialService(); @@ -377,7 +376,7 @@ public class SdlRouterService extends Service{ BluetoothDevice device = receivedBundle.getParcelable(BluetoothDevice.EXTRA_DEVICE); connectAsClient = true; if(device==null || !service.bluetoothConnect(device)){ - Log.e(TAG, "Unable to connect to bluetooth device"); + DebugTool.logError(TAG, "Unable to connect to bluetooth device"); connectAsClient = false; } } @@ -392,7 +391,7 @@ public class SdlRouterService extends Service{ appId = "" + receivedBundle.getLong(TransportConstants.APP_ID_EXTRA, -1); } if(appId.length()<=0 || msg.replyTo == null){ - Log.w(TAG, "Unable to register app as no id or messenger was included"); + DebugTool.logWarning(TAG, "Unable to register app as no id or messenger was included"); if(msg.replyTo!=null){ message.arg1 = TransportConstants.REGISTRATION_RESPONSE_DENIED_APP_ID_NOT_INCLUDED; try { @@ -404,7 +403,7 @@ public class SdlRouterService extends Service{ break; } if(service.legacyModeEnabled){ - Log.w(TAG, "Unable to register app as legacy mode is enabled"); + DebugTool.logWarning(TAG, "Unable to register app as legacy mode is enabled"); if(msg.replyTo!=null){ message.arg1 = TransportConstants.REGISTRATION_RESPONSE_DENIED_LEGACY_MODE_ENABLED; try { @@ -423,7 +422,7 @@ public class SdlRouterService extends Service{ synchronized(service.REGISTERED_APPS_LOCK){ RegisteredApp old = registeredApps.put(app.getAppId(), app); if(old!=null){ - Log.w(TAG, "Replacing already existing app with this app id"); + DebugTool.logWarning(TAG, "Replacing already existing app with this app id"); service.removeAllSessionsForApp(old, true); old.close(); } @@ -460,7 +459,7 @@ public class SdlRouterService extends Service{ if(appIdToUnregister == null){ appIdToUnregister = "" + receivedBundle.getLong(TransportConstants.APP_ID_EXTRA, -1); } - Log.i(TAG, "Unregistering client: " + appIdToUnregister); + DebugTool.logInfo(TAG, "Unregistering client: " + appIdToUnregister); RegisteredApp unregisteredApp; synchronized(service.REGISTERED_APPS_LOCK){ unregisteredApp = registeredApps.remove(appIdToUnregister); @@ -474,14 +473,14 @@ public class SdlRouterService extends Service{ response.arg1 = TransportConstants.UNREGISTRATION_RESPONSE_SUCESS; service.removeAllSessionsForApp(unregisteredApp,false); } - Log.i(TAG, "Unregistering client response: " + response.arg1 ); + DebugTool.logInfo(TAG, "Unregistering client response: " + response.arg1 ); try { msg.replyTo.send(response); //We do this because we aren't guaranteed to find the correct registeredApp to send the message through } catch (RemoteException e) { e.printStackTrace(); }catch(NullPointerException e2){ - Log.e(TAG, "No reply address included, can't send a reply"); + DebugTool.logError(TAG, "No reply address included, can't send a reply"); } break; @@ -521,7 +520,7 @@ public class SdlRouterService extends Service{ // This means no transport is connected. Likely the // router service has already disconnected and this // is now just executing. - DebugTool.logError("Can't send packet, no transport specified and none are connected."); + DebugTool.logError(TAG, "Can't send packet, no transport specified and none are connected."); return; } //Log.d(TAG, "Transport type was null, so router set it to " + transportType.name()); @@ -587,7 +586,7 @@ public class SdlRouterService extends Service{ } catch (RemoteException e) { e.printStackTrace(); }catch(NullPointerException e2){ - Log.e(TAG, "No reply address included, can't send a reply"); + DebugTool.logError(TAG, "No reply address included, can't send a reply"); } break; case TransportConstants.ROUTER_REMOVE_SESSION: @@ -628,7 +627,7 @@ public class SdlRouterService extends Service{ } catch (RemoteException e) { e.printStackTrace(); }catch(NullPointerException e2){ - Log.e(TAG, "No reply address included, can't send a reply"); + DebugTool.logError(TAG, "No reply address included, can't send a reply"); } break; case TransportConstants.ROUTER_REQUEST_SECONDARY_TRANSPORT_CONNECTION: @@ -721,7 +720,7 @@ public class SdlRouterService extends Service{ Message retMsg = Message.obtain(); retMsg.what = TransportConstants.ROUTER_REGISTER_ALT_TRANSPORT_RESPONSE; if(altTransportService == null){ //Ok no other transport is connected, this is good - Log.d(TAG, "Alt transport connected."); + DebugTool.logInfo(TAG, "Alt transport connected."); if(msg.replyTo == null){ break; } @@ -754,13 +753,13 @@ public class SdlRouterService extends Service{ if(packet!=null){ service.onPacketRead(packet); }else{ - Log.w(TAG, "Received null packet from alt transport service"); + DebugTool.logWarning(TAG, "Received null packet from alt transport service"); } }else{ - Log.w(TAG, "False positive packet reception"); + DebugTool.logWarning(TAG, "False positive packet reception"); } }else{ - Log.e(TAG, "Bundle was null while sending packet to router service from alt transport"); + DebugTool.logError(TAG, "Bundle was null while sending packet to router service from alt transport"); } break; default: @@ -813,7 +812,7 @@ public class SdlRouterService extends Service{ } break; default: - Log.w(TAG, "Unsupported request: " + msg.what); + DebugTool.logWarning(TAG, "Unsupported request: " + msg.what); break; } } @@ -905,7 +904,7 @@ public class SdlRouterService extends Service{ case TransportConstants.ALT_TRANSPORT_CONNECTED: break; default: - Log.w(TAG, "Unsupported request: " + msg.what); + DebugTool.logWarning(TAG, "Unsupported request: " + msg.what); break; } } @@ -920,7 +919,7 @@ public class SdlRouterService extends Service{ //Check intent to send back the correct binder (client binding vs alt transport) if(intent!=null){ if(closing){ - Log.w(TAG, "Denying bind request due to service shutting down."); + DebugTool.logWarning(TAG, "Denying bind request due to service shutting down."); return null; } String requestType = intent.getAction();//intent.getIntExtra(TransportConstants.ROUTER_BIND_REQUEST_TYPE_EXTRA, TransportConstants.BIND_REQUEST_TYPE_CLIENT); @@ -935,7 +934,7 @@ public class SdlRouterService extends Service{ }else if(TransportConstants.BIND_REQUEST_TYPE_USB_PROVIDER.equals(requestType)){ return this.usbTransferMessenger.getBinder(); }else{ - Log.w(TAG, "Unknown bind request type"); + DebugTool.logWarning(TAG, "Unknown bind request type"); } } @@ -946,17 +945,17 @@ public class SdlRouterService extends Service{ @Override public boolean onUnbind(Intent intent) { - Log.d(TAG, "Unbind being called."); + DebugTool.logInfo(TAG, "Unbind being called."); return super.onUnbind(intent); } private void notifyClients(final Message message){ if(message==null){ - Log.w(TAG, "Can't notify clients, message was null"); + DebugTool.logWarning(TAG, "Can't notify clients, message was null"); return; } - Log.d(TAG, "Notifying "+ registeredApps.size()+ " clients"); + DebugTool.logInfo(TAG, "Notifying "+ registeredApps.size()+ " clients"); int result; synchronized(REGISTERED_APPS_LOCK){ Collection<RegisteredApp> apps = registeredApps.values(); @@ -1028,7 +1027,7 @@ public class SdlRouterService extends Service{ @SuppressWarnings("unused") private void pingClients(){ Message message = Message.obtain(); - Log.d(TAG, "Pinging "+ registeredApps.size()+ " clients"); + DebugTool.logInfo(TAG, "Pinging "+ registeredApps.size()+ " clients"); int result; synchronized(REGISTERED_APPS_LOCK){ Collection<RegisteredApp> apps = registeredApps.values(); @@ -1088,16 +1087,16 @@ public class SdlRouterService extends Service{ */ private boolean initCheck(){ if(!processCheck()){ - Log.e(TAG, "Not using correct process. Shutting down"); + DebugTool.logError(TAG, "Not using correct process. Shutting down"); wrongProcess = true; return false; } if(!permissionCheck(Manifest.permission.BLUETOOTH)){ - Log.e(TAG, "Bluetooth Permission is not granted. Shutting down"); + DebugTool.logError(TAG, "Bluetooth Permission is not granted. Shutting down"); return false; } if(!AndroidTools.isServiceExported(this, new ComponentName(this, this.getClass()))){ //We want to check to see if our service is actually exported - Log.e(TAG, "Service isn't exported. Shutting down"); + DebugTool.logError(TAG, "Service isn't exported. Shutting down"); return false; } return true; @@ -1163,7 +1162,7 @@ public class SdlRouterService extends Service{ try{ startForegroundService(serviceIntent); }catch (Exception e){ - Log.e(TAG, "Unable to start next SDL router service. " + e.getMessage()); + DebugTool.logError(TAG, "Unable to start next SDL router service. " + e.getMessage()); } } break; @@ -1171,7 +1170,7 @@ public class SdlRouterService extends Service{ } } } else{ - Log.d(TAG, "No sdl apps found"); + DebugTool.logInfo(TAG, "No sdl apps found"); return; } closing = true; @@ -1274,7 +1273,7 @@ public class SdlRouterService extends Service{ if(intent.hasExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA)){ //Make sure we are listening on RFCOMM if(startSequenceComplete){ //We only check if we are sure we are already through the start up process - Log.i(TAG, "Received ping, making sure we are listening to bluetooth rfcomm"); + DebugTool.logInfo(TAG, "Received ping, making sure we are listening to bluetooth rfcomm"); initBluetoothSerialService(); } } @@ -1302,7 +1301,7 @@ public class SdlRouterService extends Service{ altTransportTimerHandler = null; } - Log.w(TAG, "Sdl Router Service Destroyed"); + DebugTool.logWarning(TAG, "Sdl Router Service Destroyed"); closing = true; //No need for this Broadcast Receiver anymore unregisterAllReceivers(); @@ -1443,9 +1442,9 @@ public class SdlRouterService extends Service{ @SuppressLint("NewApi") @SuppressWarnings("deprecation") private void enterForeground(String content, long chronometerLength, boolean ongoing) { - DebugTool.logInfo("Attempting to enter the foreground - " + System.currentTimeMillis()); + DebugTool.logInfo(TAG, "Attempting to enter the foreground - " + System.currentTimeMillis()); if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB){ - Log.w(TAG, "Unable to start service as foreground due to OS SDK version being lower than 11"); + DebugTool.logWarning(TAG, "Unable to start service as foreground due to OS SDK version being lower than 11"); isForeground = false; return; } @@ -1516,7 +1515,7 @@ public class SdlRouterService extends Service{ notificationChannel.enableVibration(false); notificationManager.createNotificationChannel(notificationChannel); } else { - Log.e(TAG, "Unable to retrieve notification Manager service"); + DebugTool.logError(TAG, "Unable to retrieve notification Manager service"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { safeStartForeground(FOREGROUND_SERVICE_ID, builder.build()); stopSelf(); //A valid notification channel must be supplied for SDK 27+ @@ -1558,16 +1557,16 @@ public class SdlRouterService extends Service{ notification = builder.build(); } startForeground(id, notification); - DebugTool.logInfo("Entered the foreground - " + System.currentTimeMillis()); + DebugTool.logInfo(TAG, "Entered the foreground - " + System.currentTimeMillis()); }catch (Exception e){ - DebugTool.logError("Unable to start service in foreground", e); + DebugTool.logError(TAG, "Unable to start service in foreground", e); } } private void exitForeground(){ synchronized (FOREGROUND_NOTIFICATION_LOCK) { if (isForeground && !isPrimaryTransportConnected()) { //Ensure that the service is in the foreground and no longer connected to a transport - DebugTool.logInfo("SdlRouterService to exit foreground"); + DebugTool.logInfo(TAG, "SdlRouterService to exit foreground"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { this.stopForeground(Service.STOP_FOREGROUND_DETACH); }else{ @@ -1581,7 +1580,7 @@ public class SdlRouterService extends Service{ notificationManager.deleteNotificationChannel(SDL_NOTIFICATION_CHANNEL_ID); } } catch (Exception e) { - DebugTool.logError("Issue when removing notification and channel", e); + DebugTool.logError(TAG, "Issue when removing notification and channel", e); } } isForeground = false; @@ -1688,24 +1687,24 @@ public class SdlRouterService extends Service{ ArrayList<TransportRecord> connectedTransports = getConnectedTransports(); if(connectedTransports != null && !connectedTransports.isEmpty()){ // stay open if we have any transports connected - Log.d(TAG, "1 or more transports connected, remaining open"); + DebugTool.logInfo(TAG, "1 or more transports connected, remaining open"); return true; }else if(altTransportService!=null || altTransportTimerHandler !=null){ //We have been started by an alt transport, we must remain open. "My life for Auir...." - Log.d(TAG, "Alt Transport connected, remaining open"); + DebugTool.logInfo(TAG, "Alt Transport connected, remaining open"); return true; }else if(intent!=null && TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT.equals(intent.getAction())){ - Log.i(TAG, "Received start intent with alt transport request."); + DebugTool.logInfo(TAG, "Received start intent with alt transport request."); startAltTransportTimer(); return true; }else if(!bluetoothAvailable()){//If bluetooth isn't on...there's nothing to see here //Bluetooth is off, we should shut down - Log.d(TAG, "Bluetooth not available, shutting down service"); + DebugTool.logInfo(TAG, "Bluetooth not available, shutting down service"); return connectedTransports != null && connectedTransports.size() > 0; //If a transport is connected the list will be >0 }else{ - Log.d(TAG, "Service to remain open"); + DebugTool.logInfo(TAG, "Service to remain open"); return true; } } @@ -1731,7 +1730,7 @@ public class SdlRouterService extends Service{ } private synchronized void initBluetoothSerialService(){ if(legacyModeEnabled){ - Log.d(TAG, "Not starting own bluetooth during legacy mode"); + DebugTool.logInfo(TAG, "Not starting own bluetooth during legacy mode"); return; } //init serial service @@ -1742,7 +1741,7 @@ public class SdlRouterService extends Service{ // Only if the state is STATE_NONE, do we know that we haven't started already if (bluetoothTransport.getState() == MultiplexBluetoothTransport.STATE_NONE) { // Start the Bluetooth services - Log.i(TAG, "Starting bluetooth transport"); + DebugTool.logInfo(TAG, "Starting bluetooth transport"); bluetoothTransport.start(); } @@ -1914,7 +1913,7 @@ public class SdlRouterService extends Service{ return; } - Log.e(TAG, "Notifying client service of hardware disconnect."); + DebugTool.logError(TAG, "Notifying client service of hardware disconnect."); //We've notified our clients, less clean up the mess now. @@ -2037,7 +2036,7 @@ public class SdlRouterService extends Service{ } byte[] packet = bundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME); if(packet==null) { - Log.w(TAG, "Ignoring null packet"); + DebugTool.logWarning(TAG, "Ignoring null packet"); return false; } int offset = bundle.getInt(TransportConstants.BYTES_TO_SEND_EXTRA_OFFSET, 0); //If nothing, start at the beginning of the array @@ -2066,7 +2065,7 @@ public class SdlRouterService extends Service{ } } } - Log.e(TAG, "Can't send data, no transport of specified type connected"); + DebugTool.logError(TAG, "Can't send data, no transport of specified type connected"); return false; } @@ -2107,12 +2106,12 @@ public class SdlRouterService extends Service{ try { altTransportService.send(msg); } catch (RemoteException e) { - Log.e(TAG, "Unable to send through alt transport!"); + DebugTool.logError(TAG, "Unable to send through alt transport!"); e.printStackTrace(); } return true; }else{ - Log.w(TAG, "Unable to send packet through alt transport, it was null"); + DebugTool.logWarning(TAG, "Unable to send packet through alt transport, it was null"); } return false; } @@ -2134,12 +2133,12 @@ public class SdlRouterService extends Service{ try { altTransportService.send(msg); } catch (RemoteException e) { - Log.e(TAG, "Unable to send through alt transport!"); + DebugTool.logError(TAG, "Unable to send through alt transport!"); e.printStackTrace(); } return true; }else{ - Log.w(TAG, "Unable to send packet through alt transport, it was null"); + DebugTool.logWarning(TAG, "Unable to send packet through alt transport, it was null"); } return false; } @@ -2173,7 +2172,7 @@ public class SdlRouterService extends Service{ } if(app == null){ - Log.e(TAG, "No app found for app id " + appid + " Removing session mapping and sending unregisterAI to head unit."); + DebugTool.logError(TAG, "No app found for app id " + appid + " Removing session mapping and sending unregisterAI to head unit."); //We have no app to match the app id tied to this session removeSessionFromMap(session, Collections.singletonList(packet.getTransportRecord().getType())); @@ -2197,7 +2196,7 @@ public class SdlRouterService extends Service{ byte[] stopService = SdlPacketFactory.createEndSession(SessionType.RPC, (byte)session, 0, (byte)packet.getVersion(), hashId).constructPacket(); manuallyWriteBytes(packet.getTransportRecord().getType(), stopService,0,stopService.length); }else{ - Log.w(TAG, "No where to send a packet from what appears to be a non primary transport"); + DebugTool.logWarning(TAG, "No where to send a packet from what appears to be a non primary transport"); } return false; @@ -2214,7 +2213,7 @@ public class SdlRouterService extends Service{ this.sessionHashIdMap.put(session, hashId); } } else { - Log.w(TAG, "Hash ID not found in V5 start service ACK frame for session " + session); + DebugTool.logWarning(TAG, "Hash ID not found in V5 start service ACK frame for session " + session); } } else { if (packet.getPayload() != null && packet.getDataSize() == 4){ //hashid will be 4 bytes in length @@ -2230,7 +2229,7 @@ public class SdlRouterService extends Service{ if(packet.getFrameType() == FrameType.Single && packet.getServiceType() == SdlPacket.SERVICE_TYPE_RPC) { BinaryFrameHeader binFrameHeader = BinaryFrameHeader.parseBinaryHeader(packet.getPayload()); if (binFrameHeader != null && FunctionID.UNREGISTER_APP_INTERFACE.getId() == binFrameHeader.getFunctionID()) { - Log.d(TAG, "Received an unregister app interface. Checking session hash before sending"); + DebugTool.logInfo(TAG, "Received an unregister app interface. Checking session hash before sending"); // make sure that we don't try to unregister a recently added app that might have a // session ID of a removed app whose UAI was delayed int hashOfRemoved = this.cleanedSessionMap.get(session, -1); @@ -2239,7 +2238,7 @@ public class SdlRouterService extends Service{ // Current session contains key that was held before if (hashOfRemoved != currentHash) { // App assigned same session id but is a different app. Keep this from being killed - Log.d(TAG, "same session id for different apps found, dropping packet"); + DebugTool.logInfo(TAG, "same session id for different apps found, dropping packet"); this.cleanedSessionMap.delete(session); return false; } @@ -2286,14 +2285,14 @@ public class SdlRouterService extends Service{ message.setData(bundle); //Log.d(TAG, "First packet before sending: " + message.getData().toString()); if(!sendPacketMessageToClient(app, message, version)){ - Log.w(TAG, "Error sending first message of split packet to client " + app.appId); + DebugTool.logWarning(TAG, "Error sending first message of split packet to client " + app.appId); return false; } //Log.w(TAG, "Message too big for single IPC transaction. Breaking apart. Size - " + packet.getDataSize()); ByteArrayMessageSpliter splitter = new ByteArrayMessageSpliter(appid,TransportConstants.ROUTER_RECEIVED_PACKET,bytes,0); while(splitter.isActive()){ if(!sendPacketMessageToClient(app,splitter.nextMessage(),version)){ - Log.w(TAG, "Error sending first message of split packet to client " + app.appId); + DebugTool.logWarning(TAG, "Error sending first message of split packet to client " + app.appId); splitter.close(); return false; } @@ -2302,24 +2301,24 @@ public class SdlRouterService extends Service{ } }else{ //If we can't find a session for this packet we just drop the packet - Log.e(TAG, "App Id was NULL for session! " + session); + DebugTool.logError(TAG, "App Id was NULL for session! " + session); TransportType transportType = packet.getTransportRecord().getType(); if(removeSessionFromMap(session, Collections.singletonList(transportType))){ //If we found the session id still tied to an app in our map we need to remove it and send the proper shutdown sequence. - Log.i(TAG, "Removed session from map. Sending unregister request to module."); + DebugTool.logInfo(TAG, "Removed session from map. Sending unregister request to module."); attemptToCleanUpModule(session, packet.getVersion(), transportType); }else{ //There was no mapping so let's try to resolve this if(packet.getFrameType() == FrameType.Single && packet.getServiceType() == SdlPacket.SERVICE_TYPE_RPC){ BinaryFrameHeader binFrameHeader = BinaryFrameHeader.parseBinaryHeader(packet.getPayload()); if(binFrameHeader!=null && FunctionID.UNREGISTER_APP_INTERFACE.getId() == binFrameHeader.getFunctionID()){ - Log.d(TAG, "Received an unregister app interface with no where to send it, dropping the packet."); + DebugTool.logInfo(TAG, "Received an unregister app interface with no where to send it, dropping the packet."); }else{ attemptToCleanUpModule(session, packet.getVersion(),transportType); } }else if((packet.getFrameType() == FrameType.Control && (packet.getFrameInfo() == SdlPacket.FRAME_INFO_END_SERVICE_ACK || packet.getFrameInfo() == SdlPacket.FRAME_INFO_END_SERVICE_NAK))){ //We want to ignore this - Log.d(TAG, "Received a stop service ack/nak with no where to send it, dropping the packet."); + DebugTool.logInfo(TAG, "Received a stop service ack/nak with no where to send it, dropping the packet."); }else{ attemptToCleanUpModule(session, packet.getVersion(),transportType); } @@ -2336,7 +2335,7 @@ public class SdlRouterService extends Service{ * @param version the last known version that this session was operating with */ private void attemptToCleanUpModule(int session, int version, TransportType primaryTransport){ - Log.i(TAG, "Attempting to stop session " + session); + DebugTool.logInfo(TAG, "Attempting to stop session " + session); byte[] uai = createForceUnregisterApp((byte)session, (byte)version); manuallyWriteBytes(primaryTransport,uai,0,uai.length); int hashId = 0; @@ -2354,7 +2353,7 @@ public class SdlRouterService extends Service{ private boolean sendPacketMessageToClient(RegisteredApp app, Message message, byte version){ int result = app.sendMessage(message); if(result == RegisteredApp.SEND_MESSAGE_ERROR_MESSENGER_DEAD_OBJECT){ - Log.d(TAG, "Dead object, removing app and sessions"); + DebugTool.logInfo(TAG, "Dead object, removing app and sessions"); //Get all their sessions and send out unregister info //Use the version in this packet as a best guess app.close(); @@ -2408,7 +2407,7 @@ public class SdlRouterService extends Service{ BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if(adapter != null && adapter.isEnabled()){ Set<BluetoothDevice> pairedBT= adapter.getBondedDevices(); - Log.d(TAG, "Query Bluetooth paired devices"); + DebugTool.logInfo(TAG, "Query Bluetooth paired devices"); if (pairedBT.size() > 0) { for (BluetoothDevice device : pairedBT) { String name = device.getName().toLowerCase(Locale.US); @@ -2419,14 +2418,14 @@ public class SdlRouterService extends Service{ } } }else{ - Log.e(TAG, "There was an issue with connecting as client"); + DebugTool.logError(TAG, "There was an issue with connecting as client"); } return false; } @SuppressWarnings("MissingPermission") private synchronized boolean bluetoothConnect(BluetoothDevice device){ - Log.d(TAG,"Connecting to device: " + device.getName()); + DebugTool.logInfo(TAG,"Connecting to device: " + device.getName()); if(bluetoothTransport == null || !bluetoothTransport.isConnected()) { // Set up the Bluetooth serial object bluetoothTransport = new MultiplexBluetoothTransport(bluetoothHandler); @@ -2439,7 +2438,7 @@ public class SdlRouterService extends Service{ } } - Log.d(TAG, "Bluetooth SPP Connect Attempt Completed"); + DebugTool.logInfo(TAG, "Bluetooth SPP Connect Attempt Completed"); return false; } @@ -2457,7 +2456,7 @@ public class SdlRouterService extends Service{ @SuppressWarnings("DeprecatedIsStillUsed") @Deprecated public static void setBluetoothPrefs (int level, String prefLocation) { - Log.w(TAG, "This method is deprecated and will not take any action"); + DebugTool.logWarning(TAG, "This method is deprecated and will not take any action"); } /** @@ -2512,7 +2511,7 @@ public class SdlRouterService extends Service{ SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean(key,value); editor.commit(); - Log.d(TAG, "Preference set: " + key + " : " + value); + DebugTool.logInfo(TAG, "Preference set: " + key + " : " + value); } /** @@ -2539,10 +2538,10 @@ public class SdlRouterService extends Service{ @Deprecated protected static LocalRouterService getLocalRouterService(Intent launchIntent, ComponentName name){ if(launchIntent == null){ - Log.w(TAG, "Supplied intent was null, local router service will not contain intent"); + DebugTool.logWarning(TAG, "Supplied intent was null, local router service will not contain intent"); } if(name == null){ - Log.e(TAG, "Unable to create local router service object because component name was null"); + DebugTool.logError(TAG, "Unable to create local router service object because component name was null"); return null; } //noinspection deprecation @@ -2741,7 +2740,7 @@ public class SdlRouterService extends Service{ app.registerTransport(sessionId, transportType); sessionMap.put(sessionId,appId); }else{ - Log.w(TAG, "No registered app found when register secondary transport"); + DebugTool.logWarning(TAG, "No registered app found when register secondary transport"); } } } @@ -2759,7 +2758,7 @@ public class SdlRouterService extends Service{ private boolean legacyModeEnabled = false; private void enableLegacyMode(boolean enable){ - Log.d(TAG, "Enable legacy mode: " + enable); + DebugTool.logInfo(TAG, "Enable legacy mode: " + enable); legacyModeEnabled = enable; //We put this at the end to avoid a race condition between the bluetooth d/c and notify of legacy mode enabled if(legacyModeEnabled){ @@ -2781,13 +2780,13 @@ public class SdlRouterService extends Service{ //DEBUG if(bytes[0] != 0x00){ - Log.d(TAG, "Writing packet with header: " + BitConverter.bytesToHex(bytes, 12)); //just want the header + DebugTool.logInfo(TAG, "Writing packet with header: " + BitConverter.bytesToHex(bytes, 12)); //just want the header }else{ //Log.d(TAG, "Writing packet with binary header: " + BitConverter.bytesToHex(bytes, 12)); //just want the header //int length = bytes.length-12; if(bytes.length<=8){ - Log.w(TAG, "No payload to debug or too small"); + DebugTool.logWarning(TAG, "No payload to debug or too small"); return; } //Check first byte if 0, make to json @@ -2798,7 +2797,7 @@ public class SdlRouterService extends Service{ try { JSONObject object = new JSONObject(new String(buffer)); - Log.d(TAG, "JSON: " + object.toString()); + DebugTool.logInfo(TAG, "JSON: " + object.toString()); } catch (JSONException e) { e.printStackTrace(); } @@ -2892,7 +2891,7 @@ public class SdlRouterService extends Service{ return; } if(isPingingClients){ - Log.w(TAG, "Already pinging clients. Resting count"); + DebugTool.logWarning(TAG, "Already pinging clients. Resting count"); synchronized(PING_COUNT_LOCK){ pingCount = 0; } @@ -2911,7 +2910,7 @@ public class SdlRouterService extends Service{ @Override public void run() { if(getPingCount()>=10){ - Log.d(TAG, "Hit ping limit"); + DebugTool.logInfo(TAG, "Hit ping limit"); stopClientPings(); return; } @@ -3407,7 +3406,7 @@ public class SdlRouterService extends Service{ } if(buffer != null){ if (!buffer.handleMessage(flags, packet)) { //If this returns false - Log.e(TAG, "Error handling bytes"); + DebugTool.logError(TAG, "Error handling bytes"); } if (buffer.isFinished()) { //We are finished building the buffer so we should write the bytes out byte[] bytes = buffer.getBytes(); @@ -3451,7 +3450,7 @@ public class SdlRouterService extends Service{ if(queue!=null && queue.peek().priorityCoefficient>0){ //If this has any sort of priority coefficient we want to make it wait. //Flag to wait if(queueWaitHandler == null){ - Log.e(TAG, "Unable to pause queue, handler was null"); + DebugTool.logError(TAG, "Unable to pause queue, handler was null"); } if(queueWaitRunnable == null){ queueWaitRunnable = new Runnable(){ @@ -3490,7 +3489,7 @@ public class SdlRouterService extends Service{ @Override public void binderDied() { synchronized(deathLock){ - Log.w(TAG, "Binder died for app " + RegisteredApp.this.appId); + DebugTool.logWarning(TAG, "Binder died for app " + RegisteredApp.this.appId); if(messenger.getBinder()!=null){ messenger.getBinder().unlinkToDeath(this, 0); } @@ -3821,7 +3820,7 @@ public class SdlRouterService extends Service{ builder.setOngoing(false); - Log.e(TAG, "Notification: notifySppError entering"); + DebugTool.logError(TAG, "Notification: notifySppError entering"); final String tag = "SDL"; //Now we need to add a notification channel final NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); @@ -3838,7 +3837,7 @@ public class SdlRouterService extends Service{ Notification notification = builder.build(); notificationManager.notify(tag, TransportConstants.SDL_ERROR_NOTIFICATION_CHANNEL_ID_INT, notification); } else { - Log.e(TAG, "notifySppError: Unable to retrieve notification Manager service"); + DebugTool.logError(TAG, "notifySppError: Unable to retrieve notification Manager service"); } } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java index 53e1dbbed..6a7230fcd 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlRouterStatusProvider.java @@ -42,9 +42,9 @@ import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; -import android.util.Log; import com.smartdevicelink.util.AndroidTools; +import com.smartdevicelink.util.DebugTool; import java.lang.ref.WeakReference; @@ -66,7 +66,7 @@ public class SdlRouterStatusProvider { private ServiceConnection routerConnection= new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { - Log.d(TAG, "Bound to service " + className.toString()); + DebugTool.logInfo(TAG, "Bound to service " + className.toString()); routerServiceMessenger = new Messenger(service); isBound = true; //So we just established our connection @@ -86,7 +86,7 @@ public class SdlRouterStatusProvider { } public void onServiceDisconnected(ComponentName className) { - Log.d(TAG, "UN-Bound from service " + className.getClassName()); + DebugTool.logInfo(TAG, "UN-Bound from service " + className.getClassName()); routerServiceMessenger = null; isBound = false; } @@ -146,7 +146,7 @@ public class SdlRouterStatusProvider { if(context!=null && routerConnection!=null){ context.unbindService(routerConnection); }else{ - Log.w(TAG, "Unable to unbind from router service, context was null"); + DebugTool.logWarning(TAG, "Unable to unbind from router service, context was null"); } }catch(IllegalArgumentException e){ diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java index 0fa64d7f5..32fe26fee 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/SdlTransport.java @@ -39,6 +39,7 @@ import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.util.DebugTool; public abstract class SdlTransport { + private static final String TAG = "SdlTransport"; private static final String SDL_LIB_TRACE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66"; private final static String FailurePropagating_Msg = "Failure propagating "; @@ -73,7 +74,7 @@ public abstract class SdlTransport { _transportListener.onTransportPacketReceived(packet); } // end-if } catch (Exception excp) { - DebugTool.logError(FailurePropagating_Msg + "handleBytesFromTransport: " + excp.toString(), excp); + DebugTool.logError(TAG, FailurePropagating_Msg + "handleBytesFromTransport: " + excp.toString(), excp); handleTransportError(FailurePropagating_Msg, excp); } // end-catch } // end-method @@ -113,7 +114,7 @@ public abstract class SdlTransport { SdlTrace.logTransportEvent("Transport.connected", null, InterfaceActivityDirection.Receive, null, 0, SDL_LIB_TRACE_KEY); _transportListener.onTransportConnected(); } catch (Exception excp) { - DebugTool.logError(FailurePropagating_Msg + "onTransportConnected: " + excp.toString(), excp); + DebugTool.logError(TAG, FailurePropagating_Msg + "onTransportConnected: " + excp.toString(), excp); handleTransportError(FailurePropagating_Msg + "onTransportConnected", excp); } // end-catch } // end-method @@ -127,7 +128,7 @@ public abstract class SdlTransport { SdlTrace.logTransportEvent("Transport.disconnect: " + info, null, InterfaceActivityDirection.Transmit, null, 0, SDL_LIB_TRACE_KEY); _transportListener.onTransportDisconnected(info); } catch (Exception excp) { - DebugTool.logError(FailurePropagating_Msg + "onTransportDisconnected: " + excp.toString(), excp); + DebugTool.logError(TAG, FailurePropagating_Msg + "onTransportDisconnected: " + excp.toString(), excp); } // end-catch } // end-method diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java index 4ae010a8c..3629e883c 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransport.java @@ -35,12 +35,12 @@ import android.annotation.SuppressLint; import android.annotation.TargetApi;
import android.os.Build;
import android.os.NetworkOnMainThreadException;
-import android.util.Log;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.exception.SdlExceptionCause;
import com.smartdevicelink.protocol.SdlPacket;
import com.smartdevicelink.transport.enums.TransportType;
+import com.smartdevicelink.util.DebugTool;
import java.io.IOException;
import java.io.InputStream;
@@ -77,7 +77,7 @@ import java.net.Socket; * Class that implements TCP transport
*/
public class TCPTransport extends SdlTransport {
-
+ private static final String TAG = "TCPTransport";
/**
* Size of the read buffer.
*/
@@ -293,7 +293,7 @@ public class TCPTransport extends SdlTransport { * @param message Message to log
*/
protected void logInfo(String message) {
- Log.i(getClass().getName(), message);
+ DebugTool.logInfo(TAG, message);
}
/**
@@ -301,7 +301,7 @@ public class TCPTransport extends SdlTransport { * @param message Message to log
*/
protected void logError(String message) {
- Log.e(getClass().getName(), message);
+ DebugTool.logError(TAG, message);
}
/**
@@ -309,7 +309,7 @@ public class TCPTransport extends SdlTransport { * @param message Message to log
*/
protected void logWarning(String message) {
- Log.w(getClass().getName(), message);
+ DebugTool.logWarning(TAG, message);
}
/**
@@ -318,7 +318,7 @@ public class TCPTransport extends SdlTransport { * @param throwable Exception, that was the main reason for logged error message
*/
protected void logError(String message, Throwable throwable) {
- Log.e(getClass().getName(), message, throwable);
+ DebugTool.logError(TAG, message, throwable);
}
/**
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java index 29e0c3aa1..aca8789ac 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TCPTransportManager.java @@ -2,7 +2,6 @@ package com.smartdevicelink.transport; import android.os.Handler; import android.os.Message; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; @@ -21,7 +20,7 @@ public class TCPTransportManager extends TransportManagerBase{ public TCPTransportManager(TCPTransportConfig config, TransportEventListener transportEventListener){ super(config,transportEventListener); - Log.d(TAG, "USING THE TCP TRANSPORT MANAGER"); + DebugTool.logInfo(TAG, "USING THE TCP TRANSPORT MANAGER"); this.config = config; tcpHandler = new TCPHandler(this); transport = new MultiplexTcpTransport(config.getPort(), config.getIPAddress(),config.getAutoReconnect(),tcpHandler, null); @@ -98,7 +97,7 @@ public class TCPTransportManager extends TransportManagerBase{ service.transportStatus.clear(); service.transportStatus.add(service.transport.getTransportRecord()); } - DebugTool.logInfo("TCP transport has connected"); + DebugTool.logInfo(TAG, "TCP transport has connected"); service.transportListener.onTransportConnected(service.transportStatus); break; case MultiplexBaseTransport.STATE_CONNECTING: @@ -120,7 +119,7 @@ public class TCPTransportManager extends TransportManagerBase{ } break; case MultiplexBaseTransport.STATE_ERROR: - Log.d(TAG, "TCP transport encountered an error"); + DebugTool.logInfo(TAG, "TCP transport encountered an error"); service.transportListener.onError("TCP transport encountered an error" ); break; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java index 003556109..becbdcbb4 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportBroker.java @@ -48,7 +48,6 @@ import android.os.Messenger; import android.os.Parcelable; import android.os.RemoteException; import android.os.TransactionTooLargeException; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; @@ -107,7 +106,7 @@ public class TransportBroker { routerConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { - Log.d(TAG, "Bound to service " + className.toString()); + DebugTool.logInfo(TAG, "Bound to service " + className.toString()); routerServiceMessenger = new Messenger(service); isBound = true; //So we just established our connection @@ -116,7 +115,7 @@ public class TransportBroker { } public void onServiceDisconnected(ComponentName className) { - Log.d(TAG, "Unbound from service " + className.getClassName()); + DebugTool.logInfo(TAG, "Unbound from service " + className.getClassName()); routerServiceMessenger = null; registeredWithRouterService = false; isBound = false; @@ -132,7 +131,7 @@ public class TransportBroker { protected boolean sendMessageToRouterService(Message message, int retryCount) { synchronized (MESSAGE_SEND_LOCK) { if (message == null) { - Log.w(TAG, "Attempted to send null message"); + DebugTool.logWarning(TAG, "Attempted to send null message"); return false; } //Log.i(TAG, "Attempting to send message type - " + message.what); @@ -155,23 +154,23 @@ public class TransportBroker { return sendMessageToRouterService(message, retryCount++); } else { //DeadObject, time to kill our connection - Log.d(TAG, "Dead object while attempting to send packet"); + DebugTool.logInfo(TAG, "Dead object while attempting to send packet"); stop(); onHardwareDisconnected(null, null); return false; } } catch (NullPointerException e) { - Log.d(TAG, "Null messenger while attempting to send packet"); // NPE, routerServiceMessenger is null + DebugTool.logInfo(TAG, "Null messenger while attempting to send packet"); // NPE, routerServiceMessenger is null stop(); onHardwareDisconnected(null, null); return false; } } else { - Log.e(TAG, "Unable to send message to router service. Not registered."); + DebugTool.logError(TAG, "Unable to send message to router service. Not registered."); return false; } } else { - Log.e(TAG, "Unable to send message to router service. Not bound."); + DebugTool.logError(TAG, "Unable to send message to router service. Not bound."); return false; } } @@ -194,7 +193,7 @@ public class TransportBroker { public void handleMessage(Message msg) { TransportBroker broker = provider.get(); if (broker == null) { - Log.e(TAG, "Broker object null, unable to process message"); + DebugTool.logError(TAG, "Broker object null, unable to process message"); return; } Bundle bundle = msg.getData(); @@ -233,7 +232,7 @@ public class TransportBroker { } break; case TransportConstants.REGISTRATION_RESPONSE_DENIED_LEGACY_MODE_ENABLED: - Log.d(TAG, "Denied registration because router is in legacy mode"); + DebugTool.logInfo(TAG, "Denied registration because router is in legacy mode"); broker.registeredWithRouterService = false; broker.enableLegacyMode(true); //We call this so we can start the process of legacy connection @@ -242,7 +241,7 @@ public class TransportBroker { break; default: broker.registeredWithRouterService = false; - Log.w(TAG, "Registration denied from router service. Reason - " + msg.arg1); + DebugTool.logWarning(TAG, "Registration denied from router service. Reason - " + msg.arg1); break; } ; @@ -255,14 +254,14 @@ public class TransportBroker { } else { //We were denied our unregister request to the router service, let's see why - Log.w(TAG, "Unregister request denied from router service. Reason - " + msg.arg1); + DebugTool.logWarning(TAG, "Unregister request denied from router service. Reason - " + msg.arg1); //Do we care? } break; case TransportConstants.ROUTER_RECEIVED_PACKET: if(bundle == null){ - DebugTool.logWarning("Received packet message from router service with no bundle"); + DebugTool.logWarning(TAG, "Received packet message from router service with no bundle"); return; } //So the intent has a packet with it. PEFRECT! Let's send it through the library @@ -283,7 +282,7 @@ public class TransportBroker { broker.onPacketReceived(packet); } else { - Log.w(TAG, "Received null packet from router service, not passing along"); + DebugTool.logWarning(TAG, "Received null packet from router service, not passing along"); } } else if (flags == TransportConstants.BYTES_TO_SEND_FLAG_SDL_PACKET_INCLUDED) { broker.bufferedPacket = (SdlPacket) packet; @@ -301,7 +300,7 @@ public class TransportBroker { byte[] chunk = bundle.getByteArray(TransportConstants.BYTES_TO_SEND_EXTRA_NAME); if (!broker.bufferedPayloadAssembler.handleMessage(flags, chunk)) { //If there was a problem - Log.e(TAG, "Error handling bytes for split packet"); + DebugTool.logError(TAG, "Error handling bytes for split packet"); } if (broker.bufferedPayloadAssembler.isFinished()) { broker.bufferedPacket.setPayload(broker.bufferedPayloadAssembler.getBytes()); @@ -315,18 +314,18 @@ public class TransportBroker { //} //} } else { - Log.w(TAG, "Flase positive packet reception"); + DebugTool.logWarning(TAG, "Flase positive packet reception"); } break; case TransportConstants.HARDWARE_CONNECTION_EVENT: if(bundle == null){ - DebugTool.logWarning("Received hardware connection message from router service with no bundle"); + DebugTool.logWarning(TAG, "Received hardware connection message from router service with no bundle"); return; } if (bundle.containsKey(TransportConstants.TRANSPORT_DISCONNECTED) || bundle.containsKey(TransportConstants.HARDWARE_DISCONNECTED)) { //We should shut down, so call - Log.d(TAG, "Hardware disconnected"); + DebugTool.logInfo(TAG, "Hardware disconnected"); if (isLegacyModeEnabled()) { broker.onLegacyModeEnabled(); } else { @@ -451,7 +450,7 @@ public class TransportBroker { * This method will end our communication with the router service. */ public void stop() { - DebugTool.logInfo("Stopping transport broker for " + whereToReply); + DebugTool.logInfo(TAG, "Stopping transport broker for " + whereToReply); synchronized (INIT_LOCK) { unregisterWithRouterService(); unBindFromRouterService(); @@ -467,7 +466,7 @@ public class TransportBroker { } catch (Exception e) { //This is ok - Log.w(TAG, "Unable to unbind from router service. bound? " + isBound + " context? " + (getContext()!=null) + " router connection?" + (routerConnection != null)); + DebugTool.logWarning(TAG, "Unable to unbind from router service. bound? " + isBound + " context? " + (getContext()!=null) + " router connection?" + (routerConnection != null)); }finally { isBound = false; } @@ -555,14 +554,14 @@ public class TransportBroker { //Log.d(TAG,whereToReply + "Sending packet to router service"); if (routerServiceMessenger == null) { - Log.d(TAG, whereToReply + " tried to send packet, but no where to send"); + DebugTool.logInfo(TAG, whereToReply + " tried to send packet, but no where to send"); return false; } if (packet == null //|| offset<0 //|| count<0 ) {//|| count>(bytes.length-offset)){ - Log.w(TAG, whereToReply + "incorrect params supplied"); + DebugTool.logWarning(TAG, whereToReply + "incorrect params supplied"); return false; } byte[] bytes = packet.constructPacket(); @@ -609,18 +608,18 @@ public class TransportBroker { */ private boolean registerWithRouterService() { if (getContext() == null) { - Log.e(TAG, "Context set to null, failing out"); + DebugTool.logError(TAG, "Context set to null, failing out"); return false; } if (routerServiceMessenger != null) { - Log.w(TAG, "Already registered with router service"); + DebugTool.logWarning(TAG, "Already registered with router service"); return false; } //Make sure we know where to bind to if (this.routerService == null) { if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.O) && !isRouterServiceRunning(getContext())) {//We should be able to ignore this case because of the validation now - Log.d(TAG, whereToReply + " found no router service. Shutting down."); + DebugTool.logInfo(TAG, whereToReply + " found no router service. Shutting down."); this.onHardwareDisconnected(null); return false; } @@ -630,7 +629,7 @@ public class TransportBroker { } if (!sendBindingIntent()) { - Log.e(TAG, "Something went wrong while trying to bind with the router service."); + DebugTool.logError(TAG, "Something went wrong while trying to bind with the router service."); SdlBroadcastReceiver.queryForConnectedService(currentContext); return false; } @@ -641,11 +640,11 @@ public class TransportBroker { @SuppressLint("InlinedApi") private boolean sendBindingIntent() { if(this.isBound){ - Log.e(TAG, "Already bound"); + DebugTool.logError(TAG, "Already bound"); return false; } if (this.routerPackage != null && this.routerClassName != null) { - Log.d(TAG, "Sending bind request to " + this.routerPackage + " - " + this.routerClassName); + DebugTool.logInfo(TAG, "Sending bind request to " + this.routerPackage + " - " + this.routerClassName); Intent bindingIntent = new Intent(); bindingIntent.setClassName(this.routerPackage, this.routerClassName);//This sets an explicit intent //Quickly make sure it's just up and running @@ -670,7 +669,7 @@ public class TransportBroker { } private void unregisterWithRouterService() { - Log.i(TAG, "Attempting to unregister with Sdl Router Service"); + DebugTool.logInfo(TAG, "Attempting to unregister with Sdl Router Service"); if (isBound && routerServiceMessenger != null) { Message msg = Message.obtain(); msg.what = TransportConstants.ROUTER_UNREGISTER_CLIENT; @@ -683,7 +682,7 @@ public class TransportBroker { msg.setData(bundle); sendMessageToRouterService(msg); } else { - Log.w(TAG, "Unable to unregister, not bound to router service"); + DebugTool.logWarning(TAG, "Unable to unregister, not bound to router service"); } routerServiceMessenger = null; diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java index 459a221f9..5039b0e0e 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/TransportManager.java @@ -44,7 +44,6 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Parcelable; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.protocol.enums.ControlFrameTags; @@ -97,11 +96,11 @@ public class TransportManager extends TransportManagerBase{ validator.validateAsync(new RouterServiceValidator.ValidationStatusCallback() { @Override public void onFinishedValidation(boolean valid, ComponentName name) { - DebugTool.logInfo("onFinishedValidation valid=" + valid + "; name=" + ((name == null)? "null" : name.getPackageName())); + DebugTool.logInfo(TAG, "onFinishedValidation valid=" + valid + "; name=" + ((name == null)? "null" : name.getPackageName())); if (valid) { mConfig.service = name; transport = new TransportBrokerImpl(contextWeakReference.get(), mConfig.appId, mConfig.service); - DebugTool.logInfo("TransportManager start was called; transport = " + transport); + DebugTool.logInfo(TAG, "TransportManager start was called; transport=" + transport); if(transport != null){ transport.start(); } @@ -246,7 +245,7 @@ public class TransportManager extends TransportManagerBase{ if(transport != null){ transport.requestNewSession(transportRecord); }else if(legacyBluetoothTransport != null){ - Log.w(TAG, "Session requested for non-bluetooth transport while in legacy mode"); + DebugTool.logWarning(TAG, "Session requested for non-bluetooth transport while in legacy mode"); } } @@ -295,7 +294,7 @@ public class TransportManager extends TransportManagerBase{ @Override public synchronized boolean onHardwareConnected(List<TransportRecord> transports) { super.onHardwareConnected(transports); - DebugTool.logInfo("OnHardwareConnected"); + DebugTool.logInfo(TAG, "OnHardwareConnected"); if(shuttingDown){ return false; } @@ -321,9 +320,9 @@ public class TransportManager extends TransportManagerBase{ @Override public synchronized void onHardwareDisconnected(TransportRecord record, List<TransportRecord> connectedTransports) { if(record != null){ - Log.d(TAG, "Transport disconnected - " + record); + DebugTool.logInfo(TAG, "Transport disconnected - " + record); }else{ - Log.d(TAG, "Transport disconnected"); + DebugTool.logInfo(TAG, "Transport disconnected"); } if(shuttingDown){ @@ -355,7 +354,7 @@ public class TransportManager extends TransportManagerBase{ if (foundMatch) { //Remove item after the loop to avoid concurrent modifications TransportManager.this.transportStatus.remove(record); - Log.d(TAG, "Handling corner case of transport disconnect mismatch"); + DebugTool.logInfo(TAG, "Handling corner case of transport disconnect mismatch"); } } } @@ -482,7 +481,7 @@ public class TransportManager extends TransportManagerBase{ }else if(action.equalsIgnoreCase(BluetoothAdapter.ACTION_STATE_CHANGED)){ int bluetoothState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1); if(bluetoothState == BluetoothAdapter.STATE_TURNING_OFF || bluetoothState == BluetoothAdapter.STATE_OFF){ - Log.d(TAG, "Bluetooth is shutting off, exiting legacy mode."); + DebugTool.logInfo(TAG, "Bluetooth is shutting off, exiting legacy mode."); exitLegacyMode("Bluetooth adapter shutting off"); } } @@ -530,7 +529,7 @@ public class TransportManager extends TransportManagerBase{ service.exitLegacyMode("Lost connection"); break; case MultiplexBaseTransport.STATE_ERROR: - Log.d(TAG, "Bluetooth serial server error received, setting state to none, and clearing local copy"); + DebugTool.logInfo(TAG, "Bluetooth serial server error received, setting state to none, and clearing local copy"); service.exitLegacyMode("Transport error"); break; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java index b724377ed..419ba6ca3 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBAccessoryAttachmentActivity.java @@ -42,7 +42,6 @@ import android.os.Build; import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.RequiresApi;
-import android.util.Log;
import com.smartdevicelink.util.AndroidTools;
import com.smartdevicelink.util.DebugTool;
@@ -118,7 +117,7 @@ public class USBAccessoryAttachmentActivity extends Activity { }
final Intent intent = getIntent();
String action = intent.getAction();
- Log.d(TAG, "Received intent with action: " + action);
+ DebugTool.logInfo(TAG, "Received intent with action: " + action);
if (UsbManager.ACTION_USB_ACCESSORY_ATTACHED.equals(action)) {
usbAccessory = intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
@@ -164,8 +163,8 @@ public class USBAccessoryAttachmentActivity extends Activity { serviceIntent = new Intent();
serviceIntent.setComponent(optimalRouterService.getRouterServiceComponentName());
} else{
- Log.d(TAG, "No SDL Router Services found");
- Log.d(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!");
+ DebugTool.logInfo(TAG, "No SDL Router Services found");
+ DebugTool.logInfo(TAG, "WARNING: This application has not specified its SdlRouterService correctly in the manifest. THIS WILL THROW AN EXCEPTION IN FUTURE RELEASES!!");
// At this point to ensure that USB connection is still possible it might be
// worth trying to use the legacy USB transport scheme
attemptLegacyUsbConnection(usbAccessory);
@@ -184,7 +183,7 @@ public class USBAccessoryAttachmentActivity extends Activity { if(startedService == null){
// A router service was not started or is not running.
- DebugTool.logError(TAG + " - Error starting router service. Attempting legacy connection ");
+ DebugTool.logError(TAG, " - Error starting router service. Attempting legacy connection ");
attemptLegacyUsbConnection(usbAccessory);
return;
}
@@ -207,7 +206,7 @@ public class USBAccessoryAttachmentActivity extends Activity { }
} catch (SecurityException e) {
- Log.e(TAG, "Security exception, process is bad");
+ DebugTool.logError(TAG, "Security exception, process is bad");
}
} else {
if (usbAccessory!=null) {
@@ -226,13 +225,13 @@ public class USBAccessoryAttachmentActivity extends Activity { private void attemptLegacyUsbConnection(UsbAccessory usbAccessory){
if(usbAccessory != null) {
- DebugTool.logInfo("Attempting to send USB connection intent using legacy method");
+ DebugTool.logInfo(TAG, "Attempting to send USB connection intent using legacy method");
Intent usbAccessoryAttachedIntent = new Intent(USBTransport.ACTION_USB_ACCESSORY_ATTACHED);
usbAccessoryAttachedIntent.putExtra(UsbManager.EXTRA_ACCESSORY, usbAccessory);
usbAccessoryAttachedIntent.putExtra(UsbManager.EXTRA_PERMISSION_GRANTED, permissionGranted);
AndroidTools.sendExplicitBroadcast(getApplicationContext(), usbAccessoryAttachedIntent, null);
}else{
- DebugTool.logError("Unable to start legacy USB mode as the accessory was null");
+ DebugTool.logError(TAG, "Unable to start legacy USB mode as the accessory was null");
}
finish();
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java index 698396ae1..0ab2f2fcf 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/USBTransport.java @@ -341,7 +341,7 @@ public class USBTransport extends SdlTransport { */
//@Override
public void stopReading() {
- DebugTool.logInfo("USBTransport: stop reading requested, doing nothing");
+ DebugTool.logInfo(TAG, "USBTransport: stop reading requested, doing nothing");
// TODO - put back stopUSBReading(); @see <a href="https://adc.luxoft.com/jira/browse/SmartDeviceLink-3450">SmartDeviceLink-3450</a>
}
@@ -632,7 +632,7 @@ public class USBTransport extends SdlTransport { * @param tr throwable to log
*/
private void logE(String s, Throwable tr) {
- DebugTool.logError(s, tr);
+ DebugTool.logError(TAG, s, tr);
}
/**
@@ -641,7 +641,7 @@ public class USBTransport extends SdlTransport { * @param s string to log
*/
private void logW(String s) {
- DebugTool.logWarning(s);
+ DebugTool.logWarning(TAG, s);
}
/**
@@ -665,7 +665,7 @@ public class USBTransport extends SdlTransport { * @param s string to log
*/
private void logI(String s) {
- DebugTool.logInfo(s);
+ DebugTool.logInfo(TAG, s);
}
/**
@@ -675,7 +675,7 @@ public class USBTransport extends SdlTransport { */
private void logD(String s) {
// DebugTool doesn't support DEBUG level, so we use INFO instead
- DebugTool.logInfo(DEBUG_PREFIX + s);
+ DebugTool.logInfo(TAG, DEBUG_PREFIX + s);
}
/**
@@ -882,15 +882,15 @@ public class USBTransport extends SdlTransport { // Log functions
private void logD(String s) {
- DebugTool.logInfo(DEBUG_PREFIX + s);
+ DebugTool.logInfo(TAG, DEBUG_PREFIX + s);
}
private void logI(String s) {
- DebugTool.logInfo(s);
+ DebugTool.logInfo(TAG, s);
}
private void logW(String s) {
- DebugTool.logWarning(s);
+ DebugTool.logWarning(TAG, s);
}
private void logW(String s, Throwable tr) {
@@ -903,7 +903,7 @@ public class USBTransport extends SdlTransport { }
private void logE(String s, Throwable tr) {
- DebugTool.logError(s, tr);
+ DebugTool.logError(TAG, s, tr);
}
}
diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/UsbTransferProvider.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/UsbTransferProvider.java index 6fb17172a..cd351a622 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/UsbTransferProvider.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/UsbTransferProvider.java @@ -48,9 +48,9 @@ import android.os.Message; import android.os.Messenger; import android.os.ParcelFileDescriptor; import android.os.RemoteException; -import android.util.Log; import com.smartdevicelink.util.AndroidTools; +import com.smartdevicelink.util.DebugTool; import java.io.IOException; import java.lang.ref.WeakReference; @@ -74,7 +74,7 @@ public class UsbTransferProvider { private ServiceConnection routerConnection= new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { - Log.d(TAG, "Bound to service " + className.toString()); + DebugTool.logInfo(TAG, "Bound to service " + className.toString()); routerServiceMessenger = new Messenger(service); isBound = true; //So we just established our connection @@ -95,7 +95,7 @@ public class UsbTransferProvider { } public void onServiceDisconnected(ComponentName className) { - Log.d(TAG, "UN-Bound from service " + className.getClassName()); + DebugTool.logInfo(TAG, "UN-Bound from service " + className.getClassName()); routerServiceMessenger = null; isBound = false; } @@ -121,7 +121,7 @@ public class UsbTransferProvider { usbInfoBundle.putString(MultiplexUsbTransport.DESCRIPTION, usbAccessory.getDescription()); checkIsConnected(); }else{ - Log.e(TAG, "Unable to open accessory"); + DebugTool.logError(TAG, "Unable to open accessory"); clientMessenger = null; if(callback != null){ callback.onUsbTransferUpdate(false); @@ -152,7 +152,7 @@ public class UsbTransferProvider { public void checkIsConnected(){ if(!AndroidTools.isServiceExported(context,routerService) || !bindToService()){ //We are unable to bind to service - Log.e(TAG, "Unable to bind to service"); + DebugTool.logError(TAG, "Unable to bind to service"); unBindFromService(); } } @@ -183,7 +183,7 @@ public class UsbTransferProvider { if(context!=null && routerConnection!=null){ context.unbindService(routerConnection); }else{ - Log.w(TAG, "Unable to unbind from router service, context was null"); + DebugTool.logWarning(TAG, "Unable to unbind from router service, context was null"); } }catch(IllegalArgumentException e){ @@ -222,7 +222,7 @@ public class UsbTransferProvider { } switch (msg.what) { case TransportConstants.ROUTER_USB_ACC_RECEIVED: - Log.d(TAG, "Successful USB transfer"); + DebugTool.logInfo(TAG, "Successful USB transfer"); provider.get().finish(); break; default: diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteAraryMessageAssembler.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteAraryMessageAssembler.java index 4f9c5096e..163b2268b 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteAraryMessageAssembler.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteAraryMessageAssembler.java @@ -31,10 +31,9 @@ */ package com.smartdevicelink.transport.utl; -import android.util.Log; - import com.smartdevicelink.transport.TransportConstants; import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.util.DebugTool; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -92,8 +91,8 @@ public class ByteAraryMessageAssembler { append(packet); this.isFinished = true; break; - default: - Log.e(TAG, "Error handling message"); + default: + DebugTool.logError(TAG, "Error handling message"); return false; } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java index 107901ccb..c7333fb08 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/ByteArrayMessageSpliter.java @@ -33,10 +33,10 @@ package com.smartdevicelink.transport.utl; import android.os.Bundle; import android.os.Message; -import android.util.Log; import com.smartdevicelink.transport.TransportBroker; import com.smartdevicelink.transport.TransportConstants; +import com.smartdevicelink.util.DebugTool; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -151,7 +151,7 @@ public class ByteArrayMessageSpliter { } bundle.putString(TransportConstants.APP_ID_EXTRA_STRING, appId); message.setData(bundle); - Log.i(TAG, ((100 - ((stream.available()*100)/orginalSize) ))+ " percent complete."); + DebugTool.logInfo(TAG, ((100 - ((stream.available()*100)/orginalSize) ))+ " percent complete."); return message; } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java index a396d186e..488a117b4 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/transport/utl/SdlDeviceListener.java @@ -85,7 +85,7 @@ public class SdlDeviceListener { */ public void start() { if(connectedDevice == null) { - DebugTool.logInfo(TAG + ": No supplied bluetooth device"); + DebugTool.logInfo(TAG, ": No supplied bluetooth device"); if(callback != null){ callback.onTransportError(null); } @@ -93,7 +93,7 @@ public class SdlDeviceListener { } if (hasSDLConnected(contextWeakReference.get(), connectedDevice.getAddress())) { - DebugTool.logInfo(TAG + ": Confirmed SDL device, should start router service"); + DebugTool.logInfo(TAG, ": Confirmed SDL device, should start router service"); //This device has connected to SDL previously, it is ok to start the RS right now callback.onTransportConnected(contextWeakReference.get(), connectedDevice); return; @@ -113,7 +113,7 @@ public class SdlDeviceListener { if (bluetoothTransport != null) { int state = bluetoothTransport.getState(); if (state != MultiplexBluetoothTransport.STATE_CONNECTED) { - DebugTool.logInfo(TAG + ": No bluetooth connection made"); + DebugTool.logInfo(TAG, ": No bluetooth connection made"); bluetoothTransport.stop(); } //else BT is connected; it will close itself through callbacks } @@ -188,7 +188,7 @@ public class SdlDeviceListener { public static void setSDLConnectedStatus(Context context, String address, boolean hasSDLConnected) { synchronized (LOCK) { if (context != null) { - DebugTool.logInfo(TAG + ": Saving connected status - " + address + " : " + hasSDLConnected); + DebugTool.logInfo(TAG, ": Saving connected status - " + address + " : " + hasSDLConnected); SharedPreferences preferences = context.getSharedPreferences(SDL_DEVICE_STATUS_SHARED_PREFS, Context.MODE_PRIVATE); if (preferences.contains(address) && hasSDLConnected == preferences.getBoolean(address, false)) { //The same key/value exists in our shared preferences. No reason to write again. diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpRequestTask.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpRequestTask.java index 3eee85a05..44125dff2 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpRequestTask.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/HttpRequestTask.java @@ -32,7 +32,6 @@ package com.smartdevicelink.util; import android.os.AsyncTask; -import android.util.Log; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -97,7 +96,7 @@ public class HttpRequestTask extends AsyncTask<String, String, String> { } if(urlString == null || request_type == null){ - Log.e(TAG, "Can't process request, param error"); + DebugTool.logError(TAG, "Can't process request, param error"); if(cb!=null){ cb.httpFailure(-1); cb = null; @@ -161,7 +160,7 @@ public class HttpRequestTask extends AsyncTask<String, String, String> { cb.httpFailure(responseCode); cb = null; } - Log.e(TAG, "Failed to download file - " + responseCode); + DebugTool.logError(TAG, "Failed to download file - " + responseCode); return null; } @@ -180,7 +179,7 @@ public class HttpRequestTask extends AsyncTask<String, String, String> { try { reader.close(); } catch (final IOException e) { - Log.e(TAG, "Error closing stream", e); + DebugTool.logError(TAG, "Error closing stream", e); } } if(cb!=null){ diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/Log.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/Log.java new file mode 100644 index 000000000..150d9b3e9 --- /dev/null +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/Log.java @@ -0,0 +1,22 @@ +package com.smartdevicelink.util; + +public class Log { + public static int i(String tag, String message) { + android.util.Log.i(tag, message); + return 10; + } + + public static int w(String tag, String message) { + android.util.Log.w(tag, message); + return 10; + } + + public static int e(String tag, String message, Throwable t) { + if (t != null) { + android.util.Log.e(tag, message, t); + } else { + android.util.Log.e(tag, message); + } + return 10; + } +}
\ No newline at end of file diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java index be55e1102..b74c7aac9 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/MediaStreamingStatus.java @@ -59,6 +59,7 @@ import java.util.List; */ public class MediaStreamingStatus { + private static final String TAG = "MediaStreamingStatus"; private static final Object BROADCAST_RECEIVER_LOCK = new Object(); private boolean broadcastReceiverValid = true; @@ -137,7 +138,7 @@ public class MediaStreamingStatus { * @return */ boolean isSupportedAudioDevice(int audioDevice){ - DebugTool.logInfo("Audio device connected: " + audioDevice); + DebugTool.logInfo(TAG, "Audio device connected: " + audioDevice); switch (audioDevice){ case AudioDeviceInfo.TYPE_BLUETOOTH_A2DP: if(isBluetoothActuallyAvailable()) { diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java index d90045371..8dc481323 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/SdlAppInfo.java @@ -37,7 +37,6 @@ import android.content.pm.PackageInfo; import android.content.pm.ResolveInfo; import android.os.Build; import android.os.Bundle; -import android.util.Log; import java.util.Comparator; @@ -77,7 +76,7 @@ public class SdlAppInfo { this.isCustomRouterService = metadata.getBoolean(SDL_CUSTOM_ROUTER_METADATA); } } else { - Log.w(TAG, packageName + " has not supplied metadata with their router service!"); + DebugTool.logWarning(TAG, packageName + " has not supplied metadata with their router service!"); } } diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java b/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java index 6f1740878..5ce18165f 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/util/ServiceFinder.java @@ -40,7 +40,6 @@ import android.content.pm.ResolveInfo; import android.os.Build; import android.os.Handler; import android.os.Looper; -import android.util.Log; import com.smartdevicelink.transport.SdlRouterService; @@ -98,11 +97,11 @@ public class ServiceFinder { @Override public void onReceive(Context context, Intent intent) { - Log.d(TAG, "Received intent " + intent); + DebugTool.logInfo(TAG, "Received intent " + intent); if (intent != null) { String packageName = intent.getStringExtra(BIND_LOCATION_PACKAGE_NAME_EXTRA); String className = intent.getStringExtra(BIND_LOCATION_CLASS_NAME_EXTRA); - Log.d(TAG, "Received intent from package: " + packageName + ". Classname: " + className); + DebugTool.logInfo(TAG, "Received intent from package: " + packageName + ". Classname: " + className); synchronized (LIST_LOCK) { //Add to running services services.add(new ComponentName(packageName, className)); diff --git a/base/src/main/java/android/util/Log.java b/base/src/main/java/android/util/Log.java index bdbc3cdc6..7374ff04c 100644 --- a/base/src/main/java/android/util/Log.java +++ b/base/src/main/java/android/util/Log.java @@ -16,8 +16,9 @@ * Note: This file has been modified from its original form. */ - package android.util; +package android.util; +@Deprecated public class Log { diff --git a/base/src/main/java/com/livio/BSON/BsonEncoder.java b/base/src/main/java/com/livio/BSON/BsonEncoder.java index c0e03f5cf..22c47f6cb 100644 --- a/base/src/main/java/com/livio/BSON/BsonEncoder.java +++ b/base/src/main/java/com/livio/BSON/BsonEncoder.java @@ -37,7 +37,7 @@ import org.bson.*; import java.util.*; public class BsonEncoder { - + private static final String TAG = "BsonEncoder"; public static byte[] encodeToBytes(HashMap<String, Object> map) throws ClassCastException { if(map != null) { @@ -47,7 +47,7 @@ public class BsonEncoder { return encoder.encode(bson); } - DebugTool.logError("Something went wrong encoding the map into BSON bytes"); + DebugTool.logError(TAG, "Something went wrong encoding the map into BSON bytes"); return null; } @@ -63,7 +63,7 @@ public class BsonEncoder { } } } - DebugTool.logError("Something went wrong decoding bytes into BSON"); + DebugTool.logError(TAG, "Something went wrong decoding bytes into BSON"); return null; } diff --git a/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java b/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java index 37013b914..16681e600 100644 --- a/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java +++ b/base/src/main/java/com/smartdevicelink/Dispatcher/ProxyMessageDispatcher.java @@ -37,6 +37,7 @@ import java.util.concurrent.LinkedBlockingQueue; @Deprecated
public class ProxyMessageDispatcher<T> {
+ private static final String TAG = "ProxyMessageDispatcher";
LinkedBlockingQueue<T> _queue = null;
private Thread _messageDispatchingThread = null;
IDispatchingStrategy<T> _strategy = null;
@@ -78,7 +79,7 @@ public class ProxyMessageDispatcher<T> { // Thread was interrupted by dispose() method, no action required
return;
} catch (Exception e) {
- DebugTool.logError("Error occurred dispating message.", e);
+ DebugTool.logError(TAG, "Error occurred dispating message.", e);
_strategy.handleDispatchingError("Error occurred dispating message.", e);
}
}
diff --git a/base/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java b/base/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java index 1afd69470..fb82bd8a2 100644 --- a/base/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java +++ b/base/src/main/java/com/smartdevicelink/SdlConnection/SdlSession.java @@ -32,7 +32,6 @@ package com.smartdevicelink.SdlConnection; -import android.util.Log; import com.smartdevicelink.exception.SdlException; import com.smartdevicelink.protocol.ISdlProtocol; @@ -48,6 +47,7 @@ import com.smartdevicelink.security.SdlSecurityBase; import com.smartdevicelink.streaming.video.VideoStreamingParameters; import com.smartdevicelink.transport.BaseTransportConfig; import com.smartdevicelink.transport.enums.TransportType; +import com.smartdevicelink.util.DebugTool; import com.smartdevicelink.util.Version; import java.util.HashMap; @@ -153,7 +153,7 @@ public class SdlSession implements ISdlProtocol, ISdlConnectionListener, ISecuri public void shutdown(String info){ - Log.d(TAG, "Shutdown - " + info); + DebugTool.logInfo(TAG, "Shutdown - " + info); this.sessionListener.onTransportDisconnected(info); } @@ -261,7 +261,7 @@ public class SdlSession implements ISdlProtocol, ISdlConnectionListener, ISecuri public void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) { - Log.i(TAG, "Protocol session started"); + DebugTool.logInfo(TAG, "Protocol session started"); this.sessionId = sessionID; if (sessionType.eq(SessionType.RPC)){ @@ -295,7 +295,7 @@ public class SdlSession implements ISdlProtocol, ISdlConnectionListener, ISecuri @Override public void onProtocolError(String info, Exception e) { this.sessionListener.onProtocolError(info, e); - Log.e(TAG, "on protocol error", e); + DebugTool.logError(TAG,"on protocol error", e); } @@ -397,7 +397,7 @@ public class SdlSession implements ISdlProtocol, ISdlConnectionListener, ISecuri *************************************************************************************************************************************************************************/ public void onProtocolMessageBytesToSend(SdlPacket packet) { - //Log.d(TAG, "onProtocolMessageBytesToSend - " + packet.getTransportType()); + //DebugTool.logInfo(TAG, "onProtocolMessageBytesToSend - " + packet.getTransportType()); sdlProtocol.sendPacket(packet); } diff --git a/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java b/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java index 234cbb22e..f362f990c 100644 --- a/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/BaseSdlManager.java @@ -32,7 +32,6 @@ package com.smartdevicelink.managers; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.file.FileManagerConfig; @@ -122,7 +121,7 @@ abstract class BaseSdlManager { final LifecycleManager.LifecycleListener lifecycleListener = new LifecycleManager.LifecycleListener() { @Override public void onConnected(LifecycleManager lifeCycleManager) { - Log.i(TAG, "Proxy is connected. Now initializing."); + DebugTool.logInfo(TAG, "Proxy is connected. Now initializing."); synchronized (this) { changeRegistrationRetry = 0; checkLifecycleConfiguration(); @@ -142,7 +141,7 @@ abstract class BaseSdlManager { @Override public void onClosed(LifecycleManager lifeCycleManager, String info, Exception e, SdlDisconnectedReason reason) { - Log.i(TAG, "Proxy is closed."); + DebugTool.logInfo(TAG, "Proxy is closed."); if (reason == null || !reason.equals(SdlDisconnectedReason.LANGUAGE_CHANGE)) { dispose(); } @@ -159,7 +158,7 @@ abstract class BaseSdlManager { @Override public synchronized void onComplete(boolean success) { if (!success) { - Log.e(TAG, "Sub manager failed to initialize"); + DebugTool.logError(TAG, "Sub manager failed to initialize"); } checkState(); } @@ -222,7 +221,7 @@ abstract class BaseSdlManager { } } try { - DebugTool.logInfo(response.serializeJSON().toString()); + DebugTool.logInfo(TAG, response.serializeJSON().toString()); } catch (JSONException e) { e.printStackTrace(); } @@ -230,7 +229,7 @@ abstract class BaseSdlManager { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Change Registration onError: " + resultCode + " | Info: " + info); + DebugTool.logError(TAG, "Change Registration onError: " + resultCode + " | Info: " + info); retryChangeRegistration(); } }); @@ -257,9 +256,9 @@ abstract class BaseSdlManager { } } - void checkSdlManagerState() { - if (getState() != BaseSubManager.READY && getState() != BaseSubManager.LIMITED) { - Log.e(TAG, "SdlManager is not ready for use, be sure to initialize with start() method, implement callback, and use SubManagers in the SdlManager's callback"); + void checkSdlManagerState(){ + if (getState() != BaseSubManager.READY && getState() != BaseSubManager.LIMITED){ + DebugTool.logError(TAG, "SdlManager is not ready for use, be sure to initialize with start() method, implement callback, and use SubManagers in the SdlManager's callback"); } } @@ -294,7 +293,7 @@ abstract class BaseSdlManager { listener.onNotified(notification); } } catch (Exception e) { - DebugTool.logError("Error going through queued notifications", e); + DebugTool.logError(TAG, "Error going through queued notifications", e); } } } @@ -433,7 +432,7 @@ abstract class BaseSdlManager { */ public PermissionManager getPermissionManager() { if (permissionManager.getState() != BaseSubManager.READY && permissionManager.getState() != BaseSubManager.LIMITED) { - Log.e(TAG, "PermissionManager should not be accessed because it is not in READY/LIMITED state"); + DebugTool.logError(TAG, "PermissionManager should not be accessed because it is not in READY/LIMITED state"); } checkSdlManagerState(); return permissionManager; @@ -447,7 +446,7 @@ abstract class BaseSdlManager { */ public FileManager getFileManager() { if (fileManager.getState() != BaseSubManager.READY && fileManager.getState() != BaseSubManager.LIMITED) { - Log.e(TAG, "FileManager should not be accessed because it is not in READY/LIMITED state"); + DebugTool.logError(TAG, "FileManager should not be accessed because it is not in READY/LIMITED state"); } checkSdlManagerState(); return fileManager; @@ -461,7 +460,7 @@ abstract class BaseSdlManager { */ public ScreenManager getScreenManager() { if (screenManager.getState() != BaseSubManager.READY && screenManager.getState() != BaseSubManager.LIMITED) { - Log.e(TAG, "ScreenManager should not be accessed because it is not in READY/LIMITED state"); + DebugTool.logError(TAG, "ScreenManager should not be accessed because it is not in READY/LIMITED state"); } checkSdlManagerState(); return screenManager; diff --git a/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java b/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java index 6dd65b40b..30a9f92bc 100644 --- a/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/file/BaseFileManager.java @@ -34,7 +34,6 @@ package com.smartdevicelink.managers.file; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -161,7 +160,7 @@ abstract class BaseFileManager extends BaseSubManager { @Override public void onError(int correlationId, Result resultCode, String info) { // file list could not be received. assume that setting can work and allow SDLManager to start - DebugTool.logError("File Manager could not list files"); + DebugTool.logError(TAG, "File Manager could not list files"); bytesAvailable = SPACE_AVAILABLE_MAX_VALUE; transitionToState(BaseSubManager.READY); } @@ -325,12 +324,12 @@ abstract class BaseFileManager extends BaseSubManager { */ public void uploadFile(@NonNull final SdlFile file, final CompletionListener listener) { if (file.isStaticIcon()) { - Log.w(TAG, String.format("%s is a static icon and doesn't need to be uploaded", file.getName())); + DebugTool.logWarning(TAG, String.format("%s is a static icon and doesn't need to be uploaded", file.getName())); listener.onComplete(true); return; } if (!file.getOverwrite() && hasUploadedFile(file)) { - Log.w(TAG, String.format("%s has already been uploaded and the overwrite property is set to false. It will not be uploaded again", file.getName())); + DebugTool.logWarning(TAG, String.format("%s has already been uploaded and the overwrite property is set to false. It will not be uploaded again", file.getName())); listener.onComplete(true); return; } @@ -398,11 +397,11 @@ abstract class BaseFileManager extends BaseSubManager { final List<PutFile> putFileRequests = new ArrayList<>(); for (SdlFile file : files) { if (file.isStaticIcon()) { - Log.w(TAG, String.format("%s is a static icon and doesn't need to be uploaded", file.getName())); + DebugTool.logWarning(TAG, String.format("%s is a static icon and doesn't need to be uploaded", file.getName())); continue; } if (!file.getOverwrite() && hasUploadedFile(file)) { - Log.w(TAG, String.format("%s has already been uploaded and the overwrite property is set to false. It will not be uploaded again", file.getName())); + DebugTool.logWarning(TAG, String.format("%s has already been uploaded and the overwrite property is set to false. It will not be uploaded again", file.getName())); continue; } putFileRequests.add(createPutFile(file)); @@ -480,7 +479,7 @@ abstract class BaseFileManager extends BaseSubManager { } return os.toByteArray(); } catch (IOException e){ - Log.e(TAG, "Can't read from InputStream", e); + DebugTool.logError(TAG, "Can't read from InputStream", e); return null; } } diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java index eca2ce239..33bb0a67a 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseEncryptionLifecycleManager.java @@ -52,6 +52,7 @@ import java.util.List; import java.util.Set; abstract class BaseEncryptionLifecycleManager { + private static final String TAG = "BaseEncryptionLifecycleManager"; private ISdl internalInterface; private ServiceEncryptionListener serviceEncryptionListener; private HMILevel currentHMILevel; @@ -104,7 +105,7 @@ abstract class BaseEncryptionLifecycleManager { if (serviceEncryptionListener != null) { serviceEncryptionListener.onEncryptionServiceUpdated(type, isEncrypted, null); } - DebugTool.logInfo("onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted); + DebugTool.logInfo(TAG, "onServiceStarted, session Type: " + type.getName() + ", isEncrypted: " + isEncrypted); } @Override @@ -115,7 +116,7 @@ abstract class BaseEncryptionLifecycleManager { if (serviceEncryptionListener != null) { serviceEncryptionListener.onEncryptionServiceUpdated(type, false, null); } - DebugTool.logInfo("onServiceEnded, session Type: " + type.getName()); + DebugTool.logInfo(TAG, "onServiceEnded, session Type: " + type.getName()); } @Override @@ -126,7 +127,7 @@ abstract class BaseEncryptionLifecycleManager { if (serviceEncryptionListener != null) { serviceEncryptionListener.onEncryptionServiceUpdated(type, false, "onServiceError: " + reason); } - DebugTool.logError("onServiceError, session Type: " + type.getName() + ", reason: " + reason); + DebugTool.logError(TAG, "onServiceError, session Type: " + type.getName() + ", reason: " + reason); } }; diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java index 2934e5736..4a0d0f096 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/BaseLifecycleManager.java @@ -34,7 +34,6 @@ package com.smartdevicelink.managers.lifecycle; import android.support.annotation.NonNull; import android.support.annotation.RestrictTo; -import android.util.Log; import com.livio.taskmaster.Taskmaster; import com.smartdevicelink.SdlConnection.ISdlConnectionListener; @@ -346,7 +345,7 @@ abstract class BaseLifecycleManager { } void onClose(String info, Exception e, SdlDisconnectedReason reason) { - Log.i(TAG, "onClose"); + DebugTool.logInfo(TAG, "onClose"); if (lifecycleListener != null) { lifecycleListener.onClosed((LifecycleManager) this, info, e, reason); } @@ -389,7 +388,7 @@ abstract class BaseLifecycleManager { switch (functionID) { case REGISTER_APP_INTERFACE: //We have begun - Log.i(TAG, "RAI Response"); + DebugTool.logInfo(TAG, "RAI Response"); raiResponse = (RegisterAppInterfaceResponse) message; SdlMsgVersion rpcVersion = ((RegisterAppInterfaceResponse) message).getSdlMsgVersion(); if (rpcVersion != null) { @@ -398,7 +397,7 @@ abstract class BaseLifecycleManager { BaseLifecycleManager.this.rpcSpecVersion = MAX_SUPPORTED_RPC_VERSION; } if (minimumRPCVersion != null && minimumRPCVersion.isNewerThan(rpcSpecVersion) == 1) { - Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion)); + DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum RPC version %s is greater than the supported RPC version %s", minimumRPCVersion, rpcSpecVersion)); UnregisterAppInterface msg = new UnregisterAppInterface(); msg.setCorrelationID(UNREGISTER_APP_INTERFACE_CORRELATION_ID); sendRPCMessagePrivate(msg, true); @@ -409,7 +408,7 @@ abstract class BaseLifecycleManager { systemCapabilityManager.parseRAIResponse(raiResponse); break; case ON_HMI_STATUS: - Log.i(TAG, "on hmi status"); + DebugTool.logInfo(TAG, "on hmi status"); boolean shouldInit = currentHMIStatus == null; currentHMIStatus = (OnHMIStatus) message; if (lifecycleListener != null && shouldInit) { @@ -449,7 +448,7 @@ abstract class BaseLifecycleManager { sendRPCMessagePrivate(systemRequest, true); } } else { - DebugTool.logError("File was null at: " + urlHttps); + DebugTool.logError(TAG, "File was null at: " + urlHttps); } } }; @@ -461,15 +460,15 @@ abstract class BaseLifecycleManager { OnAppInterfaceUnregistered onAppInterfaceUnregistered = (OnAppInterfaceUnregistered) message; if (!onAppInterfaceUnregistered.getReason().equals(AppInterfaceUnregisteredReason.LANGUAGE_CHANGE)) { - Log.v(TAG, "on app interface unregistered"); + DebugTool.logInfo(TAG, "on app interface unregistered"); clean(); } else { - Log.v(TAG, "re-registering for language change"); + DebugTool.logInfo(TAG, "re-registering for language change"); cycle(SdlDisconnectedReason.LANGUAGE_CHANGE); } break; case UNREGISTER_APP_INTERFACE: - Log.v(TAG, "unregister app interface"); + DebugTool.logInfo(TAG, "unregister app interface"); clean(); break; } @@ -614,10 +613,10 @@ abstract class BaseLifecycleManager { @SuppressWarnings("UnusedReturnValue") private boolean onRPCNotificationReceived(RPCNotification notification) { if (notification == null) { - DebugTool.logError("onRPCNotificationReceived - Notification was null"); + DebugTool.logError(TAG, "onRPCNotificationReceived - Notification was null"); return false; } - DebugTool.logInfo("onRPCNotificationReceived - " + notification.getFunctionName()); + DebugTool.logInfo(TAG, "onRPCNotificationReceived - " + notification.getFunctionName()); //Before updating any listeners, make sure to do any final updates to the notification RPC now if (FunctionID.ON_HMI_STATUS.toString().equals(notification.getFunctionName())) { @@ -677,7 +676,7 @@ abstract class BaseLifecycleManager { DebugTool.logError("onRPCRequestReceived - request was null"); return false; } - DebugTool.logInfo("onRPCRequestReceived - " + request.getFunctionName()); + DebugTool.logInfo(TAG, "onRPCRequestReceived - " + request.getFunctionName()); synchronized (ON_REQUEST_LISTENER_LOCK) { CopyOnWriteArrayList<OnRPCRequestListener> listeners = rpcRequestListeners.get(FunctionID.getFunctionId(request.getFunctionName())); @@ -807,7 +806,7 @@ abstract class BaseLifecycleManager { listener.onError(request.getCorrelationID(), Result.ABORTED, errorInfo); } } - DebugTool.logWarning(errorInfo); + DebugTool.logWarning(TAG, errorInfo); return; } @@ -815,7 +814,7 @@ abstract class BaseLifecycleManager { pm.setRPCType((byte) 0x00); Integer corrId = ((RPCRequest) message).getCorrelationID(); if (corrId == null) { - Log.e(TAG, "No correlation ID attached to request. Not sending"); + DebugTool.logError(TAG, "No correlation ID attached to request. Not sending"); return; } else { pm.setCorrID(corrId); @@ -831,7 +830,7 @@ abstract class BaseLifecycleManager { if (response.getCorrelationID() == null) { //Log error here //throw new SdlException("CorrelationID cannot be null. RPC: " + response.getFunctionName(), SdlExceptionCause.INVALID_ARGUMENT); - Log.e(TAG, "No correlation ID attached to response. Not sending"); + DebugTool.logError(TAG, "No correlation ID attached to response. Not sending"); return; } else { pm.setCorrID(response.getCorrelationID()); @@ -887,7 +886,7 @@ abstract class BaseLifecycleManager { RPCMessage rpc = RpcConverter.extractRpc(msg, session.getProtocolVersion()); if (rpc != null) { String messageType = rpc.getMessageType(); - Log.v(TAG, "RPC received - " + messageType); + DebugTool.logInfo(TAG, "RPC received - " + messageType); rpc.format(rpcSpecVersion, true); @@ -914,7 +913,7 @@ abstract class BaseLifecycleManager { } } else { - Log.w(TAG, "Shouldn't be here"); + DebugTool.logWarning(TAG, "Shouldn't be here"); } } @@ -922,13 +921,13 @@ abstract class BaseLifecycleManager { @Override public void onProtocolSessionStartedNACKed(SessionType sessionType, byte sessionID, byte version, String correlationID, List<String> rejectedParams) { - Log.w(TAG, sessionType.getName() + " onProtocolSessionStartedNACKed " + sessionID + " RejectedParams: " + rejectedParams); + DebugTool.logWarning(TAG, sessionType.getName() + " onProtocolSessionStartedNACKed " + sessionID + " RejectedParams: " + rejectedParams); BaseLifecycleManager.this.onStartServiceNACKed(sessionType); } @Override public void onProtocolSessionStarted(SessionType sessionType, byte sessionID, byte version, String correlationID, int hashID, boolean isEncrypted) { - Log.i(TAG, "on protocol session started"); + DebugTool.logInfo(TAG, "on protocol session started"); BaseLifecycleManager.this.onServiceStarted(sessionType); } @@ -944,7 +943,7 @@ abstract class BaseLifecycleManager { @Override public void onProtocolError(String info, Exception e) { - DebugTool.logError("Protocol Error - " + info, e); + DebugTool.logError(TAG, "Protocol Error - " + info, e); } @Override @@ -1007,13 +1006,13 @@ abstract class BaseLifecycleManager { @Override public IVideoStreamListener startVideoStream(boolean isEncrypted, VideoStreamingParameters parameters) { - DebugTool.logWarning("startVideoStream is not currently implemented"); + DebugTool.logWarning(TAG, "startVideoStream is not currently implemented"); return null; } @Override public void startAudioService(boolean encrypted, AudioStreamingCodec codec, AudioStreamingParams params) { - DebugTool.logWarning("startAudioService is not currently implemented"); + DebugTool.logWarning(TAG, "startAudioService is not currently implemented"); } @Override @@ -1028,7 +1027,7 @@ abstract class BaseLifecycleManager { @Override public IAudioStreamListener startAudioStream(boolean isEncrypted, AudioStreamingCodec codec, AudioStreamingParams params) { - DebugTool.logWarning("startAudioStream is not currently implemented"); + DebugTool.logWarning(TAG, "startAudioStream is not currently implemented"); return null; } @@ -1321,7 +1320,7 @@ abstract class BaseLifecycleManager { void onServiceStarted(SessionType sessionType) { if (sessionType != null) { if (minimumProtocolVersion != null && minimumProtocolVersion.isNewerThan(getProtocolVersion()) == 1) { - Log.w(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion())); + DebugTool.logWarning(TAG, String.format("Disconnecting from head unit, the configured minimum protocol version %s is greater than the supported protocol version %s", minimumProtocolVersion, getProtocolVersion())); session.endService(sessionType, session.getSessionId()); clean(); return; @@ -1354,7 +1353,7 @@ abstract class BaseLifecycleManager { sendRPCMessagePrivate(rai, true); } else { - Log.e(TAG, "App config was null, soo..."); + DebugTool.logError(TAG, "App config was null, soo..."); } } } diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/PoliciesFetcher.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/PoliciesFetcher.java index 714686a96..a217cfb07 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/PoliciesFetcher.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/PoliciesFetcher.java @@ -31,7 +31,6 @@ */ package com.smartdevicelink.managers.lifecycle; -import android.util.Log; import com.smartdevicelink.proxy.RPCRequest; import com.smartdevicelink.proxy.rpc.Headers; import com.smartdevicelink.proxy.rpc.OnSystemRequest; @@ -150,7 +149,7 @@ class PoliciesFetcher { urlConnection = getURLConnection(myHeader, sURLString, iTimeout, length); if (urlConnection == null) { - Log.i(TAG, "urlConnection is null, check RPC input parameters"); + DebugTool.logInfo(TAG, "urlConnection is null, check RPC input parameters"); return null; } @@ -172,7 +171,7 @@ class PoliciesFetcher { int iResponseCode = urlConnection.getResponseCode(); if (iResponseCode != HttpURLConnection.HTTP_OK) { - Log.i(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl."); + DebugTool.logInfo(TAG, "Response code not HTTP_OK, returning from sendOnSystemRequestToUrl."); return null; } @@ -206,16 +205,16 @@ class PoliciesFetcher { for (int i = 0; i < jsonArray.length(); i++) { if (jsonArray.get(i) instanceof String) { cloudDataReceived.add(jsonArray.getString(i)); - //Log.i("sendSystemRequestToUrl", "jsonArray.getString(i): " + jsonArray.getString(i)); + //DebugTool.logInfo(TAG, "sendSystemRequestToUrl", "jsonArray.getString(i): " + jsonArray.getString(i)); } } } else if (jsonResponse.get(dataKey) instanceof String) { cloudDataReceived.add(jsonResponse.getString(dataKey)); - //Log.i("sendSystemRequestToUrl", "jsonResponse.getString(data): " + jsonResponse.getString("data")); + //DebugTool.logInfo(TAG, "sendSystemRequestToUrl", "jsonResponse.getString(data): " + jsonResponse.getString("data")); } } else { - DebugTool.logError("sendSystemRequestToUrl: Data in JSON Object neither an array nor a string."); - //Log.i("sendSystemRequestToUrl", "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string."); + DebugTool.logError(TAG, "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string."); + //DebugTool.logInfo(TAG, "sendSystemRequestToUrl", "sendSystemRequestToUrl: Data in JSON Object neither an array nor a string."); return null; } @@ -246,17 +245,17 @@ class PoliciesFetcher { } } catch (JSONException e) { - DebugTool.logError("sendSystemRequestToUrl: JSONException: ", e); + DebugTool.logError(TAG, "sendSystemRequestToUrl: JSONException: ", e); } catch (UnsupportedEncodingException e) { - DebugTool.logError("sendSystemRequestToUrl: Could not encode string.", e); + DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not encode string.", e); } catch (ProtocolException e) { - DebugTool.logError("sendSystemRequestToUrl: Could not set request method to post.", e); + DebugTool.logError(TAG, "sendSystemRequestToUrl: Could not set request method to post.", e); } catch (MalformedURLException e) { - DebugTool.logError("sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e); + DebugTool.logError(TAG, "sendSystemRequestToUrl: URL Exception when sending SystemRequest to an external server.", e); } catch (IOException e) { - DebugTool.logError("sendSystemRequestToUrl: IOException: ", e); + DebugTool.logError(TAG, "sendSystemRequestToUrl: IOException: ", e); } catch (Exception e) { - DebugTool.logError("sendSystemRequestToUrl: Unexpected Exception: ", e); + DebugTool.logError(TAG, "sendSystemRequestToUrl: Unexpected Exception: ", e); } finally { if (urlConnection != null) { urlConnection.disconnect(); diff --git a/base/src/main/java/com/smartdevicelink/managers/lifecycle/RpcConverter.java b/base/src/main/java/com/smartdevicelink/managers/lifecycle/RpcConverter.java index c8e234504..9cc9eee25 100644 --- a/base/src/main/java/com/smartdevicelink/managers/lifecycle/RpcConverter.java +++ b/base/src/main/java/com/smartdevicelink/managers/lifecycle/RpcConverter.java @@ -31,8 +31,6 @@ */ package com.smartdevicelink.managers.lifecycle; -import android.util.Log; - import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.ProtocolMessage; import com.smartdevicelink.protocol.enums.FunctionID; @@ -68,7 +66,7 @@ public class RpcConverter { try{ return convertTableToRpc(tempTable); }catch (Exception e){ - DebugTool.logError("Error converting RPC",e); + DebugTool.logError(TAG, "Error converting RPC",e); } } return null; @@ -92,7 +90,7 @@ public class RpcConverter { if (functionName != null) { hashTemp.put(RPCMessage.KEY_FUNCTION_NAME, functionName); } else { - DebugTool.logWarning("Dispatch Incoming Message - function name is null unknown RPC. FunctionId: " + message.getFunctionID()); + DebugTool.logWarning(TAG, "Dispatch Incoming Message - function name is null unknown RPC. FunctionId: " + message.getFunctionID()); return null; } @@ -124,7 +122,7 @@ public class RpcConverter { }else if(rpcHashTable.containsKey((RPCMessage.KEY_REQUEST))){ params = (Hashtable)rpcHashTable.get((RPCMessage.KEY_REQUEST)); }else{ - DebugTool.logError(TAG + " Corrupted RPC table."); + DebugTool.logError(TAG, " Corrupted RPC table."); return null; } @@ -132,7 +130,7 @@ public class RpcConverter { if (params != null) { Set<String> keySet = params.keySet(); for (String key : keySet) { - Log.i(TAG, key + " - " + params.get(key)); + DebugTool.logInfo(TAG, key + " - " + params.get(key)); } } } @@ -151,7 +149,7 @@ public class RpcConverter { rpcClassName.append(RESPONSE_KEY); } - DebugTool.logInfo(TAG + " Attempting to create " + rpcClassName.toString()); + DebugTool.logInfo(TAG, " Attempting to create " + rpcClassName.toString()); try { Class rpcClass = Class.forName(rpcClassName.toString()); if(rpcClass != null){ @@ -160,13 +158,13 @@ public class RpcConverter { return (RPCMessage)rpcConstructor.newInstance(rpcHashTable); } } else { - DebugTool.logError(TAG + " Java class cannot be found for " + rpcClassName.toString()); + DebugTool.logError(TAG, " Java class cannot be found for " + rpcClassName.toString()); } } catch (Exception e) { - DebugTool.logError("RPCConverter was unable to process RPC", e); + DebugTool.logError(TAG, "RPCConverter was unable to process RPC", e); } }else{ - DebugTool.logError(TAG + " Unable to parse into RPC"); + DebugTool.logError(TAG, " Unable to parse into RPC"); } return null; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java index 8ab2caecd..7b6ee1c30 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseScreenManager.java @@ -33,7 +33,6 @@ package com.smartdevicelink.managers.screen; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.util.Log; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -84,23 +83,23 @@ abstract class BaseScreenManager extends BaseSubManager { if (softButtonManager != null && textAndGraphicManager != null && voiceCommandManager != null && menuManager != null && choiceSetManager != null && subscribeButtonManager != null) { if (softButtonManager.getState() == BaseSubManager.READY && textAndGraphicManager.getState() == BaseSubManager.READY && voiceCommandManager.getState() == BaseSubManager.READY && menuManager.getState() == BaseSubManager.READY && subscribeButtonManager.getState() == BaseSubManager.READY) { - DebugTool.logInfo("Starting screen manager, all sub managers are in ready state"); + DebugTool.logInfo(TAG, "Starting screen manager, all sub managers are in ready state"); transitionToState(READY); } else if (softButtonManager.getState() == BaseSubManager.ERROR && textAndGraphicManager.getState() == BaseSubManager.ERROR && voiceCommandManager.getState() == BaseSubManager.ERROR && menuManager.getState() == BaseSubManager.ERROR && choiceSetManager.getState() == BaseSubManager.ERROR && subscribeButtonManager.getState() == BaseSubManager.ERROR) { - Log.e(TAG, "ERROR starting screen manager, all sub managers are in error state"); + DebugTool.logError(TAG, "ERROR starting screen manager, all sub managers are in error state"); transitionToState(ERROR); } else if (textAndGraphicManager.getState() == BaseSubManager.SETTING_UP || softButtonManager.getState() == BaseSubManager.SETTING_UP || voiceCommandManager.getState() == BaseSubManager.SETTING_UP || menuManager.getState() == BaseSubManager.SETTING_UP || choiceSetManager.getState() == BaseSubManager.SETTING_UP || subscribeButtonManager.getState() == BaseSubManager.SETTING_UP) { - DebugTool.logInfo("SETTING UP screen manager, at least one sub manager is still setting up"); + DebugTool.logInfo(TAG, "SETTING UP screen manager, at least one sub manager is still setting up"); transitionToState(SETTING_UP); } else { - Log.w(TAG, "LIMITED starting screen manager, at least one sub manager is in error state and the others are ready"); + DebugTool.logWarning(TAG, "LIMITED starting screen manager, at least one sub manager is in error state and the others are ready"); transitionToState(LIMITED); } } else { // We should never be here, but somehow one of the sub-sub managers is null - Log.e(TAG, "ERROR one of the screen sub managers is null"); + DebugTool.logError(TAG, "ERROR one of the screen sub managers is null"); transitionToState(ERROR); } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseSoftButtonManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseSoftButtonManager.java index cd61a31f0..a1c54e7de 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseSoftButtonManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseSoftButtonManager.java @@ -68,7 +68,7 @@ import java.util.concurrent.CopyOnWriteArrayList; * Note: This class must be accessed through the SdlManager->ScreenManager. Do not instantiate it by itself.<br> */ abstract class BaseSoftButtonManager extends BaseSubManager { - + private static final String TAG = "BaseSoftButtonManager"; private final WeakReference<FileManager> fileManager; SoftButtonCapabilities softButtonCapabilities; private CopyOnWriteArrayList<SoftButtonObject> softButtonObjects; @@ -154,7 +154,7 @@ abstract class BaseSoftButtonManager extends BaseSubManager { @Override public void onError(String info) { - DebugTool.logError("Display Capability cannot be retrieved"); + DebugTool.logError(TAG, "Display Capability cannot be retrieved"); softButtonCapabilities = null; // Update the queue's suspend state @@ -245,10 +245,10 @@ abstract class BaseSoftButtonManager extends BaseSubManager { // OR if the HMI level is NONE since we want to delay sending RPCs until we're in non-NONE private void updateTransactionQueueSuspended() { if (softButtonCapabilities == null || HMILevel.HMI_NONE.equals(currentHMILevel)) { - DebugTool.logInfo(String.format("Suspending the transaction queue. Current HMI level is NONE: %b, soft button capabilities are null: %b", HMILevel.HMI_NONE.equals(currentHMILevel), softButtonCapabilities == null)); + DebugTool.logInfo(TAG, String.format("Suspending the transaction queue. Current HMI level is NONE: %b, soft button capabilities are null: %b", HMILevel.HMI_NONE.equals(currentHMILevel), softButtonCapabilities == null)); transactionQueue.pause(); } else { - DebugTool.logInfo("Starting the transaction queue"); + DebugTool.logInfo(TAG, "Starting the transaction queue"); transactionQueue.resume(); } } @@ -276,19 +276,19 @@ abstract class BaseSoftButtonManager extends BaseSubManager { // Only update if something changed. This prevents, for example, an empty array being reset if (softButtonObjects.equals(this.softButtonObjects)) { - DebugTool.logInfo("New soft button objects are equivalent to existing soft button objects, skipping..."); + DebugTool.logInfo(TAG, "New soft button objects are equivalent to existing soft button objects, skipping..."); return; } // Check if two soft button objects have the same name if (hasTwoSoftButtonObjectsOfSameName(softButtonObjects)) { this.softButtonObjects = new CopyOnWriteArrayList<>(); - DebugTool.logError("Attempted to set soft button objects, but two buttons had the same name"); + DebugTool.logError(TAG, "Attempted to set soft button objects, but two buttons had the same name"); return; } if (!checkAndAssignButtonIds(softButtonObjects)) { - DebugTool.logError("Attempted to set soft button objects, but multiple buttons had the same id"); + DebugTool.logError(TAG, "Attempted to set soft button objects, but multiple buttons had the same id"); return; } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseSubscribeButtonManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseSubscribeButtonManager.java index 70996db4c..7d9bf26e1 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseSubscribeButtonManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseSubscribeButtonManager.java @@ -1,7 +1,6 @@ package com.smartdevicelink.managers.screen; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -17,6 +16,7 @@ import com.smartdevicelink.proxy.rpc.enums.ButtonName; import com.smartdevicelink.proxy.rpc.enums.Result; import com.smartdevicelink.proxy.rpc.listeners.OnRPCNotificationListener; import com.smartdevicelink.proxy.rpc.listeners.OnRPCResponseListener; +import com.smartdevicelink.util.DebugTool; import java.util.HashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -64,7 +64,7 @@ abstract class BaseSubscribeButtonManager extends BaseSubManager { */ void addButtonListener(ButtonName buttonName, OnButtonListener listener) { if (listener == null) { - Log.e(TAG, "OnButtonListener cannot be null"); + DebugTool.logError(TAG, "OnButtonListener cannot be null"); return; } if (buttonName == null) { @@ -78,7 +78,7 @@ abstract class BaseSubscribeButtonManager extends BaseSubManager { } if (onButtonListeners.get(buttonName).contains(listener)) { - Log.w(TAG, "Already subscribed to button named: " + buttonName); + DebugTool.logWarning(TAG, "Already subscribed to button named: " + buttonName); return; } onButtonListeners.get(buttonName).add(listener); @@ -92,7 +92,7 @@ abstract class BaseSubscribeButtonManager extends BaseSubManager { */ void removeButtonListener(final ButtonName buttonName, final OnButtonListener listener) { if (listener == null) { - Log.e(TAG, "OnButtonListener cannot be null: "); + DebugTool.logError(TAG, "OnButtonListener cannot be null: "); return; } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java index 491111b2b..096bb4d62 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/BaseTextAndGraphicManager.java @@ -32,7 +32,6 @@ package com.smartdevicelink.managers.screen; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.managers.BaseSubManager; import com.smartdevicelink.managers.CompletionListener; @@ -168,7 +167,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { currentHMILevel = onHMIStatus.getHmiLevel(); if (currentHMILevel == HMILevel.HMI_FULL){ if (pendingHMIFull){ - DebugTool.logInfo( "Acquired HMI_FULL with pending update. Sending now"); + DebugTool.logInfo(TAG, "Acquired HMI_FULL with pending update. Sending now"); pendingHMIFull = false; sdlUpdate(pendingHMIListener); pendingHMIListener = null; @@ -185,7 +184,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { // instead of using the parameter it's more safe to use the convenience method List<DisplayCapability> capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); if (capabilities == null || capabilities.size() == 0) { - DebugTool.logError("TextAndGraphic Manager - Capabilities sent here are null or empty"); + DebugTool.logError(TAG, "TextAndGraphic Manager - Capabilities sent here are null or empty"); }else { DisplayCapability display = capabilities.get(0); for (WindowCapability windowCapability : display.getWindowCapabilities()) { @@ -199,7 +198,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { @Override public void onError(String info) { - DebugTool.logError("Display Capability cannot be retrieved"); + DebugTool.logError(TAG, "Display Capability cannot be retrieved"); defaultMainWindowCapability = null; } }; @@ -284,7 +283,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { @Override public void onComplete(boolean success) { if (!success){ - Log.e(TAG, "Error uploading image"); + DebugTool.logError(TAG, "Error uploading image"); inProgressUpdate = extractTextFromShow(inProgressUpdate); sendShow(); } @@ -358,7 +357,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { } if (artworksToUpload.size() == 0 && (primaryGraphic.isStaticIcon() || secondaryGraphic.isStaticIcon())){ - DebugTool.logInfo("Upload attempted on static icons, sending them without upload instead"); + DebugTool.logInfo(TAG, "Upload attempted on static icons, sending them without upload instead"); listener.onComplete(true); } @@ -368,7 +367,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { @Override public void onComplete(Map<String, String> errors) { if (errors != null) { - Log.e(TAG, "Error Uploading Artworks. Error: " + errors.toString()); + DebugTool.logError(TAG, "Error Uploading Artworks. Error: " + errors.toString()); listener.onComplete(false); } else { listener.onComplete(true); @@ -648,7 +647,7 @@ abstract class BaseTextAndGraphicManager extends BaseSubManager { private void updateCurrentScreenDataState(Show show){ if (show == null){ - Log.e(TAG, "can not updateCurrentScreenDataFromShow from null show"); + DebugTool.logError(TAG, "can not updateCurrentScreenDataFromShow from null show"); return; } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonObject.java b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonObject.java index 8a040b967..76c2622a6 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonObject.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonObject.java @@ -50,7 +50,7 @@ import java.util.List; * @see SoftButtonState */ public class SoftButtonObject { - + private static final String TAG = "SoftButtonObject"; static int SOFT_BUTTON_ID_NOT_SET_VALUE = -1; static int SOFT_BUTTON_ID_MIN_VALUE = 0; static int SOFT_BUTTON_ID_MAX_VALUE = 65535; @@ -73,7 +73,7 @@ public class SoftButtonObject { // Make sure there aren't two states with the same name if (hasTwoStatesOfSameName(states)) { - DebugTool.logError("Two states have the same name in states list for soft button object"); + DebugTool.logError(TAG, "Two states have the same name in states list for soft button object"); return; } @@ -112,23 +112,23 @@ public class SoftButtonObject { public boolean transitionToStateByName(@NonNull String newStateName) { SoftButtonState newState = getStateByName(newStateName); if (newState == null) { - DebugTool.logError(String.format("Attempted to transition to state: %s on soft button object: %s but no state with that name was found", newStateName, this.name)); + DebugTool.logError(TAG, String.format("Attempted to transition to state: %s on soft button object: %s but no state with that name was found", newStateName, this.name)); return false; } if (states.size() == 1) { - DebugTool.logWarning("There's only one state, so no transitioning is possible!"); + DebugTool.logWarning(TAG, "There's only one state, so no transitioning is possible!"); return false; } - DebugTool.logInfo(String.format("Transitioning soft button object %s to state %s", this.name, newStateName)); + DebugTool.logInfo(TAG, String.format("Transitioning soft button object %s to state %s", this.name, newStateName)); currentStateName = newStateName; // Send a new Show RPC because the state has changed which means the actual SoftButton has changed if (updateListener != null) { updateListener.onUpdate(); } else { - DebugTool.logError(String.format("SoftButtonManager is not set for soft button object: %s. Update cannot be triggered", this.name)); + DebugTool.logError(TAG, String.format("SoftButtonManager is not set for soft button object: %s. Update cannot be triggered", this.name)); } return true; @@ -147,7 +147,7 @@ public class SoftButtonObject { } } if (nextStateName == null) { - DebugTool.logError(String.format("Current state name : %s cannot be found for soft button object %s", currentStateName, this.name)); + DebugTool.logError(TAG, String.format("Current state name : %s cannot be found for soft button object %s", currentStateName, this.name)); return; } transitionToStateByName(nextStateName); @@ -160,7 +160,7 @@ public class SoftButtonObject { public SoftButtonState getCurrentState() { SoftButtonState state = getStateByName(currentStateName); if (state == null) { - DebugTool.logError(String.format("Current state name : %s cannot be found for soft button object %s", currentStateName, this.name)); + DebugTool.logError(TAG, String.format("Current state name : %s cannot be found for soft button object %s", currentStateName, this.name)); } return state; } @@ -285,7 +285,7 @@ public class SoftButtonObject { */ public void setButtonId(int buttonId) { if (buttonId < SOFT_BUTTON_ID_MIN_VALUE){ - DebugTool.logError("buttonId has to be equal or more than " + SOFT_BUTTON_ID_MIN_VALUE); + DebugTool.logError(TAG, "buttonId has to be equal or more than " + SOFT_BUTTON_ID_MIN_VALUE); return; } this.buttonId = buttonId; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonReplaceOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonReplaceOperation.java index 0aecbc616..106806562 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonReplaceOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonReplaceOperation.java @@ -25,7 +25,7 @@ import java.util.concurrent.CopyOnWriteArrayList; * Created by Bilal Alsharifi on 6/15/20. */ class SoftButtonReplaceOperation extends Task { - + private static final String TAG = "SoftButtonReplaceOperation"; private final WeakReference<ISdl> internalInterface; private final WeakReference<FileManager> fileManager; private final SoftButtonCapabilities softButtonCapabilities; @@ -54,14 +54,14 @@ class SoftButtonReplaceOperation extends Task { // Check the state of our images if (!supportsSoftButtonImages()) { // We don't support images at all - DebugTool.logWarning("Soft button images are not supported. Attempting to send text-only soft buttons. If any button does not contain text, no buttons will be sent."); + DebugTool.logWarning(TAG, "Soft button images are not supported. Attempting to send text-only soft buttons. If any button does not contain text, no buttons will be sent."); // Send text buttons if all the soft buttons have text sendCurrentStateTextOnlySoftButtons(new CompletionListener() { @Override public void onComplete(boolean success) { if (!success) { - DebugTool.logError("Head unit does not support images and some of the soft buttons do not have text, so none of the buttons will be sent."); + DebugTool.logError(TAG, "Head unit does not support images and some of the soft buttons do not have text, so none of the buttons will be sent."); } onFinished(); } @@ -83,7 +83,7 @@ class SoftButtonReplaceOperation extends Task { uploadOtherStateImages(new CompletionListener() { @Override public void onComplete(boolean success) { - DebugTool.logInfo("Finished sending other images for soft buttons"); + DebugTool.logInfo(TAG, "Finished sending other images for soft buttons"); onFinished(); } }); @@ -96,13 +96,13 @@ class SoftButtonReplaceOperation extends Task { sendCurrentStateSoftButtons(new CompletionListener() { @Override public void onComplete(boolean success) { - DebugTool.logInfo("Finished sending soft buttons with images"); + DebugTool.logInfo(TAG, "Finished sending soft buttons with images"); // Upload other images uploadOtherStateImages(new CompletionListener() { @Override public void onComplete(boolean success) { if (success) { - DebugTool.logInfo("Finished sending other images for soft buttons"); + DebugTool.logInfo(TAG, "Finished sending other images for soft buttons"); } onFinished(); } @@ -123,22 +123,22 @@ class SoftButtonReplaceOperation extends Task { } if (initialStatesToBeUploaded.isEmpty()) { - DebugTool.logInfo("No initial state artworks to upload"); + DebugTool.logInfo(TAG, "No initial state artworks to upload"); if (completionListener != null) { completionListener.onComplete(false); } return; } - DebugTool.logInfo("Uploading soft button initial artworks"); + DebugTool.logInfo(TAG, "Uploading soft button initial artworks"); if (fileManager.get() != null) { fileManager.get().uploadArtworks(initialStatesToBeUploaded, new MultipleFileCompletionListener() { @Override public void onComplete(Map<String, String> errors) { if (errors != null) { - DebugTool.logError("Error uploading soft button artworks: " + errors.keySet()); + DebugTool.logError(TAG, "Error uploading soft button artworks: " + errors.keySet()); } else { - DebugTool.logInfo("Soft button initial state artworks uploaded"); + DebugTool.logInfo(TAG, "Soft button initial state artworks uploaded"); } if (getState() == Task.CANCELED) { @@ -171,22 +171,22 @@ class SoftButtonReplaceOperation extends Task { } if (otherStatesToBeUploaded.isEmpty()) { - DebugTool.logInfo("No other state artworks to upload"); + DebugTool.logInfo(TAG, "No other state artworks to upload"); if (completionListener != null) { completionListener.onComplete(false); } return; } - DebugTool.logInfo("Uploading soft button other state artworks"); + DebugTool.logInfo(TAG, "Uploading soft button other state artworks"); if (fileManager.get() != null) { fileManager.get().uploadArtworks(otherStatesToBeUploaded, new MultipleFileCompletionListener() { @Override public void onComplete(Map<String, String> errors) { if (errors != null) { - DebugTool.logError("Error uploading soft button artworks: " + errors.keySet()); + DebugTool.logError(TAG, "Error uploading soft button artworks: " + errors.keySet()); } else { - DebugTool.logInfo("Soft button other state artworks uploaded"); + DebugTool.logInfo(TAG, "Soft button other state artworks uploaded"); } if (getState() == Task.CANCELED) { @@ -210,7 +210,7 @@ class SoftButtonReplaceOperation extends Task { onFinished(); } - DebugTool.logInfo("Preparing to send full soft buttons"); + DebugTool.logInfo(TAG, "Preparing to send full soft buttons"); List<SoftButton> softButtons = new ArrayList<>(); for (SoftButtonObject softButtonObject : softButtonObjects) { softButtons.add(softButtonObject.getCurrentStateSoftButton()); @@ -221,9 +221,9 @@ class SoftButtonReplaceOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()) { - DebugTool.logInfo("Finished sending text only soft buttons"); + DebugTool.logInfo(TAG, "Finished sending text only soft buttons"); } else { - DebugTool.logWarning("Failed to update soft buttons with text buttons"); + DebugTool.logWarning(TAG, "Failed to update soft buttons with text buttons"); } if (completionListener != null) { completionListener.onComplete(response.getSuccess()); @@ -232,7 +232,7 @@ class SoftButtonReplaceOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logWarning("Failed to update soft buttons with text buttons"); + DebugTool.logWarning(TAG, "Failed to update soft buttons with text buttons"); if (completionListener != null) { completionListener.onComplete(false); } @@ -252,12 +252,12 @@ class SoftButtonReplaceOperation extends Task { onFinished(); } - DebugTool.logInfo("Preparing to send text-only soft buttons"); + DebugTool.logInfo(TAG, "Preparing to send text-only soft buttons"); List<SoftButton> textButtons = new ArrayList<>(); for (SoftButtonObject softButtonObject : softButtonObjects) { SoftButton softButton = softButtonObject.getCurrentStateSoftButton(); if (softButton.getText() == null) { - DebugTool.logWarning("Attempted to create text buttons, but some buttons don't support text, so no text-only soft buttons will be sent"); + DebugTool.logWarning(TAG, "Attempted to create text buttons, but some buttons don't support text, so no text-only soft buttons will be sent"); if (completionListener != null) { completionListener.onComplete(false); } @@ -277,9 +277,9 @@ class SoftButtonReplaceOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()) { - DebugTool.logInfo("Finished sending text only soft buttons"); + DebugTool.logInfo(TAG, "Finished sending text only soft buttons"); } else { - DebugTool.logWarning("Failed to update soft buttons with text buttons"); + DebugTool.logWarning(TAG, "Failed to update soft buttons with text buttons"); } if (completionListener != null) { completionListener.onComplete(response.getSuccess()); @@ -288,7 +288,7 @@ class SoftButtonReplaceOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logWarning("Failed to update soft buttons with text buttons"); + DebugTool.logWarning(TAG, "Failed to update soft buttons with text buttons"); if (completionListener != null) { completionListener.onComplete(false); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonState.java b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonState.java index 33ead8136..a2272c461 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonState.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonState.java @@ -47,7 +47,7 @@ import com.smartdevicelink.util.DebugTool; * @see SoftButtonObject */ public class SoftButtonState { - + private static final String TAG = "SoftButtonState"; private String name; private SdlArtwork artwork; private final SoftButton softButton; @@ -61,7 +61,7 @@ public class SoftButtonState { */ public SoftButtonState(@NonNull String name, String text, SdlArtwork artwork) { if (text == null && artwork == null) { - DebugTool.logError("Attempted to create an invalid soft button state: text and artwork are both null"); + DebugTool.logError(TAG, "Attempted to create an invalid soft button state: text and artwork are both null"); softButton = null; return; } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonTransitionOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonTransitionOperation.java index cd414bc73..355c6aeaf 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonTransitionOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/SoftButtonTransitionOperation.java @@ -18,7 +18,7 @@ import java.util.concurrent.CopyOnWriteArrayList; * Created by Bilal Alsharifi on 6/15/20. */ class SoftButtonTransitionOperation extends Task { - + private static final String TAG = "SoftButtonTransitionOperation"; private final WeakReference<ISdl> internalInterface; private final CopyOnWriteArrayList<SoftButtonObject> softButtonObjects; private String currentMainField1; @@ -49,7 +49,7 @@ class SoftButtonTransitionOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { if (!response.getSuccess()) { - DebugTool.logWarning("Failed to transition soft button to new state"); + DebugTool.logWarning(TAG, "Failed to transition soft button to new state"); } onFinished(); } @@ -57,7 +57,7 @@ class SoftButtonTransitionOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info) { super.onError(correlationId, resultCode, info); - DebugTool.logWarning("Failed to transition soft button to new state. " + info); + DebugTool.logWarning(TAG, "Failed to transition soft button to new state. " + info); onFinished(); } }); diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java index a06334fc2..1a5023133 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/BaseChoiceSetManager.java @@ -73,7 +73,7 @@ import java.util.List; * Note: This class must be accessed through the SdlManager. Do not instantiate it by itself. <br> */ abstract class BaseChoiceSetManager extends BaseSubManager { - + private static final String TAG = "BaseChoiceSetManager"; // additional state private static final int CHECKING_VOICE = 0xA0; private KeyboardProperties keyboardConfiguration; @@ -161,14 +161,14 @@ abstract class BaseChoiceSetManager extends BaseSubManager { public void onCheckChoiceVROperationComplete(boolean vrOptional) { isVROptional = vrOptional; transitionToState(READY); - DebugTool.logInfo("VR is optional: "+ isVROptional); + DebugTool.logInfo(TAG, "VR is optional: "+ isVROptional); } @Override public void onError(String error) { // At this point, there were errors trying to send a test PICS // If we reach this state, we cannot use the manager - DebugTool.logError(error); + DebugTool.logError(TAG, error); transitionToState(ERROR); // checking VR will always be first in the queue. // If pre-load operations were added while this was in progress @@ -217,7 +217,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { listener.onComplete(true); } }else { - DebugTool.logError("There was an error pre loading choice cells"); + DebugTool.logError(TAG, "There was an error pre loading choice cells"); if (listener != null) { listener.onComplete(false); } @@ -227,7 +227,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { transactionQueue.add(preloadChoicesOperation, false); } else { - DebugTool.logError("File Manager was null in preload choice operation"); + DebugTool.logError(TAG, "File Manager was null in preload choice operation"); } } @@ -238,7 +238,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { public void deleteChoices(@NonNull List<ChoiceCell> choices){ if (getState() == ERROR) { - DebugTool.logWarning("Choice Manager In Error State"); + DebugTool.logWarning(TAG, "Choice Manager In Error State"); return; } @@ -253,7 +253,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { if (pendingPresentOperation != null && pendingPresentOperation.getState() != Task.CANCELED && pendingPresentOperation.getState() != Task.FINISHED && (cellsToBeDeleted.retainAll(pendingPresentationChoices) || cellsToBeRemovedFromPending.retainAll(pendingPresentationChoices))){ pendingPresentOperation.cancelTask(); - DebugTool.logWarning("Attempting to delete choice cells while there is a pending presentation operation. Pending presentation cancelled."); + DebugTool.logWarning(TAG, "Attempting to delete choice cells while there is a pending presentation operation. Pending presentation cancelled."); pendingPresentOperation = null; } @@ -266,7 +266,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { // Find Choices to delete if (cellsToBeDeleted.size() == 0){ - DebugTool.logInfo("Cells to be deleted size == 0"); + DebugTool.logInfo(TAG, "Cells to be deleted size == 0"); return; } findIdsOnChoices(cellsToBeDeleted); @@ -275,7 +275,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { @Override public void onComplete(boolean success) { if (!success){ - DebugTool.logError("Failed to delete choices"); + DebugTool.logError(TAG, "Failed to delete choices"); return; } preloadedChoices.removeAll(cellsToBeDeleted); @@ -293,7 +293,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { public void presentChoiceSet(@NonNull final ChoiceSet choiceSet, @Nullable final InteractionMode mode, @Nullable final KeyboardListener keyboardListener){ if (getState() == ERROR) { - DebugTool.logWarning("Choice Manager In Error State"); + DebugTool.logWarning(TAG, "Choice Manager In Error State"); return; } @@ -302,7 +302,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { if (this.pendingPresentationSet != null && pendingPresentOperation != null){ pendingPresentOperation.cancelTask(); - DebugTool.logWarning("Presenting a choice set while one is currently presented. Cancelling previous and continuing"); + DebugTool.logWarning(TAG, "Presenting a choice set while one is currently presented. Cancelling previous and continuing"); } this.pendingPresentationSet = choiceSet; @@ -347,11 +347,11 @@ abstract class BaseChoiceSetManager extends BaseSubManager { if (keyboardListener == null){ // Non-searchable choice set - DebugTool.logInfo("Creating non-searchable choice set"); + DebugTool.logInfo(TAG, "Creating non-searchable choice set"); presentOp = new PresentChoiceSetOperation(internalInterface, pendingPresentationSet, mode, null, null, privateChoiceListener, nextCancelId++); } else { // Searchable choice set - DebugTool.logInfo("Creating searchable choice set"); + DebugTool.logInfo(TAG, "Creating searchable choice set"); presentOp = new PresentChoiceSetOperation(internalInterface, pendingPresentationSet, mode, keyboardConfiguration, keyboardListener, privateChoiceListener, nextCancelId++); } @@ -368,19 +368,19 @@ abstract class BaseChoiceSetManager extends BaseSubManager { */ public Integer presentKeyboard(@NonNull String initialText, @Nullable KeyboardProperties customKeyboardConfig, @NonNull KeyboardListener listener){ if (initialText == null || initialText.length() == 0){ - DebugTool.logError("initialText cannot be an empty string."); + DebugTool.logError(TAG, "initialText cannot be an empty string."); return null; } if (getState() == ERROR) { - DebugTool.logWarning("Choice Manager In Error State"); + DebugTool.logWarning(TAG, "Choice Manager In Error State"); return null; } if (pendingPresentationSet != null && pendingPresentOperation != null){ pendingPresentOperation.cancelTask(); pendingPresentationSet = null; - DebugTool.logWarning("There is a current or pending choice set, cancelling and continuing."); + DebugTool.logWarning(TAG, "There is a current or pending choice set, cancelling and continuing."); } if (customKeyboardConfig == null){ @@ -392,7 +392,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { } // Present a keyboard with the choice set that we used to test VR's optional state - DebugTool.logInfo("Presenting Keyboard - Choice Set Manager"); + DebugTool.logInfo(TAG, "Presenting Keyboard - Choice Set Manager"); Integer keyboardCancelID = nextCancelId++; PresentKeyboardOperation keyboardOp = new PresentKeyboardOperation(internalInterface, keyboardConfiguration, initialText, customKeyboardConfig, listener, keyboardCancelID); currentlyPresentedKeyboardOperation = keyboardOp; @@ -410,7 +410,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { */ public void dismissKeyboard(@NonNull Integer cancelID) { if (getState() == ERROR) { - DebugTool.logWarning("Choice Manager In Error State"); + DebugTool.logWarning(TAG, "Choice Manager In Error State"); return; } @@ -518,7 +518,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { // instead of using the parameter it's more safe to use the convenience method List<DisplayCapability> capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); if (capabilities == null || capabilities.size() == 0) { - DebugTool.logError("SoftButton Manager - Capabilities sent here are null or empty"); + DebugTool.logError(TAG, "SoftButton Manager - Capabilities sent here are null or empty"); }else { DisplayCapability display = capabilities.get(0); displayName = display.getDisplayName(); @@ -533,7 +533,7 @@ abstract class BaseChoiceSetManager extends BaseSubManager { @Override public void onError(String info) { - DebugTool.logError("Unable to retrieve display capabilities. Many things will probably break. Info: "+ info); + DebugTool.logError(TAG, "Unable to retrieve display capabilities. Many things will probably break. Info: "+ info); defaultMainWindowCapability = null; } }; @@ -581,13 +581,13 @@ abstract class BaseChoiceSetManager extends BaseSubManager { // Choices are not optional here if (choices == null || choices.size() == 0) { - DebugTool.logError("Cannot initiate a choice set with no choices"); + DebugTool.logError(TAG, "Cannot initiate a choice set with no choices"); return false; } if (choiceSet.getTimeout() != null) { if (choiceSet.getTimeout() < 5 || choiceSet.getTimeout() > 100) { - DebugTool.logWarning("Attempted to create a choice set with a " + choiceSet.getTimeout() + " second timeout; Only 5 - 100 seconds is valid. When using the choice set manager, setTimeout() uses seconds."); + DebugTool.logWarning(TAG, "Attempted to create a choice set with a " + choiceSet.getTimeout() + " second timeout; Only 5 - 100 seconds is valid. When using the choice set manager, setTimeout() uses seconds."); return false; } } @@ -610,19 +610,19 @@ abstract class BaseChoiceSetManager extends BaseSubManager { // Cell text MUST be unique if (choiceTextSet.size() < choices.size()) { - DebugTool.logError("Attempted to create a choice set with duplicate cell text. Cell text must be unique. The choice set will not be set."); + DebugTool.logError(TAG, "Attempted to create a choice set with duplicate cell text. Cell text must be unique. The choice set will not be set."); return false; } // All or none of the choices MUST have VR Commands if (choiceCellWithVoiceCommandCount > 0 && choiceCellWithVoiceCommandCount < choices.size()) { - DebugTool.logError("If using voice recognition commands, all of the choice set cells must have unique VR commands. There are " + uniqueVoiceCommands.size() + " cells with unique voice commands and " + choices.size() + " total cells. The choice set will not be set."); + DebugTool.logError(TAG, "If using voice recognition commands, all of the choice set cells must have unique VR commands. There are " + uniqueVoiceCommands.size() + " cells with unique voice commands and " + choices.size() + " total cells. The choice set will not be set."); return false; } // All VR Commands MUST be unique if (uniqueVoiceCommands.size() < allVoiceCommandsCount) { - DebugTool.logError("If using voice recognition commands, all VR commands must be unique. There are " + uniqueVoiceCommands.size() + " unique VR commands and " + allVoiceCommandsCount + " VR commands. The choice set will not be set."); + DebugTool.logError(TAG, "If using voice recognition commands, all VR commands must be unique. There are " + uniqueVoiceCommands.size() + " unique VR commands and " + allVoiceCommandsCount + " VR commands. The choice set will not be set."); return false; } return true; diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperation.java index 9eaba87cd..6e606b62d 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/CheckChoiceVROptionalOperation.java @@ -49,7 +49,7 @@ import java.lang.ref.WeakReference; import java.util.Collections; class CheckChoiceVROptionalOperation extends Task { - + private static final String TAG = "CheckChoiceVROptionalOperation"; private CheckChoiceVROptionalInterface checkChoiceVROptionalInterface; private WeakReference<ISdl> internalInterface; private boolean isVROptional; @@ -62,7 +62,7 @@ class CheckChoiceVROptionalOperation extends Task { @Override public void onExecute() { - DebugTool.logInfo("Choice Operation: Executing check vr optional operation"); + DebugTool.logInfo(TAG, "Choice Operation: Executing check vr optional operation"); sendTestChoiceNoVR(); } @@ -77,19 +77,19 @@ class CheckChoiceVROptionalOperation extends Task { public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()) { // The request was successful, now send the SDLPerformInteraction RPC - DebugTool.logInfo("Connected head unit supports choice cells without voice commands. " + + DebugTool.logInfo(TAG, "Connected head unit supports choice cells without voice commands. " + "Cells without voice will be sent without voice from now on (no placeholder voice)."); isVROptional = true; deleteTestChoiceSet(); }else{ - DebugTool.logWarning("Head unit doesn't support choices with no VR."); + DebugTool.logWarning(TAG, "Head unit doesn't support choices with no VR."); sendTestChoiceWithVR(); } } @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logWarning("Head unit doesn't support choices with no VR. Error: " + info + " resultCode: " + resultCode); + DebugTool.logWarning(TAG, "Head unit doesn't support choices with no VR. Error: " + info + " resultCode: " + resultCode); sendTestChoiceWithVR(); } }); @@ -109,12 +109,12 @@ class CheckChoiceVROptionalOperation extends Task { public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()) { // The request was successful, now send the SDLPerformInteraction RPC - DebugTool.logWarning("Connected head unit does not support choice cells without voice commands. " + + DebugTool.logWarning(TAG, "Connected head unit does not support choice cells without voice commands. " + "Cells without voice will be sent with placeholder voices from now on."); isVROptional = false; deleteTestChoiceSet(); }else{ - DebugTool.logError("Connected head unit has rejected all choice cells, choice manager disabled. Error: " + response.getInfo()); + DebugTool.logError(TAG, "Connected head unit has rejected all choice cells, choice manager disabled. Error: " + response.getInfo()); isVROptional = false; if (checkChoiceVROptionalInterface != null){ checkChoiceVROptionalInterface.onError(response.getInfo()); @@ -126,7 +126,7 @@ class CheckChoiceVROptionalOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("There was an error in the check choice vr optional operation. Send test choice with VR failed. Error: " + info + " resultCode: " + resultCode); + DebugTool.logError(TAG, "There was an error in the check choice vr optional operation. Send test choice with VR failed. Error: " + info + " resultCode: " + resultCode); isVROptional = false; if (checkChoiceVROptionalInterface != null){ checkChoiceVROptionalInterface.onError(info); @@ -147,7 +147,7 @@ class CheckChoiceVROptionalOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess() != null){ - DebugTool.logInfo("Delete choice test set: "+ response.getSuccess()); + DebugTool.logInfo(TAG, "Delete choice test set: "+ response.getSuccess()); } if (checkChoiceVROptionalInterface != null){ @@ -159,7 +159,7 @@ class CheckChoiceVROptionalOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("There was an error presenting the keyboard. Finishing operation - choice set manager - . Error: " + info + " resultCode: " + resultCode); + DebugTool.logError(TAG, "There was an error presenting the keyboard. Finishing operation - choice set manager - . Error: " + info + " resultCode: " + resultCode); if (checkChoiceVROptionalInterface != null){ checkChoiceVROptionalInterface.onError(info); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java index 34bdbd6a4..7009c89b1 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/ChoiceSet.java @@ -46,6 +46,7 @@ import java.util.Hashtable; import java.util.List; public class ChoiceSet { + private static final String TAG = "ChoiceSet"; private String title; private List<TTSChunk> initialPrompt, timeoutPrompt, helpPrompt; private ChoiceSetLayout layout; @@ -361,17 +362,17 @@ public class ChoiceSet { if (DebugTool.isDebugEnabled()) { if (getTitle() != null) { if (getTitle().length() == 0 || getTitle().length() > 500) { - DebugTool.logWarning("Attempted to create a choice set with a title of " + getTitle().length() + " length. Only 500 characters are supported."); + DebugTool.logWarning(TAG, "Attempted to create a choice set with a title of " + getTitle().length() + " length. Only 500 characters are supported."); } } if (getTimeout() != null) { if (getTimeout() < 5 || getTimeout() > 100) { - DebugTool.logWarning("Attempted to create a choice set with a " + getTimeout() + " second timeout; Only 5 - 100 seconds is valid"); + DebugTool.logWarning(TAG, "Attempted to create a choice set with a " + getTimeout() + " second timeout; Only 5 - 100 seconds is valid"); } } if (getChoices() != null) { if (getChoices().size() == 0 || getChoices().size() > 100) { - DebugTool.logWarning("Attempted to create a choice set with "+getChoices().size()+" choices; Only 1 - 100 choices are valid"); + DebugTool.logWarning(TAG, "Attempted to create a choice set with "+getChoices().size()+" choices; Only 1 - 100 choices are valid"); } } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperation.java index c12178da5..de328b8eb 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/DeleteChoicesOperation.java @@ -50,7 +50,7 @@ import java.util.HashSet; import java.util.List; class DeleteChoicesOperation extends Task { - + private static final String TAG = "DeleteChoicesOperation"; private WeakReference<ISdl> internalInterface; private HashSet<ChoiceCell> cellsToDelete; private CompletionListener completionListener; @@ -64,7 +64,7 @@ class DeleteChoicesOperation extends Task { @Override public void onExecute() { - DebugTool.logInfo("Choice Operation: Executing delete choices operation"); + DebugTool.logInfo(TAG, "Choice Operation: Executing delete choices operation"); sendDeletions(); } @@ -85,7 +85,7 @@ class DeleteChoicesOperation extends Task { if (completionListener != null) { completionListener.onComplete(true); } - DebugTool.logInfo("Successfully deleted choices"); + DebugTool.logInfo(TAG, "Successfully deleted choices"); DeleteChoicesOperation.super.onFinished(); } @@ -95,7 +95,7 @@ class DeleteChoicesOperation extends Task { if (completionListener != null) { completionListener.onComplete(false); } - DebugTool.logError("Failed to delete choice: " + info + " | Corr ID: " + correlationId); + DebugTool.logError(TAG, "Failed to delete choice: " + info + " | Corr ID: " + correlationId); DeleteChoicesOperation.super.onFinished(); } @@ -109,7 +109,7 @@ class DeleteChoicesOperation extends Task { if (completionListener != null) { completionListener.onComplete(true); } - DebugTool.logInfo("No Choices to delete, continue"); + DebugTool.logInfo(TAG, "No Choices to delete, continue"); } } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperation.java index d94b88ecb..6d8423027 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PreloadChoicesOperation.java @@ -64,7 +64,7 @@ import java.util.List; import java.util.Map; class PreloadChoicesOperation extends Task { - + private static final String TAG = "PreloadChoicesOperation"; private WeakReference<ISdl> internalInterface; private WeakReference<FileManager> fileManager; private WindowCapability defaultMainWindowCapability; @@ -88,7 +88,7 @@ class PreloadChoicesOperation extends Task { @Override public void onExecute() { - DebugTool.logInfo("Choice Operation: Executing preload choices operation"); + DebugTool.logInfo(TAG, "Choice Operation: Executing preload choices operation"); preloadCellArtworks(new CompletionListener() { @Override public void onComplete(boolean success) { @@ -108,7 +108,7 @@ class PreloadChoicesOperation extends Task { List<SdlArtwork> artworksToUpload = artworksToUpload(); if (artworksToUpload.size() == 0){ - DebugTool.logInfo("Choice Preload: No Choice Artworks to upload"); + DebugTool.logInfo(TAG, "Choice Preload: No Choice Artworks to upload"); listener.onComplete(true); isRunning = false; return; @@ -119,18 +119,18 @@ class PreloadChoicesOperation extends Task { @Override public void onComplete(Map<String, String> errors) { if (errors != null && errors.size() > 0){ - DebugTool.logError("Error uploading choice cell Artworks: "+ errors.toString()); + DebugTool.logError(TAG, "Error uploading choice cell Artworks: "+ errors.toString()); listener.onComplete(false); isRunning = false; }else{ - DebugTool.logInfo("Choice Artworks Uploaded"); + DebugTool.logInfo(TAG, "Choice Artworks Uploaded"); listener.onComplete(true); isRunning = false; } } }); }else{ - DebugTool.logError("File manager is null in choice preload operation"); + DebugTool.logError(TAG, "File manager is null in choice preload operation"); listener.onComplete(false); isRunning = false; } @@ -147,7 +147,7 @@ class PreloadChoicesOperation extends Task { } if (choiceRPCs.size() == 0){ - DebugTool.logError(" All Choice cells to send are null, so the choice set will not be shown"); + DebugTool.logError(TAG, " All Choice cells to send are null, so the choice set will not be shown"); completionListener.onComplete(true); isRunning = false; return; @@ -163,7 +163,7 @@ class PreloadChoicesOperation extends Task { @Override public void onFinished() { isRunning = false; - DebugTool.logInfo("Finished pre loading choice cells"); + DebugTool.logInfo(TAG, "Finished pre loading choice cells"); completionListener.onComplete(true); PreloadChoicesOperation.super.onFinished(); @@ -171,7 +171,7 @@ class PreloadChoicesOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("There was an error uploading a choice cell: "+ info + " resultCode: " + resultCode); + DebugTool.logError(TAG, "There was an error uploading a choice cell: "+ info + " resultCode: " + resultCode); PreloadChoicesOperation.super.onFinished(); } @@ -182,7 +182,7 @@ class PreloadChoicesOperation extends Task { } }); }else{ - DebugTool.logError("Internal Interface null in preload choice operation"); + DebugTool.logError(TAG, "Internal Interface null in preload choice operation"); isRunning = false; completionListener.onComplete(false); } @@ -200,7 +200,7 @@ class PreloadChoicesOperation extends Task { String menuName = shouldSendChoiceText() ? cell.getText() : null; if (menuName == null){ - DebugTool.logError("Could not convert Choice Cell to CreateInteractionChoiceSet. It will not be shown. Cell: "+ cell.toString()); + DebugTool.logError(TAG, "Could not convert Choice Cell to CreateInteractionChoiceSet. It will not be shown. Cell: "+ cell.toString()); return null; } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java index a94f33ec0..7038a48ab 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentChoiceSetOperation.java @@ -62,7 +62,7 @@ import java.util.ArrayList; import java.util.List; class PresentChoiceSetOperation extends Task { - + private static final String TAG = "PresentChoiceSetOperation"; private WeakReference<ISdl> internalInterface; private ChoiceSet choiceSet; private Integer cancelID; @@ -100,7 +100,7 @@ class PresentChoiceSetOperation extends Task { @Override public void onExecute() { - DebugTool.logInfo("Choice Operation: Executing present choice set operation"); + DebugTool.logInfo(TAG, "Choice Operation: Executing present choice set operation"); addListeners(); start(); } @@ -148,7 +148,7 @@ class PresentChoiceSetOperation extends Task { if (listener != null){ listener.onComplete(false); } - DebugTool.logError("Error Setting keyboard properties in present choice set operation"); + DebugTool.logError(TAG, "Error Setting keyboard properties in present choice set operation"); return; } @@ -157,7 +157,7 @@ class PresentChoiceSetOperation extends Task { if (listener != null){ listener.onComplete(true); } - DebugTool.logInfo("Success Setting keyboard properties in present choice set operation"); + DebugTool.logInfo(TAG, "Success Setting keyboard properties in present choice set operation"); } @Override @@ -165,13 +165,13 @@ class PresentChoiceSetOperation extends Task { if (listener != null){ listener.onComplete(false); } - DebugTool.logError("Error Setting keyboard properties in present keyboard operation - choice manager - " + info); + DebugTool.logError(TAG, "Error Setting keyboard properties in present keyboard operation - choice manager - " + info); } }); if (internalInterface.get() != null){ internalInterface.get().sendRPC(setGlobalProperties); } else { - DebugTool.logError("Internal interface null - present choice set op - choice"); + DebugTool.logError(TAG, "Internal interface null - present choice set op - choice"); } } @@ -181,7 +181,7 @@ class PresentChoiceSetOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { if (!response.getSuccess()){ - DebugTool.logError("Presenting Choice set failed: "+ response.getInfo()); + DebugTool.logError(TAG, "Presenting Choice set failed: "+ response.getInfo()); if (choiceSetSelectionListener != null){ choiceSetSelectionListener.onError(response.getInfo()); @@ -202,7 +202,7 @@ class PresentChoiceSetOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Presenting Choice set failed: " + resultCode + ", " + info); + DebugTool.logError(TAG, "Presenting Choice set failed: " + resultCode + ", " + info); if (choiceSetSelectionListener != null){ choiceSetSelectionListener.onError(resultCode + ", " + info); @@ -213,7 +213,7 @@ class PresentChoiceSetOperation extends Task { if (internalInterface.get() != null){ internalInterface.get().sendRPC(pi); }else { - DebugTool.logError("Internal Interface null when presenting choice set in operation"); + DebugTool.logError(TAG, "Internal Interface null when presenting choice set in operation"); } } @@ -226,13 +226,13 @@ class PresentChoiceSetOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { updatedKeyboardProperties = false; - DebugTool.logInfo("Successfully reset choice keyboard properties to original config"); + DebugTool.logInfo(TAG, "Successfully reset choice keyboard properties to original config"); PresentChoiceSetOperation.super.onFinished(); } @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Failed to reset choice keyboard properties to original config " + resultCode + ", " + info); + DebugTool.logError(TAG, "Failed to reset choice keyboard properties to original config " + resultCode + ", " + info); PresentChoiceSetOperation.super.onFinished(); } }); @@ -241,7 +241,7 @@ class PresentChoiceSetOperation extends Task { internalInterface.get().sendRPC(setGlobalProperties); internalInterface.get().removeOnRPCNotificationListener(FunctionID.ON_KEYBOARD_INPUT, keyboardRPCListener); } else { - DebugTool.logError("Internal Interface null when finishing choice keyboard reset"); + DebugTool.logError(TAG, "Internal Interface null when finishing choice keyboard reset"); } } else { PresentChoiceSetOperation.super.onFinished(); @@ -253,39 +253,39 @@ class PresentChoiceSetOperation extends Task { */ private void cancelInteraction() { if ((getState() == Task.FINISHED)) { - DebugTool.logInfo("This operation has already finished so it can not be canceled."); + DebugTool.logInfo(TAG, "This operation has already finished so it can not be canceled."); return; } else if (getState() == Task.CANCELED) { - DebugTool.logInfo("This operation has already been canceled. It will be finished at some point during the operation."); + DebugTool.logInfo(TAG, "This operation has already been canceled. It will be finished at some point during the operation."); return; } else if ((getState() == Task.IN_PROGRESS)) { if (sdlMsgVersion.getMajorVersion() < 6){ - DebugTool.logWarning("Canceling a presented choice set is not supported on this head unit"); + DebugTool.logWarning(TAG, "Canceling a presented choice set is not supported on this head unit"); return; } - DebugTool.logInfo("Canceling the presented choice set interaction."); + DebugTool.logInfo(TAG, "Canceling the presented choice set interaction."); CancelInteraction cancelInteraction = new CancelInteraction(FunctionID.PERFORM_INTERACTION.getId(), cancelID); cancelInteraction.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse response) { - DebugTool.logInfo("Canceled the presented choice set " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully")); + DebugTool.logInfo(TAG, "Canceled the presented choice set " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully")); } @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("Error canceling the presented choice set " + resultCode + " " + info); + DebugTool.logError(TAG, "Error canceling the presented choice set " + resultCode + " " + info); } }); if (internalInterface.get() != null){ internalInterface.get().sendRPC(cancelInteraction); } else { - DebugTool.logError("Internal interface null - could not send cancel interaction for choice set"); + DebugTool.logError(TAG, "Internal interface null - could not send cancel interaction for choice set"); } } else { - DebugTool.logInfo("Canceling a choice set that has not yet been sent to Core"); + DebugTool.logInfo(TAG, "Canceling a choice set that has not yet been sent to Core"); this.cancelTask(); } } @@ -351,7 +351,7 @@ class PresentChoiceSetOperation extends Task { } if (keyboardListener == null){ - DebugTool.logError("Received Keyboard Input But Listener is null"); + DebugTool.logError(TAG, "Received Keyboard Input But Listener is null"); return; } @@ -395,7 +395,7 @@ class PresentChoiceSetOperation extends Task { if (internalInterface.get() != null) { internalInterface.get().addOnRPCNotificationListener(FunctionID.ON_KEYBOARD_INPUT, keyboardRPCListener); } else { - DebugTool.logError("Present Choice Set Keyboard Listener Not Added"); + DebugTool.logError(TAG, "Present Choice Set Keyboard Listener Not Added"); } } }
\ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java index 45420b881..446826616 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/choiceset/PresentKeyboardOperation.java @@ -61,7 +61,7 @@ import java.util.Collections; import java.util.List; class PresentKeyboardOperation extends Task { - + private static final String TAG = "PresentKeyboardOperation"; private WeakReference<ISdl> internalInterface; private KeyboardListener keyboardListener; private KeyboardProperties originalKeyboardProperties, keyboardProperties, customConfig; @@ -85,13 +85,13 @@ class PresentKeyboardOperation extends Task { @Override public void onExecute() { - DebugTool.logInfo("Keyboard Operation: Executing present keyboard operation"); + DebugTool.logInfo(TAG, "Keyboard Operation: Executing present keyboard operation"); addListeners(); start(); } private void start(){ - DebugTool.logInfo("Choice Operation: Executing present keyboard operation"); + DebugTool.logInfo(TAG, "Choice Operation: Executing present keyboard operation"); if (getState() == Task.CANCELED) { finishOperation(); @@ -129,7 +129,7 @@ class PresentKeyboardOperation extends Task { @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("There was an error presenting the keyboard. Finishing operation - choice set manager - . Error: " + info + " resultCode: " + resultCode); + DebugTool.logError(TAG, "There was an error presenting the keyboard. Finishing operation - choice set manager - . Error: " + info + " resultCode: " + resultCode); finishOperation(); } }); @@ -137,7 +137,7 @@ class PresentKeyboardOperation extends Task { internalInterface.get().sendRPC(pi); }else{ - DebugTool.logError("Internal Interface null in present keyboard operation - choice"); + DebugTool.logError(TAG, "Internal Interface null in present keyboard operation - choice"); } } @@ -148,38 +148,38 @@ class PresentKeyboardOperation extends Task { */ void dismissKeyboard() { if ((getState() == Task.FINISHED)) { - DebugTool.logInfo("This operation has already finished so it can not be canceled."); + DebugTool.logInfo(TAG, "This operation has already finished so it can not be canceled."); return; } else if (getState() == Task.CANCELED) { - DebugTool.logInfo("This operation has already been canceled. It will be finished at some point during the operation."); + DebugTool.logInfo(TAG, "This operation has already been canceled. It will be finished at some point during the operation."); return; } else if (getState() == Task.IN_PROGRESS) { if (sdlMsgVersion.getMajorVersion() < 6){ - DebugTool.logWarning("Canceling a keyboard is not supported on this head unit"); + DebugTool.logWarning(TAG, "Canceling a keyboard is not supported on this head unit"); return; } - DebugTool.logInfo("Canceling the presented keyboard."); + DebugTool.logInfo(TAG, "Canceling the presented keyboard."); CancelInteraction cancelInteraction = new CancelInteraction(FunctionID.PERFORM_INTERACTION.getId(), cancelID); cancelInteraction.setOnRPCResponseListener(new OnRPCResponseListener() { @Override public void onResponse(int correlationId, RPCResponse response) { - DebugTool.logInfo("Canceled the presented keyboard " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully")); + DebugTool.logInfo(TAG, "Canceled the presented keyboard " + ((response.getResultCode() == Result.SUCCESS) ? "successfully" : "unsuccessfully")); } @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("Error canceling the presented keyboard " + resultCode + " " + info); + DebugTool.logError(TAG, "Error canceling the presented keyboard " + resultCode + " " + info); } }); if (internalInterface.get() != null){ internalInterface.get().sendRPC(cancelInteraction); } else { - DebugTool.logError("Internal interface null - could not send cancel interaction for keyboard."); + DebugTool.logError(TAG, "Internal interface null - could not send cancel interaction for keyboard."); } } else { - DebugTool.logInfo("Canceling a keyboard that has not yet been sent to Core."); + DebugTool.logInfo(TAG, "Canceling a keyboard that has not yet been sent to Core."); this.cancelTask(); } } @@ -202,7 +202,7 @@ class PresentKeyboardOperation extends Task { if (listener != null){ listener.onComplete(false); } - DebugTool.logError("Error Setting keyboard properties in present keyboard operation - choice manager"); + DebugTool.logError(TAG, "Error Setting keyboard properties in present keyboard operation - choice manager"); return; } @@ -211,7 +211,7 @@ class PresentKeyboardOperation extends Task { if (listener != null){ listener.onComplete(true); } - DebugTool.logInfo("Success Setting keyboard properties in present keyboard operation - choice manager"); + DebugTool.logInfo(TAG, "Success Setting keyboard properties in present keyboard operation - choice manager"); } @Override @@ -219,7 +219,7 @@ class PresentKeyboardOperation extends Task { if (listener != null){ listener.onComplete(false); } - DebugTool.logError("Error Setting keyboard properties in present keyboard operation - choice manager - " + info); + DebugTool.logError(TAG, "Error Setting keyboard properties in present keyboard operation - choice manager - " + info); super.onError(correlationId, resultCode, info); } }); @@ -227,7 +227,7 @@ class PresentKeyboardOperation extends Task { if (internalInterface.get() != null){ internalInterface.get().sendRPC(setGlobalProperties); } else { - DebugTool.logError("Internal interface null - present keyboard op - choice"); + DebugTool.logError(TAG, "Internal interface null - present keyboard op - choice"); } } @@ -240,13 +240,13 @@ class PresentKeyboardOperation extends Task { @Override public void onResponse(int correlationId, RPCResponse response) { updatedKeyboardProperties = false; - DebugTool.logInfo("Successfully reset choice keyboard properties to original config"); + DebugTool.logInfo(TAG, "Successfully reset choice keyboard properties to original config"); PresentKeyboardOperation.super.onFinished(); } @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Failed to reset choice keyboard properties to original config " + resultCode + ", " + info); + DebugTool.logError(TAG, "Failed to reset choice keyboard properties to original config " + resultCode + ", " + info); PresentKeyboardOperation.super.onFinished(); } }); @@ -255,7 +255,7 @@ class PresentKeyboardOperation extends Task { internalInterface.get().sendRPC(setGlobalProperties); internalInterface.get().removeOnRPCNotificationListener(FunctionID.ON_KEYBOARD_INPUT, keyboardRPCListener); } else { - DebugTool.logError("Internal Interface null when finishing choice keyboard reset"); + DebugTool.logError(TAG, "Internal Interface null when finishing choice keyboard reset"); } } else { PresentKeyboardOperation.super.onFinished(); @@ -291,7 +291,7 @@ class PresentKeyboardOperation extends Task { } if (keyboardListener == null){ - DebugTool.logError("Received Keyboard Input But Listener is null"); + DebugTool.logError(TAG, "Received Keyboard Input But Listener is null"); return; } @@ -336,7 +336,7 @@ class PresentKeyboardOperation extends Task { if (internalInterface.get() != null) { internalInterface.get().addOnRPCNotificationListener(FunctionID.ON_KEYBOARD_INPUT, keyboardRPCListener); } else { - DebugTool.logError("Present Keyboard Listener Not Added - choice manager"); + DebugTool.logError(TAG, "Present Keyboard Listener Not Added - choice manager"); } } }
\ No newline at end of file diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java index 928a1277b..7d7649e9c 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseMenuManager.java @@ -80,7 +80,7 @@ import java.util.List; import java.util.Map; abstract class BaseMenuManager extends BaseSubManager { - + private static final String TAG = "BaseMenuManager"; private static final int KEEP = 0; private static final int MARKED_FOR_ADDITION = 1; private static final int MARKED_FOR_DELETION = 2; @@ -208,13 +208,13 @@ abstract class BaseMenuManager extends BaseSubManager { } // Check for duplicate titles if (titleCheckSet.size() != menuCells.size()){ - DebugTool.logError("Not all cell titles are unique. The menu will not be set"); + DebugTool.logError(TAG, "Not all cell titles are unique. The menu will not be set"); return; } // Check for duplicate voice commands if (allMenuVoiceCommands.size() != voiceCommandCount){ - DebugTool.logError("Attempted to create a menu with duplicate voice commands. Voice commands must be unique. The menu will not be set"); + DebugTool.logError(TAG, "Attempted to create a menu with duplicate voice commands. Voice commands must be unique. The menu will not be set"); return; } @@ -226,9 +226,9 @@ abstract class BaseMenuManager extends BaseSubManager { public void onComplete(Map<String, String> errors) { if (errors != null && errors.size() > 0){ - DebugTool.logError("Error uploading Menu Artworks: "+ errors.toString()); + DebugTool.logError(TAG, "Error uploading Menu Artworks: "+ errors.toString()); }else{ - DebugTool.logInfo("Menu Artworks Uploaded"); + DebugTool.logInfo(TAG, "Menu Artworks Uploaded"); } // proceed updateMenuAndDetermineBestUpdateMethod(); @@ -271,7 +271,7 @@ abstract class BaseMenuManager extends BaseSubManager { public boolean openMenu(){ if (sdlMsgVersion.getMajorVersion() < 6){ - DebugTool.logWarning("Menu opening is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); + DebugTool.logWarning(TAG, "Menu opening is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); return false; } @@ -280,15 +280,15 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()){ - DebugTool.logInfo("Open Main Menu Request Successful"); + DebugTool.logInfo(TAG, "Open Main Menu Request Successful"); } else { - DebugTool.logError("Open Main Menu Request Failed"); + DebugTool.logError(TAG, "Open Main Menu Request Failed"); } } @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("Open Main Menu onError: "+ resultCode+ " | Info: "+ info); + DebugTool.logError(TAG, "Open Main Menu onError: "+ resultCode+ " | Info: "+ info); } }); internalInterface.sendRPC(showAppMenu); @@ -302,12 +302,12 @@ abstract class BaseMenuManager extends BaseSubManager { public boolean openSubMenu(@NonNull MenuCell cell){ if (sdlMsgVersion.getMajorVersion() < 6){ - DebugTool.logWarning("Sub menu opening is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); + DebugTool.logWarning(TAG, "Sub menu opening is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); return false; } if (oldMenuCells == null){ - DebugTool.logError("open sub menu called, but no Menu cells have been set"); + DebugTool.logError(TAG, "open sub menu called, but no Menu cells have been set"); return false; } // We must see if we have a copy of this cell, since we clone the objects @@ -329,15 +329,15 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()){ - DebugTool.logInfo("Open Sub Menu Request Successful"); + DebugTool.logInfo(TAG, "Open Sub Menu Request Successful"); } else { - DebugTool.logError("Open Sub Menu Request Failed"); + DebugTool.logError(TAG, "Open Sub Menu Request Failed"); } } @Override public void onError(int correlationId, Result resultCode, String info){ - DebugTool.logError("Open Sub Menu onError: "+ resultCode+ " | Info: "+ info); + DebugTool.logError(TAG, "Open Sub Menu onError: "+ resultCode+ " | Info: "+ info); } }); @@ -354,18 +354,18 @@ abstract class BaseMenuManager extends BaseSubManager { public void setMenuConfiguration(@NonNull final MenuConfiguration menuConfiguration) { if (sdlMsgVersion == null) { - DebugTool.logError("SDL Message Version is null. Cannot set Menu Configuration"); + DebugTool.logError(TAG, "SDL Message Version is null. Cannot set Menu Configuration"); return; } if (sdlMsgVersion.getMajorVersion() < 6){ - DebugTool.logWarning("Menu configurations is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); + DebugTool.logWarning(TAG, "Menu configurations is only supported on head units with RPC spec version 6.0.0 or later. Currently connected head unit RPC spec version is: "+sdlMsgVersion.getMajorVersion() + "." + sdlMsgVersion.getMinorVersion()+ "." +sdlMsgVersion.getPatchVersion()); return; } if (currentHMILevel == null || currentHMILevel.equals(HMILevel.HMI_NONE) || currentSystemContext.equals(SystemContext.SYSCTXT_MENU)){ // We are in NONE or the menu is in use, bail out of here - DebugTool.logError("Could not set main menu configuration, HMI level: "+currentHMILevel+", required: 'Not-NONE', system context: "+currentSystemContext+", required: 'Not MENU'"); + DebugTool.logError(TAG, "Could not set main menu configuration, HMI level: "+currentHMILevel+", required: 'Not-NONE', system context: "+currentSystemContext+", required: 'Not MENU'"); return; } @@ -380,18 +380,18 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onResponse(int correlationId, RPCResponse response) { if (response.getSuccess()) { - DebugTool.logInfo("Menu Configuration successfully set: " + menuConfiguration.toString()); + DebugTool.logInfo(TAG, "Menu Configuration successfully set: " + menuConfiguration.toString()); } } @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("onError: " + resultCode + " | Info: " + info); + DebugTool.logError(TAG, "onError: " + resultCode + " | Info: " + info); } }); internalInterface.sendRPC(setGlobalProperties); } else { - DebugTool.logInfo("Menu Layout is null, not sending setGlobalProperties"); + DebugTool.logInfo(TAG, "Menu Layout is null, not sending setGlobalProperties"); } } @@ -406,7 +406,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (currentHMILevel == null || currentHMILevel.equals(HMILevel.HMI_NONE) || currentSystemContext.equals(SystemContext.SYSCTXT_MENU)){ // We are in NONE or the menu is in use, bail out of here - DebugTool.logInfo("HMI in None or System Context Menu, returning"); + DebugTool.logInfo(TAG, "HMI in None or System Context Menu, returning"); waitingOnHMIUpdate = true; waitingUpdateMenuCells = menuCells; return; @@ -414,7 +414,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (inProgressUpdate != null && inProgressUpdate.size() > 0){ // there's an in-progress update so this needs to wait - DebugTool.logInfo("There is an in progress Menu Update, returning"); + DebugTool.logInfo(TAG, "There is an in progress Menu Update, returning"); hasQueuedUpdate = true; return; } @@ -428,14 +428,14 @@ abstract class BaseMenuManager extends BaseSubManager { if (rootScore == null) { // send initial menu (score will return null) // make a copy of our current cells - DebugTool.logInfo("Creating initial Menu"); + DebugTool.logInfo(TAG, "Creating initial Menu"); // Set the IDs if needed lastMenuId = menuCellIdMin; updateIdsOnMenuCells(menuCells, parentIdNotFound); this.oldMenuCells = new ArrayList<>(menuCells); createAndSendEntireMenu(); } else { - DebugTool.logInfo("Dynamically Updating Menu"); + DebugTool.logInfo(TAG, "Dynamically Updating Menu"); if (menuCells.size() == 0 && (oldMenuCells != null && oldMenuCells.size() > 0)) { // the dev wants to clear the menu. We have old cells and an empty array of new ones. deleteMenuWhenNewCellsEmpty(); @@ -446,7 +446,7 @@ abstract class BaseMenuManager extends BaseSubManager { } } else { // we are in compatibility mode - DebugTool.logInfo("Updating menus in compatibility mode"); + DebugTool.logInfo(TAG, "Updating menus in compatibility mode"); lastMenuId = menuCellIdMin; updateIdsOnMenuCells(menuCells, parentIdNotFound); // if the old cell array is not null, we want to delete the entire thing, else copy the new array @@ -481,9 +481,9 @@ abstract class BaseMenuManager extends BaseSubManager { inProgressUpdate = null; if (!success){ - DebugTool.logError("Error Sending Current Menu"); + DebugTool.logError(TAG, "Error Sending Current Menu"); }else{ - DebugTool.logInfo("Successfully Cleared Menu"); + DebugTool.logInfo(TAG, "Successfully Cleared Menu"); } oldMenuCells = null; if (hasQueuedUpdate){ @@ -533,10 +533,10 @@ abstract class BaseMenuManager extends BaseSubManager { transferIdsToKeptCells(keepsNew); if (adds.size() > 0){ - DebugTool.logInfo("Sending root menu updates"); + DebugTool.logInfo(TAG, "Sending root menu updates"); sendDynamicRootMenuRPCs(deleteCommands, adds); }else{ - DebugTool.logInfo("All root menu items are kept. Check the sub menus"); + DebugTool.logInfo(TAG, "All root menu items are kept. Check the sub menus"); runSubMenuCompareAlgorithm(); } } @@ -553,7 +553,7 @@ abstract class BaseMenuManager extends BaseSubManager { inProgressUpdate = null; if (!success){ - DebugTool.logError("Error Sending Current Menu"); + DebugTool.logError(TAG, "Error Sending Current Menu"); } if (hasQueuedUpdate){ @@ -588,7 +588,7 @@ abstract class BaseMenuManager extends BaseSubManager { RunScore subScore = compareOldAndNewLists(oldKeptCell.getSubCells(), keptCell.getSubCells()); if (subScore != null){ - DebugTool.logInfo("Sub menu Run Score: "+ oldKeptCell.getTitle()+ " Score: "+ subScore.getScore()); + DebugTool.logInfo(TAG, "Sub menu Run Score: "+ oldKeptCell.getTitle()+ " Score: "+ subScore.getScore()); SubCellCommandList commandList = new SubCellCommandList(oldKeptCell.getTitle(), oldKeptCell.getCellId(), subScore, oldKeptCell.getSubCells(), keptCell.getSubCells()); commandLists.add(commandList); } @@ -606,17 +606,17 @@ abstract class BaseMenuManager extends BaseSubManager { } if (hasQueuedUpdate) { - DebugTool.logInfo("Menu Manager has waiting updates, sending now"); + DebugTool.logInfo(TAG, "Menu Manager has waiting updates, sending now"); setMenuCells(waitingUpdateMenuCells); hasQueuedUpdate = false; } - DebugTool.logInfo("All menu updates, including sub menus - done."); + DebugTool.logInfo(TAG, "All menu updates, including sub menus - done."); return; } final SubCellCommandList commandList = commandLists.remove(0); - DebugTool.logInfo("Creating and Sending Dynamic Sub Commands For Root Menu Cell: "+ commandList.getMenuTitle()); + DebugTool.logInfo(TAG, "Creating and Sending Dynamic Sub Commands For Root Menu Cell: "+ commandList.getMenuTitle()); // grab the scores RunScore score = commandList.getListsScore(); @@ -667,13 +667,13 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onComplete(boolean success) { // recurse through next sub list - DebugTool.logInfo("Finished Sending Dynamic Sub Commands For Root Menu Cell: "+ commandList.getMenuTitle()); + DebugTool.logInfo(TAG, "Finished Sending Dynamic Sub Commands For Root Menu Cell: "+ commandList.getMenuTitle()); createSubMenuDynamicCommands(commandLists); } }); } else{ // no add commands to send, recurse through next sub list - DebugTool.logInfo("Finished Sending Dynamic Sub Commands For Root Menu Cell: "+ commandList.getMenuTitle()); + DebugTool.logInfo(TAG, "Finished Sending Dynamic Sub Commands For Root Menu Cell: "+ commandList.getMenuTitle()); createSubMenuDynamicCommands(commandLists); } } @@ -691,7 +691,7 @@ abstract class BaseMenuManager extends BaseSubManager { } RunScore bestScore = compareOldAndNewLists(oldCells, newCells); - DebugTool.logInfo("Best menu run score: "+ bestScore.getScore()); + DebugTool.logInfo(TAG, "Best menu run score: "+ bestScore.getScore()); return bestScore; } @@ -1015,7 +1015,7 @@ abstract class BaseMenuManager extends BaseSubManager { // instead of using the parameter it's more safe to use the convenience method List<DisplayCapability> capabilities = SystemCapabilityManager.convertToList(capability, DisplayCapability.class); if (capabilities == null || capabilities.size() == 0) { - DebugTool.logError("SoftButton Manager - Capabilities sent here are null or empty"); + DebugTool.logError(TAG, "SoftButton Manager - Capabilities sent here are null or empty"); }else { DisplayCapability display = capabilities.get(0); displayType = display.getDisplayName(); @@ -1030,7 +1030,7 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onError(String info) { - DebugTool.logError("Display Capability cannot be retrieved"); + DebugTool.logError(TAG, "Display Capability cannot be retrieved"); defaultMainWindowCapability = null; } }; @@ -1050,7 +1050,7 @@ abstract class BaseMenuManager extends BaseSubManager { // Auto-send an updated menu if we were in NONE and now we are not, and we need an update if (oldHMILevel == HMILevel.HMI_NONE && currentHMILevel != HMILevel.HMI_NONE && currentSystemContext != SystemContext.SYSCTXT_MENU){ if (waitingOnHMIUpdate){ - DebugTool.logInfo("We now have proper HMI, sending waiting update"); + DebugTool.logInfo(TAG, "We now have proper HMI, sending waiting update"); setMenuCells(waitingUpdateMenuCells); waitingUpdateMenuCells.clear(); return; @@ -1064,7 +1064,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (oldContext == SystemContext.SYSCTXT_MENU && currentSystemContext != SystemContext.SYSCTXT_MENU && currentHMILevel != HMILevel.HMI_NONE){ if (waitingOnHMIUpdate){ - DebugTool.logInfo("We now have a proper system context, sending waiting update"); + DebugTool.logInfo(TAG, "We now have a proper system context, sending waiting update"); setMenuCells(waitingUpdateMenuCells); waitingUpdateMenuCells.clear(); } @@ -1090,7 +1090,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (currentHMILevel == null || currentHMILevel.equals(HMILevel.HMI_NONE) || currentSystemContext.equals(SystemContext.SYSCTXT_MENU)){ // We are in NONE or the menu is in use, bail out of here - DebugTool.logInfo("HMI in None or System Context Menu, returning"); + DebugTool.logInfo(TAG, "HMI in None or System Context Menu, returning"); waitingOnHMIUpdate = true; waitingUpdateMenuCells = menuCells; return; @@ -1098,7 +1098,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (inProgressUpdate != null && inProgressUpdate.size() > 0){ // there's an in-progress update so this needs to wait - DebugTool.logInfo("There is an in progress Menu Update, returning"); + DebugTool.logInfo(TAG, "There is an in progress Menu Update, returning"); hasQueuedUpdate = true; return; } @@ -1112,7 +1112,7 @@ abstract class BaseMenuManager extends BaseSubManager { inProgressUpdate = null; if (!success) { - DebugTool.logError("Error Sending Current Menu"); + DebugTool.logError(TAG, "Error Sending Current Menu"); } if (hasQueuedUpdate) { @@ -1162,27 +1162,27 @@ abstract class BaseMenuManager extends BaseSubManager { if (subMenuCommands.size() > 0) { sendSubMenuCommandRPCs(subMenuCommands, listener); - DebugTool.logInfo("Finished sending main menu commands. Sending sub menu commands."); + DebugTool.logInfo(TAG, "Finished sending main menu commands. Sending sub menu commands."); } else { if (keepsNew != null && keepsNew.size() > 0){ runSubMenuCompareAlgorithm(); }else { inProgressUpdate = null; - DebugTool.logInfo("Finished sending main menu commands."); + DebugTool.logInfo(TAG, "Finished sending main menu commands."); } } } @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Result: " + resultCode.toString() + " Info: " + info); + DebugTool.logError(TAG, "Result: " + resultCode.toString() + " Info: " + info); } @Override public void onResponse(int correlationId, RPCResponse response) { try { - DebugTool.logInfo("Main Menu response: " + response.serializeJSON().toString()); + DebugTool.logInfo(TAG, "Main Menu response: " + response.serializeJSON().toString()); } catch (JSONException e) { e.printStackTrace(); } @@ -1204,7 +1204,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (keepsNew != null && keepsNew.size() > 0){ runSubMenuCompareAlgorithm(); }else { - DebugTool.logInfo("Finished Updating Menu"); + DebugTool.logInfo(TAG, "Finished Updating Menu"); inProgressUpdate = null; if (listener != null) { @@ -1215,7 +1215,7 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Failed to send sub menu commands: "+ info); + DebugTool.logError(TAG, "Failed to send sub menu commands: "+ info); if (listener != null){ listener.onComplete(false); } @@ -1224,7 +1224,7 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onResponse(int correlationId, RPCResponse response) { try { - DebugTool.logInfo("Sub Menu response: "+ response.serializeJSON().toString()); + DebugTool.logInfo(TAG, "Sub Menu response: "+ response.serializeJSON().toString()); } catch (JSONException e) { e.printStackTrace(); } @@ -1237,7 +1237,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (adds.size() == 0){ if (listener != null){ // This can be considered a success if the user was clearing out their menu - DebugTool.logError("Called createAndSendDynamicSubMenuRPCs with empty menu"); + DebugTool.logError(TAG, "Called createAndSendDynamicSubMenuRPCs with empty menu"); listener.onComplete(true); } return; @@ -1268,13 +1268,13 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onError(int correlationId, Result resultCode, String info) { - DebugTool.logError("Result: " + resultCode.toString() + " Info: " + info); + DebugTool.logError(TAG, "Result: " + resultCode.toString() + " Info: " + info); } @Override public void onResponse(int correlationId, RPCResponse response) { try { - DebugTool.logInfo("Dynamic Sub Menu response: " + response.serializeJSON().toString()); + DebugTool.logInfo(TAG, "Dynamic Sub Menu response: " + response.serializeJSON().toString()); } catch (JSONException e) { e.printStackTrace(); } @@ -1289,7 +1289,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (oldMenuCells == null || oldMenuCells.size() == 0) { if (listener != null){ // technically this method is successful if there's nothing to delete - DebugTool.logInfo("No old cells to delete, returning"); + DebugTool.logInfo(TAG, "No old cells to delete, returning"); listener.onComplete(true); } } else { @@ -1301,7 +1301,7 @@ abstract class BaseMenuManager extends BaseSubManager { if (oldMenuCells != null && oldMenuCells.size() == 0) { if (listener != null){ // technically this method is successful if there's nothing to delete - DebugTool.logInfo("No old cells to delete, returning"); + DebugTool.logInfo(TAG, "No old cells to delete, returning"); listener.onComplete(true); } return; @@ -1324,7 +1324,7 @@ abstract class BaseMenuManager extends BaseSubManager { @Override public void onFinished() { - DebugTool.logInfo("Successfully deleted cells"); + DebugTool.logInfo(TAG, "Successfully deleted cells"); if (listener != null){ listener.onComplete(true); } diff --git a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java index 731504735..8004413b7 100644 --- a/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java +++ b/base/src/main/java/com/smartdevicelink/managers/screen/menu/BaseVoiceCommandManager.java @@ -55,7 +55,7 @@ import java.util.ArrayList; import java.util.List; abstract class BaseVoiceCommandManager extends BaseSubManager { - + private static final String TAG = "BaseVoiceCommandManager"; List<VoiceCommand> voiceCommands, oldVoiceCommands; List<AddCommand> inProgressUpdate; @@ -111,7 +111,7 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { // we actually need voice commands to set. if (voiceCommands == null || voiceCommands.size() == 0){ - DebugTool.logInfo("Trying to set empty list of voice commands, returning"); + DebugTool.logInfo(TAG, "Trying to set empty list of voice commands, returning"); return; } @@ -169,7 +169,7 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { } if (!success2){ - DebugTool.logError("Error sending voice commands"); + DebugTool.logError(TAG, "Error sending voice commands"); } } }); @@ -199,7 +199,7 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { @Override public void onFinished() { - DebugTool.logInfo("Successfully deleted old voice commands"); + DebugTool.logInfo(TAG, "Successfully deleted old voice commands"); if (listener != null){ listener.onComplete(true); } @@ -237,7 +237,7 @@ abstract class BaseVoiceCommandManager extends BaseSubManager { @Override public void onFinished() { - DebugTool.logInfo("Sending Voice Commands Complete"); + DebugTool.logInfo(TAG, "Sending Voice Commands Complete"); if (listener != null){ listener.onComplete(true); } diff --git a/base/src/main/java/com/smartdevicelink/marshal/JsonRPCMarshaller.java b/base/src/main/java/com/smartdevicelink/marshal/JsonRPCMarshaller.java index 1164ec58f..8f74fbdaa 100644 --- a/base/src/main/java/com/smartdevicelink/marshal/JsonRPCMarshaller.java +++ b/base/src/main/java/com/smartdevicelink/marshal/JsonRPCMarshaller.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.marshal;
import com.smartdevicelink.proxy.RPCMessage;
@@ -52,7 +52,7 @@ import java.util.List; */
public class JsonRPCMarshaller {
-
+ private static final String TAG = "JsonRPCMarshaller";
private static final String SDL_LIB_PRIVATE_KEY = "42baba60-eb57-11df-98cf-0800200c9a66";
/**
@@ -68,7 +68,7 @@ public class JsonRPCMarshaller { SdlTrace.logMarshallingEvent(InterfaceActivityDirection.Transmit, jsonBytes, SDL_LIB_PRIVATE_KEY);
} catch (JSONException e) {
- DebugTool.logError("Failed to encode messages to JSON.", e);
+ DebugTool.logError(TAG, "Failed to encode messages to JSON.", e);
}
return jsonBytes;
}
@@ -81,7 +81,7 @@ public class JsonRPCMarshaller { JSONObject jsonObject = new JSONObject(jsonString);
ret = deserializeJSONObject(jsonObject);
} catch (JSONException e) {
- DebugTool.logError("Failed to parse JSON", e);
+ DebugTool.logError(TAG, "Failed to parse JSON", e);
}
return ret;
}
diff --git a/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java b/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java index da6682918..ebf0353bc 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java +++ b/base/src/main/java/com/smartdevicelink/protocol/BinaryFrameHeader.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.protocol;
-import android.util.Log;
import com.smartdevicelink.util.BitConverter;
+import com.smartdevicelink.util.DebugTool;
public class BinaryFrameHeader {
private static final String TAG = "BinaryFrameHeader";
@@ -76,7 +76,7 @@ public class BinaryFrameHeader { msg.setBulkData(_bulkData);
}
} catch (OutOfMemoryError|ArrayIndexOutOfBoundsException e){
- Log.e(TAG, "Unable to process data to form header");
+ DebugTool.logError(TAG, "Unable to process data to form header");
return null;
}
diff --git a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java index db342de39..1468f9477 100644 --- a/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java +++ b/base/src/main/java/com/smartdevicelink/protocol/SdlProtocolBase.java @@ -32,7 +32,6 @@ package com.smartdevicelink.protocol; import android.support.annotation.NonNull; -import android.util.Log; import com.smartdevicelink.exception.SdlException; import com.smartdevicelink.exception.SdlExceptionCause; @@ -237,7 +236,7 @@ public class SdlProtocolBase { activeTransportString.append("\n"); } } - Log.d(TAG, activeTransportString.toString()); + DebugTool.logInfo(TAG, activeTransportString.toString()); } protected void printSecondaryTransportDetails(List<String> secondary, List<Integer> audio, List<Integer> video){ @@ -251,7 +250,7 @@ public class SdlProtocolBase { } secondaryDetailsBldr.append("\n"); }else{ - Log.d(TAG, "Supported secondary transports list is empty!"); + DebugTool.logInfo(TAG, "Supported secondary transports list is empty!"); } if(audio != null){ secondaryDetailsBldr.append("Supported audio transports: "); @@ -268,7 +267,7 @@ public class SdlProtocolBase { secondaryDetailsBldr.append("\n"); } - Log.d(TAG, secondaryDetailsBldr.toString()); + DebugTool.logInfo(TAG, secondaryDetailsBldr.toString()); } @@ -299,7 +298,7 @@ public class SdlProtocolBase { private void handleSecondaryTransportRegistration(TransportRecord transportRecord, boolean registered){ if(registered) { //Session has been registered on secondary transport - Log.d(TAG, transportRecord.getType().toString() + " transport was registered!"); + DebugTool.logInfo(TAG, transportRecord.getType().toString() + " transport was registered!"); if (supportedSecondaryTransports.contains(transportRecord.getType())) { // If the transport type that is now available to be used it should be checked // against the list of services that might be able to be started on it @@ -325,7 +324,7 @@ public class SdlProtocolBase { } } }else{ - Log.d(TAG, transportRecord.toString() + " transport was NOT registered!"); + DebugTool.logInfo(TAG, transportRecord.toString() + " transport was NOT registered!"); } //Notify any listeners for this secondary transport List<ISecondaryTransportListener> listenerList = secondaryTransportListeners.remove(transportRecord.getType()); @@ -345,7 +344,7 @@ public class SdlProtocolBase { } private void onTransportsConnectedUpdate(List<TransportRecord> transports){ - //Log.d(TAG, "Connected transport update"); + //DebugTool.logInfo(TAG, "Connected transport update"); //Temporary: this logic should all be changed to handle multiple transports of the same type ArrayList<TransportType> connectedTransports = new ArrayList<>(); @@ -783,7 +782,7 @@ public class SdlProtocolBase { header.setTransportRecord(connectedPrimaryTransport); handlePacketToSend(header); }else{ - Log.d(TAG, "Failed to connect secondary transport, threw away StartService"); + DebugTool.logInfo(TAG, "Failed to connect secondary transport, threw away StartService"); } } }; @@ -799,13 +798,13 @@ public class SdlProtocolBase { listenerList.add(secondaryListener); transportManager.requestSecondaryTransportConnection(sessionID, secondaryTransportParams.get(secondaryTransportType)); } else { - Log.w(TAG, "No params to connect to secondary transport"); + DebugTool.logWarning(TAG, "No params to connect to secondary transport"); //Unable to register or start a secondary connection. Use the callback in case //there is a chance to use the primary transport for this service. secondaryListener.onConnectionFailure(); } } else { - Log.e(TAG, "transportManager is null"); + DebugTool.logError(TAG, "transportManager is null"); } } @@ -877,7 +876,7 @@ public class SdlProtocolBase { builder.append(rejectedParam); builder.append(" "); } - DebugTool.logWarning(builder.toString()); + DebugTool.logWarning(TAG, builder.toString()); } } @@ -999,7 +998,7 @@ public class SdlProtocolBase { notifyDevTransportListener(); } else { - DebugTool.logInfo("Received a start service ack for RPC service while already active on a different transport."); + DebugTool.logInfo(TAG, "Received a start service ack for RPC service while already active on a different transport."); iSdlProtocol.onProtocolSessionStarted(serviceType, (byte) packet.getSessionId(), (byte)protocolVersion.getMajor(), "", hashID, packet.isEncrypted()); return; } @@ -1098,7 +1097,7 @@ public class SdlProtocolBase { builder.append(rejectedParam); builder.append(" "); } - DebugTool.logWarning(builder.toString()); + DebugTool.logWarning(TAG, builder.toString()); } } @@ -1145,7 +1144,7 @@ public class SdlProtocolBase { @Override public void onTransportConnected(List<TransportRecord> connectedTransports) { - Log.d(TAG, "onTransportConnected"); + DebugTool.logInfo(TAG, "onTransportConnected"); //In the future we should move this logic into the Protocol Layer TransportRecord transportRecord = getTransportForSession(SessionType.RPC); if(transportRecord == null && !requestedSession){ //There is currently no transport registered @@ -1163,14 +1162,14 @@ public class SdlProtocolBase { @Override public void onTransportDisconnected(String info, TransportRecord disconnectedTransport, List<TransportRecord> connectedTransports) { if (disconnectedTransport == null) { - Log.d(TAG, "onTransportDisconnected"); + DebugTool.logInfo(TAG, "onTransportDisconnected"); if (transportManager != null) { transportManager.close(iSdlProtocol.getSessionId()); } iSdlProtocol.shutdown("No transports left connected"); return; } else { - Log.d(TAG, "onTransportDisconnected - " + disconnectedTransport.getType().name()); + DebugTool.logInfo(TAG, "onTransportDisconnected - " + disconnectedTransport.getType().name()); } //In the future we will actually compare the record but at this point we can assume only @@ -1193,7 +1192,7 @@ public class SdlProtocolBase { boolean primaryTransportAvailable = false; if(requestedPrimaryTransports != null && requestedPrimaryTransports.size() > 1){ for (TransportType transportType: requestedPrimaryTransports){ - DebugTool.logInfo( "Checking " + transportType.name()); + DebugTool.logInfo(TAG, "Checking " + transportType.name()); if(!disconnectedTransport.getType().equals(transportType) && transportManager != null @@ -1210,7 +1209,7 @@ public class SdlProtocolBase { && requestedSecondaryTransports != null && supportedSecondaryTransports != null) { for (TransportType secondaryTransport : requestedSecondaryTransports) { - DebugTool.logInfo("Checking secondary " + secondaryTransport.name()); + DebugTool.logInfo(TAG, "Checking secondary " + secondaryTransport.name()); if (supportedSecondaryTransports.contains(secondaryTransport)) { //Should only be USB or TCP highBandwidthAvailable = true; @@ -1258,11 +1257,11 @@ public class SdlProtocolBase { //Await a connection from the legacy transport if(requestedPrimaryTransports!= null && requestedPrimaryTransports.contains(TransportType.BLUETOOTH) && !SdlProtocolBase.this.requiresHighBandwidth){ - Log.d(TAG, "Entering legacy mode; creating new protocol instance"); + DebugTool.logInfo(TAG, "Entering legacy mode; creating new protocol instance"); reset(); return true; }else{ - Log.d(TAG, "Bluetooth is not an acceptable transport; not moving to legacy mode"); + DebugTool.logInfo(TAG, "Bluetooth is not an acceptable transport; not moving to legacy mode"); return false; } } @@ -1283,7 +1282,7 @@ public class SdlProtocolBase { try { accumulator = new ByteArrayOutputStream(totalSize); }catch(OutOfMemoryError e){ - DebugTool.logError("OutOfMemory error", e); //Garbled bits were received + DebugTool.logError(TAG, "OutOfMemory error", e); //Garbled bits were received accumulator = null; } } @@ -1321,7 +1320,7 @@ public class SdlProtocolBase { try { iSdlProtocol.onProtocolMessageReceived(message); } catch (Exception excp) { - DebugTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp); + DebugTool.logError(TAG, FailurePropagating_Msg + "onProtocolMessageReceived: " + excp.toString(), excp); } // end-catch accumulator = null; @@ -1374,7 +1373,7 @@ public class SdlProtocolBase { private void handleProtocolHeartbeatACK(SdlPacket packet) { //Heartbeat is not supported in the SdlProtocol class beyond responding with ACKs to //heartbeat messages. Receiving this ACK is suspicious and should be logged - DebugTool.logInfo("Received HeartbeatACK - " + packet.toString()); + DebugTool.logInfo(TAG, "Received HeartbeatACK - " + packet.toString()); } private void handleProtocolHeartbeat(SdlPacket packet) { @@ -1427,7 +1426,7 @@ public class SdlProtocolBase { } else if (frameInfo == FrameDataControlFrameType.RegisterSecondaryTransportNACK.getValue()) { String reason = (String) packet.getTag(ControlFrameTags.RPC.RegisterSecondaryTransportNAK.REASON); - DebugTool.logWarning(reason); + DebugTool.logWarning(TAG, reason); handleSecondaryTransportRegistration(packet.getTransportRecord(),false); } else if (frameInfo == FrameDataControlFrameType.TransportEventUpdate.getValue()) { @@ -1492,7 +1491,7 @@ public class SdlProtocolBase { try { iSdlProtocol.onProtocolMessageReceived(message); } catch (Exception ex) { - DebugTool.logError(FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex); + DebugTool.logError(TAG, FailurePropagating_Msg + "onProtocolMessageReceived: " + ex.toString(), ex); handleProtocolError(FailurePropagating_Msg + "onProtocolMessageReceived: ", ex); } // end-catch } // end-method diff --git a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java b/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java index 26e9c1e1a..357d26799 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java +++ b/base/src/main/java/com/smartdevicelink/proxy/SystemCapabilityManager.java @@ -74,6 +74,7 @@ import java.util.ListIterator; import java.util.concurrent.CopyOnWriteArrayList; public class SystemCapabilityManager { + private static final String TAG = "SystemCapabilityManager"; private final HashMap<SystemCapabilityType, Object> cachedSystemCapabilities; private final HashMap<SystemCapabilityType, Boolean> systemCapabilitiesSubscriptionStatus; private final HashMap<SystemCapabilityType, CopyOnWriteArrayList<OnSystemCapabilityListener>> onSystemCapabilityListeners; @@ -180,7 +181,7 @@ public class SystemCapabilityManager { private void updateCachedDisplayCapabilityList(List<DisplayCapability> newCapabilities) { if (newCapabilities == null || newCapabilities.size() == 0) { - DebugTool.logWarning("Received invalid display capability list"); + DebugTool.logWarning(TAG, "Received invalid display capability list"); return; } @@ -563,7 +564,7 @@ public class SystemCapabilityManager { if (currentHMILevel != null && currentHMILevel.equals(HMILevel.HMI_NONE)) { String message = String.format("Attempted to update type: %s in HMI level NONE, which is not allowed. " + "Please wait until you are in HMI BACKGROUND, LIMITED, or FULL before attempting to update any SystemCapabilityType", systemCapabilityType); - DebugTool.logError(message); + DebugTool.logError(TAG, message); if (scListener != null) { scListener.onError(message); } @@ -571,7 +572,7 @@ public class SystemCapabilityManager { } if (!systemCapabilityType.isQueryable() || systemCapabilityType == SystemCapabilityType.DISPLAYS) { String message = "This systemCapabilityType cannot be queried for"; - DebugTool.logError(message); + DebugTool.logError(TAG, message); if (scListener != null) { scListener.onError(message); } diff --git a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java index 819ab95fc..c542e98e4 100644 --- a/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java +++ b/base/src/main/java/com/smartdevicelink/proxy/rpc/OnSystemRequest.java @@ -1,38 +1,37 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.proxy.rpc;
import android.support.annotation.NonNull;
-import android.util.Log;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
import com.smartdevicelink.protocol.enums.FunctionID;
@@ -40,6 +39,7 @@ import com.smartdevicelink.proxy.RPCNotification; import com.smartdevicelink.proxy.RPCStruct;
import com.smartdevicelink.proxy.rpc.enums.FileType;
import com.smartdevicelink.proxy.rpc.enums.RequestType;
+import com.smartdevicelink.util.DebugTool;
import org.json.JSONException;
import org.json.JSONObject;
@@ -121,6 +121,7 @@ import java.util.List; * @since SmartDeviceLink 2.3.2
*/
public class OnSystemRequest extends RPCNotification {
+ private static final String TAG = "OnSystemRequest";
public static final String KEY_URL_V1 = "URL";
public static final String KEY_URL = "url";
public static final String KEY_TIMEOUT_V1 = "Timeout";
@@ -177,10 +178,10 @@ public class OnSystemRequest extends RPCNotification { tempBody = getBody(httpJson);
tempHeaders = getHeaders(httpJson);
}catch(JSONException e){
- Log.e("OnSystemRequest", "HTTPRequest in bulk data was malformed.");
+ DebugTool.logError(TAG, "HTTPRequest in bulk data was malformed.");
e.printStackTrace();
}catch(NullPointerException e){
- Log.e("OnSystemRequest", "Invalid HTTPRequest object in bulk data.");
+ DebugTool.logError(TAG, "Invalid HTTPRequest object in bulk data.");
e.printStackTrace();
}
}else if(RequestType.HTTP.equals(this.getRequestType())){
@@ -207,7 +208,7 @@ public class OnSystemRequest extends RPCNotification { try{
result = httpJson.getString("body");
}catch(JSONException e){
- Log.e("OnSystemRequest", "\"body\" key doesn't exist in bulk data.");
+ DebugTool.logError(TAG, "\"body\" key doesn't exist in bulk data.");
e.printStackTrace();
}
@@ -222,7 +223,7 @@ public class OnSystemRequest extends RPCNotification { Hashtable<String, Object> httpHeadersHash = JsonRPCMarshaller.deserializeJSONObject(httpHeadersJson);
result = new Headers(httpHeadersHash);
}catch(JSONException e){
- Log.e("OnSystemRequest", "\"headers\" key doesn't exist in bulk data.");
+ DebugTool.logError(TAG, "\"headers\" key doesn't exist in bulk data.");
e.printStackTrace();
}
diff --git a/base/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java b/base/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java index 7c2a61090..a031defec 100644 --- a/base/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java +++ b/base/src/main/java/com/smartdevicelink/streaming/StreamPacketizer.java @@ -118,7 +118,7 @@ public class StreamPacketizer extends AbstractPacketizer implements IVideoStream mPauseLock.wait(); } catch (InterruptedException e) { - DebugTool.logError("Streaming thread has been interrupted", e); + DebugTool.logError(TAG, "Streaming thread has been interrupted", e); } } } diff --git a/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java b/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java index e689fb817..d66b75ed4 100644 --- a/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java +++ b/base/src/main/java/com/smartdevicelink/streaming/video/VideoStreamingParameters.java @@ -43,6 +43,7 @@ import java.util.List; @SuppressWarnings("FieldCanBeLocal") public class VideoStreamingParameters { + private static final String TAG = "VideoStreamingParameters"; private final VideoStreamingProtocol DEFAULT_PROTOCOL = VideoStreamingProtocol.RAW; private final VideoStreamingCodec DEFAULT_CODEC = VideoStreamingCodec.H264; private final VideoStreamingFormat[] CURRENTLY_SUPPORTED_FORMATS = { new VideoStreamingFormat(VideoStreamingProtocol.RTP, VideoStreamingCodec.H264), @@ -163,7 +164,7 @@ public class VideoStreamingParameters { } } } - DebugTool.logWarning("The VideoStreamingFormat has not been updated because none of the provided formats are supported."); + DebugTool.logWarning(TAG, "The VideoStreamingFormat has not been updated because none of the provided formats are supported."); //TODO In the future we should set format to null, but might be a breaking change // For now, format will remain whatever was set prior to this update @@ -201,7 +202,7 @@ public class VideoStreamingParameters { } } } - DebugTool.logWarning("The VideoStreamingFormat has not been updated because none of the provided formats are supported."); + DebugTool.logWarning(TAG, "The VideoStreamingFormat has not been updated because none of the provided formats are supported."); //TODO In the future we should set format to null, but might be a breaking change // For now, format will remain whatever was set prior to this update diff --git a/base/src/main/java/com/smartdevicelink/trace/SdlTrace.java b/base/src/main/java/com/smartdevicelink/trace/SdlTrace.java index c02d5b8c8..4e654603b 100644 --- a/base/src/main/java/com/smartdevicelink/trace/SdlTrace.java +++ b/base/src/main/java/com/smartdevicelink/trace/SdlTrace.java @@ -419,7 +419,7 @@ public class SdlTrace { try { localTraceListener.logXmlMsg(msg, SDL_LIB_TRACE_KEY); } catch (Exception ex) { - DebugTool.logError("Failure calling ISTListener: " + ex.toString(), ex); + DebugTool.logError(SYSTEM_LOG_TAG,"Failure calling ISTListener: " + ex.toString(), ex); return false; } } diff --git a/base/src/main/java/com/smartdevicelink/transport/CustomTransport.java b/base/src/main/java/com/smartdevicelink/transport/CustomTransport.java index 4e604ecf9..ad02f96d2 100644 --- a/base/src/main/java/com/smartdevicelink/transport/CustomTransport.java +++ b/base/src/main/java/com/smartdevicelink/transport/CustomTransport.java @@ -138,7 +138,7 @@ public abstract class CustomTransport implements TransportInterface{ try { onWrite(bytes, 0, bytes.length); } catch (Exception exc) { - DebugTool.logError("Error attempting to write packet", exc); + DebugTool.logError(TAG, "Error attempting to write packet", exc); } } } diff --git a/base/src/main/java/com/smartdevicelink/transport/SiphonServer.java b/base/src/main/java/com/smartdevicelink/transport/SiphonServer.java index c7c749cb2..d9dbb54e9 100644 --- a/base/src/main/java/com/smartdevicelink/transport/SiphonServer.java +++ b/base/src/main/java/com/smartdevicelink/transport/SiphonServer.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following - * disclaimer in the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ +/*
+ * Copyright (c) 2017 - 2019, SmartDeviceLink Consortium, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of the SmartDeviceLink Consortium, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
package com.smartdevicelink.transport;
import com.smartdevicelink.util.BitConverter;
@@ -42,6 +42,7 @@ import java.net.ServerSocket; import java.net.Socket;
public class SiphonServer {
+ private static final String TAG = "SiphonServer";
// Prohibit use of no-arg ctor
private SiphonServer() {}
@@ -379,7 +380,7 @@ public class SiphonServer { m_siphonSocketOutputStream = m_siphonSocket.getOutputStream();
// Output version number to the Siphon upon connection (version number prepending to logInfo)
- DebugTool.logInfo("Siphon connected.");
+ DebugTool.logInfo(TAG, "Siphon connected.");
} // end-lock
} // end-method
diff --git a/base/src/main/java/com/smartdevicelink/transport/TransportManager.java b/base/src/main/java/com/smartdevicelink/transport/TransportManager.java index 377266e4b..c8a07a1cc 100644 --- a/base/src/main/java/com/smartdevicelink/transport/TransportManager.java +++ b/base/src/main/java/com/smartdevicelink/transport/TransportManager.java @@ -33,11 +33,10 @@ package com.smartdevicelink.transport; -import android.util.Log; - import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.transport.utl.TransportRecord; +import com.smartdevicelink.util.DebugTool; import java.util.Collections; import java.util.List; @@ -181,7 +180,7 @@ public class TransportManager extends TransportManagerBase{ @Override public void onError() { - Log.e(TAG, "Error in the transport manager from the web socket server"); + DebugTool.logError(TAG, "Error in the transport manager from the web socket server"); if(transportListener != null){ transportListener.onError(""); } @@ -190,9 +189,9 @@ public class TransportManager extends TransportManagerBase{ @Override public void onConnectionTerminated(String reason) { if(record != null){ - Log.d(TAG, "Transport disconnected - " + record); + DebugTool.logInfo(TAG, "Transport disconnected - " + record); }else{ - Log.d(TAG, "Transport disconnected"); + DebugTool.logInfo(TAG, "Transport disconnected"); } diff --git a/base/src/main/java/com/smartdevicelink/transport/WebSocketServer.java b/base/src/main/java/com/smartdevicelink/transport/WebSocketServer.java index 884afaa9c..8f5411ce0 100644 --- a/base/src/main/java/com/smartdevicelink/transport/WebSocketServer.java +++ b/base/src/main/java/com/smartdevicelink/transport/WebSocketServer.java @@ -32,7 +32,6 @@ package com.smartdevicelink.transport; -import android.util.Log; import com.smartdevicelink.protocol.SdlPacket; import com.smartdevicelink.transport.enums.TransportType; import com.smartdevicelink.transport.utl.SSLWebSocketFactoryGenerator; @@ -67,7 +66,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i if(factory!=null){ this.setWebSocketFactory(factory); }else{ - DebugTool.logError("WebSocketServer: Unable to generate SSL Web Socket Server Factory"); + DebugTool.logError(TAG, "WebSocketServer: Unable to generate SSL Web Socket Server Factory"); } } @@ -88,7 +87,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i @Override public void write(SdlPacket packet){ - //Log.i(TAG, "Atttempt to write packet " + packet); + //DebugTool.logInfo(TAG, "Atttempt to write packet " + packet); if(packet != null && this.webSocket != null && this.webSocket.isOpen()) { @@ -104,7 +103,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i @Override public void onOpen(WebSocket webSocket, ClientHandshake clientHandshake) { - Log.i(TAG, "onOpen"); + DebugTool.logInfo(TAG, "onOpen"); this.webSocket = webSocket; if(callback!=null){ @@ -114,11 +113,11 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i @Override public void onClose(WebSocket webSocket, int i, String s, boolean b) { - Log.i(TAG, "onClose"); + DebugTool.logInfo(TAG, "onClose"); try{ - DebugTool.logInfo("Closing id - " + i); - DebugTool.logInfo("Closing string - " + s); - DebugTool.logInfo("Closing from remote? " + b); + DebugTool.logInfo(TAG, "Closing id - " + i); + DebugTool.logInfo(TAG, "Closing string - " + s); + DebugTool.logInfo(TAG, "Closing from remote? " + b); }catch (Exception e){ e.printStackTrace(); } @@ -133,19 +132,19 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i public void onWebsocketCloseInitiated(WebSocket conn, int code, String reason) { super.onWebsocketCloseInitiated(conn, code, reason); try{ - DebugTool.logInfo("Code - " + code + " Reason - " + reason); + DebugTool.logInfo(TAG, "Code - " + code + " Reason - " + reason); }catch (Exception e){} } @Override public void onMessage(WebSocket webSocket, String s) { - DebugTool.logError("Incorrect message type received, dropping. - String: " + s); + DebugTool.logError(TAG, "Incorrect message type received, dropping. - String: " + s); } @Override public void onMessage(WebSocket conn, ByteBuffer message) { super.onMessage(conn, message); - //Log.i(TAG, "on Message - ByteBuffer"); + //DebugTool.logInfo(TAG, "on Message - ByteBuffer"); byte input; if(message != null){ @@ -156,7 +155,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i stateProgress = psm.handleByte(input); if (!stateProgress) {//We are trying to weed through the bad packet info until we get something - //Log.w(TAG, "Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); + //DebugTool.logWarning("Packet State Machine did not move forward from state - "+ psm.getState()+". PSM being Reset."); psm.reset(); } @@ -164,7 +163,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i synchronized (WebSocketServer.this) { SdlPacket packet = psm.getFormedPacket(); if (callback != null && packet != null) { - /// Log.i(TAG, "Read a packet: " + packet); + /// DebugTool.logInfo(TAG, "Read a packet: " + packet); packet.setTransportRecord(transportRecord); callback.onPacketReceived(packet); } @@ -183,7 +182,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i @Override public void onError(WebSocket webSocket, Exception e) { - Log.e(TAG, "bad", e); + DebugTool.logError(TAG, "bad", e); if(callback!=null) { callback.onError(); } @@ -191,7 +190,7 @@ public class WebSocketServer extends org.java_websocket.server.WebSocketServer i @Override public void onStart() { - Log.i(TAG, "onStart"); + DebugTool.logInfo(TAG, "onStart"); psm = new SdlPsm(); } diff --git a/base/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java b/base/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java index a0bc592f6..95d0ceac2 100644 --- a/base/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java +++ b/base/src/main/java/com/smartdevicelink/transport/utl/SSLWebSocketFactoryGenerator.java @@ -55,7 +55,7 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; public class SSLWebSocketFactoryGenerator { - + private static final String TAG = "SSLWebSocketFactoryGenerator"; private static final String JAVA_KEY_STORE = "JKS"; private static final String TLS = "TLS"; private static final String SUNX509 = "SunX509"; @@ -70,13 +70,13 @@ public class SSLWebSocketFactoryGenerator { context = getSSLContextFromPem(config); break; default: - DebugTool.logError("Unable to generateWebSocketServer. Unsupported cert type."); + DebugTool.logError(TAG, "Unable to generateWebSocketServer. Unsupported cert type."); return null; } if(context != null) { return new DefaultSSLWebSocketServerFactory(context); }else{ - DebugTool.logError("SSLWebSocketFactoryGenerator: Unable to create SSL Context"); + DebugTool.logError(TAG, "SSLWebSocketFactoryGenerator: Unable to create SSL Context"); return null; } } @@ -101,7 +101,7 @@ public class SSLWebSocketFactoryGenerator { return sslContext; } catch(Exception e){ - DebugTool.logError("Issue creating SSLContext with JKS : " , e); + DebugTool.logError(TAG, "Issue creating SSLContext with JKS : " , e); } return null; } @@ -133,7 +133,7 @@ public class SSLWebSocketFactoryGenerator { context.init( km, null, null ); } catch ( Exception e ) { context = null; - DebugTool.logError("Issue creating SSLContext with PEM Cert : " , e); + DebugTool.logError(TAG, "Issue creating SSLContext with PEM Cert : " , e); } return context; } diff --git a/base/src/main/java/com/smartdevicelink/util/DebugTool.java b/base/src/main/java/com/smartdevicelink/util/DebugTool.java index dbf9185a8..d073fc654 100644 --- a/base/src/main/java/com/smartdevicelink/util/DebugTool.java +++ b/base/src/main/java/com/smartdevicelink/util/DebugTool.java @@ -31,8 +31,6 @@ */
package com.smartdevicelink.util;
-import android.util.Log;
-
import com.smartdevicelink.BuildConfig;
import com.smartdevicelink.exception.SdlException;
import com.smartdevicelink.marshal.JsonRPCMarshaller;
@@ -52,7 +50,7 @@ import java.util.Vector; public class DebugTool {
- public static final String TAG = "SdlProxy";
+ public static final String TAG = "SDL";
private static boolean isErrorEnabled = false;
private static boolean isWarningEnabled = false;
@@ -86,71 +84,100 @@ public class DebugTool { return string;
}
- public static void logError(String msg) {
-
+ public static void logError(String tag, String msg) {
Boolean wasWritten = false;
-
+
msg = prependProxyVersionNumberToString(msg);
-
+
wasWritten = logToSiphon(msg);
-
+
if (isErrorEnabled && !wasWritten) {
- NativeLogTool.logError(TAG, msg);
+ tag = tag != null ? tag : TAG;
+ NativeLogTool.logError(tag, msg);
}
}
- public static void logError(String msg, Throwable ex) {
+ @Deprecated
+ public static void logError(String msg) {
+ logError(TAG, msg);
+ }
+
+ public static void logError(String tag, String msg, Throwable ex) {
Boolean wasWritten = false;
-
+
msg = prependProxyVersionNumberToString(msg);
-
+
if (ex != null) {
wasWritten = logToSiphon(msg + " Exception String: " + ex.toString());
} else {
wasWritten = logToSiphon(msg);
}
-
+
if (isErrorEnabled && !wasWritten) {
- NativeLogTool.logError(TAG, msg, ex);
+ tag = tag != null ? tag : TAG;
+ NativeLogTool.logError(tag, msg, ex);
}
}
-
- public static void logWarning(String msg) {
+
+ @Deprecated
+ public static void logError(String msg, Throwable ex) {
+ logError(TAG, msg, ex);
+ }
+
+ public static void logWarning(String tag, String msg) {
Boolean wasWritten = false;
-
+
msg = prependProxyVersionNumberToString(msg);
-
+
wasWritten = logToSiphon(msg);
-
+
if (isWarningEnabled && !wasWritten) {
- NativeLogTool.logWarning(TAG, msg);
+ tag = tag != null ? tag : TAG;
+ NativeLogTool.logWarning(tag, msg);
}
}
- public static void logInfo(String msg) {
+ @Deprecated
+ public static void logWarning(String msg) {
+ logWarning(TAG, msg);
+ }
+
+ public static void logInfo(String tag, String msg) {
Boolean wasWritten = false;
-
+
msg = prependProxyVersionNumberToString(msg);
-
+
wasWritten = logToSiphon(msg);
-
+
if (isInfoEnabled && !wasWritten) {
- NativeLogTool.logInfo(TAG, msg);
+ tag = tag != null ? tag : TAG;
+ NativeLogTool.logInfo(tag, msg);
}
}
- public static void logInfo(String msg, boolean bPrependVersion) {
+ @Deprecated
+ public static void logInfo(String msg) {
+ logInfo(TAG, msg);
+ }
+
+ public static void logInfo(String tag, String msg, Boolean bPrependVersion) {
Boolean wasWritten = false;
-
+
if (bPrependVersion) msg = prependProxyVersionNumberToString(msg);
-
+
wasWritten = logToSiphon(msg);
-
+
if (isInfoEnabled && !wasWritten) {
- NativeLogTool.logInfo(TAG, msg);
+ tag = tag != null ? tag : TAG;
+ NativeLogTool.logInfo(tag, msg);
}
}
-
+
+ @Deprecated
+ public static void logInfo(String msg, boolean bPrependVersion) {
+ logInfo(TAG, msg, bPrependVersion);
+ }
+
protected static Boolean logToSiphon(String msg) {
if (SiphonServer.getSiphonEnabledStatus()) {
// Initialize the SiphonServer, will be ignored if already initialized
@@ -207,21 +234,21 @@ public class DebugTool { public static void logTransport(String msg) {
if (isTransportEnabled) {
- Log.d(TAG, msg);
+ Log.i(TAG, msg);
logInfoToConsole(msg);
}
}
public static void logRPCSend(String rpcMsg) {
if (isRPCEnabled) {
- Log.d(TAG, "Sending RPC message: " + rpcMsg);
+ Log.i(TAG, "Sending RPC message: " + rpcMsg);
logRPCSendToConsole(rpcMsg);
}
}
public static void logRPCReceive(String rpcMsg) {
if (isRPCEnabled) {
- Log.d(TAG, "Received RPC message: " + rpcMsg);
+ Log.i(TAG, "Received RPC message: " + rpcMsg);
logRPCSendToConsole(rpcMsg);
}
}
diff --git a/base/src/main/java/com/smartdevicelink/util/FileUtls.java b/base/src/main/java/com/smartdevicelink/util/FileUtls.java index 5f317340b..6c5e955eb 100644 --- a/base/src/main/java/com/smartdevicelink/util/FileUtls.java +++ b/base/src/main/java/com/smartdevicelink/util/FileUtls.java @@ -42,7 +42,7 @@ import java.net.URLConnection; import java.nio.file.Files; public class FileUtls { - + private static final String TAG = "FileUtls"; /** * When using on Android, this method should only be used for Android Oreo and newer @@ -94,7 +94,7 @@ public class FileUtls { } return buffer.toByteArray(); }catch (Exception e){ - DebugTool.logError("Unable to download file - " + urlStr, e); + DebugTool.logError(TAG, "Unable to download file - " + urlStr, e); return null; } } diff --git a/base/src/main/java/com/smartdevicelink/util/NativeLogTool.java b/base/src/main/java/com/smartdevicelink/util/NativeLogTool.java index ced98a083..61d3932c8 100644 --- a/base/src/main/java/com/smartdevicelink/util/NativeLogTool.java +++ b/base/src/main/java/com/smartdevicelink/util/NativeLogTool.java @@ -31,8 +31,6 @@ */
package com.smartdevicelink.util;
-import android.util.Log;
-
public class NativeLogTool {
private static String TAG = "NativeLogTool";
static private boolean logToSystemEnabled = true;
@@ -61,7 +59,7 @@ public class NativeLogTool { } // end-method
public static boolean logInfo(String message) {
- return logInfo(TAG, message); + return logInfo(TAG, message);
}
public static boolean logInfo(String tag, String message) {
@@ -72,7 +70,7 @@ public class NativeLogTool { }
public static boolean logWarning(String message) {
- return logWarning(TAG, message); + return logWarning(TAG, message);
}
public static boolean logWarning(String tag, String message) {
@@ -83,7 +81,7 @@ public class NativeLogTool { }
public static boolean logError(String message) {
- return logError(TAG, message); + return logError(TAG, message);
}
public static boolean logError(String tag, String message) {
@@ -94,7 +92,7 @@ public class NativeLogTool { }
public static boolean logError(String message, Throwable t) {
- return logError(TAG, message, t); + return logError(TAG, message, t);
}
public static boolean logError(String tag, String message, Throwable t) {
@@ -126,7 +124,7 @@ public class NativeLogTool { bytesWritten = Log.w(source, chunk);
break;
case Error:
- bytesWritten = Log.e(source, chunk);
+ bytesWritten = Log.e(source, chunk, null);
break;
}
if (bytesWritten < chunk.length()) {
@@ -134,7 +132,7 @@ public class NativeLogTool { }
}
} catch (Exception ex) {
- Log.e(TAG, "Failure writing " + ltarg.name() + " fragments to android log:" + ex.toString());
+ Log.e(TAG, "Failure writing " + ltarg.name() + " fragments to android log:" + ex.toString(), null);
return false;
}
return true;
diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java index f34ab0df2..daa94f21a 100644 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java +++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/Main.java @@ -36,7 +36,7 @@ import com.smartdevicelink.transport.WebSocketServerConfig; import com.smartdevicelink.util.DebugTool; public class Main { - + private static final String TAG = "Main"; static Thread thread = null, mainThread; static Object LOCK; @@ -54,9 +54,9 @@ public class Main { } System.gc(); Thread.sleep(500); - DebugTool.logInfo( "Attempting to start SDL Service again"); + DebugTool.logInfo(TAG, "Attempting to start SDL Service again"); startSdlService(); - DebugTool.logInfo("SdlService started"); + DebugTool.logInfo(TAG, "SdlService started"); } catch (InterruptedException e) { e.printStackTrace(); @@ -85,7 +85,7 @@ public class Main { @Override public void run() { - DebugTool.logInfo("Starting SDL Service"); + DebugTool.logInfo(TAG, "Starting SDL Service"); sdlService = new SdlService(new WebSocketServerConfig(5432, -1), serviceCallback); sdlService.start(); diff --git a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java index d53b64b9c..0c1b87c6a 100644 --- a/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java +++ b/hello_sdl_java/src/main/java/com/smartdevicelink/java/SdlService.java @@ -32,7 +32,6 @@ package com.smartdevicelink.java; -import android.util.Log; import com.smartdevicelink.managers.CompletionListener; import com.smartdevicelink.managers.screen.OnButtonListener; import com.smartdevicelink.managers.SdlManager; @@ -89,7 +88,7 @@ public class SdlService { } public void start() { - DebugTool.logInfo("SdlService start() "); + DebugTool.logInfo(TAG, "SdlService start() "); if(sdlManager != null){ sdlManager.start(); } @@ -107,7 +106,7 @@ public class SdlService { // Build flavors are selected by the "build variants" tab typically located in the bottom left of Android Studio // Typically in your app, you will only set one of these. if (sdlManager == null) { - DebugTool.logInfo("Creating SDL Manager"); + DebugTool.logInfo(TAG, "Creating SDL Manager"); //FIXME add the transport type // The app type to be used @@ -119,12 +118,12 @@ public class SdlService { SdlManagerListener listener = new SdlManagerListener() { @Override public void onStart(SdlManager sdlManager) { - DebugTool.logInfo("SdlManager onStart"); + DebugTool.logInfo(TAG, "SdlManager onStart"); } @Override public void onDestroy(SdlManager sdlManager) { - DebugTool.logInfo("SdlManager onDestroy "); + DebugTool.logInfo(TAG, "SdlManager onDestroy "); SdlService.this.sdlManager = null; if(SdlService.this.callback != null){ SdlService.this.callback.onEnd(); @@ -219,14 +218,14 @@ public class SdlService { VoiceCommand voiceCommand1 = new VoiceCommand(list1, new VoiceCommandSelectionListener() { @Override public void onVoiceCommandSelected() { - Log.i(TAG, "Voice Command 1 triggered"); + DebugTool.logInfo(TAG, "Voice Command 1 triggered"); } }); VoiceCommand voiceCommand2 = new VoiceCommand(list2, new VoiceCommandSelectionListener() { @Override public void onVoiceCommandSelected() { - Log.i(TAG, "Voice Command 2 triggered"); + DebugTool.logInfo(TAG, "Voice Command 2 triggered"); } }); @@ -247,7 +246,7 @@ public class SdlService { MenuCell mainCell1 = new MenuCell("Test Cell 1 (speak)", livio, null, new MenuSelectionListener() { @Override public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Test cell 1 triggered. Source: "+ trigger.toString()); + DebugTool.logInfo(TAG, "Test cell 1 triggered. Source: "+ trigger.toString()); showTest(); } }); @@ -255,7 +254,7 @@ public class SdlService { MenuCell mainCell2 = new MenuCell("Test Cell 2", null, voice2, new MenuSelectionListener() { @Override public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Test cell 2 triggered. Source: "+ trigger.toString()); + DebugTool.logInfo(TAG, "Test cell 2 triggered. Source: "+ trigger.toString()); } }); @@ -264,14 +263,14 @@ public class SdlService { MenuCell subCell1 = new MenuCell("SubCell 1",null, null, new MenuSelectionListener() { @Override public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString()); + DebugTool.logInfo(TAG, "Sub cell 1 triggered. Source: "+ trigger.toString()); } }); MenuCell subCell2 = new MenuCell("SubCell 2",null, null, new MenuSelectionListener() { @Override public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString()); + DebugTool.logInfo(TAG, "Sub cell 2 triggered. Source: "+ trigger.toString()); } }); @@ -288,7 +287,7 @@ public class SdlService { MenuCell mainCell5 = new MenuCell("Clear the menu",null, null, new MenuSelectionListener() { @Override public void onTriggered(TriggerSource trigger) { - Log.i(TAG, "Clearing Menu. Source: "+ trigger.toString()); + DebugTool.logInfo(TAG, "Clearing Menu. Source: "+ trigger.toString()); // Clear this thing sdlManager.getScreenManager().setMenu(Collections.<MenuCell>emptyList()); showAlert("Menu Cleared"); @@ -320,7 +319,7 @@ public class SdlService { @Override public void onComplete(boolean success) { if (success){ - Log.i(TAG, "welcome show successful"); + DebugTool.logInfo(TAG, "welcome show successful"); } } }); @@ -338,7 +337,7 @@ public class SdlService { @Override public void onPress(ButtonName buttonName, OnButtonPress buttonPress) { sdlManager.getScreenManager().setTextField1(buttonName + " pressed"); - Log.i(TAG, "onPress: " + buttonName); + DebugTool.logInfo(TAG, "onPress: " + buttonName); } @Override @@ -348,7 +347,7 @@ public class SdlService { @Override public void onError(String info) { - Log.i(TAG, "onError: " + info); + DebugTool.logInfo(TAG, "onError: " + info); } }; @@ -400,7 +399,7 @@ public class SdlService { @Override public void onError(String error) { - Log.e(TAG, "There was an error showing the perform interaction: "+ error); + DebugTool.logError(TAG, "There was an error showing the perform interaction: "+ error); } }); sdlManager.getScreenManager().presentChoiceSet(choiceSet, InteractionMode.MANUAL_ONLY); diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java index 3edb6b4ea..37c8ae14e 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/SdlManager.java @@ -33,7 +33,7 @@ package com.smartdevicelink.managers; import android.support.annotation.NonNull; -import android.util.Log; +import com.smartdevicelink.util.Log; import com.smartdevicelink.managers.file.FileManager; import com.smartdevicelink.managers.permission.PermissionManager; @@ -68,7 +68,7 @@ public class SdlManager extends BaseSdlManager { } }); - Log.i(TAG, "start"); + DebugTool.logInfo(TAG, "start"); if (lifecycleManager == null) { if (transport != null && (transport.getTransportType().equals(TransportType.WEB_SOCKET_SERVER) || transport.getTransportType().equals(TransportType.CUSTOM))) { super.start(); @@ -96,22 +96,22 @@ public class SdlManager extends BaseSdlManager { void checkState() { if (permissionManager != null && fileManager != null && screenManager != null) { if (permissionManager.getState() == BaseSubManager.READY && fileManager.getState() == BaseSubManager.READY && screenManager.getState() == BaseSubManager.READY) { - DebugTool.logInfo("Starting sdl manager, all sub managers are in ready state"); + DebugTool.logInfo(TAG, "Starting sdl manager, all sub managers are in ready state"); transitionToState(BaseSubManager.READY); handleQueuedNotifications(); notifyDevListener(null); onReady(); } else if (permissionManager.getState() == BaseSubManager.ERROR && fileManager.getState() == BaseSubManager.ERROR && screenManager.getState() == BaseSubManager.ERROR) { String info = "ERROR starting sdl manager, all sub managers are in error state"; - Log.e(TAG, info); + DebugTool.logError(TAG, info); transitionToState(BaseSubManager.ERROR); notifyDevListener(info); } else if (permissionManager.getState() == BaseSubManager.SETTING_UP || fileManager.getState() == BaseSubManager.SETTING_UP || screenManager.getState() == BaseSubManager.SETTING_UP) { - DebugTool.logInfo("SETTING UP sdl manager, some sub managers are still setting up"); + DebugTool.logInfo(TAG, "SETTING UP sdl manager, some sub managers are still setting up"); transitionToState(BaseSubManager.SETTING_UP); // No need to notify developer here! } else { - Log.w(TAG, "LIMITED starting sdl manager, some sub managers are in error or limited state and the others finished setting up"); + DebugTool.logWarning(TAG, "LIMITED starting sdl manager, some sub managers are in error or limited state and the others finished setting up"); transitionToState(BaseSubManager.LIMITED); handleQueuedNotifications(); notifyDevListener(null); @@ -120,7 +120,7 @@ public class SdlManager extends BaseSdlManager { } else { // We should never be here, but somehow one of the sub-sub managers is null String info = "ERROR one of the sdl sub managers is null"; - Log.e(TAG, info); + DebugTool.logError(TAG, info); transitionToState(BaseSubManager.ERROR); notifyDevListener(info); } diff --git a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java index 6a8ebe136..4cfadf611 100644 --- a/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java +++ b/javaSE/src/main/java/com/smartdevicelink/managers/lifecycle/LifecycleManager.java @@ -33,6 +33,7 @@ package com.smartdevicelink.managers.lifecycle; import android.support.annotation.RestrictTo; +import com.smartdevicelink.util.Log; import com.smartdevicelink.SdlConnection.SdlSession; import com.smartdevicelink.exception.SdlException; diff --git a/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java b/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java index 6ecc73e6e..77c9f4f7a 100644 --- a/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java +++ b/javaSE/src/main/java/com/smartdevicelink/util/HttpRequestTask.java @@ -1,7 +1,6 @@ package com.smartdevicelink.util; import android.os.AsyncTask; -import android.util.Log; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -69,7 +68,7 @@ public class HttpRequestTask extends AsyncTask<String, String, String> { } if(urlString == null || request_type == null){ - Log.e(TAG, "Can't process request, param error"); + DebugTool.logError(TAG, "Can't process request, param error"); if(cb!=null){ cb.httpFailure(-1); cb = null; @@ -133,7 +132,7 @@ public class HttpRequestTask extends AsyncTask<String, String, String> { cb.httpFailure(responseCode); cb = null; } - Log.e(TAG, "Failed to download file - " + responseCode); + DebugTool.logError(TAG, "Failed to download file - " + responseCode); return null; } @@ -152,7 +151,7 @@ public class HttpRequestTask extends AsyncTask<String, String, String> { try { reader.close(); } catch (final IOException e) { - Log.e(TAG, "Error closing stream", e); + DebugTool.logError(TAG, "Error closing stream", e); } } if(cb!=null){ diff --git a/javaSE/src/main/java/com/smartdevicelink/util/Log.java b/javaSE/src/main/java/com/smartdevicelink/util/Log.java new file mode 100644 index 000000000..914ce6366 --- /dev/null +++ b/javaSE/src/main/java/com/smartdevicelink/util/Log.java @@ -0,0 +1,22 @@ +package com.smartdevicelink.util; + +public class Log { + public static int i(String tag, String message) { + System.out.print("\r\nINFO: " + tag + " - " + message); + return 10; + } + + public static int w(String tag, String message) { + System.out.print("\r\nWARN: " + tag + " - " + message); + return 10; + } + + public static int e(String tag, String message, Throwable t) { + if (t != null) { + System.out.print("\r\nERROR: " + tag + " - " + message + " - " + t.getMessage()); + } else { + System.out.print("\r\nERROR: " + tag + " - " + message); + } + return 10; + } +}
\ No newline at end of file |